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, urlFields 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 TypeMethodDescriptionvoidAdds a child.booleanReturns true ifItem.equals(Object)returns true and if the specifiedTree's and this instance'schildrenare equal.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.toString()Methods inherited from class org.craftercms.core.service.Item
getDescriptorDom, getDescriptorUrl, getName, getProperties, getProperty, getUrl, isFolder, queryDescriptorValue, queryDescriptorValues, setDescriptorDom, setDescriptorUrl, setName, setProperties, setProperty, setUrlMethods 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. Setsfolderto true, since a tree is always a folder. -
Tree
Copy constructor that takes an item and calls theItem(Item). Setsfolderto true, since a tree is always a folder. -
Tree
Copy constructor that takes an item and calls theItem(Item, boolean). Setsfolderto 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 thedeepCopyflag. 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:
setFolderin 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'schildrenare equal. -
hashCode
public int hashCode()Returns the hash code, which is a combination ofItem.hashCode()and the list of children's hash code. -
toString
-