org.mycore.datamodel.ifs
Class MCRFilesystemNode

java.lang.Object
  extended by org.mycore.datamodel.ifs.MCRFilesystemNode
Direct Known Subclasses:
MCRDirectory, MCRFile

public abstract class MCRFilesystemNode
extends Object

Represents a stored file or directory node with its metadata and content.

Version:
$Revision: 14596 $ $Date: 2009-01-19 08:12:38 +0100 (Mon, 19 Jan 2009) $
Author:
Frank Lützenkirchen

Field Summary
protected  boolean deleted
          A flag indicating if this node is deleted and therefore invalid
protected static DateFormat formatter
           
protected  String ID
           
protected  String label
          The optional label of this node
protected  GregorianCalendar lastModified
          The date of last modification of this node
protected static MCRFileMetadataManager manager
           
protected  String name
          The name of this node
protected  String ownerID
          The ID of the node owner, e .g.
protected  String parentID
          The ID of the parent directory, if any
protected  long size
          The size in number of bytes
 
Constructor Summary
protected MCRFilesystemNode(String name, MCRDirectory parent)
           
protected MCRFilesystemNode(String name, MCRDirectory parent, boolean checkName)
           
protected MCRFilesystemNode(String name, String ownerID)
           
protected MCRFilesystemNode(String ID, String parentID, String ownerID, String name, String label, long size, GregorianCalendar date)
           
 
Method Summary
protected  void checkName(String name, boolean doExistCheck)
          Changed method because of problems with update of files.
 void delete()
           
protected  void ensureNotDeleted()
           
 String getAbsolutePath()
           
 Element getAdditionalData(String dataName)
          Gets additional XML data stored for this node, if any.
 Document getAllAdditionalData()
          Gets all additional XML data stored for this node, if any.
 String getID()
           
 String getLabel()
          Returns the label of this node
 GregorianCalendar getLastModified()
          Returns the time of last modification of this node
 String getName()
          Returns the name of this node
static MCRFilesystemNode getNode(String ID)
           
 String getOwnerID()
          Returns the ID of the owner of this node
 MCRDirectory getParent()
           
 String getParentID()
           
 String getPath()
           
 MCRDirectory getRootDirectory()
           
static MCRFilesystemNode getRootNode(String ownerID)
           
 long getSize()
          Returns the node size as number of bytes
 String getSizeFormatted()
          Returns the node size, formatted as a string
static String getSizeFormatted(long bytes)
          Takes a file size in bytes and formats it as a string for output.
 boolean hasParent()
           
 void removeAdditionalData(String dataName)
          Removes additional XML data from this node.
 void removeAllAdditionalData()
          Removes all additional XML data stored for this node, if any.
 void setAdditionalData(Element data)
          Stores additional XML data for this node.
 void setLabel(String label)
          Sets the label of this node
 void setName(String name)
          Sets the name of this node
protected  void storeNew()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

manager

protected static MCRFileMetadataManager manager

ID

protected String ID

ownerID

protected String ownerID
The ID of the node owner, e .g. a MILESS derivate ID


parentID

protected String parentID
The ID of the parent directory, if any


name

protected String name
The name of this node


label

protected String label
The optional label of this node


size

protected long size
The size in number of bytes


lastModified

protected GregorianCalendar lastModified
The date of last modification of this node


deleted

protected boolean deleted
A flag indicating if this node is deleted and therefore invalid


formatter

protected static DateFormat formatter
Constructor Detail

MCRFilesystemNode

protected MCRFilesystemNode(String name,
                            String ownerID)

MCRFilesystemNode

protected MCRFilesystemNode(String name,
                            MCRDirectory parent)

MCRFilesystemNode

protected MCRFilesystemNode(String name,
                            MCRDirectory parent,
                            boolean checkName)

MCRFilesystemNode

protected MCRFilesystemNode(String ID,
                            String parentID,
                            String ownerID,
                            String name,
                            String label,
                            long size,
                            GregorianCalendar date)
Method Detail

getNode

public static MCRFilesystemNode getNode(String ID)

getRootNode

public static MCRFilesystemNode getRootNode(String ownerID)

storeNew

protected void storeNew()

delete

public void delete()

checkName

protected void checkName(String name,
                         boolean doExistCheck)
Changed method because of problems with update of files.


getID

public String getID()

getOwnerID

public String getOwnerID()
Returns the ID of the owner of this node

Returns:
the ID of the owner of this node

getParentID

public String getParentID()

getParent

public MCRDirectory getParent()

hasParent

public boolean hasParent()

getRootDirectory

public MCRDirectory getRootDirectory()

ensureNotDeleted

protected void ensureNotDeleted()

setName

public void setName(String name)
Sets the name of this node


getName

public String getName()
Returns the name of this node

Returns:
the name of this node

setLabel

public void setLabel(String label)
Sets the label of this node

Parameters:
label - the label (may be null)

getLabel

public String getLabel()
Returns the label of this node

Returns:
the label of this node, or null

getPath

public String getPath()

getAbsolutePath

public String getAbsolutePath()

getSize

public long getSize()
Returns the node size as number of bytes


getSizeFormatted

public String getSizeFormatted()
Returns the node size, formatted as a string


getSizeFormatted

public static String getSizeFormatted(long bytes)
Takes a file size in bytes and formats it as a string for output. For values < 5 KB the output format is for example "320 Byte". For values > 5 KB the output format is for example "6,8 KB". For values > 1 MB the output format is for example "3,45 MB".


getLastModified

public GregorianCalendar getLastModified()
Returns the time of last modification of this node


setAdditionalData

public void setAdditionalData(Element data)
                       throws IOException,
                              JDOMException
Stores additional XML data for this node. The name of the data element is used as unique key for storing data. If data with this name already exists, it is overwritten.

Parameters:
data - the additional XML data to be saved
Throws:
IOException - if the XML data can not be retrieved
JDOMException - if the XML data can not be parsed

removeAdditionalData

public void removeAdditionalData(String dataName)
                          throws IOException,
                                 JDOMException
Removes additional XML data from this node.

Parameters:
dataName - the name of the additional XML data element to be removed
Throws:
IOException - if the XML data can not be retrieved
JDOMException - if the XML data can not be parsed

removeAllAdditionalData

public void removeAllAdditionalData()
Removes all additional XML data stored for this node, if any.


getAdditionalData

public Element getAdditionalData(String dataName)
                          throws IOException,
                                 JDOMException
Gets additional XML data stored for this node, if any.

Parameters:
dataName - the name of the additional XML data element to be retrieved
Returns:
the additional XML data elemet that was stored, or null
Throws:
IOException - if the XML data can not be retrieved
JDOMException - if the XML data can not be parsed

getAllAdditionalData

public Document getAllAdditionalData()
                              throws IOException,
                                     JDOMException
Gets all additional XML data stored for this node, if any.

Returns:
the additional XML data document that was stored, or null
Throws:
IOException - if the XML data can not be retrieved
JDOMException - if the XML data can not be parsed

toString

public String toString()
Overrides:
toString in class Object