Interface Type

  • All Superinterfaces:
    Serializable
    All Known Subinterfaces:
    ComplexType, CompositeType, DocumentType, ListType, Schema, SimpleType
    All Known Implementing Classes:
    AbstractType, AnyType, BinaryType, BooleanType, ComplexTypeImpl, CompositeTypeImpl, DateType, DocumentTypeImpl, DoubleType, IntegerType, ListTypeImpl, LongType, PrimitiveType, SchemaImpl, SimpleTypeImpl, StringType

    public interface Type
    extends Serializable
    A Type object is used to describe some ECM content.

    There are two groups of content types:

    • primitive types - these are builtin types used to describe simple values like string, integers, dates etc
    • custom types - these are used defined types based on the primitive types
    Custom types are structured in two groups:
    • simple types - constrained primitive types. Constraints are specific to each primitive type.
      For example the "string" type may have constraints like maximum length, regular expression pattern etc.
      So you can define a custom simple type as being a string that match the regular expression .+@.+
    • complex types - structured types that can be expressed as a tree like structure of other primitive, simple or complex types.
    The typing system is mainly inspired from XML schemas.

    There is a root type called ANY type.
    Apart this special type, each type has a super type (a type from which it is derived)

    On top of this typing system there are two high level content types:

    • schemas - a schema is a complex that can be used to form composite types
      Because multiple schemas may live together in a composite type they must provide a namespace to avoid name collisions inside a composite type
    • composite types - a composite type is made of several schemas.
      You can see a composite type as a type derived from multiple complex super types.
      Composite types are used to define ECM documents
    Type names must not contains a : character. This character may be used internally to prefix the type name so it must not be used in the type name.
    • Method Detail

      • getName

        String getName()
        Gets the name of this type.
        Returns:
        the type name
      • getSchemaName

        String getSchemaName()
        Gets the local name of this type.
        Returns:
        the local name
      • getSuperType

        Type getSuperType()
        Gets the super type.
        Returns:
        the super type or null if this is a primitive type
      • getTypeHierarchy

        Type[] getTypeHierarchy()
        Gets the entire hierarchy of super-types.

        The array is ordered as follows:

        • the direct super type is the first element,
        • the super super type is the second element,
        • and so on.

        The returned array is never null. An empty array is returned in the case of ANY type.

        Returns:
        an array containing the supertypes of this type
      • isSuperTypeOf

        boolean isSuperTypeOf​(Type type)
        Tests whether the given type is derived from this type.
        Parameters:
        type - the type to test
        Returns:
        true if the given type is derived from this type, false otherwise
      • isSimpleType

        boolean isSimpleType()
        Tests whether this type is a simple type.
        Returns:
        true if this type is a simple type, false otherwise
      • isComplexType

        boolean isComplexType()
        Tests whether this type is a complex type.
        Returns:
        true if this type is a complex type, false otherwise
      • isListType

        boolean isListType()
        Tests whether this type is a list type.
        Returns:
        true if is a list type, false otherwise
      • isAnyType

        boolean isAnyType()
        Tests whether this type is the ANY type.
        Returns:
        true if it is the ANY type, false otherwise
      • isCompositeType

        boolean isCompositeType()
        Tests whether this is a composite type.
        Returns:
        true if this is a composite type, false otherwise
      • validate

        boolean validate​(Object object)
                  throws TypeException
        Tests whether the given object is of this type.
        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
      • decode

        Object decode​(String string)
        Decodes the string representation into an object of this type.

        Returns null if the string can not be decoded.

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

        String encode​(Object object)
        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.

        Parameters:
        object - the object to convert
        Returns:
        the string representation of the given object or null if object cannot be converted
      • newInstance

        Object newInstance()
        Creates a new instance according to this type and filled with default values.
      • convert

        Object convert​(Object value)
                throws TypeException
        Converts the given value to an object compatible with the associated type.
        Parameters:
        value - the value to convert
        Returns:
        the converted value
        Throws:
        TypeException - if the value to convert is not compatible with the associated type