Package org.nuxeo.ecm.core.schema.types
Class AbstractType
- java.lang.Object
-
- org.nuxeo.ecm.core.schema.types.AbstractType
-
- All Implemented Interfaces:
Serializable
,Type
- Direct Known Subclasses:
AnyType
,ComplexTypeImpl
,ListTypeImpl
,PrimitiveType
,SimpleTypeImpl
public abstract class AbstractType extends Object implements Type
Abstract (common) implementation for a Type.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Set<Constraint>
constraints
static Type[]
EMPTY_SUPERTYPES
protected String
name
protected String
schema
protected Type
superType
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractType(Type superType, String schema, String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConstraints(Collection<Constraint> constraints)
Object
decode(String string)
Decodes the string representation into an object of this type.String
encode(Object object)
Encodes the given object that is assumed to be of this type into a string representation.Set<Constraint>
getConstraints()
String
getName()
Gets the name of this type.ObjectResolver
getObjectResolver()
Provides aObjectResolver
if this type is a reference to an external entity.Schema
getSchema()
Gets the schema defining this type.String
getSchemaName()
Gets the local name of this type.Type
getSuperType()
Gets the super type.Type[]
getTypeHierarchy()
Gets the entire hierarchy of super-types.boolean
isAny()
boolean
isAnyType()
Tests whether this type is the ANY type.boolean
isComplexType()
Tests whether this type is a complex type.boolean
isCompositeType()
Tests whether this is a composite type.boolean
isListType()
Tests whether this type is a list type.boolean
isSimpleType()
Tests whether this type is a simple type.boolean
isSuperTypeOf(Type type)
Tests whether the given type is derived from this type.Object
newInstance()
Creates a new instance according to this type and filled with default values.boolean
validate(Object object)
Tests whether the given object is of this type.protected boolean
validateConstraints(Object object)
-
-
-
Method Detail
-
getSuperType
public Type getSuperType()
Description copied from interface:Type
Gets the super type.- Specified by:
getSuperType
in interfaceType
- Returns:
- the super type or null if this is a primitive type
-
getSchemaName
public String getSchemaName()
Description copied from interface:Type
Gets the local name of this type.- Specified by:
getSchemaName
in interfaceType
- Returns:
- the local name
-
getSchema
public Schema getSchema()
Description copied from interface:Type
Gets the schema defining this type.
-
isSuperTypeOf
public boolean isSuperTypeOf(Type type)
Description copied from interface:Type
Tests whether the given type is derived from this type.- Specified by:
isSuperTypeOf
in interfaceType
- Parameters:
type
- the type to test- Returns:
- true if the given type is derived from this type, false otherwise
-
isAny
public boolean isAny()
-
getTypeHierarchy
public Type[] getTypeHierarchy()
Description copied from interface:Type
Gets the entire hierarchy of super-types.The array is ordered as follows:
- the direct super type is the first element,
- the super super type is the second element,
- and so on.
The returned array is never null. An empty array is returned in the case of
ANY
type.- Specified by:
getTypeHierarchy
in interfaceType
- Returns:
- an array containing the supertypes of this type
-
isSimpleType
public boolean isSimpleType()
Description copied from interface:Type
Tests whether this type is a simple type.- Specified by:
isSimpleType
in interfaceType
- Returns:
- true if this type is a simple type, false otherwise
-
isComplexType
public boolean isComplexType()
Description copied from interface:Type
Tests whether this type is a complex type.- Specified by:
isComplexType
in interfaceType
- Returns:
- true if this type is a complex type, false otherwise
-
isListType
public boolean isListType()
Description copied from interface:Type
Tests whether this type is a list type.- Specified by:
isListType
in interfaceType
- Returns:
- true if is a list type, false otherwise
-
isAnyType
public boolean isAnyType()
Description copied from interface:Type
Tests whether this type is the ANY type.
-
isCompositeType
public boolean isCompositeType()
Description copied from interface:Type
Tests whether this is a composite type.- Specified by:
isCompositeType
in interfaceType
- Returns:
- true if this is a composite type, false otherwise
-
validate
public boolean validate(Object object) throws TypeException
Description copied from interface:Type
Tests whether the given object is of this type.- Specified by:
validate
in interfaceType
- Parameters:
object
- the object to test- Returns:
- true if the given object if of this type, false otherwise
- Throws:
TypeException
- if an error occurs trying to retrieve the supertypes
-
decode
public Object decode(String string)
Description copied from interface:Type
Decodes the string representation into an object of this type.Returns null if the string can not be decoded.
-
encode
public String encode(Object object)
Description copied from interface:Type
Encodes the given object that is assumed to be of this type into a string representation.Null is returned if the object cannot be converted.
-
newInstance
public Object newInstance()
Description copied from interface:Type
Creates a new instance according to this type and filled with default values.- Specified by:
newInstance
in interfaceType
-
getConstraints
public Set<Constraint> getConstraints()
- Specified by:
getConstraints
in interfaceType
- Returns:
- this type's constraints
-
addConstraints
public void addConstraints(Collection<Constraint> constraints)
-
validateConstraints
protected boolean validateConstraints(Object object)
-
getObjectResolver
public ObjectResolver getObjectResolver()
Description copied from interface:Type
Provides aObjectResolver
if this type is a reference to an external entity.- Specified by:
getObjectResolver
in interfaceType
- Returns:
- a resolver if available, null otherwise.
-
-