public class ComplexTypeImpl extends AbstractType implements ComplexType
EMPTY_SUPERTYPES
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 |
---|---|
Field |
addField(String name,
Type type,
String defaultValue,
int flags)
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.
|
decode, encode, getName, getSchema, getSchemaName, getSuperType, getTypeHierarchy, isAny, isAnyType, isCompositeType, isListType, isSimpleType, isSuperTypeOf
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
decode, encode, getName, getSchema, getSchemaName, getSuperType, getTypeHierarchy, isAnyType, isCompositeType, isListType, isSimpleType, isSuperTypeOf
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)
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
supertypespublic 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 typeCopyright © 2013 Nuxeo SA. All Rights Reserved.