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
FolderItemthat also contains it's children.- Author:
- Sumer Jabri, Alfonso Vásquez
-
-
Field Summary
Fields Modifier and Type Field Description protected List<Item>childrenThe 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 voidaddChild(Item child)Adds a child.booleanequals(Object o)Returns true ifItem.equals(Object)returns true and if the specifiedTree's and this instance'schildrenare equal.List<Item>getChildren()Returns the tree's children.inthashCode()Returns the hash code, which is a combination ofItem.hashCode()and the list of children's hash code.booleanremoveChild(Item child)Removes a child.voidsetChildren(List<Item> children)Sets the tree's children.voidsetFolder(boolean folder)OverridesItem.setFolder(boolean), by checking that the flag is never set to false, since a tree is always a folder.StringtoString()-
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. Setsfolderto true, since a tree is always a folder.
-
Tree
public Tree(Item item)
Copy constructor that takes an item and calls theItem(Item). Setsfolderto 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). Setsfolderto 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 thedeepCopyflag. 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:
setFolderin 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'schildrenare equal.
-
hashCode
public int hashCode()
Returns the hash code, which is a combination ofItem.hashCode()and the list of children's hash code.
-
-