org.mycore.datamodel.classifications2.impl
Class MCRAbstractCategoryImpl

java.lang.Object
  extended by org.mycore.datamodel.classifications2.impl.MCRAbstractCategoryImpl
All Implemented Interfaces:
MCRCategory
Direct Known Subclasses:
MCRCategoryImpl

public abstract class MCRAbstractCategoryImpl
extends Object
implements MCRCategory

Since:
2.0
Version:
$Revision: 14980 $ $Date: 2009-03-20 14:02:28 +0100 (Fri, 20 Mar 2009) $
Author:
Thomas Scheffler (yagee)

Field Summary
protected  List<MCRCategory> children
           
protected  ReentrantReadWriteLock childrenLock
           
protected  Collection<MCRLabel> labels
           
protected  MCRCategory parent
           
protected  MCRCategory root
           
 
Constructor Summary
MCRAbstractCategoryImpl()
           
 
Method Summary
(package private)  void detachFromParent()
           
 List<MCRCategory> getChildren()
          Returns a list of subcategories.
 MCRLabel getCurrentLabel()
           
 MCRCategoryID getId()
           
 MCRLabel getLabel(String lang)
           
 Collection<MCRLabel> getLabels()
           
 MCRCategory getParent()
          Returns the parent element
 MCRCategory getRoot()
          Returns root category (the classification).
 URI getURI()
          Returns the URI associated with this category.
 boolean hasChildren()
          Tells if this category has subcategories.
 boolean isCategory()
           
 boolean isClassification()
           
protected abstract  void setChildren(List<MCRCategory> children)
           
 void setId(MCRCategoryID id)
           
 void setParent(MCRCategory parent)
           
 void setURI(URI uri)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mycore.datamodel.classifications2.MCRCategory
getLevel
 

Field Detail

root

protected MCRCategory root

parent

protected MCRCategory parent

labels

protected Collection<MCRLabel> labels

children

protected List<MCRCategory> children

childrenLock

protected final ReentrantReadWriteLock childrenLock
Constructor Detail

MCRAbstractCategoryImpl

public MCRAbstractCategoryImpl()
Method Detail

getChildren

public List<MCRCategory> getChildren()
Description copied from interface: MCRCategory
Returns a list of subcategories. Implementors must never return null if no children are present. As this method may need a new call the underlaying persistence layer use hasChildren() if you just want to know if subcategories are present. Changes to the list may not affect the underlaying persistence layer.

Specified by:
getChildren in interface MCRCategory
Returns:
subcategories
See Also:
MCRCategory.hasChildren()

setChildren

protected abstract void setChildren(List<MCRCategory> children)

getId

public MCRCategoryID getId()
Specified by:
getId in interface MCRCategory
Returns:
the id

getLabels

public Collection<MCRLabel> getLabels()
Specified by:
getLabels in interface MCRCategory
Returns:
the labels

getRoot

public MCRCategory getRoot()
Description copied from interface: MCRCategory
Returns root category (the classification).

Specified by:
getRoot in interface MCRCategory
Returns:
the root category

getURI

public URI getURI()
Description copied from interface: MCRCategory
Returns the URI associated with this category.

Specified by:
getURI in interface MCRCategory
Returns:
the URI

hasChildren

public boolean hasChildren()
Description copied from interface: MCRCategory
Tells if this category has subcategories.

Specified by:
hasChildren in interface MCRCategory
Returns:
true if this category has subcategories
See Also:
MCRCategory.getChildren()

isCategory

public final boolean isCategory()
Specified by:
isCategory in interface MCRCategory
Returns:
true if this is not a root category
See Also:
MCRCategory.isClassification()

isClassification

public final boolean isClassification()
Specified by:
isClassification in interface MCRCategory
Returns:
true if this is a root category

setId

public void setId(MCRCategoryID id)
Specified by:
setId in interface MCRCategory
Parameters:
id - the id to set

setURI

public void setURI(URI uri)
Specified by:
setURI in interface MCRCategory
Parameters:
uri - the URI to set

getParent

public MCRCategory getParent()
Description copied from interface: MCRCategory
Returns the parent element

Specified by:
getParent in interface MCRCategory
Returns:
the categories parent or null if isClassification()==true or category currently not attached

setParent

public void setParent(MCRCategory parent)

detachFromParent

void detachFromParent()

getCurrentLabel

public MCRLabel getCurrentLabel()
Specified by:
getCurrentLabel in interface MCRCategory
Returns:
the label in the current language (if available), default language (if available) or any other language

getLabel

public MCRLabel getLabel(String lang)
Specified by:
getLabel in interface MCRCategory
Returns:
the label in the specified language (if available) or null