Nuxeo Enterprise Platform 5.4

org.nuxeo.ecm.core.schema.types
Class ListTypeImpl

java.lang.Object
  extended by org.nuxeo.ecm.core.schema.types.AbstractType
      extended by org.nuxeo.ecm.core.schema.types.ListTypeImpl
All Implemented Interfaces:
java.io.Serializable, ListType, Type, ValueConverter

public class ListTypeImpl
extends AbstractType
implements ListType

Author:
Bogdan Stefanescu
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.nuxeo.ecm.core.schema.types.AbstractType
EMPTY_SUPERTYPES, F_NOTNULL, F_READONLY
 
Fields inherited from interface org.nuxeo.ecm.core.schema.types.Type
ANY
 
Constructor Summary
ListTypeImpl(java.lang.String schema, java.lang.String name, Type type)
           
ListTypeImpl(java.lang.String schema, java.lang.String name, TypeRef<? extends Type> type)
           
ListTypeImpl(java.lang.String schema, java.lang.String name, TypeRef<? extends Type> type, java.lang.String defaultValue)
           
ListTypeImpl(java.lang.String schema, java.lang.String name, TypeRef<? extends Type> type, java.lang.String fieldName, java.lang.String defaultValue, int minOccurs, int maxOccurs)
           
ListTypeImpl(java.lang.String schema, java.lang.String name, Type type, java.lang.String defaultValue)
           
ListTypeImpl(java.lang.String schema, java.lang.String name, Type type, java.lang.String fieldName, java.lang.String defaultValue, int minOccurs, int maxOccurs)
           
 
Method Summary
 java.lang.Object convert(java.lang.Object object)
          Converts the given value to an object compatible with the associated type.
 java.lang.Object decode(java.lang.String string)
          Decodes the string representation into an object of this type.
 java.lang.Object getDefaultValue()
          Gets the default value of the list elements, if any.
 Field getField()
          Get the field defining the elements stored by this list.
 java.lang.String getFieldName()
          The field name if any was specified.
 Type getFieldType()
          Get the field describing the element type the list accept.
 int getMaxCount()
          Gets the required maximum count of allowed elements in this list.
 int getMinCount()
          Gets the required minimum count of elements in this list.
 TypeRef<ListType> getRef()
          Gets a proxy (or reference to this type).
 Type getType()
           
 boolean isArray()
          Whether the instances of this list are arrays.
 boolean isListType()
          Tests whether this type is a list type.
 boolean isScalarList()
          This method is provided for compatibility.
 java.lang.Object newInstance()
          Creates a new instance according to this type and filled with default values.
 void setDefaultValue(java.lang.String value)
          Sets the default value encoded as a string.
 void setLimits(int minOccurs, int maxOccurs)
          Sets list limits.
 boolean validate(java.lang.Object object)
          Tests whether the given object is of this type.
 
Methods inherited from class org.nuxeo.ecm.core.schema.types.AbstractType
encode, getHelper, getName, getSchema, getSchemaName, getSuperType, getTypeHierarchy, isAny, isAnyType, isComplexType, isCompositeType, isNotNull, isReadOnly, isSimpleType, isSuperTypeOf, setNotNull, setReadOnly
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.nuxeo.ecm.core.schema.types.Type
encode, getHelper, getName, getSchema, getSchemaName, getSuperType, getTypeHierarchy, isAnyType, isComplexType, isCompositeType, isNotNull, isReadOnly, isSimpleType, isSuperTypeOf
 

Constructor Detail

ListTypeImpl

public ListTypeImpl(java.lang.String schema,
                    java.lang.String name,
                    TypeRef<? extends Type> type,
                    java.lang.String fieldName,
                    java.lang.String defaultValue,
                    int minOccurs,
                    int maxOccurs)

ListTypeImpl

public ListTypeImpl(java.lang.String schema,
                    java.lang.String name,
                    Type type)

ListTypeImpl

public ListTypeImpl(java.lang.String schema,
                    java.lang.String name,
                    Type type,
                    java.lang.String defaultValue)

ListTypeImpl

public ListTypeImpl(java.lang.String schema,
                    java.lang.String name,
                    Type type,
                    java.lang.String fieldName,
                    java.lang.String defaultValue,
                    int minOccurs,
                    int maxOccurs)

ListTypeImpl

public ListTypeImpl(java.lang.String schema,
                    java.lang.String name,
                    TypeRef<? extends Type> type)

ListTypeImpl

public ListTypeImpl(java.lang.String schema,
                    java.lang.String name,
                    TypeRef<? extends Type> type,
                    java.lang.String defaultValue)
Method Detail

setLimits

public void setLimits(int minOccurs,
                      int maxOccurs)
Description copied from interface: ListType
Sets list limits.

Specified by:
setLimits in interface ListType

setDefaultValue

public void setDefaultValue(java.lang.String value)
Description copied from interface: ListType
Sets the default value encoded as a string.

Specified by:
setDefaultValue in interface ListType

getFieldName

public java.lang.String getFieldName()
Description copied from interface: ListType
The field name if any was specified.

This is used to more for outputting the list as XML and for compatibility with XSD.

Specified by:
getFieldName in interface ListType
Returns:
the field name

getFieldType

public Type getFieldType()
Description copied from interface: ListType
Get the field describing the element type the list accept.

Specified by:
getFieldType in interface ListType
Returns:
the field describing the list element types

getField

public Field getField()
Description copied from interface: ListType
Get the field defining the elements stored by this list.

Specified by:
getField in interface ListType
Returns:
the field

getDefaultValue

public java.lang.Object getDefaultValue()
Description copied from interface: ListType
Gets the default value of the list elements, if any.

Specified by:
getDefaultValue in interface ListType
Returns:
the default value or null if none

getType

public Type getType()

getMinCount

public int getMinCount()
Description copied from interface: ListType
Gets the required minimum count of elements in this list.

Specified by:
getMinCount in interface ListType
Returns:
the minimum count of required elements

getMaxCount

public int getMaxCount()
Description copied from interface: ListType
Gets the required maximum count of allowed elements in this list.

Specified by:
getMaxCount in interface ListType
Returns:
the maximum count of allowed elements

isListType

public boolean isListType()
Description copied from interface: Type
Tests whether this type is a list type.

Specified by:
isListType in interface Type
Overrides:
isListType in class AbstractType
Returns:
true if is a list type, false otherwise

decode

public java.lang.Object decode(java.lang.String string)
Description copied from interface: Type
Decodes the string representation into an object of this type.

Returns null if the string can not be decoded.

Specified by:
decode in interface Type
Overrides:
decode in class AbstractType
Parameters:
string - the string to decode
Returns:
the converted object that can be use as a value for an object of this type or null if the given object cannot be converted

validate

public boolean validate(java.lang.Object object)
                 throws TypeException
Description copied from interface: Type
Tests whether the given object is of this type.

Specified by:
validate in interface Type
Overrides:
validate in class AbstractType
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

newInstance

public java.lang.Object newInstance()
Description copied from interface: Type
Creates a new instance according to this type and filled with default values.

Specified by:
newInstance in interface Type
Overrides:
newInstance in class AbstractType
Returns:

convert

public java.lang.Object convert(java.lang.Object object)
                         throws TypeException
Description copied from interface: ValueConverter
Converts the given value to an object compatible with the associated type.

Specified by:
convert in interface ValueConverter
Parameters:
object - the value to convert
Returns:
the converted value
Throws:
TypeException - if the value to convert is not compatible with the associated type

getRef

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

Specified by:
getRef in interface ListType
Specified by:
getRef in interface Type
Overrides:
getRef in class AbstractType
Returns:
a reference to the type

isArray

public boolean isArray()
Description copied from interface: ListType
Whether the instances of this list are arrays.

Specified by:
isArray in interface ListType

isScalarList

public boolean isScalarList()
Description copied from interface: ListType
This method is provided for compatibility. Existing code is mapping scalar lists to arrays but this should be changed in order to map only explicit scalar list (those declared using xs:list) to arrays and not all list that have scalar items.

Specified by:
isScalarList in interface ListType
Returns:
true if the list items are of a scalar type TODO FIXME XXX remove the method and use instead isArray

Nuxeo Enterprise Platform 5.4

Copyright © 2010 Nuxeo SAS. All Rights Reserved.