public class ComplexTypeImpl extends AbstractType implements ComplexType
Modifier and Type | Field and Description |
---|---|
static int |
F_UNSTRUCT_DEFAULT |
static int |
F_UNSTRUCT_FALSE |
static int |
F_UNSTRUCT_TRUE |
EMPTY_SUPERTYPES, F_NOTNULL, F_READONLY
Constructor and Description |
---|
ComplexTypeImpl(ComplexType superType,
String schema,
String name) |
ComplexTypeImpl(ComplexType superType,
String schema,
String name,
Namespace ns) |
ComplexTypeImpl(TypeRef<? extends ComplexType> superType,
String schema,
String name) |
ComplexTypeImpl(TypeRef<? extends ComplexType> superType,
String schema,
String name,
Namespace ns) |
ComplexTypeImpl(TypeRef<? extends ComplexType> superType,
String schema,
String name,
Namespace ns,
int struct) |
Modifier and Type | Method and Description |
---|---|
Field |
addField(QName name,
TypeRef<? extends Type> type)
Adds a field to this complex type.
|
Field |
addField(QName name,
TypeRef<? extends Type> type,
String defaultValue,
int flags)
Adds a field to this complex type.
|
Field |
addField(String name,
TypeRef<? extends Type> type)
Adds a field to this complex type.
|
Field |
addField(String name,
TypeRef<? extends 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.
|
TypeRef<? extends ComplexType> |
getRef()
Gets a proxy (or reference to this type).
|
boolean |
hasField(QName name)
Tests whether this type defines the given field name.
|
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.
|
boolean |
isUnstructured()
Tests whether this type is structured or not.
|
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, getHelper, getName, getSchema, getSchemaName, getSuperType, getTypeHierarchy, isAny, isAnyType, isCompositeType, isListType, isNotNull, isReadOnly, isSimpleType, isSuperTypeOf, setNotNull, setReadOnly
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
decode, encode, getHelper, getName, getSchema, getSchemaName, getSuperType, getTypeHierarchy, isAnyType, isCompositeType, isListType, isNotNull, isReadOnly, isSimpleType, isSuperTypeOf
public static final int F_UNSTRUCT_DEFAULT
public static final int F_UNSTRUCT_FALSE
public static final int F_UNSTRUCT_TRUE
public ComplexTypeImpl(TypeRef<? extends ComplexType> superType, String schema, String name, Namespace ns, int struct)
public ComplexTypeImpl(ComplexType superType, String schema, String name)
public ComplexTypeImpl(ComplexType superType, String schema, String name, Namespace ns)
public ComplexTypeImpl(TypeRef<? extends ComplexType> superType, String schema, String name)
public ComplexTypeImpl(TypeRef<? extends ComplexType> superType, String schema, String name, Namespace ns)
public Namespace getNamespace()
ComplexType
getNamespace
in interface ComplexType
Namespace.DEFAULT_NS
if none was
specifiedpublic boolean isUnstructured()
ComplexType
An unstructured complex type accepts any field name and type.
By default, complex types inherit their unstructured property. If a type has no super-type then it is considered unstructured if it is not specifying any field.
isUnstructured
in interface ComplexType
public 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 Field addField(String name, TypeRef<? extends Type> type)
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 typepublic Field addField(QName name, TypeRef<? extends Type> type)
ComplexType
addField
in interface ComplexType
name
- the field nametype
- the field typepublic Field addField(String name, TypeRef<? extends 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 Field addField(QName name, TypeRef<? extends Type> type, String defaultValue, int flags)
ComplexType
addField
in interface ComplexType
name
- the field nametype
- the field typedefaultValue
- an optional default value (null if none)flags
- optional flags
Possible values are:
public boolean hasField(String name)
ComplexType
The name is supposed to be non prefixed.
hasField
in interface ComplexType
name
- the field namepublic boolean hasField(QName name)
ComplexType
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
ValueConverter
convert
in interface ValueConverter
object
- the value to convertTypeException
- if the value to convert is not compatible with the associated typepublic TypeRef<? extends ComplexType> getRef()
Type
getRef
in interface ComplexType
getRef
in interface Type
getRef
in class AbstractType
Copyright © 2011 Nuxeo SA. All Rights Reserved.