com.ibm.tivoli.maximo.dbmanage.statement

Class AttributeStorage

  • java.lang.Object
    • com.ibm.tivoli.maximo.dbmanage.statement.AttributeStorage


  • public class AttributeStorage
    extends java.lang.Object
    This class stores a set of attributes and their values in a chosen Class. Attribute names are case sensitive. Storage classes supported are String, Boolean, Integer.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void clear(java.lang.String attrName)
      remove a definition of an attribute
      protected java.lang.Object clone() 
      void copyFromStorage(AttributeStorage attr)
      Copy all values from the storage that apply to this storage.
      java.lang.Object get(int n)
      Return the value for the n'th attribute.
      java.lang.Object get(java.lang.String attrName)
      Only this get method can be overridden.
      AttributeClass getAttrClass(java.lang.String attr)
      Return the storage class for an attribute.
      java.lang.Boolean getBoolean(java.lang.String attrName) 
      java.lang.String getCommaLine()
      Give the values of the attributes in a comma separated line.
      AttributeStorageDefinition getDefinition() 
      java.lang.Double getDouble(java.lang.String attrName) 
      java.lang.Integer getInt(java.lang.String attrName) 
      java.lang.Long getLong(java.lang.String attrName) 
      java.util.Iterator getNameIterator() 
      java.util.Set getSetAttr()
      Returns the set of attribute names which have values.
      java.lang.String getString(java.lang.String attrName) 
      java.sql.Timestamp getTimestamp(java.lang.String attrName) 
      java.lang.Object[] getValues() 
      boolean hasAttribute(java.lang.String attrName)
      Is there an attribute defined with this name? This checks that there is an attribute, not if it has a value or not.
      int hashCode() 
      boolean hasNoValues()
      Does this AS storage any values.
      boolean isSet(java.lang.String attrName) 
      void loadFromElement(org.jdom2.Element fromElement)
      Load attributes from an XML Element.
      void loadFromResultSet(java.sql.ResultSet rs) 
      void saveToElement(org.jdom2.Element toElement) 
      void saveToElement(java.lang.String[] columnDefAttributes, org.jdom2.Element toElement)
      This version takes a list of attributes to save
      void set(java.lang.String attrName, java.lang.Object value)
      Set an attribute a value from an object.
      void setWithIgnore(java.lang.String string, java.lang.Object object) 
      int size()
      Size of the storage.
      java.lang.String toString() 
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • AttributeStorage

        public AttributeStorage(java.lang.String[] names,
                                AttributeClass[] storage)
        Helper Constructor
        Parameters:
        names - The names of the attributes
        storage - How to store the attribute values.
      • AttributeStorage

        public AttributeStorage(AttributeStorageDefinition definition)
        Constructor
        Parameters:
        definition - Definition data.
      • AttributeStorage

        public AttributeStorage(AttributeStorageDefinition asd,
                                org.jdom2.Element element)
        This constructor the same as creating an AttributeStorage for the ASD then calling loadFromElement.
        Parameters:
        asd - Used to define the AttributeStorage element.
        seqRow - Values immediately loaded from here.
        See Also:
        This method used to load the values.
    • Method Detail

      • set

        public void set(java.lang.String attrName,
                        java.lang.Object value)
        Set an attribute a value from an object. Only this set method can be overridden.
        Parameters:
        attrName -
        value - The value is converted to the storage class of the attribute.
        Throws:
        java.lang.Exception - If the attribute name isn't one specified in the constructor.
        java.lang.Exception - The object cannot be converted to a storage class for the attribute.
      • get

        public java.lang.Object get(java.lang.String attrName)
        Only this get method can be overridden.
      • getInt

        public final java.lang.Integer getInt(java.lang.String attrName)
      • getBoolean

        public final java.lang.Boolean getBoolean(java.lang.String attrName)
      • getDouble

        public final java.lang.Double getDouble(java.lang.String attrName)
      • getLong

        public final java.lang.Long getLong(java.lang.String attrName)
      • getString

        public final java.lang.String getString(java.lang.String attrName)
      • isSet

        public boolean isSet(java.lang.String attrName)
      • clear

        public void clear(java.lang.String attrName)
        remove a definition of an attribute
      • loadFromElement

        public void loadFromElement(org.jdom2.Element fromElement)
        Load attributes from an XML Element. Any exceptions will be ignored.
        Parameters:
        fromElement -
      • saveToElement

        public void saveToElement(org.jdom2.Element toElement)
        Parameters:
        data -
      • saveToElement

        public void saveToElement(java.lang.String[] columnDefAttributes,
                                  org.jdom2.Element toElement)
        This version takes a list of attributes to save
        Parameters:
        columnDefAttributes - The attributes to save.
        columndef - The Element to save the attributes to.
      • size

        public int size()
        Size of the storage.
        Returns:
        The number of attributes stored. Not the number of attributes.
      • getSetAttr

        public java.util.Set getSetAttr()
        Returns the set of attribute names which have values.
        Returns:
        a Set of String, which maybe be empty.
      • setWithIgnore

        public void setWithIgnore(java.lang.String string,
                                  java.lang.Object object)
        Parameters:
        string -
        object -
      • copyFromStorage

        public void copyFromStorage(AttributeStorage attr)
        Copy all values from the storage that apply to this storage.
        Parameters:
        attr -
      • loadFromResultSet

        public void loadFromResultSet(java.sql.ResultSet rs)
                               throws java.sql.SQLException
        Parameters:
        rs -
        Throws:
        java.sql.SQLException
      • hasAttribute

        public boolean hasAttribute(java.lang.String attrName)
        Is there an attribute defined with this name? This checks that there is an attribute, not if it has a value or not.
        Parameters:
        attrName - The name of the attribute to check for.
        Returns:
        true if the attribute is defined.
        See Also:
        This method returns whether a defined attribute has a value
      • getAttrClass

        public AttributeClass getAttrClass(java.lang.String attr)
        Return the storage class for an attribute.
        Parameters:
        attr - The name of the attribute
        Returns:
        The attribute's storage class.
      • clone

        protected java.lang.Object clone()
                                  throws java.lang.CloneNotSupportedException
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException
      • getNameIterator

        public java.util.Iterator getNameIterator()
      • getValues

        public java.lang.Object[] getValues()
      • getCommaLine

        public java.lang.String getCommaLine()
        Give the values of the attributes in a comma separated line. Nulls will be represented by empty strings. Values will be given in the default format for their type. The values will be ordered as in the AttributeStorageDefinition.
        Returns:
        The line, or an empty string if there are no values.
      • getTimestamp

        public java.sql.Timestamp getTimestamp(java.lang.String attrName)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hasNoValues

        public boolean hasNoValues()
        Does this AS storage any values.
        Returns:
        true if all values are null
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • get

        public java.lang.Object get(int n)
        Return the value for the n'th attribute.
        Parameters:
        n -
        Returns: