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
public class Tree extends Item
FolderItem
that also contains it's children.- Author:
- Sumer Jabri, Alfonso Vásquez
-
-
Field Summary
Fields Modifier and Type Field Description protected List<Item>
children
The folder's children.-
Fields 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
Constructors Constructor Description Tree()
Default no-arg constructor.Tree(Item item)
Copy constructor that takes an item and calls theItem(Item)
.Tree(Item item, boolean deepCopy)
Copy constructor that takes an item and calls theItem(Item, boolean)
.Tree(Tree tree)
Copy constructor that takes another tree.Tree(Tree tree, boolean deepCopy)
Copy constructor that takes another tree.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChild(Item child)
Adds a child.boolean
equals(Object o)
Returns true ifItem.equals(Object)
returns true and if the specifiedTree
's and this instance'schildren
are equal.List<Item>
getChildren()
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.String
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
-
-
-
-
Constructor Detail
-
Tree
public Tree()
Default no-arg constructor. Setsfolder
to true, since a tree is always a folder.
-
Tree
public Tree(Item item)
Copy constructor that takes an item and calls theItem(Item)
. Setsfolder
to true, since a tree is always a folder.
-
Tree
public Tree(Item item, boolean deepCopy)
Copy constructor that takes an item and calls theItem(Item, boolean)
. Setsfolder
to true, since a tree is always a folder.
-
Tree
public Tree(Tree tree)
Copy constructor that takes another tree. Performs a deep copy (callsItem(Item, boolean)
with true).
-
Tree
public Tree(Tree tree, boolean deepCopy)
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 Detail
-
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).
-
addChild
public void addChild(Item child)
-
removeChild
public boolean removeChild(Item child)
Removes a child.
-
equals
public boolean equals(Object o)
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.
-
-