Package org.craftercms.core.service
Class Tree
java.lang.Object
org.craftercms.core.util.cache.impl.AbstractCachingAwareObject
org.craftercms.core.service.Item
org.craftercms.core.service.Tree
- All Implemented Interfaces:
CachingAwareObject
Folder
Item
that also contains it's children.- Author:
- Sumer Jabri, Alfonso Vásquez
-
Field Summary
FieldsFields inherited from class org.craftercms.core.service.Item
descriptorDom, descriptorUrl, isFolder, name, properties, url
Fields inherited from class org.craftercms.core.util.cache.impl.AbstractCachingAwareObject
cachingTime, key, scope
-
Constructor Summary
ConstructorsConstructorDescriptionTree()
Default no-arg constructor.Copy constructor that takes an item and calls theItem(Item)
.Copy constructor that takes an item and calls theItem(Item, boolean)
.Copy constructor that takes another tree.Copy constructor that takes another tree. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a child.boolean
Returns true ifItem.equals(Object)
returns true and if the specifiedTree
's and this instance'schildren
are equal.Returns the tree's children.int
hashCode()
Returns the hash code, which is a combination ofItem.hashCode()
and the list of children's hash code.boolean
removeChild
(Item child) Removes a child.void
setChildren
(List<Item> children) Sets the tree's children.void
setFolder
(boolean folder) OverridesItem.setFolder(boolean)
, by checking that the flag is never set to false, since a tree is always a folder.toString()
Methods inherited from class org.craftercms.core.service.Item
getDescriptorDom, getDescriptorUrl, getName, getProperties, getProperty, getUrl, isFolder, queryDescriptorValue, queryDescriptorValues, setDescriptorDom, setDescriptorUrl, setName, setProperties, setProperty, setUrl
Methods inherited from class org.craftercms.core.util.cache.impl.AbstractCachingAwareObject
getCachingTime, getKey, getScope, setCachingTime, setKey, setScope
-
Field Details
-
children
-
-
Constructor Details
-
Tree
public Tree()Default no-arg constructor. Setsfolder
to true, since a tree is always a folder. -
Tree
Copy constructor that takes an item and calls theItem(Item)
. Setsfolder
to true, since a tree is always a folder. -
Tree
Copy constructor that takes an item and calls theItem(Item, boolean)
. Setsfolder
to true, since a tree is always a folder. -
Tree
Copy constructor that takes another tree. Performs a deep copy (callsItem(Item, boolean)
with true). -
Tree
Copy constructor that takes another tree. Performs a deep copy depending on the value of thedeepCopy
flag. In a deep copy, a deep copy of each child is done (by callingItem(Item, boolean)
andTree(Tree, boolean)
).
-
-
Method Details
-
setFolder
public void setFolder(boolean folder) OverridesItem.setFolder(boolean)
, by checking that the flag is never set to false, since a tree is always a folder.- Overrides:
setFolder
in classItem
- Throws:
IllegalArgumentException
- if the method was called with false (the folder flag should never being set to false).
-
getChildren
-
setChildren
- Parameters:
children
-
-
addChild
-
removeChild
Removes a child. -
equals
Returns true ifItem.equals(Object)
returns true and if the specifiedTree
's and this instance'schildren
are equal. -
hashCode
public int hashCode()Returns the hash code, which is a combination ofItem.hashCode()
and the list of children's hash code. -
toString
-