Package org.nuxeo.ecm.core.schema.types
Interface Type
- All Superinterfaces:
Serializable
- All Known Subinterfaces:
ComplexType
,CompositeType
,DocumentType
,ListType
,Schema
,SimpleType
- All Known Implementing Classes:
AbstractType
,AnyType
,BinaryType
,BooleanType
,ComplexTypeImpl
,CompositeTypeImpl
,DateType
,DocumentTypeImpl
,DoubleType
,IntegerType
,ListTypeImpl
,LongType
,PrimitiveType
,SchemaImpl
,SimpleTypeImpl
,StringType
A Type object is used to describe some ECM content.
There are two groups of content types:
- primitive types - these are builtin types used to describe simple values like string, integers, dates etc
- custom types - these are used defined types based on the primitive types
- simple types - constrained primitive types. Constraints are specific to each primitive type.
For example the "string" type may have constraints like maximum length, regular expression pattern etc.
So you can define a custom simple type as being a string that match the regular expression.+@.+
- complex types - structured types that can be expressed as a tree like structure of other primitive, simple or complex types.
There is a root type called ANY
type.
Apart this special type, each type has a super type (a type from which it is derived)
On top of this typing system there are two high level content types:
- schemas - a schema is a complex that can be used to form composite types
Because multiple schemas may live together in a composite type they must provide a namespace to avoid name collisions inside a composite type - composite types - a composite type is made of several schemas.
You can see a composite type as a type derived from multiple complex super types.
Composite types are used to define ECM documents
:
character. This character may be used internally to prefix the type
name so it must not be used in the type name.-
Method Summary
Modifier and TypeMethodDescriptionConverts the given value to an object compatible with the associated type.Decodes the string representation into an object of this type.Encodes the given object that is assumed to be of this type into a string representation.getName()
Gets the name of this type.Provides aObjectResolver
if this type is a reference to an external entity.Gets the schema defining this type.Gets the local name of this type.Gets the super type.Type[]
Gets the entire hierarchy of super-types.boolean
Tests whether this type is the ANY type.boolean
Tests whether this type is a complex type.boolean
Tests whether this is a composite type.boolean
Tests whether this type is a list type.boolean
Tests whether this type is a simple type.boolean
isSuperTypeOf
(Type type) Tests whether the given type is derived from this type.Creates a new instance according to this type and filled with default values.boolean
Tests whether the given object is of this type.
-
Method Details
-
getName
String getName()Gets the name of this type.- Returns:
- the type name
-
getSchemaName
String getSchemaName()Gets the local name of this type.- Returns:
- the local name
-
getSchema
Schema getSchema()Gets the schema defining this type. -
getSuperType
Type getSuperType()Gets the super type.- Returns:
- the super type or null if this is a primitive type
-
getTypeHierarchy
Type[] getTypeHierarchy()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.- Returns:
- an array containing the supertypes of this type
-
isSuperTypeOf
Tests whether the given type is derived from this type.- Parameters:
type
- the type to test- Returns:
- true if the given type is derived from this type, false otherwise
-
isSimpleType
boolean isSimpleType()Tests whether this type is a simple type.- Returns:
- true if this type is a simple type, false otherwise
-
isComplexType
boolean isComplexType()Tests whether this type is a complex type.- Returns:
- true if this type is a complex type, false otherwise
-
isListType
boolean isListType()Tests whether this type is a list type.- Returns:
- true if is a list type, false otherwise
-
isAnyType
boolean isAnyType()Tests whether this type is the ANY type.- Returns:
- true if it is the ANY type, false otherwise
-
isCompositeType
boolean isCompositeType()Tests whether this is a composite type.- Returns:
- true if this is a composite type, false otherwise
-
validate
Tests whether the given object is of this type.- 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
Decodes the string representation into an object of this type.Returns null if the string can not be decoded.
- Parameters:
string
- the string to decode- Returns:
- the converted object that can be use as a value for an object of this type or null if the given object cannot be converted
-
encode
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.
- Parameters:
object
- the object to convert- Returns:
- the string representation of the given object or null if object cannot be converted
-
newInstance
Object newInstance()Creates a new instance according to this type and filled with default values. -
convert
Converts the given value to an object compatible with the associated type.- Parameters:
value
- the value to convert- Returns:
- the converted value
- Throws:
TypeException
- if the value to convert is not compatible with the associated type
-
getConstraints
Set<Constraint> getConstraints()- Returns:
- this type's constraints
- Since:
- 7.1
-
getObjectResolver
ObjectResolver getObjectResolver()Provides aObjectResolver
if this type is a reference to an external entity.- Returns:
- a resolver if available, null otherwise.
- Since:
- 7.1
-