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>constraintsstatic Type[]EMPTY_SUPERTYPESprotected Stringnameprotected Stringschemaprotected TypesuperType
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractType(Type superType, String schema, String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConstraints(Collection<Constraint> constraints)Objectdecode(String string)Decodes the string representation into an object of this type.Stringencode(Object object)Encodes the given object that is assumed to be of this type into a string representation.Set<Constraint>getConstraints()StringgetName()Gets the name of this type.ObjectResolvergetObjectResolver()Provides aObjectResolverif this type is a reference to an external entity.SchemagetSchema()Gets the schema defining this type.StringgetSchemaName()Gets the local name of this type.TypegetSuperType()Gets the super type.Type[]getTypeHierarchy()Gets the entire hierarchy of super-types.booleanisAny()booleanisAnyType()Tests whether this type is the ANY type.booleanisComplexType()Tests whether this type is a complex type.booleanisCompositeType()Tests whether this is a composite type.booleanisListType()Tests whether this type is a list type.booleanisSimpleType()Tests whether this type is a simple type.booleanisSuperTypeOf(Type type)Tests whether the given type is derived from this type.ObjectnewInstance()Creates a new instance according to this type and filled with default values.booleanvalidate(Object object)Tests whether the given object is of this type.protected booleanvalidateConstraints(Object object)
-
-
-
Method Detail
-
getSuperType
public Type getSuperType()
Description copied from interface:TypeGets the super type.- Specified by:
getSuperTypein interfaceType- Returns:
- the super type or null if this is a primitive type
-
getSchemaName
public String getSchemaName()
Description copied from interface:TypeGets the local name of this type.- Specified by:
getSchemaNamein interfaceType- Returns:
- the local name
-
getSchema
public Schema getSchema()
Description copied from interface:TypeGets the schema defining this type.
-
isSuperTypeOf
public boolean isSuperTypeOf(Type type)
Description copied from interface:TypeTests whether the given type is derived from this type.- Specified by:
isSuperTypeOfin 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:TypeGets 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
ANYtype.- Specified by:
getTypeHierarchyin interfaceType- Returns:
- an array containing the supertypes of this type
-
isSimpleType
public boolean isSimpleType()
Description copied from interface:TypeTests whether this type is a simple type.- Specified by:
isSimpleTypein interfaceType- Returns:
- true if this type is a simple type, false otherwise
-
isComplexType
public boolean isComplexType()
Description copied from interface:TypeTests whether this type is a complex type.- Specified by:
isComplexTypein interfaceType- Returns:
- true if this type is a complex type, false otherwise
-
isListType
public boolean isListType()
Description copied from interface:TypeTests whether this type is a list type.- Specified by:
isListTypein interfaceType- Returns:
- true if is a list type, false otherwise
-
isAnyType
public boolean isAnyType()
Description copied from interface:TypeTests whether this type is the ANY type.
-
isCompositeType
public boolean isCompositeType()
Description copied from interface:TypeTests whether this is a composite type.- Specified by:
isCompositeTypein interfaceType- Returns:
- true if this is a composite type, false otherwise
-
validate
public boolean validate(Object object) throws TypeException
Description copied from interface:TypeTests whether the given object is of this type.- Specified by:
validatein 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:TypeDecodes 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:TypeEncodes 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:TypeCreates a new instance according to this type and filled with default values.- Specified by:
newInstancein interfaceType
-
getConstraints
public Set<Constraint> getConstraints()
- Specified by:
getConstraintsin 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:TypeProvides aObjectResolverif this type is a reference to an external entity.- Specified by:
getObjectResolverin interfaceType- Returns:
- a resolver if available, null otherwise.
-
-