com.day.cq.tagging.impl
Class JcrTagImpl

java.lang.Object
  extended by org.apache.sling.adapter.SlingAdaptable
      extended by com.day.cq.tagging.impl.JcrTagImpl
All Implemented Interfaces:
Tag, org.apache.sling.api.adapter.Adaptable

public class JcrTagImpl
extends org.apache.sling.adapter.SlingAdaptable
implements Tag

JcrTagImpl is the JCR based implementation of the Tag interface.


Field Summary
static String TAG_NODE_TYPE
           
 
Constructor Summary
JcrTagImpl(org.apache.sling.api.resource.Resource resource, JcrTagManagerImpl tagManager)
           
 
Method Summary
<AdapterType>
AdapterType
adaptTo(Class<AdapterType> type)
           
 Iterator<org.apache.sling.api.resource.Resource> find()
          Returns all nodes tagged with this tag.
 long getCount()
          Returns the usage count of the tag, which can be used for tag cloud and other visualisations.
 String getDescription()
          Returns an optional description for a tag.
 String getLocalTagID()
          Returns the tag path below a namespace.
 String getName()
          Returns the node name, ie.
 Tag getNamespace()
          Returns the tag namespace inside which this tag resides as tag object.
 Tag getParent()
          Gets the parent of this tag.
 String getPath()
          Returns the full absolute path of a tag or a tag namespace.
 org.apache.sling.api.resource.ValueMap getProperties()
           
 String getTagID()
          Returns the short tag ID.
 String getTitle()
          Returns a title that should be displayed instead of the tag name or tag id.
 String getTitlePath()
          Returns the title variant of the tag ID: a path made up of the single titles of the namespace and all tags leading to this tag.
 boolean isNamespace()
          Returns true if this tag object refers to a tag namespace.
static boolean isTagNode(Node node)
           
 Iterator<Tag> listAllSubTags()
          Lists all sub-tags, ie.
 Iterator<Tag> listChildren()
          Lists the direct child tags for both tag namespaces and tag containers.
 Iterator<Tag> listChildren(Filter<Tag> filter)
          Lists the child tags for both tag namespaces and tag containers, but only those included by a filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG_NODE_TYPE

public static final String TAG_NODE_TYPE
See Also:
Constant Field Values
Constructor Detail

JcrTagImpl

public JcrTagImpl(org.apache.sling.api.resource.Resource resource,
                  JcrTagManagerImpl tagManager)
Method Detail

isTagNode

public static boolean isTagNode(Node node)
                         throws RepositoryException
Throws:
RepositoryException

adaptTo

public <AdapterType> AdapterType adaptTo(Class<AdapterType> type)
Specified by:
adaptTo in interface org.apache.sling.api.adapter.Adaptable
Overrides:
adaptTo in class org.apache.sling.adapter.SlingAdaptable

getProperties

public org.apache.sling.api.resource.ValueMap getProperties()

getName

public String getName()
Description copied from interface: Tag
Returns the node name, ie. either the name of the namespace if this Tag represents a tag namespace, the name of the part of a taxonomy (eg. "fruit" in "fruit/apple") or the name of the tag itself.

Specified by:
getName in interface Tag

getTagID

public String getTagID()
Description copied from interface: Tag
Returns the short tag ID. If namespace is default, it will be left out. If this tag represents a namespace, null is returned.

Specified by:
getTagID in interface Tag

getLocalTagID

public String getLocalTagID()
Description copied from interface: Tag
Returns the tag path below a namespace. If this tag represents a namespace, null is returned.

Specified by:
getLocalTagID in interface Tag

getTitlePath

public String getTitlePath()
Description copied from interface: Tag
Returns the title variant of the tag ID: a path made up of the single titles of the namespace and all tags leading to this tag.

Specified by:
getTitlePath in interface Tag

getPath

public String getPath()
Description copied from interface: Tag
Returns the full absolute path of a tag or a tag namespace.

Specified by:
getPath in interface Tag

getDescription

public String getDescription()
Description copied from interface: Tag
Returns an optional description for a tag. If none is available, null is returned.

Specified by:
getDescription in interface Tag

getTitle

public String getTitle()
Description copied from interface: Tag
Returns a title that should be displayed instead of the tag name or tag id. If no separate title is available, the tag name is returned.

Specified by:
getTitle in interface Tag

getCount

public long getCount()
Description copied from interface: Tag
Returns the usage count of the tag, which can be used for tag cloud and other visualisations. An implementation does not have to ensure a completely exact number, but it should be as up-to-date as possible, so each call can trigger a search for all tags.

Specified by:
getCount in interface Tag

isNamespace

public boolean isNamespace()
Description copied from interface: Tag
Returns true if this tag object refers to a tag namespace.

Specified by:
isNamespace in interface Tag

getNamespace

public Tag getNamespace()
Description copied from interface: Tag
Returns the tag namespace inside which this tag resides as tag object.

Specified by:
getNamespace in interface Tag

getParent

public Tag getParent()
Description copied from interface: Tag
Gets the parent of this tag. This could be either a tag container, a tag namespace or null if this object is a tag namespace.

Specified by:
getParent in interface Tag

listChildren

public Iterator<Tag> listChildren()
Description copied from interface: Tag
Lists the direct child tags for both tag namespaces and tag containers.

Specified by:
listChildren in interface Tag

listChildren

public Iterator<Tag> listChildren(Filter<Tag> filter)
Description copied from interface: Tag
Lists the child tags for both tag namespaces and tag containers, but only those included by a filter.

Specified by:
listChildren in interface Tag

listAllSubTags

public Iterator<Tag> listAllSubTags()
Description copied from interface: Tag
Lists all sub-tags, ie. children, grand-children and so on. Note that the returned list might not be in order.

Specified by:
listAllSubTags in interface Tag

find

public Iterator<org.apache.sling.api.resource.Resource> find()
Description copied from interface: Tag
Returns all nodes tagged with this tag. These are all nodes with a cq:tags property that contains either the tagID or the full absolute path to that tag. Returns null in case of errors.

Specified by:
find in interface Tag
See Also:
TagManager.find(String), TagManager.find(String, String[])


Copyright © 2008 Day Management AG. All Rights Reserved.