Class AttributeDescriptionModel

java.lang.Object
com.highdeal.udr.hci.AttributeDescriptionModel
All Implemented Interfaces:
XMLMarshallable

public class AttributeDescriptionModel extends Object implements XMLMarshallable
This Java class represents the description of an attribute as seen by your client application and can represent a basic search criterion; An attribute description has a type (boolean, number, string, date) and can have a default value, a storage format, and a constraint.

Important Note

You use some attribute descriptions when implementing some search filters in search operations. Consider the search filter dedicated to your search operation.

The storage format respects the following syntax: X.Y where X represents the total number of digits and Y the number of digits in the fractionnal part.

Note

For example, if storage format "5.3" is applied to the decimal value 2.34567 then the stored value will be 2.345.

The stored value is an integer value if format storage has no fractionnal part otherwise the stored value is a bigdecimal value.

XML API for HCI

The XML APIs specify the following XSD fragment:

XSD Fragment

<xs:element name="attributeDescription">
   <xs:complexType>
     <xs:attribute name="name" type="xs:string" use="required"/>
     <xs:attribute name="type" type="DefaultValueType"/>
     <xs:attribute name="description" type="xs:string"/>
     <xs:attribute name="usingMode" type="UsingMode" />
     <xs:attribute name="defaultValue" type="xs:string"/>
     <xs:attribute name="format" type="xs:string"/>
     <xs:attribute name="constraint" type="xs:string"/>
     <xs:attribute name="group" type="GroupType" default="main"/>
     <xs:attribute name="additionalGroupKey" type="xs:string" use="optional" default="" />
   </xs:complexType>
 </xs:element>
<xs:simpleType name="DefaultValueType">
   <xs:restriction base="xs:string">
     <xs:enumeration value="boolean"/>
     <xs:enumeration value="number"/>
     <xs:enumeration value="string"/>
     <xs:enumeration value="date"/>
   </xs:restriction>
 </xs:simpleType>
<xs:simpleType name="UsingMode">
   <xs:restriction base="xs:string">
     <xs:enumeration value="required"/>
     <xs:enumeration value="optional"/>
   </xs:restriction>
 </xs:simpleType>
