net.sf.mmm.content.model.base
Class AbstractContentClass

java.lang.Object
  extended by net.sf.mmm.content.base.AbstractContentObject
      extended by net.sf.mmm.content.model.base.AbstractContentReflectionObject
          extended by net.sf.mmm.content.model.base.AbstractContentClass
All Implemented Interfaces:
Serializable, ContentObject, ContentClass, ContentReflectionObject, MetaData, MutableMetaData
Direct Known Subclasses:
ContentClassImpl

public abstract class AbstractContentClass
extends AbstractContentReflectionObject
implements ContentClass

This is the abstract base implementation of the ContentClass interface.

Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.mmm.content.base.AbstractContentObject
AbstractContentObject.AbstractContentObjectModifier
 
Field Summary
 
Fields inherited from interface net.sf.mmm.content.model.api.ContentClass
CLASS_ID, CLASS_NAME, FIELD_NAME_DECLARED_FIELDS, FIELD_NAME_FIELDS, FIELD_NAME_SUB_CLASSES, FIELD_NAME_SUPER_CLASS, XML_TAG_CLASS, XML_TAG_CONTENT_MODEL
 
Fields inherited from interface net.sf.mmm.content.model.api.ContentReflectionObject
FIELD_NAME_MODIFIERS
 
Fields inherited from interface net.sf.mmm.content.api.ContentObject
ENV_VARIABLE_THIS, FIELD_NAME_DELETED, FIELD_NAME_ID, FIELD_NAME_NAME, PATH_SEPARATOR
 
Fields inherited from interface net.sf.mmm.content.value.api.MutableMetaData
VALUE_NAME
 
Constructor Summary
AbstractContentClass()
          The constructor.
AbstractContentClass(String name, SmartId id)
          The constructor.
 
Method Summary
 void addField(AbstractContentField field)
          This method adds the given field to this class.
 void addSubClass(AbstractContentClass subClass)
          This method adds a sub-class to this class.
 List<? extends AbstractContentClass> getChildren()
          This method gets the list containing all direct children of this object.
 AbstractContentField getDeclaredField(String name)
          This method gets the declared field with the given name.
 Collection<AbstractContentField> getDeclaredFields()
          This method gets an iterator of all fields declared by this class.
 AbstractContentField getField(String name)
          This method gets the field with the given name.
 Collection<AbstractContentField> getFields()
          This method gets all fields defined in this class or inherited by the super-class(es).
 Class<? extends ContentObject> getJavaClass()
          This method gets the class reflecting the closest type of this content-class.
 ClassModifiers getModifiers()
          This method gets the modifiers of this object.
 List<AbstractContentClass> getSubClasses()
          This method gets the list of all sub-classes.
 AbstractContentClass getSuperClass()
          This method gets the super-class of this class.
 boolean isClass()
          This method determines if this is a content-class or a content-field.
 boolean isFolderClass()
          This method determines if the entity represented by this ContentClass is a folder.
 boolean isRevisionControlled()
          This method determines if the entities of this ContentClass are revision-controlled.
 boolean isSubClassOf(ContentClass contentClass)
          This is the opposite of the method ContentClass.isSuperClassOf(ContentClass).
 boolean isSuperClassOf(ContentClass contentClass)
          This method determines is this class is a super class of the given class.
 void setFolderClass(boolean isFolderClass)
           
protected  void setJavaClass(Class<? extends ContentObject> javaClass)
          This method sets the Java-class of this content-class.
protected  void setModifiers(ClassModifiers modifiers)
           
 void setRevisionControlled(boolean revisionControlled)
           
protected  void setSuperClass(AbstractContentClass superClass)
          This method sets the super-class.
 
Methods inherited from class net.sf.mmm.content.model.base.AbstractContentReflectionObject
setDeletedFlag, setLock, setMetaDataSet, toString
 
Methods inherited from class net.sf.mmm.content.base.AbstractContentObject
equals, getChild, getContentClass, getDeletedFlag, getId, getLock, getMetaDataSet, getModificationCount, getName, getParent, getPath, getRevision, getRevisionHistory, getValue, getValue, hashCode, isDeleted, isFolder, isRevisionClosed, removeValue, setModificationCount, setValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.mmm.content.model.api.ContentClass
getParent
 
Methods inherited from interface net.sf.mmm.content.api.ContentObject
getChild, getContentClass, getDeletedFlag, getId, getLock, getMetaDataSet, getName, getPath, getRevision, getRevisionHistory, getValue, getValue, isDeleted, isFolder, isRevisionClosed, setValue
 

Constructor Detail

AbstractContentClass

public AbstractContentClass()
The constructor.


AbstractContentClass

public AbstractContentClass(String name,
                            SmartId id)
The constructor.

Parameters:
name - is the name.
id - is the ID.
Method Detail

getSuperClass

@FieldAnnotation(id=25)
public AbstractContentClass getSuperClass()
This method gets the super-class of this class. Like in java this class inherits everything from its super-classes.
This method is equivalent to ContentClass.getParent() and only exists for its more precise name.

Specified by:
getSuperClass in interface ContentClass
Returns:
the super-class that is extended by this class.

getChildren

public List<? extends AbstractContentClass> getChildren()
This method gets the list containing all direct children of this object. If this object is NOT a folder the result will always be an empty list.
Typically the direct children are the ContentObjects that have this object as parent.
ATTENTION:
For some specific entities this method may return children that do NOT have this object as ContentObject.getParent(). E.g. a SearchFolder may be a virtual folder that performs a dynamic search returning arbitrary objects from this method that themselves reside in different, physical folders.

