|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.millstone.base.data.util.FilesystemContainer
A hierarchical container wrapper for a filesystem.
Nested Class Summary | |
class |
FilesystemContainer.FileExtensionFilter
Generic file extension filter for displaying only files having certain extension. |
class |
FilesystemContainer.FileItem
A Item wrapper for files in a filesystem. |
Nested classes inherited from class org.millstone.base.data.Container |
Container.Editor, Container.Hierarchical, Container.Indexed, Container.ItemSetChangeEvent, Container.ItemSetChangeListener, Container.ItemSetChangeNotifier, Container.Ordered, Container.PropertySetChangeEvent, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.Viewer |
Field Summary | |
static java.util.Collection |
FILE_PROPERTIES
List of the string identifiers for the available properties |
static java.lang.String |
PROPERTY_ICON
String identifier of a file's "icon" property. |
static java.lang.String |
PROPERTY_LASTMODIFIED
String identifier of a file's "last modified" property. |
static java.lang.String |
PROPERTY_NAME
String identifier of a file's "name" property. |
static java.lang.String |
PROPERTY_SIZE
String identifier of a file's "size" property. |
Fields inherited from interface org.millstone.base.data.Container |
NULL_ITEM_ID |
Constructor Summary | |
FilesystemContainer(java.io.File root)
Construct a new FileSystemContainer with the specified
file as the root of the filesystem. |
|
FilesystemContainer(java.io.File root,
boolean recursive)
Construct a new FileSystemContainer with the specified
file as the root of the filesystem. |
|
FilesystemContainer(java.io.File root,
java.io.FilenameFilter filter,
boolean recursive)
Construct a new FileSystemContainer with the specified
root and recursivity status. |
|
FilesystemContainer(java.io.File root,
java.lang.String extension,
boolean recursive)
Construct a new FileSystemContainer with the specified
file as the root of the filesystem. |
Method Summary | |
boolean |
addContainerProperty(java.lang.Object propertyId,
java.lang.Class type,
java.lang.Object defaultValue)
Adds a new Property to all Items in the Container. |
java.lang.Object |
addItem()
Creates a new Item into the Container, and assign it an automatic ID. |
Item |
addItem(java.lang.Object itemId)
Creates a new Item with the given ID into the Container. |
void |
addRoot(java.io.File root)
Add new root file directory. |
boolean |
areChildrenAllowed(java.lang.Object itemId)
Tests if the specified Item in the container may have children. |
boolean |
containsId(java.lang.Object itemId)
Tests if the Container contains the specified Item |
java.util.Collection |
getChildren(java.lang.Object itemId)
Gets the IDs of all Items that are children of the specified Item. |
Property |
getContainerProperty(java.lang.Object itemId,
java.lang.Object propertyId)
Gets the specified property of the specified file Item. |
java.util.Collection |
getContainerPropertyIds()
Gets the collection of available file properties. |
java.io.FilenameFilter |
getFilter()
Returns the file filter used to limit the files in this container. |
Item |
getItem(java.lang.Object itemId)
Gets the Item with the given Item ID from the Container. |
java.util.Collection |
getItemIds()
Gets the ID's of all Items stored in the Container. |
java.lang.Object |
getParent(java.lang.Object itemId)
Gets the ID of the parent Item of the specified Item. |
java.lang.Class |
getType(java.lang.Object propertyId)
Gets the specified property's data type. |
boolean |
hasChildren(java.lang.Object itemId)
Tests if the Item specified with itemId has any
child Items, that is, is it a leaf Item. |
boolean |
isRecursive()
Is this container recursive filesystem. |
boolean |
isRoot(java.lang.Object itemId)
Tests if the Item specified with itemId is a root
Item. |
boolean |
removeAllItems()
Removes all Items from the Container. |
boolean |
removeContainerProperty(java.lang.Object propertyId)
Removes a Property specified by the given Property ID from the Container. |
boolean |
removeItem(java.lang.Object itemId)
Removes the Item identified by ItemId from the
Container. |
java.util.Collection |
rootItemIds()
Gets the IDs of all Items in the container that don't have a parent. |
boolean |
setChildrenAllowed(java.lang.Object itemId,
boolean areChildrenAllowed)
Return false - conversion from files to directories is not supported. |
void |
setFilter(java.io.FilenameFilter filter)
Sets the file filter used to limit the files in this container. |
void |
setFilter(java.lang.String extension)
Sets the file filter used to limit the files in this container. |
boolean |
setParent(java.lang.Object itemId,
java.lang.Object newParentId)
Return false - moving files around in the filesystem is not supported. |
void |
setRecursive(boolean recursive)
Sets the container recursive property. |
int |
size()
Gets the number of Items in the container. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static java.lang.String PROPERTY_NAME
public static java.lang.String PROPERTY_SIZE
public static java.lang.String PROPERTY_ICON
public static java.lang.String PROPERTY_LASTMODIFIED
public static java.util.Collection FILE_PROPERTIES
Constructor Detail |
public FilesystemContainer(java.io.File root)
FileSystemContainer
with the specified
file as the root of the filesystem. The files are included recursively.
root
- root file for the new file-system container. Null values are ignored.public FilesystemContainer(java.io.File root, boolean recursive)
FileSystemContainer
with the specified
file as the root of the filesystem. The files are included recursively.
root
- root file for the new file-system containerrecursive
- should the container recursively contain subdirectories.public FilesystemContainer(java.io.File root, java.lang.String extension, boolean recursive)
FileSystemContainer
with the specified
file as the root of the filesystem.
root
- root file for the new file-system containerextension
- Filename extension (w/o separator) to limit the files in container.recursive
- should the container recursively contain subdirectories.public FilesystemContainer(java.io.File root, java.io.FilenameFilter filter, boolean recursive)
FileSystemContainer
with the specified
root and recursivity status.
root
- root file for the new file-system containerfilter
- Filename filter to limit the files in container.recursive
- should the container recursively contain subdirectories.Method Detail |
public void addRoot(java.io.File root)
root
- File to be added as root directory. Null values are ignored.public boolean areChildrenAllowed(java.lang.Object itemId)
FileSystemContainer
contains files and
directories, this method returns true
for directory
Items only.
areChildrenAllowed
in interface Container.Hierarchical
itemId
- ID of the Item in the container whose child
capability is to be tested
true
if the specified Item is a directory,
false
otherwise.public java.util.Collection getChildren(java.lang.Object itemId)
Container.Hierarchical
getChildren
in interface Container.Hierarchical
itemId
- ID of the Item whose children the caller is
interested in
collection
containing the IDs of all
other Items that are children in the container hierarchypublic java.lang.Object getParent(java.lang.Object itemId)
Container.Hierarchical
getParent
in interface Container.Hierarchical
itemId
- ID of the Item whose parent the caller
wishes to find out.
null
if
the specified Item is a root element.public boolean hasChildren(java.lang.Object itemId)
Container.Hierarchical
Tests if the Item specified with itemId
has any
child Items, that is, is it a leaf Item. The
Container.Hierarchical.getChildren(Object itemId)
method always
returns null
for leaf Items.
Note that being a leaf does not imply whether or not an Item is allowed to have children.
.
hasChildren
in interface Container.Hierarchical
itemId
- ID of the Item whose leaf status is to be tested
true
if the specified Item is a leaf,
false
if notpublic boolean isRoot(java.lang.Object itemId)
Container.Hierarchical
itemId
is a root
Item. The hierarchical container can have more than one root and
must have at least one unless it is empty. The
Container.Hierarchical.getParent(Object itemId)
method always returns
null
for root Items.
isRoot
in interface Container.Hierarchical
itemId
- ID of the Item whose root status is to be tested
true
if the specified Item is a root,
false
if notpublic java.util.Collection rootItemIds()
Container.Hierarchical
root
Items. The
returned collection is unmodifiable.
rootItemIds
in interface Container.Hierarchical
collection
containing IDs of all
root elements of the containerpublic boolean setChildrenAllowed(java.lang.Object itemId, boolean areChildrenAllowed) throws java.lang.UnsupportedOperationException
setChildrenAllowed
in interface Container.Hierarchical
itemId
- ID of the Item in the container whose child
capability is to be setareChildrenAllowed
- boolean value specifying if the Item
can have children or not
false
java.lang.UnsupportedOperationException
public boolean setParent(java.lang.Object itemId, java.lang.Object newParentId) throws java.lang.UnsupportedOperationException
setParent
in interface Container.Hierarchical
itemId
- ID of the item to be set as the child of the Item
identified with newParentId
newParentId
- ID of the Item that's to be the new parent
of the Item identified with itemId
false
java.lang.UnsupportedOperationException
public boolean containsId(java.lang.Object itemId)
Container
containsId
in interface Container
itemId
- ID the of Item to be tested
public Item getItem(java.lang.Object itemId)
Container
null
is
returned.
getItem
in interface Container
itemId
- ID of the Item to retrieve
null
if the Item
is not found in the Containerpublic java.util.Collection getItemIds()
Container
getItemIds
in interface Container
public Property getContainerProperty(java.lang.Object itemId, java.lang.Object propertyId)
propertyId
is not one of those, null
is
returned.
getContainerProperty
in interface Container
itemId
- ID of the file whose property is requestedpropertyId
- The property's ID
null
public java.util.Collection getContainerPropertyIds()
getContainerPropertyIds
in interface Container
public java.lang.Class getType(java.lang.Object propertyId)
String
, "Size" is a Long
, "Last Modified"
is a Date
. If propertyId
is not one of
those, null
is returned.
getType
in interface Container
propertyId
- ID of the property whose type is requested.
null
public int size()
size
in interface Container
public java.io.FilenameFilter getFilter()
public void setFilter(java.io.FilenameFilter filter)
filter
- The filter to set. null
disables filtering.public void setFilter(java.lang.String extension)
extension
- Filename extension (w/o separator) to limit the files in container.public boolean isRecursive()
public void setRecursive(boolean recursive)
public boolean addContainerProperty(java.lang.Object propertyId, java.lang.Class type, java.lang.Object defaultValue) throws java.lang.UnsupportedOperationException
Container
addContainerProperty
in interface Container
propertyId
- ID of the Propertytype
- Data type of the new PropertydefaultValue
- The value all created Properties are
initialized to
true
if the operation succeeded,
false
if not
java.lang.UnsupportedOperationException
Container.addContainerProperty(Object, Class, Object)
public java.lang.Object addItem() throws java.lang.UnsupportedOperationException
Container
The new ID is returned, or null
if the
operation fails. After a successful call you can use the
method to
fetch the Item.getItem
This functionality is optional.
addItem
in interface Container
null
in
case of a failure
java.lang.UnsupportedOperationException
Container.addItem()
public Item addItem(java.lang.Object itemId) throws java.lang.UnsupportedOperationException
Container
Item is returned, and it is ready to have its Properties
modified. Returns null
if the operation fails or the
Container already contains a Item with the given ID.
This functionality is optional.
addItem
in interface Container
itemId
- ID of the Item to be created
null
in case of a
failure
java.lang.UnsupportedOperationException
Container.addItem(Object)
public boolean removeAllItems() throws java.lang.UnsupportedOperationException
Container
Note that Property ID and type information is preserved. This functionality is optional.
removeAllItems
in interface Container
true
if the operation succeeded,
false
if not
java.lang.UnsupportedOperationException
Container.removeAllItems()
public boolean removeItem(java.lang.Object itemId) throws java.lang.UnsupportedOperationException
Container
ItemId
from the
Container. This functionality is optional.
removeItem
in interface Container
itemId
- ID of the Item to remove
true
if the operation succeeded,
false
if not
java.lang.UnsupportedOperationException
Container.removeItem(Object)
public boolean removeContainerProperty(java.lang.Object propertyId) throws java.lang.UnsupportedOperationException
Container
removeContainerProperty
in interface Container
propertyId
- ID of the Property to remove
true
if the operation succeeded,
false
if not
java.lang.UnsupportedOperationException
Container.removeContainerProperty(Object)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |