Package org.nuxeo.ecm.core.schema.types
Class ComplexTypeImpl
java.lang.Object
org.nuxeo.ecm.core.schema.types.AbstractType
org.nuxeo.ecm.core.schema.types.ComplexTypeImpl
- All Implemented Interfaces:
Serializable
,ComplexType
,Type
- Direct Known Subclasses:
CompositeTypeImpl
,SchemaImpl
A Complex Type holds several fields.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionThe fields held by this complex type.The map of name or prefixed name to field.protected final Namespace
Fields inherited from class org.nuxeo.ecm.core.schema.types.AbstractType
constraints, EMPTY_SUPERTYPES, name, schema, superType
-
Constructor Summary
ConstructorDescriptionComplexTypeImpl
(ComplexType superType, String schema, String name) ComplexTypeImpl
(ComplexType superType, String schema, String name, Namespace ns) -
Method Summary
Modifier and TypeMethodDescriptionaddField
(String name, Type type, String defaultValue, int flags, Collection<Constraint> constraints) Adds a field to this complex type.protected void
static String
canonicalXPath
(String xpath) Canonicalizes a Nuxeo-xpath.Converts the given value to an object compatible with the associated type.Gets the field with the given name.Gets the field having the given name.Gets all fields as a (field name, field type) map.int
Gets the number of fields defined for this complex type.Gets the namespace used by this complex type.boolean
Tests whether this type defines the given field name.boolean
Tests whether this type has any field defined.boolean
Tests whether this type is a complex type.Creates a new instance according to this type and filled with default values.toString()
boolean
Tests whether the given object is of this type.Methods inherited from class org.nuxeo.ecm.core.schema.types.AbstractType
addConstraints, decode, encode, getConstraints, getName, getObjectResolver, getSchema, getSchemaName, getSuperType, getTypeHierarchy, isAny, isAnyType, isCompositeType, isListType, isSimpleType, isSuperTypeOf, validateConstraints
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.nuxeo.ecm.core.schema.types.Type
decode, encode, getConstraints, getName, getObjectResolver, getSchema, getSchemaName, getSuperType, getTypeHierarchy, isAnyType, isCompositeType, isListType, isSimpleType, isSuperTypeOf
-
Field Details
-
fields
The fields held by this complex type. -
fieldsByName
The map of name or prefixed name to field. -
ns
-
-
Constructor Details
-
ComplexTypeImpl
-
ComplexTypeImpl
-
-
Method Details
-
addField
-
addField
public Field addField(String name, Type type, String defaultValue, int flags, Collection<Constraint> constraints) Description copied from interface:ComplexType
Adds a field to this complex type.If the given name is not prefixed it will be prefixed with the type prefix. If one was specified otherwise the default prefix will be used (e.g. "" - no prefix). If the given name is prefixed it will be stored as is (using the specified prefix).
- Specified by:
addField
in interfaceComplexType
- Parameters:
name
- the field nametype
- the field typedefaultValue
- an optional default value (null if none)flags
- optional flags- Returns:
- the created field
-
getNamespace
Description copied from interface:ComplexType
Gets the namespace used by this complex type.- Specified by:
getNamespace
in interfaceComplexType
- Returns:
- the namespace or
Namespace.DEFAULT_NS
if none was specified
-
getField
Description copied from interface:ComplexType
Gets the field with the given name.If the name is non-prefixed the first matching field is returned if any is found. If the name is prefixed then the right field is returned if any is found.
- Specified by:
getField
in interfaceComplexType
- Parameters:
name
- the field name- Returns:
- the field
-
getField
Description copied from interface:ComplexType
Gets the field having the given name.- Specified by:
getField
in interfaceComplexType
- Parameters:
name
- the name- Returns:
- the field or null if no field with that name was found
-
getFields
Description copied from interface:ComplexType
Gets all fields as a (field name, field type) map.- Specified by:
getFields
in interfaceComplexType
- Returns:
- the fields map
-
getFieldsCount
public int getFieldsCount()Description copied from interface:ComplexType
Gets the number of fields defined for this complex type.- Specified by:
getFieldsCount
in interfaceComplexType
- Returns:
- the fields count
-
hasField
Description copied from interface:ComplexType
Tests whether this type defines the given field name.The name is supposed to be non prefixed.
- Specified by:
hasField
in interfaceComplexType
- Parameters:
name
- the field name- Returns:
- true if the field exists, false otherwise
-
hasFields
public boolean hasFields()Description copied from interface:ComplexType
Tests whether this type has any field defined.If a complex type has no fields, it is considered as unstructured and it accepts any field with any type and name.
- Specified by:
hasFields
in interfaceComplexType
- Returns:
- true if the at least one field exists, false otherwise
-
isComplexType
public boolean isComplexType()Description copied from interface:Type
Tests whether this type is a complex type.- Specified by:
isComplexType
in interfaceType
- Overrides:
isComplexType
in classAbstractType
- Returns:
- true if this type is a complex type, false otherwise
-
validate
Description copied from interface:Type
Tests whether the given object is of this type.- Specified by:
validate
in interfaceType
- Overrides:
validate
in classAbstractType
- 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
-
toString
-
newInstance
Description copied from interface:Type
Creates a new instance according to this type and filled with default values.- Specified by:
newInstance
in interfaceType
- Overrides:
newInstance
in classAbstractType
-
convert
Description copied from interface:Type
Converts the given value to an object compatible with the associated type.- Specified by:
convert
in interfaceType
- Parameters:
object
- the value to convert- Returns:
- the converted value
- Throws:
TypeException
- if the value to convert is not compatible with the associated type
-
canonicalXPath
Canonicalizes a Nuxeo-xpath.Replaces
a/foo[123]/b
witha/123/b
A star can be used instead of the digits as well (for configuration).
- Parameters:
xpath
- the xpath- Returns:
- the canonicalized xpath.
-