<xs:simpleType name="GroupType">
   <xs:restriction base="xs:string">
     <xs:enumeration value="main"/>
     <xs:enumeration value="additional"/>
     <xs:enumeration value="parameter"/>
     <xs:enumeration value="counter"/>
   </xs:restriction>
 </xs:simpleType>

  • Field Details

  • Constructor Details

    • AttributeDescriptionModel

      public AttributeDescriptionModel()
      Builds an empty attribute description.
    • AttributeDescriptionModel

      @Deprecated public AttributeDescriptionModel(String name, String description, int type)
      Builds an attribute description.
      Parameters:
      name - The name of the attribute description
      description - A textual description for this attribute description
      type - The forced type of the attribute
    • AttributeDescriptionModel

      public AttributeDescriptionModel(String name, String description, int type, String defaultGroup)
      Builds an attribute description.
      Parameters:
      name - The name of the attribute description
      description - A textual description for this attribute description
      type - The forced type of the attribute
      defaultGroup - The default group to use. Possible values are "main", "additional", "parameter", or "counter".
    • AttributeDescriptionModel

      @Deprecated public AttributeDescriptionModel(String name, String description)
      Builds an attribute description.
      Parameters:
      name - The name of the attribute description
      description - A textual description for this attribute description
    • AttributeDescriptionModel

      public AttributeDescriptionModel(String name, String description, String defaultGroup)
      Builds an attribute description.
      Parameters:
      name - The name of the attribute description
      description - A textual description for this attribute description
      defaultGroup - The default group to use. Possible values are "main" or "additional" or "parameter" or "counter"
    • AttributeDescriptionModel

      @Deprecated public AttributeDescriptionModel(String name, String description, int usingMode, Object defaultValue, ConstraintObject constraint)
      Builds an attribute description.
      Parameters:
      name - The name of the attribute description (must be unique inside a user defined record)
      description - A textual description of the attribute description
      usingMode - The type of using mode (required, optional) for default value
      defaultValue - The default value
      constraint - ConstraintObject the constraint associated to the default value
    • AttributeDescriptionModel

      public AttributeDescriptionModel(String name, String description, int usingMode, String defaultGroup, Object defaultValue, ConstraintObject constraint)
      Builds an attribute description.
      Parameters:
      name - The name of the attribute description; it must be unique inside a user defined record.
      description - A textual description of the attribute description
      usingMode - The type of using mode (required, optional) for default value
      defaultGroup - The default group to use. Possible values are "main" or "additional" or "parameter" or "counter"
      defaultValue - The default value
      constraint - The ConstraintObject the constraint associated to the default value
  • Method Details

    • duplicate

      public AttributeDescriptionModel duplicate()
      Returns a clone of the current instance.
      Returns:
      A clone of the current instance
    • getName

      public String getName()
      Returns the name of the attribute description.
      Returns:
      The name of the attribute description
    • setName

      public void setName(String n)
      Sets the name of the attribute description.
      Parameters:
      n - The name of the attribute description
    • getDescription

      public String getDescription()
      Returns the textual description of the attribute description.
      Returns:
      The textual description
    • setDescription

      public void setDescription(String description)
      Sets the textual description of the attribute description.
      Parameters:
      description - The textual description of the attribute description
    • getGroup

      public String getGroup()
      Returns the group of the attribute description.
      Returns:
      The group
    • setGroup

      public void setGroup(String group)
      Sets the group of the attribute description.
      Parameters:
      group - The group of the attribute description
    • getAdditionalGroupKey

      public String getAdditionalGroupKey()
      If group is ADDITIONAL_GROUP, provides an optional additional group selection key. By default, empty selection key is used.
      Returns:
      An additional group selection key
    • setAdditionalGroupKey

      public void setAdditionalGroupKey(String additionalGroupKey)
      Sets the optional additional group selection key.
      Parameters:
      additionalGroupKey - An additional group selection key
    • getFormat

      public String getFormat()
      Returns the storage format for default number associated to the attribute description.
      Returns:
      The textual storage format
    • setFormat

      public void setFormat(String f)
      Sets the storage format of the attribute description.
      Parameters:
      f - The storage format of the attribute description
    • applyFormat

      public Object applyFormat(Object value)
      Returns the formatted object ready to be stored.
      Returns:
      The formatted object; This object can be an integer or Bigdecimal according to storage format value (null if object cannot be formatted).
    • getAttributeDescriptionType

      public int getAttributeDescriptionType()
      Returns the type of this attribute description.
      See Also:
    • setForcedType

      public void setForcedType(int type)
      Sets the forced type for this AttributeDescriptionModel; The forced type is used when the defaultValue is null.
      Parameters:
      type - The forced type
      See Also:
    • getValueType

      public static int getValueType(Object object)
      Returns the type of the value.
      See Also:
    • getUsingMode

      public int getUsingMode()
      Returns the using mode of this attribute description.
      See Also:
    • setUsingMode

      public void setUsingMode(int u)
      Sets the using mode of this attribute description. The using mode indicates if the described attribute is mandatory or not. The using mode is usefull only if the AttributeDescriptionModel is used inside a templateModel. Otherwise the value is ignored.

      Each attribute description specifies a using mode for the attribute description. The permitted types are:

      REQUIRED_MODE
      The described attribute must be filled (e.g. in a GUI)
      OPTIONAL_MODE
      The described attribute may be filled (e.g. in a GUI)
      Parameters:
      u - The type of using mode
    • getDefaultValue

      public Object getDefaultValue()
      Returns the default value of this attribute description.
      Returns:
      The default value
    • setDefaultValue

      public void setDefaultValue(Object o)
      Sets the default value of the attribute description.
      Parameters:
      o - The default value of the attribute description
    • getConstraint

      public ConstraintObject getConstraint()
      Returns the associated constraint.
      Returns:
      The associated ConstraintModel
    • setConstraint

      public void setConstraint(ConstraintObject constraint)
      Sets the constraint of the attribute description.
      Parameters:
      constraint - The constraint of the attribute description
    • isValid

      public boolean isValid()
      Checks if a name exists and the default value respects the constraint.
      Returns:
      true if the attribute description is valid, false otherwise
    • isValidDefaultValue

      public boolean isValidDefaultValue()
      Checks if the default value respects the constraint.
      Returns:
      true if the default value is valid, false otherwise
    • isValidFormat

      public boolean isValidFormat()
      Checks if the storage format is valid.
      Returns:
      true if the storage format is valid, false otherwise
    • isValid

      public boolean isValid(Object value)
      Checks if the value respects the constraint.
      Returns:
      true if value respects the constraint, false otherwise
    • setAttributes

      public void setAttributes(XMLAttributes atts)
      Description copied from interface: XMLMarshallable
      Sets the attributes of the XML representation of the element being processed.
      Specified by:
      setAttributes in interface XMLMarshallable
      Parameters:
      atts - The XML attributes of the current element
    • addChild

      public void addChild(String tagname, XMLMarshallable child)
      Description copied from interface: XMLMarshallable
      Adds a child to the object, the child representing the marshallable object which must be added to the element.
      Specified by:
      addChild in interface XMLMarshallable
      Parameters:
      tagname - The name of tag for the child
      child - The child to be added
    • addCharacterData

      public void addCharacterData(String cData)
      Description copied from interface: XMLMarshallable
      Adds character data to the content element.
      Specified by:
      addCharacterData in interface XMLMarshallable
      Parameters:
      cData - The character data to be added
    • marshal

      public void marshal(XMLOutputter output)
      Description copied from interface: XMLMarshallable
      Gives an XML representation of this object, including its children.
      Specified by:
      marshal in interface XMLMarshallable
      Parameters:
      output - The XML output to marshal the object into