Nuxeo ECM Projects 5.4.3-SNAPSHOT

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

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

public class SimpleTypeImpl
extends AbstractType
implements SimpleType

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
SimpleTypeImpl(SimpleType superType, String schema, String name)
           
SimpleTypeImpl(TypeRef<? extends SimpleType> superType, String schema, String name)
           
 
Method Summary
 Object convert(Object value)
          Converts the given value to an object compatible with the associated type.
 Object decode(String str)
          Decodes the string representation into an object of this type.
 String encode(Object value)
          Encodes the given object that is assumed to be of this type into a string representation.
 Constraint[] getConstraints()
           
 SimpleType getPrimitiveType()
           
 TypeRef<? extends SimpleType> getRef()
          Gets a proxy (or reference to this type).
 boolean isPrimitive()
          Tests whether this type is a primitive type.
 boolean isSimpleType()
          Tests whether this type is a simple type.
 Object newInstance()
          Creates a new instance according to this type and filled with default values.
 void setConstraints(Constraint[] constraints)
           
 boolean validate(Object object)
          Tests whether the given object is of this type.
 
Methods inherited from class org.nuxeo.ecm.core.schema.types.AbstractType
getHelper, getName, getSchema, getSchemaName, getSuperType, getTypeHierarchy, isAny, isAnyType, isComplexType, isCompositeType, isListType, isNotNull, isReadOnly, 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
getHelper, getName, getSchema, getSchemaName, getSuperType, getTypeHierarchy, isAnyType, isComplexType, isCompositeType, isListType, isNotNull, isReadOnly, isSuperTypeOf
 

Constructor Detail

SimpleTypeImpl

public SimpleTypeImpl(SimpleType superType,
                      String schema,
                      String name)

SimpleTypeImpl

public SimpleTypeImpl(TypeRef<? extends SimpleType> superType,
                      String schema,
                      String name)
Method Detail

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 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

setConstraints

public void setConstraints(Constraint[] constraints)

getConstraints

public Constraint[] getConstraints()

getPrimitiveType

public SimpleType getPrimitiveType()
Specified by:
getPrimitiveType in interface SimpleType

isPrimitive

public boolean isPrimitive()
Description copied from interface: SimpleType
Tests whether this type is a primitive type.

Specified by:
isPrimitive in interface SimpleType
Returns:
true if this type is a primitive type, false otherwise

isSimpleType

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

Specified by:
isSimpleType in interface Type
Overrides:
isSimpleType in class AbstractType
Returns:
true if this type is a simple type, false otherwise

decode

public Object decode(String str)
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:
str - 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

encode

public String encode(Object value)
Description copied from interface: Type
Encodes the given object that is assumed to be of this type into a string representation.

Null is returned if the object cannot be converted.

Specified by:
encode in interface Type
Overrides:
encode in class AbstractType
Parameters:
value - the object to convert
Returns:
the string representation of the given object or null if object cannot be converted

convert

public Object convert(Object value)
               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:
value - the value to convert
Returns:
the converted value
Throws:
TypeException - if the value to convert is not compatible with the associated type

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 interface Type
Overrides:
newInstance in class AbstractType
Returns:

getRef

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

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

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.