Humboldt Alignment Editor 2.5.0

eu.esdihumboldt.hale.common.schema.model.impl
Class AbstractDefinition<C>

java.lang.Object
  extended by eu.esdihumboldt.hale.common.schema.model.impl.AbstractDefinition<C>
Type Parameters:
C - the supported constraint type
All Implemented Interfaces:
Locatable, Definition<C>, Comparable<Definition<?>>
Direct Known Subclasses:
AbstractChildDefinition, DefaultTypeDefinition, XmlAttribute, XmlElement

public abstract class AbstractDefinition<C>
extends Object
implements Definition<C>

Basic definition implementation to be subclassed

Author:
Simon Templer

Field Summary
protected  QName name
          The qualified definition name
 
Constructor Summary
AbstractDefinition(QName name)
          Creates a new definition with the given name.
 
Method Summary
 int compareTo(Definition<?> other)
           
 boolean equals(Object obj)
          Two definitions are equal if their name is equal (namespace and local part)
<T extends C>
T
getConstraint(Class<T> constraintType)
          Get the constraint with the given constraint type.
Should usually not be called while creating the model, exceptions can be getting mutable constraints where this is intended.
 String getDescription()
          Get the definition description
 String getDisplayName()
          Returns the local part of the qualified name.
 String getIdentifier()
          Get the definitions identifier
protected
<T extends C>
T
getInheritedConstraint(Class<T> constraintType)
          Get the inherited constraint of the given constraint type.

This implementation returns null, as inheritance is not supported generally for definitions.
 URI getLocation()
          Get the location
 QName getName()
          Get the definition's qualified name
 boolean hasConstraint(Class<? extends C> constraintType)
          Determines if the constraint with the given type is set explicitly for the definition.
 int hashCode()
           
 void setConstraint(C constraint)
          Set a constraint on the definition
 void setConstraintIfNotSet(C constraint)
          Set a constraint on the definition if none of the same type has been set yet.
 void setDescription(String description)
          Set the definition description
 void setLocation(URI location)
          Set the definition location
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected final QName name
The qualified definition name

Constructor Detail

AbstractDefinition

public AbstractDefinition(QName name)
Creates a new definition with the given name. Description and location are not set.

Parameters:
name - the qualified definition name
Method Detail

getConstraint

public <T extends C> T getConstraint(Class<T> constraintType)
Description copied from interface: Definition
Get the constraint with the given constraint type.
Should usually not be called while creating the model, exceptions can be getting mutable constraints where this is intended.

Specified by:
getConstraint in interface Definition<C>
Type Parameters:
T - the constraint type
Parameters:
constraintType - the constraint type, see Constraint
Returns:
the constraint with the given type
See Also:
Definition.getConstraint(Class)

getInheritedConstraint

protected <T extends C> T getInheritedConstraint(Class<T> constraintType)
Get the inherited constraint of the given constraint type.

This implementation returns null, as inheritance is not supported generally for definitions.

Parameters:
constraintType - the constraint type
Returns:
the inherited constraint or null if there is none or inheritance is not allowed

hasConstraint

public boolean hasConstraint(Class<? extends C> constraintType)
Determines if the constraint with the given type is set explicitly for the definition.

Parameters:
constraintType - the constraint type
Returns:
if the constraint is set explicitly

setConstraint

public void setConstraint(C constraint)
Set a constraint on the definition

Parameters:
constraint - the constraint to set

setConstraintIfNotSet

public void setConstraintIfNotSet(C constraint)
Set a constraint on the definition if none of the same type has been set yet.

Parameters:
constraint - the constraint to set

setDescription

public void setDescription(String description)
Set the definition description

Parameters:
description - the description to set

setLocation

public void setLocation(URI location)
Set the definition location

Parameters:
location - the location to set

getLocation

public URI getLocation()
Description copied from interface: Locatable
Get the location

Specified by:
getLocation in interface Locatable
Returns:
the location, may be null
See Also:
Locatable.getLocation()

getDisplayName

public String getDisplayName()
Returns the local part of the qualified name. Override to change this behavior.

Specified by:
getDisplayName in interface Definition<C>
Returns:
the display name
See Also:
Definition.getDisplayName()

getName

public QName getName()
Description copied from interface: Definition
Get the definition's qualified name

Specified by:
getName in interface Definition<C>
Returns:
the qualified name
See Also:
Definition.getName()

getDescription

public String getDescription()
Description copied from interface: Definition
Get the definition description

Specified by:
getDescription in interface Definition<C>
Returns:
the description string or null
See Also:
Definition.getDescription()

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

equals

public boolean equals(Object obj)
Two definitions are equal if their name is equal (namespace and local part)

Overrides:
equals in class Object
See Also:
Object.equals(Object)

compareTo

public int compareTo(Definition<?> other)
Specified by:
compareTo in interface Comparable<Definition<?>>
See Also:
Comparable.compareTo(Object)

getIdentifier

public String getIdentifier()
Description copied from interface: Definition
Get the definitions identifier

Specified by:
getIdentifier in interface Definition<C>
Returns:
the unique name of the definition
See Also:
Definition.getIdentifier()

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()

Humboldt Alignment Editor 2.5.0

Build 2012-12-03_12-30-59
Revision 9d2dd4b0318cda9f1393b1ddd390f7f792d70a2d