Class 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:
  1. 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.
  2. Regular files: Regular non-descriptor files (like documents, images, templates, scripts, etc)
  3. 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 Details

    • 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, the descriptorUrl will be the same as the url.
    • 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 Details

    • Item

      public Item()
      Default no-arg constructor.
    • Item

      public Item(Item item)
      Copy constructor. Performs a deep copy (calls Item(Item, boolean) with true).
    • Item

      public Item(Item item, boolean deepCopy)
      Copy constructor. Performs a deep copy depending on the value of the deepCopy flag. In a deep copy, the descriptorDom and properties are cloned.
  • Method Details

    • 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, the descriptorUrl will be the same as the url.
    • 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, the descriptorUrl should be set to the same value as the url.
    • 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 specified Item's and this instance's name, url, descriptorUrl and isFolder are equal.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Returns the hash code, which is the combination of the hash code of name, url, descriptorUrl and folder.
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object