Specified by:
getChildren in interface ContentObject
Specified by:
getChildren in interface ContentClass
Overrides:
getChildren in class AbstractContentObject
Returns:
the child resources.

isFolderClass

@FieldAnnotation(id=26)
public boolean isFolderClass()
This method determines if the entity represented by this ContentClass is a folder.

Specified by:
isFolderClass in interface ContentClass
Returns:
true if the represented entity is a folder, false if it is a leaf.
See Also:
ContentObject.isFolder()

setFolderClass

public void setFolderClass(boolean isFolderClass)
Parameters:
isFolderClass - the isFolderClass to set

isRevisionControlled

public boolean isRevisionControlled()
This method determines if the entities of this ContentClass are revision-controlled. Such entity can be frozen to a closed revision creating a history. Besides the latest revision, the closed revisions can still be accessed.
If an entity that is NOT under revision-control is modified, every except the current state is lost.

Specified by:
isRevisionControlled in interface ContentClass
Returns:
true if this type is revisioned, false otherwise.
See Also:
ClassAnnotation.revisionControl()

setRevisionControlled

public void setRevisionControlled(boolean revisionControlled)
Parameters:
revisionControlled - the revisionControlled to set

setSuperClass

protected void setSuperClass(AbstractContentClass superClass)
This method sets the super-class.

Parameters:
superClass - the super-class to set.

getDeclaredFields

public Collection<AbstractContentField> getDeclaredFields()
This method gets an iterator of all fields declared by this class. This does NOT include fields inherited from the super-class except they are overridden by this class. An inherited field can be overridden (if supported by the content-model) in order to declare it more specific. Then the type of the field is a subtype of the field that is overridden or the validator is more restrictive.

Specified by:
getDeclaredFields in interface ContentClass
Returns:
a (read-only) collection of all declared fields.

getDeclaredField

public AbstractContentField getDeclaredField(String name)
This method gets the declared field with the given name. Declared means that the field is initially defined or overridden in this class.
An inherited field can be overridden (if supported by the content-model) in order to declare it more specific (typically the field-type is specialized). Such field can be identified via ContentField.getInitiallyDefiningClass().

Specified by:
getDeclaredField in interface ContentClass
Parameters:
name - is the name of the requested field of this class.
Returns:
the field with the given name or null if no such field is declared by this class.
See Also:
ContentClass.getField(String)

getField

public AbstractContentField getField(String name)
This method gets the field with the given name. A field is either declared in this class or inherited from a super-class.

Specified by:
getField in interface ContentClass
Parameters:
name - is the name of the requested field of this class.
Returns:
the field with the given name or null if no such field exists for this class.

getFields

public Collection<AbstractContentField> getFields()
This method gets all fields defined in this class or inherited by the super-class(es). An inherited field can be identified via ContentField.getDeclaringClass().
ATTENTION:
The Collection.size() method of the returned instance may be very expensive. Please avoid unnecessary or repetitive calls.

Specified by:
getFields in interface ContentClass
Returns:
a (read-only) collection of fields of this class.

getModifiers

public ClassModifiers getModifiers()
This method gets the modifiers of this object. The modifiers are a set of flags.

Specified by:
getModifiers in interface ContentClass
Specified by:
getModifiers in interface ContentReflectionObject
Specified by:
getModifiers in class AbstractContentReflectionObject
Returns:
the objects modifiers.
See Also:
ContentClass.getModifiers(), ContentField.getModifiers()

setModifiers

protected void setModifiers(ClassModifiers modifiers)
Parameters:
modifiers - the modifiers to set

getSubClasses

public List<AbstractContentClass> getSubClasses()
This method gets the list of all sub-classes.

Specified by:
getSubClasses in interface ContentClass
Returns:
an un-modifiable list of all sub-class.

getJavaClass

@FieldAnnotation(id=33)
public Class<? extends ContentObject> getJavaClass()
This method gets the class reflecting the closest type of this content-class.

Specified by:
getJavaClass in interface ContentClass
Returns:
the "implementation".

setJavaClass

protected void setJavaClass(Class<? extends ContentObject> javaClass)
This method sets the Java-class of this content-class.

Parameters:
javaClass - is the class realizing the entity.

isClass

public boolean isClass()
This method determines if this is a content-class or a content-field. It is allowed to cast this object according to the result of this method.

Specified by:
isClass in interface ContentReflectionObject
Returns:
true if this is a content-class, false if this is a content-field.

isSubClassOf

public boolean isSubClassOf(ContentClass contentClass)
This is the opposite of the method ContentClass.isSuperClassOf(ContentClass). This means that class1.isSubClassOf(class2) is equal to class2.isSuperClassOf(class1).

Specified by:
isSubClassOf in interface ContentClass
Parameters:
contentClass - is the class to compare with.
Returns:
true if this class is a sub-class of the given class.

isSuperClassOf

public boolean isSuperClassOf(ContentClass contentClass)
This method determines is this class is a super class of the given class.

Specified by:
isSuperClassOf in interface ContentClass
Parameters:
contentClass - is the class to compare with.
Returns:
true if this class is a super-class of the given class.

addSubClass

public void addSubClass(AbstractContentClass subClass)
                 throws ContentModelException
This method adds a sub-class to this class.
It is an idem-potent operation. Therefore it will have no effect if the given subClass is already a registered sub-class of this class.

Parameters:
subClass - is the sub-class to add.
Throws:
ContentModelException - if the operation fails.

addField

public void addField(AbstractContentField field)
              throws ContentModelException
This method adds the given field to this class.

Parameters:
field - is the field to add.
Throws:
ContentModelException - if the field could NOT be added.


Copyright © 2001-2008 mmm-Team. All Rights Reserved.