com.sas.entities
Interface AttributeTypeInterface

All Superinterfaces:
BaseAttributeDescriptorInterface, java.rmi.Remote, com.sas.RemoteObjectInterface
All Known Implementing Classes:
AttributeType

public interface AttributeTypeInterface
extends BaseAttributeDescriptorInterface

AttributeTypeInterface describes AttributeTypes which define properties that are common to AttributeDescriptors of that type. The Attribute type provides the following information about the AttributeDescriptor:

validators
a list of components which can validate a value assigned to an attribute.
editor
a component which can edit a value of this type

Additional information is obtained from BaseAttributeDescriptorInterface:
  1. name
  2. label
  3. description
  4. smallIconURL
  5. largeIconURL
  6. customizer

In addition to defining properties, AttributeTypes constrain the data types that are acceptable values for an AttributeDescriptor. As an example, an "int" AttributeType limits values to those that can be used to create the java primitive type of int.

Components of an AttributeType

An AttributeType consists of three components:

name
a name associated with the AttributeType. Useful in UI (User Interface) applications where users can specify AttributeTypes for AttributeDescriptors. This field can be null.
sql type
corresponds to a generic SQL type as defined in Types. Constrains values assigned to an AttributeDescriptor to be compatible with the sql type. As an example, specifying Types.INTEGER, should limit values to those that can be used to create a java primitive type of int.
object type
used with sql types of Types.ARRAY and Types.JAVA_OBJECT. Return the array component type (if the AttributeType was defined with sql type of Types.ARRAY) or the classname of the object if the AttributeType was defined as Types.OBJECT.

Creating Attribute Types

AttributeTypeFactory

