|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.millstone.base.data.util.ContainerHierarchicalWrapper
A wrapper class for adding external hierarchy to containers not
implementing the Container.Hierarchical
interface.
If the wrapped container is changed directly (that is, not through
the wrapper), the hierarchy information must be updated with the
updateHierarchicalWrapper()
method.
Nested Class Summary |
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 |
Fields inherited from interface org.millstone.base.data.Container |
NULL_ITEM_ID |
Constructor Summary | |
ContainerHierarchicalWrapper(Container toBeWrapped)
Constructs a new hierarchical wrapper for an existing Container. |
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, assigns it an automatic ID, and adds it to the hierarchy. |
Item |
addItem(java.lang.Object itemId)
Adds a new Item by its ID to the underlying container and to the hierarchy. |
void |
addListener(Container.ItemSetChangeListener listener)
Adds a Item set change listener for the object. |
void |
addListener(Container.PropertySetChangeListener listener)
Registers a new Property set change listener for this Container. |
boolean |
areChildrenAllowed(java.lang.Object itemId)
Tests if the Item with given ID can have any 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 Property identified by the given itemId and propertyId from the Container. |
java.util.Collection |
getContainerPropertyIds()
Gets the ID's of all Properties stored in the 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 data type of all Properties identified by the given Property ID. |
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 |
isRoot(java.lang.Object itemId)
Tests if the Item specified with itemId is a root
Item. |
boolean |
removeAllItems()
Removes all items from the underlying container and from the hierarcy. |
boolean |
removeContainerProperty(java.lang.Object propertyId)
Removes the specified Property from the underlying container and from the hierarchy. |
boolean |
removeItem(java.lang.Object itemId)
Removes an Item specified by itemId from the underlying
container and from the hierarcy. |
void |
removeListener(Container.ItemSetChangeListener listener)
Removes a Item set change listener from the object. |
void |
removeListener(Container.PropertySetChangeListener listener)
Removes a previously registered Property set change listener. |
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 childrenAllowed)
Sets the given Item's capability to have children. |
boolean |
setParent(java.lang.Object itemId,
java.lang.Object newParentId)
Sets the parent of an Item. |
int |
size()
Gets the number of Items in the Container. |
void |
updateHierarchicalWrapper()
Updates the wrapper's internal hierarchy data to include all Items in the underlying container. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ContainerHierarchicalWrapper(Container toBeWrapped)
toBeWrapped
- the container that needs to be accessed
hierarchicallyMethod Detail |
public void updateHierarchicalWrapper()
public boolean areChildrenAllowed(java.lang.Object itemId)
Container.Hierarchical
Managed
interface,
the items created with newItem
can have children by
default.
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 exists in the
Container and it can have children, false
if it's
not found from the container or it can't have children.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 childrenAllowed)
Sets the given Item's capability to have children. If the Item
identified with itemId
already has children and
areChildrenAllowed
is false this method fails and
false
is returned; the children must be first explicitly
removed with setParent(Object itemId, Object newParentId)
or
Container.removeItem(Object itemId)
.
setChildrenAllowed
in interface Container.Hierarchical
itemId
- ID of the Item in the container whose child
capability is to be setchildrenAllowed
- boolean value specifying if the Item
can have children or not
true
if the operation succeeded,
false
if notpublic boolean setParent(java.lang.Object itemId, java.lang.Object newParentId)
Sets the parent of an Item. The new parent item must exist and be
able to have children.
(canHaveChildren(newParentId) == true
). It is also
possible to detach a node from the hierarchy (and thus make it root)
by setting the parent null
.
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
true
if the operation succeeded,
false
if notpublic java.lang.Object addItem() throws java.lang.UnsupportedOperationException
addItem
in interface Container
null
if the operation failed
java.lang.UnsupportedOperationException
public Item addItem(java.lang.Object itemId) throws java.lang.UnsupportedOperationException
addItem
in interface Container
itemId
- ID of the Item to be created
null
if the operation failed
java.lang.UnsupportedOperationException
public boolean removeAllItems() throws java.lang.UnsupportedOperationException
removeAllItems
in interface Container
true
if the operation succeeded,
false
if not
java.lang.UnsupportedOperationException
public boolean removeItem(java.lang.Object itemId) throws java.lang.UnsupportedOperationException
itemId
from the underlying
container and from the hierarcy.
removeItem
in interface Container
itemId
- ID of the Item to remove
true
if the operation succeeded,
false
if not
java.lang.UnsupportedOperationException
public boolean addContainerProperty(java.lang.Object propertyId, java.lang.Class type, java.lang.Object defaultValue) throws java.lang.UnsupportedOperationException
addContainerProperty
in interface Container
propertyId
- ID of the new 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
public boolean removeContainerProperty(java.lang.Object propertyId) throws java.lang.UnsupportedOperationException
removeContainerProperty
in interface Container
propertyId
- ID of the Property to remove
true
if the operation succeeded,
false
if not
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)
Container
null
is returned.
getContainerProperty
in interface Container
itemId
- ID of the Item which contains the PropertypropertyId
- ID of the Property to retrieve
null
public java.util.Collection getContainerPropertyIds()
Container
getContainerPropertyIds
in interface Container
public java.lang.Class getType(java.lang.Object propertyId)
Container
getType
in interface Container
propertyId
- ID identifying the Properties
public int size()
Container
size
in interface Container
public void addListener(Container.ItemSetChangeListener listener)
Container.ItemSetChangeNotifier
addListener
in interface Container.ItemSetChangeNotifier
listener
- listener to be addedpublic void removeListener(Container.ItemSetChangeListener listener)
Container.ItemSetChangeNotifier
removeListener
in interface Container.ItemSetChangeNotifier
listener
- listener to be removedpublic void addListener(Container.PropertySetChangeListener listener)
Container.PropertySetChangeNotifier
addListener
in interface Container.PropertySetChangeNotifier
listener
- The new Listener to be registeredpublic void removeListener(Container.PropertySetChangeListener listener)
Container.PropertySetChangeNotifier
removeListener
in interface Container.PropertySetChangeNotifier
listener
- Listener to be removed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |