Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.core.schema.types
Interface ComplexType

All Superinterfaces:
Serializable, Type, ValueConverter
All Known Subinterfaces:
CompositeType, DocumentType, Schema
All Known Implementing Classes:
ComplexTypeImpl, CompositeTypeImpl, DocumentTypeImpl, SchemaImpl

public interface ComplexType
extends Type

A complex type is tree-like structure of named elements which can be of any type.

Complex types can describe and validate java Map objects.

Author:
Bogdan Stefanescu

Field Summary
 
Fields inherited from interface org.nuxeo.ecm.core.schema.types.Type
ANY
 
Method Summary
 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.
 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 isUnstructured()
          Tests whether this type is structured or not.
 
Methods inherited from interface org.nuxeo.ecm.core.schema.types.Type
decode, encode, getHelper, getName, getSchema, getSchemaName, getSuperType, getTypeHierarchy, isAnyType, isComplexType, isCompositeType, isListType, isNotNull, isReadOnly, isSimpleType, isSuperTypeOf, newInstance, validate
 
Methods inherited from interface org.nuxeo.ecm.core.schema.types.ValueConverter
convert
 

Method Detail

isUnstructured

boolean isUnstructured()
Tests whether this type is structured or not.

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.

Returns:
true if unstructured, false otherwise

getNamespace

Namespace getNamespace()
Gets the namespace used by this complex type.

Returns:
the namespace or Namespace.DEFAULT_NS if none was specified

getField

Field getField(String name)
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.

Parameters:
name - the field name
Returns:
the field

getField

Field getField(QName name)
Gets the field having the given name.

Parameters:
name - the name
Returns:
the field or null if no field with that name was found

addField

Field addField(String name,
               TypeRef<? extends Type> type)
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).

Parameters:
name - the field name
type - the field type
Returns:
the created field

addField

Field addField(String name,
               TypeRef<? extends Type> type,
               String defaultValue,
               int flags)
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).

Parameters:
name - the field name
type - the field type
defaultValue - an optional default value (null if none)
flags - optional flags
Returns:
the created field

addField

Field addField(QName name,
               TypeRef<? extends Type> type)
Adds a field to this complex type.

Parameters:
name - the field name
type - the field type
Returns:
the created field

addField

Field addField(QName name,
               TypeRef<? extends Type> type,
               String defaultValue,
               int flags)
Adds a field to this complex type.

Parameters:
name - the field name
type - the field type
defaultValue - an optional default value (null if none)
flags - optional flags Possible values are:
Returns:
the created field

hasField

boolean hasField(String name)
Tests whether this type defines the given field name.

The name is supposed to be non prefixed.

Parameters:
name - the field name
Returns:
true if the field exists, false otherwise

hasField

boolean hasField(QName name)
Tests whether this type defines the given field name.

Parameters:
name - the field name
Returns:
true if the field exists, false otherwise

hasFields

boolean hasFields()
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.

Returns:
true if the at least one field exists, false otherwise

getFields

Collection<Field> getFields()
Gets all fields as a (field name, field type) map.

Returns:
the fields map

getFieldsCount

int getFieldsCount()
Gets the number of fields defined for this complex type.

Returns:
the fields count

getRef

TypeRef<? extends ComplexType> getRef()
Description copied from interface: Type
Gets a proxy (or reference to this type).

Specified by:
getRef in interface Type
Returns:
a reference to the type

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.