The class, AttributeTypeFactory, contains constants and static functions for creating common attribute types:

  • AttributeType at = AttributeTypeFactory.STRING_ATTRIBUTE_TYPE; // String
  • AttributeType at = AttributeTypeFactory.INTEGER_ATTRIBUTE_TYPE; // Integer

    Specifying Constructor Arguments

    AttributeTypes can be created by either specifying the SQLType (as defined in java.sql.Types) or by specifying a String that corresponds to a java type.

  • AttributeType at = new AttributeType("String","java.lang.String"); // String

    where "String" is the name of the AttributeType

    Primitive types and String attribute types are easily created using constants to specify the SQLType:

  • AttributeType at = new AttributeType("long",LONG_TYPE); // long

    where "long" is the name of the AttributeType

    AttributeTypes can be created by specifying the SQLType:

  • AttributeType at = new AttributeType("int",Types.INTEGER ); // int

    Attribute Type SQL Constant
    String Types.VARCHAR
    long Types.BIGINT
    boolean Types.BOOLEAN
    double Types.DOUBLE
    float Types.FLOAT
    int Types.INTEGER
    java.lang.Object Types.OBJECT

    Array and Object Attribute Types

    Object types can be created by simply specifying the object's class name:

  • AttributeType at = new AttributeType("Date","java.util.Date"); // Date

    Object-type arrays can be created by specifying the object's class name followed by "[]":

  • AttributeType at = new AttributeType("Color Array","java.awt.Color[]"); // Color []

    Date Attribute Types

    When creating dates for a Date Attribute Type (sql type = Types.DATE), the date needs to created using the GMT timezone in order for it to be shared in a multi-timezone environment.


    Field Summary
    static int ARRAY_TYPE
              Constant for creating array attribute types
    static int BOOLEAN_TYPE
              Constant for creating boolean attribute type
    static int BYTE_TYPE
              Constant for creating byte attribute type
    static int CHAR_TYPE
              Constant for creating char attribute type
    static int DOUBLE_TYPE
              Constant for creating double attribute type
    static int FLOAT_TYPE
              Constant for creating float attribute type
    static int INT_TYPE
              Constant for creating int attribute type
    static int LONG_TYPE
              Constant for creating long attribute type
    static int OBJECT_TYPE
              Constant for creating java.lang.Object attribute type
    static int OTHER_TYPE
              Constant for creating "other" types
    static int SHORT_TYPE
              Constant for creating short attribute type
    static int STRING_TYPE
              Constant for creating java.lang.String attribute type
     
    Method Summary
     java.lang.String getObjectType()
              Return the component type (if the AttributeType was defined as Types.ARRAY) or the classname of the object if the AttributeType was defined as Types.OBJECT.
     int getSQLType()
              Return the SQL type.
     java.lang.String getType()
              Return the java type.
     java.util.List getValidators(java.lang.String context)
              Return the validators.
     java.util.List getValidatorsContexts()
              Returns a list of validators contexts defined for this AttributeType.
     void setObjectType(java.lang.String type)
              Sets the component type (if the AttributeType was defined as Types.ARRAY) or the classname of the object if the AttributeType was defined as Types.OBJECT.
     void setSQLType(int sqlType)
              Set the SQL type.
     void setType(java.lang.String type)
              Set the java type setType("java.lang.String"); //String AttributeType setType("java.util.Date"); //Date AttributeType
     void setValidators(java.lang.String context, java.util.List validators)
              Set the validators.
     
    Methods inherited from interface com.sas.entities.BaseAttributeDescriptorInterface
    getAttributeCustomizerContexts, getAttributeCustomizers, getConfigurationXML, getCustomizer, getDescription, getDescriptions, getLabel, getLabels, getLargeIconURL, getLargeIconURLs, getName, getSmallIconURL, getSmallIconURLs, setConfigurationXML, setCustomizer, setDescription, setLabel, setLargeIconURL, setName, setSmallIconURL
     

    Field Detail

    STRING_TYPE

    static final int STRING_TYPE
    Constant for creating java.lang.String attribute type

    See Also:
    Constant Field Values

    FLOAT_TYPE

    static final int FLOAT_TYPE
    Constant for creating float attribute type

    See Also:
    Constant Field Values

    LONG_TYPE

    static final int LONG_TYPE
    Constant for creating long attribute type

    See Also:
    Constant Field Values

    DOUBLE_TYPE

    static final int DOUBLE_TYPE
    Constant for creating double attribute type

    See Also:
    Constant Field Values

    INT_TYPE

    static final int INT_TYPE
    Constant for creating int attribute type

    See Also:
    Constant Field Values

    SHORT_TYPE

    static final int SHORT_TYPE
    Constant for creating short attribute type

    See Also:
    Constant Field Values

    BOOLEAN_TYPE

    static final int BOOLEAN_TYPE
    Constant for creating boolean attribute type

    See Also:
    Constant Field Values

    BYTE_TYPE

    static final int BYTE_TYPE
    Constant for creating byte attribute type

    See Also:
    Constant Field Values

    CHAR_TYPE

    static final int CHAR_TYPE
    Constant for creating char attribute type

    See Also:
    Constant Field Values

    OBJECT_TYPE

    static final int OBJECT_TYPE
    Constant for creating java.lang.Object attribute type

    See Also:
    Constant Field Values

    ARRAY_TYPE

    static final int ARRAY_TYPE
    Constant for creating array attribute types

    See Also:
    Constant Field Values

    OTHER_TYPE

    static final int OTHER_TYPE
    Constant for creating "other" types

    See Also:
    Constant Field Values
    Method Detail

    getSQLType

    int getSQLType()
    Return the SQL type.

    Returns:
    the SQL type
    See Also:
    setSQLType(int sqlType), Types

    setSQLType

    void setSQLType(int sqlType)
    Set the SQL type. Valid SQL types are defined in Types.

    Parameters:
    sqlType - generic SQL type
    See Also:
    getSQLType(), Types

    getType

    java.lang.String getType()
    Return the java type. If the type is an array, it is returned in the form of "classname[]" (.ie int[], java.lang.String[])

    Returns:
    java type
    See Also:
    setType(String type)

    setType

    void setType(java.lang.String type)
    Set the java type
    • setType("java.lang.String"); //String AttributeType
    • setType("java.util.Date"); //Date AttributeType

    Parameters:
    type - classname
    See Also:
    getType()

    getValidators

    java.util.List getValidators(java.lang.String context)
    Return the validators.

    Parameters:
    context - the context in which the validators are instantiated/used; it is a platform specification from EntityContextInterface
    Returns:
    list of validators for the specified context
    See Also:
    setValidators(String context, List validators)

    setValidators

    void setValidators(java.lang.String context,
                       java.util.List validators)
    Set the validators. Validators are used to validate input, normalize input, and return error information when the input is invalid.

    Parameters:
    context - the context in which the validators are instantiated/used; it is a platform specification from EntityContextInterface
    validators - names of the validators
    See Also:
    getValidators(String context), EntityContextInterface

    getValidatorsContexts

    java.util.List getValidatorsContexts()
    Returns a list of validators contexts defined for this AttributeType.

    Returns:
    list of contexts

    getObjectType

    java.lang.String getObjectType()
    Return the component type (if the AttributeType was defined as Types.ARRAY) or the classname of the object if the AttributeType was defined as Types.OBJECT. This method is used for persisting AttributeTypes and is usually invoked from other methods.

    Returns:
    component type
    See Also:
    setObjectType(String type)

    setObjectType

    void setObjectType(java.lang.String type)
    Sets the component type (if the AttributeType was defined as Types.ARRAY) or the classname of the object if the AttributeType was defined as Types.OBJECT. This method is used for persisting AttributeTypes and will be invoked from other methods.

    Parameters:
    type - component type
    See Also:
    getObjectType()



    Copyright © 2009 SAS Institute Inc. All Rights Reserved.