public class ComplexTypeImpl extends AbstractType implements ComplexType
Modifier and Type | Field and Description |
---|---|
protected Map<QName,Field> |
fields
The fields held by this complex type.
|
protected Map<String,Field> |
fieldsByName
The map of name or prefixed name to field.
|
protected Namespace |
ns |
constraints, EMPTY_SUPERTYPES, name, schema, superType
Constructor and Description |
---|
ComplexTypeImpl(ComplexType superType,
String schema,
String name) |
ComplexTypeImpl(ComplexType superType,
String schema,
String name,
Namespace ns) |
Modifier and Type | Method and Description |
---|---|
protected void |
addField(Field field) |
Field |
addField(String name,
Type type,
String defaultValue,
int flags,
Collection<Constraint> constraints)
Adds a field to this complex type.
|
static String |
canonicalXPath(String xpath)
Canonicalizes a Nuxeo-xpath.
|
Object |
convert(Object object)
Converts the given value to an object compatible with the associated type.
|
Field |
getField(QName name)
Gets the field having the given name.
|
Field |
getField(String name)
Gets the field with the given name.
|
Collection<Field> |
getFields()
Gets all fields as a (field name, field type) map.
|
int |
getFieldsCount()
Gets the number of fields defined for this complex type.
|
Namespace |
getNamespace()
Gets the namespace used by this complex type.
|
boolean |
hasField(String name)
Tests whether this type defines the given field name.
|
boolean |
hasFields()
Tests whether this type has any field defined.
|
boolean |
isComplexType()
Tests whether this type is a complex type.
|
Map<String,Object> |
newInstance()
Creates a new instance according to this type and filled with default values.
|
String |
toString() |
boolean |
validate(Object object)
Tests whether the given object is of this type.
|
protected boolean |
validateMap(Map<Object,Object> map) |
addConstraints, decode, encode, getConstraints, getName, getObjectResolver, getSchema, getSchemaName, getSuperType, getTypeHierarchy, isAny, isAnyType, isCompositeType, isListType, isSimpleType, isSuperTypeOf, validateConstraints
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
decode, encode, getConstraints, getName, getObjectResolver, getSchema, getSchemaName, getSuperType, getTypeHierarchy, isAnyType, isCompositeType, isListType, isSimpleType, isSuperTypeOf
protected volatile Map<String,Field> fieldsByName
public ComplexTypeImpl(ComplexType superType, String schema, String name, Namespace ns)
public ComplexTypeImpl(ComplexType superType, String schema, String name)
public Field addField(String name, Type type, String defaultValue, int flags, Collection<Constraint> constraints)
ComplexType
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).
addField
in interface ComplexType
name
- the field nametype
- the field typedefaultValue
- an optional default value (null if none)flags
- optional flagspublic Namespace getNamespace()
ComplexType
getNamespace
in interface ComplexType
Namespace.DEFAULT_NS
if none was specifiedpublic Field getField(String name)
ComplexType
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.
getField
in interface ComplexType
name
- the field namepublic Field getField(QName name)
ComplexType
getField
in interface ComplexType
name
- the namepublic Collection<Field> getFields()
ComplexType
getFields
in interface ComplexType
public int getFieldsCount()
ComplexType
getFieldsCount
in interface ComplexType
public boolean hasField(String name)
ComplexType
The name is supposed to be non prefixed.
hasField
in interface ComplexType
name
- the field namepublic boolean hasFields()
ComplexType
If a complex type has no fields, it is considered as unstructured and it accepts any field with any type and name.
hasFields
in interface ComplexType
public boolean isComplexType()
Type
isComplexType
in interface Type
isComplexType
in class AbstractType
public boolean validate(Object object) throws TypeException
Type
validate
in interface Type
validate
in class AbstractType
object
- the object to testTypeException
- if an error occurs trying to retrieve the supertypesprotected boolean validateMap(Map<Object,Object> map)
public Map<String,Object> newInstance()
Type
newInstance
in interface Type
newInstance
in class AbstractType
public Object convert(Object object) throws TypeException
Type
convert
in interface Type
object
- the value to convertTypeException
- if the value to convert is not compatible with the associated typepublic static String canonicalXPath(String xpath)
Replaces a/foo[123]/b
with a/123/b
A star can be used instead of the digits as well (for configuration).
xpath
- the xpathCopyright © 2018 Nuxeo. All rights reserved.