Class ComplexTypeImpl

    • Field Detail

      • fields

        protected final Map<QName,​Field> fields
        The fields held by this complex type.
      • fieldsByName

        protected volatile Map<String,​Field> fieldsByName
        The map of name or prefixed name to field.
    • Method Detail

      • addField

        protected void addField​(Field field)
      • addField

        public Field addField​(String name,
                              Type type,
                              String defaultValue,
                              int flags,
                              Collection<Constraint> constraints)
        Description copied from interface: ComplexType
        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).

        Specified by:
        addField in interface ComplexType
        Parameters:
        name - the field name
        type - the field type
        defaultValue - an optional default value (null if none)
        flags - optional flags
        Returns:
        the created field
      • getField

        public Field getField​(String name)
        Description copied from interface: ComplexType
        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.

        Specified by:
        getField in interface ComplexType
        Parameters:
        name - the field name
        Returns:
        the field
      • getField

        public Field getField​(QName name)
        Description copied from interface: ComplexType
        Gets the field having the given name.
        Specified by:
        getField in interface ComplexType
        Parameters:
        name - the name
        Returns:
        the field or null if no field with that name was found
      • getFieldsCount

        public int getFieldsCount()
        Description copied from interface: ComplexType
        Gets the number of fields defined for this complex type.
        Specified by:
        getFieldsCount in interface ComplexType
        Returns:
        the fields count
      • hasField

        public boolean hasField​(String name)
        Description copied from interface: ComplexType
        Tests whether this type defines the given field name.

        The name is supposed to be non prefixed.

        Specified by:
        hasField in interface ComplexType
        Parameters:
        name - the field name
        Returns:
        true if the field exists, false otherwise
      • hasFields

        public boolean hasFields()
        Description copied from interface: ComplexType
        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.

        Specified by:
        hasFields in interface ComplexType
        Returns:
        true if the at least one field exists, false otherwise
      • isComplexType

        public boolean isComplexType()
        Description copied from interface: Type
        Tests whether this type is a complex type.
        Specified by:
        isComplexType in interface Type
        Overrides:
        isComplexType in class AbstractType
        Returns:
        true if this type is a complex type, false otherwise
      • 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
      • 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 interface Type
        Parameters:
        object - the value to convert
        Returns:
        the converted value
        Throws:
        TypeException - if the value to convert is not compatible with the associated type
      • canonicalXPath

        public static String canonicalXPath​(String xpath)
        Canonicalizes a Nuxeo-xpath.

        Replaces a/foo[123]/b with a/123/b

        A star can be used instead of the digits as well (for configuration).

        Parameters:
        xpath - the xpath
        Returns:
        the canonicalized xpath.