|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mycore.datamodel.ifs.MCRFilesystemNode
org.mycore.datamodel.ifs.MCRDirectory
public class MCRDirectory
Represents a directory node with its metadata and content.
| Field Summary | |
|---|---|
static int |
DIRECTORIES
Constant for choosing directory nodes * |
static int |
FILES
Constant for choosing file nodes * |
static int |
HERE
Constant for choosing only direct child nodes of this directory * |
static int |
NODES
Constant for choosing any node type * |
static Comparator |
SORT_BY_DATE
Sorts children by date of last modification * |
static Comparator |
SORT_BY_NAME
Sorts children by filename, case sensitive * |
static Comparator |
SORT_BY_NAME_IGNORECASE
Sorts children by filename, case insensitive * |
static Comparator |
SORT_BY_SIZE
Sorts children by file size or total directory size * |
static int |
TOTAL
Constant for choosing both direct and indirect child nodes contained in subdirectories of this directory * |
| Fields inherited from class org.mycore.datamodel.ifs.MCRFilesystemNode |
|---|
deleted, formatter, ID, label, lastModified, manager, name, ownerID, parentID, size |
| Constructor Summary | |
|---|---|
MCRDirectory(String name,
MCRDirectory parent)
Creates a new, empty MCRDirectory with the given name in the parent MCRDirectory. |
|
MCRDirectory(String name,
MCRDirectory parent,
boolean doExistCheck)
Creates a new, empty MCRDirectory with the given name in the parent MCRDirectory. |
|
MCRDirectory(String name,
String ownerID)
Creates a new, empty root MCRDirectory with the given name, belonging to the given ownerID. |
|
MCRDirectory(String ID,
String parentID,
String ownerID,
String name,
String label,
long size,
GregorianCalendar date,
int numchdd,
int numchdf,
int numchtd,
int numchtf)
Internal constructor, do not use on your own. |
|
| Method Summary | |
|---|---|
protected void |
addChild(MCRFilesystemNode child)
Adds a child node to this directory. |
byte[] |
buildFingerprint()
Builds a fingerprint of all file's contents of this directory, by collecting the MD5 checksums of all direct or indirect child files of this directory, sorting them to ascending order and writing this list line by line as UTF-8 encoded bytes. |
protected void |
collectMD5Lines(List list)
Creates a list of all MD5 checksums of all files that are direct or indirect children of this directory and adds them to the given list object. |
void |
delete()
Deletes this directory and its content stored in the system |
MCRFilesystemNode |
getChild(int index)
Returns the direct child of this directory at the given position in the natural order of the children |
MCRFilesystemNode |
getChild(String name)
Returns the child node with the given filename. |
MCRFilesystemNode |
getChildByPath(String path)
Returns the node that is addressed by the given absolute or relative path. |
MCRFilesystemNode[] |
getChildren()
Returns all direct child nodes in this directory. |
MCRFilesystemNode[] |
getChildren(Comparator sortOrder)
Returns all direct child nodes in this directory, sorted by the given Comparator implementation. |
static MCRDirectory |
getDirectory(String ID)
Returns the MCRDirectory with the given ID. |
int |
getNumChildren(int nodetype,
int where)
Returns the number of child nodes in this directory. |
static MCRDirectory |
getRootDirectory(String ownerID)
Returns the root MCRDirectory that has no parent and is logically owned by the object with the given ID. |
boolean |
hasChild(String name)
Returns true, if this directory contains a direct child with the given filename. |
boolean |
hasChildren()
Returns true if this directory is not empty and therefore contains any subdirectories or files. |
protected void |
removeChild(MCRFilesystemNode child)
Removes a child node from this directory |
protected void |
sizeOfChildChanged(long sizeDiff)
Internal method that is called when the size of a child node has changed, to update the total size of the parent directory. |
String |
toString()
|
protected void |
touch()
Updates the date of last modification to the current date and time, without changing anything else. |
| Methods inherited from class org.mycore.datamodel.ifs.MCRFilesystemNode |
|---|
checkName, ensureNotDeleted, getAbsolutePath, getAdditionalData, getAllAdditionalData, getID, getLabel, getLastModified, getName, getNode, getOwnerID, getParent, getParentID, getPath, getRootDirectory, getRootNode, getSize, getSizeFormatted, getSizeFormatted, hasParent, removeAdditionalData, removeAllAdditionalData, setAdditionalData, setLabel, setName, storeNew |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int FILES
public static final int DIRECTORIES
public static final int NODES
public static final int HERE
public static final int TOTAL
public static final Comparator SORT_BY_NAME_IGNORECASE
public static final Comparator SORT_BY_NAME
public static final Comparator SORT_BY_SIZE
public static final Comparator SORT_BY_DATE
| Constructor Detail |
|---|
public MCRDirectory(String name,
String ownerID)
name - the name of the new MCRDirectoryownerID - any ID String of the logical owner of this file
public MCRDirectory(String name,
MCRDirectory parent)
name - the name of the new MCRDirectoryparent - the parent directory that will contain the new child
MCRUsageException - if that directory already contains a child with that name
public MCRDirectory(String name,
MCRDirectory parent,
boolean doExistCheck)
name - the name of the new MCRDirectoryparent - the parent directory that will contain the new childdoExistCheck - checks if file with that Name already exists
MCRUsageException - if that directory already contains a child with that name
MCRDirectory(String ID,
String parentID,
String ownerID,
String name,
String label,
long size,
GregorianCalendar date,
int numchdd,
int numchdf,
int numchtd,
int numchtf)
| Method Detail |
|---|
public static MCRDirectory getDirectory(String ID)
ID - the unique ID of the MCRDirectory to return
public static MCRDirectory getRootDirectory(String ownerID)
ownerID - the ID of the logical owner of that directory
protected void addChild(MCRFilesystemNode child)
child - the new childprotected void removeChild(MCRFilesystemNode child)
child - the child to be removed from this directorypublic MCRFilesystemNode[] getChildren()
public MCRFilesystemNode[] getChildren(Comparator sortOrder)
sortOrder - the Comparator to be used to sort the children
public boolean hasChild(String name)
name - the name of the child file or directorypublic MCRFilesystemNode getChild(int index)
index - the index of the child in the list of childrenpublic MCRFilesystemNode getChild(String name)
name - the name of the child file or directorypublic MCRFilesystemNode getChildByPath(String path)
path - the absolute path (starting with a "/") or path relative to this directory, possibly containing "." or ".." aliases
public boolean hasChildren()
public int getNumChildren(int nodetype,
int where)
nodetype - one of the constants FILES, DIRECTORIES, or NODES for both typeswhere - either HERE to only count direct children, or TOTAL to count also indirect childrenprotected void sizeOfChildChanged(long sizeDiff)
protected void touch()
public void delete()
throws MCRPersistenceException
delete in class MCRFilesystemNodeMCRPersistenceExceptionprotected void collectMD5Lines(List list)
public byte[] buildFingerprint()
public String toString()
toString in class MCRFilesystemNode
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||