Package org.nuxeo.ecm.core.schema.types
Class ListTypeImpl
- java.lang.Object
-
- org.nuxeo.ecm.core.schema.types.AbstractType
-
- org.nuxeo.ecm.core.schema.types.ListTypeImpl
-
- All Implemented Interfaces:
Serializable
,ListType
,Type
public class ListTypeImpl extends AbstractType implements ListType
The implementation for a List type.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
DEFAULT_VALUE_SEPARATOR
protected String
defaultValue
protected Field
field
protected boolean
isArray
protected int
maxOccurs
protected int
minOccurs
protected Type
type
-
Fields inherited from class org.nuxeo.ecm.core.schema.types.AbstractType
constraints, EMPTY_SUPERTYPES, name, schema, superType
-
-
Constructor Summary
Constructors Constructor Description ListTypeImpl(String schema, String name, Type type)
ListTypeImpl(String schema, String name, Type type, String fieldName, String defaultValue, int minOccurs, int maxOccurs)
ListTypeImpl(String schema, String name, Type type, String fieldName, String defaultValue, int flags, Set<Constraint> constraints, int minOccurs, int maxOccurs)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
convert(Object object)
Converts the given value to an object compatible with the associated type.Object
decode(String string)
Decodes the string representation into an object of this type.Object
getDefaultValue()
Gets the default value of the list elements, if any.Field
getField()
Get the field defining the elements stored by this list.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.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.Object
newInstance()
Creates a new instance according to this type and filled with default values.void
setDefaultValue(String value)
Sets the default value encoded as a string.void
setLimits(int minOccurs, int maxOccurs)
Sets list limits.boolean
validate(Object object)
Tests whether the given object is of this type.-
Methods inherited from class org.nuxeo.ecm.core.schema.types.AbstractType
addConstraints, encode, getConstraints, getName, getObjectResolver, getSchema, getSchemaName, getSuperType, getTypeHierarchy, isAny, isAnyType, isComplexType, isCompositeType, isSimpleType, isSuperTypeOf, validateConstraints
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.ecm.core.schema.types.Type
encode, getConstraints, getName, getObjectResolver, getSchema, getSchemaName, getSuperType, getTypeHierarchy, isAnyType, isComplexType, isCompositeType, isSimpleType, isSuperTypeOf
-
-
-
-
Field Detail
-
DEFAULT_VALUE_SEPARATOR
protected static final String DEFAULT_VALUE_SEPARATOR
- See Also:
- Constant Field Values
-
defaultValue
protected String defaultValue
-
minOccurs
protected int minOccurs
-
maxOccurs
protected int maxOccurs
-
isArray
protected boolean isArray
-
-
Constructor Detail
-
ListTypeImpl
public ListTypeImpl(String schema, String name, Type type, String fieldName, String defaultValue, int flags, Set<Constraint> constraints, int minOccurs, int maxOccurs)
-
ListTypeImpl
public ListTypeImpl(String schema, String name, Type type, String fieldName, String defaultValue, int minOccurs, int maxOccurs)
-
ListTypeImpl
public ListTypeImpl(String schema, String name, Type type)
-
-
Method Detail
-
setLimits
public void setLimits(int minOccurs, int maxOccurs)
Description copied from interface:ListType
Sets list limits.
-
setDefaultValue
public void setDefaultValue(String value)
Description copied from interface:ListType
Sets the default value encoded as a string.- Specified by:
setDefaultValue
in interfaceListType
-
getFieldName
public 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 interfaceListType
- 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 interfaceListType
- 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.
-
getDefaultValue
public Object getDefaultValue()
Description copied from interface:ListType
Gets the default value of the list elements, if any.- Specified by:
getDefaultValue
in interfaceListType
- Returns:
- the default value or null if none
-
getMinCount
public int getMinCount()
Description copied from interface:ListType
Gets the required minimum count of elements in this list.- Specified by:
getMinCount
in interfaceListType
- 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 interfaceListType
- 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 interfaceType
- Overrides:
isListType
in classAbstractType
- Returns:
- true if is a list type, false otherwise
-
decode
public Object decode(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 interfaceType
- Overrides:
decode
in classAbstractType
- 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(Object object) throws TypeException
Description copied from interface:Type
Tests whether the given object is of this type.- Specified by:
validate
in interfaceType
- Overrides:
validate
in classAbstractType
- 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 Object newInstance()
Description copied from interface:Type
Creates a new instance according to this type and filled with default values.- Specified by:
newInstance
in interfaceType
- Overrides:
newInstance
in classAbstractType
-
convert
public Object convert(Object object) throws TypeException
Description copied from interface:Type
Converts the given value to an object compatible with the associated type.- Specified by:
convert
in interfaceType
- Parameters:
object
- the value to convert- Returns:
- the converted value
- Throws:
TypeException
- if the value to convert is not compatible with the associated type
-
isArray
public boolean isArray()
Description copied from interface:ListType
Whether the instances of this list are arrays.
-
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 interfaceListType
- Returns:
- true if the list items are of a scalar type TODO FIXME XXX remove the method and use instead isArray
-
-