Package org.craftercms.core.service
Class Item
- java.lang.Object
-
- org.craftercms.core.util.cache.impl.AbstractCachingAwareObject
-
- org.craftercms.core.service.Item
-
- All Implemented Interfaces:
CachingAwareObject
- Direct Known Subclasses:
Tree
public class Item extends AbstractCachingAwareObject
Represents an item of a content store. Content store items can be separated into 3 main categories:- Standalone descriptors: XML files that contain metadata and content for web pages. These type of descriptors are in themselves items, so the item url and the descriptor url should be the same.
- Regular files: Regular non-descriptor files (like documents, images, templates, scripts, etc)
- Folders: Plain old folders/directories.
Both regular files and folders can have their own metadata files or descriptors. So we can also say that there are two types of descriptors: standalone descriptors and (regular file and folder) metadata files.
- Author:
- Sumer Jabri, Alfonso Vásquez
-
-
Field Summary
Fields Modifier and Type Field Description protected org.dom4j.Document
descriptorDom
The DOM (Document Object Model) of the item's descriptor.protected String
descriptorUrl
The url or path of the item's descriptor in the content store.protected boolean
isFolder
Flag that indicates if the item is a folder or not.protected String
name
The name of the item (basically the file name).protected Map<String,Object>
properties
The properties of the item, which most of the time are metadata information on the item.protected String
url
The url or path of the item in the content store.-
Fields inherited from class org.craftercms.core.util.cache.impl.AbstractCachingAwareObject
cachingTime, key, scope
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
Returns true if the specifiedItem
's and this instance'sname
,url
,descriptorUrl
andisFolder
are equal.org.dom4j.Document
getDescriptorDom()
Returns the DOM (Document Object Model) of the item's descriptor.String
getDescriptorUrl()
Returns the url or path of the item's descriptor in the content store.String
getName()
Returns name of the item (basically the file name).Map<String,Object>
getProperties()
Returns the properties of the item, which most of the time are metadata information on the item.Object
getProperty(String key)
Returns the property value for the specified key.String
getUrl()
Returns the url or path of the item in the content store.int
hashCode()
Returns the hash code, which is the combination of the hash code ofname
,url
,descriptorUrl
andfolder
.boolean
isFolder()
Returns true if the item is a folder.String
queryDescriptorValue(String xpathQuery)
Queries a single descriptor node text value.List<String>
queryDescriptorValues(String xpathQuery)
Queries multiple descriptor node text values.void
setDescriptorDom(org.dom4j.Document descriptorDom)
Sets the DOM (Document Object Model) of the item's descriptor.void
setDescriptorUrl(String descriptorUrl)
Sets the url or path of the item's descriptor in the content store.void
setFolder(boolean folder)
Sets whether the item is a folder or not.void
setName(String name)
Sets the name of the item (basically the file name).void
setProperties(Map<String,Object> properties)
Sets properties of the item, which most of the time are metadata information on the item.void
setProperty(String key, Object value)
Adds the specified property value, associated to the specified key.void
setUrl(String url)
Sets the url or path of the item in the content store.String
toString()
-
Methods inherited from class org.craftercms.core.util.cache.impl.AbstractCachingAwareObject
getCachingTime, getKey, getScope, setCachingTime, setKey, setScope
-
-
-
-
Field Detail
-
name
protected String name
The name of the item (basically the file name).
-
url
protected String url
The url or path of the item in the content store.
-
descriptorUrl
protected String descriptorUrl
The url or path of the item's descriptor in the content store. If the item is a standalone descriptor, thedescriptorUrl
will be the same as theurl
.
-
descriptorDom
protected org.dom4j.Document descriptorDom
The DOM (Document Object Model) of the item's descriptor.
-
properties
protected Map<String,Object> properties
The properties of the item, which most of the time are metadata information on the item.
-
isFolder
protected boolean isFolder
Flag that indicates if the item is a folder or not.
-
-
Constructor Detail
-
Item
public Item()
Default no-arg constructor.
-
Item
public Item(Item item)
Copy constructor. Performs a deep copy (callsItem(Item, boolean)
with true).
-
Item
public Item(Item item, boolean deepCopy)
Copy constructor. Performs a deep copy depending on the value of thedeepCopy
flag. In a deep copy, thedescriptorDom
andproperties
are cloned.
-
-
Method Detail
-
getName
public String getName()
Returns name of the item (basically the file name).
-
setName
public void setName(String name)
Sets the name of the item (basically the file name).
-
getUrl
public String getUrl()
Returns the url or path of the item in the content store.
-
setUrl
public void setUrl(String url)
Sets the url or path of the item in the content store.
-
getDescriptorUrl
public String getDescriptorUrl()
Returns the url or path of the item's descriptor in the content store. If the item is a standalone descriptor, thedescriptorUrl
will be the same as theurl
.
-
setDescriptorUrl
public void setDescriptorUrl(String descriptorUrl)
Sets the url or path of the item's descriptor in the content store. If the item is a standalone descriptor, thedescriptorUrl
should be set to the same value as theurl
.
-
getDescriptorDom
public org.dom4j.Document getDescriptorDom()
Returns the DOM (Document Object Model) of the item's descriptor.
-
setDescriptorDom
public void setDescriptorDom(org.dom4j.Document descriptorDom)
Sets the DOM (Document Object Model) of the item's descriptor.
-
getProperties
public Map<String,Object> getProperties()
Returns the properties of the item, which most of the time are metadata information on the item.
-
setProperties
public void setProperties(Map<String,Object> properties)
Sets properties of the item, which most of the time are metadata information on the item.
-
getProperty
public Object getProperty(String key)
Returns the property value for the specified key.
-
setProperty
public void setProperty(String key, Object value)
Adds the specified property value, associated to the specified key.
-
queryDescriptorValue
public String queryDescriptorValue(String xpathQuery)
Queries a single descriptor node text value. First looks in the properties, if not found it executes the XPath query.
-
queryDescriptorValues
public List<String> queryDescriptorValues(String xpathQuery)
Queries multiple descriptor node text values. First looks in the properties, if not found it executes the XPath query.
-
isFolder
public boolean isFolder()
Returns true if the item is a folder.
-
setFolder
public void setFolder(boolean folder)
Sets whether the item is a folder or not.
-
equals
public boolean equals(Object o)
Returns true if the specifiedItem
's and this instance'sname
,url
,descriptorUrl
andisFolder
are equal.
-
hashCode
public int hashCode()
Returns the hash code, which is the combination of the hash code ofname
,url
,descriptorUrl
andfolder
.
-
-