com.ibm.di.entry
Class Attribute

java.lang.Object
  extended by com.ibm.di.entry.Attribute
All Implemented Interfaces:
AttributeInterface, Serializable

public class Attribute
extends Object
implements AttributeInterface, Serializable

The Attribute class is used in conjunction with the Entry object to store information about an attribute. The attribute has a name and a list of zero or more values. Each value can be any type of Java object so you can add values of any kind to the attribute.

See Also:
Serialized Form

Field Summary
static char ATTRIBUTE_ADD
          Add value
static char ATTRIBUTE_DELETE
          Delete value
static char ATTRIBUTE_MOD
          Values modified
static char ATTRIBUTE_REPLACE
          Replace value
static char ATTRIBUTE_UNCHANGED
          Unchanged
static String[] OPER
           
 
Constructor Summary
Attribute()
          Initialize this attribute with no name, no values and the operation code set to ATTRIBUTE_REPLACE.
Attribute(String name)
          Initializes this attribute with no values and the operation code set to ATTRIBUTE_REPLACE, the name is set to name.
Attribute(String name, Object value)
          Initializes this attribute with operation code set to ATTRIBUTE_REPLACE, the name is set to name and the value value is added to the list of values.
 
Method Summary
 void addValue(Object p1)
          Adds a value to the attribute's list of values.
 void addValue(Object p1, int valueOper)
          Adds a value to this Attribute's list of values.
 Attribute addValues(Attribute attr)
          Add the values in another Attribute to this Attribute.
 void clear()
          Removes all values from this attribute and sets the operation to ATTRIBUTE_REPLACE.
 Object clone()
          Returns a clone of this object.
 boolean contains(Object value)
          Checks if a value is contained in this Attribute.
 String getName()
          Returns this Attribute's name.
 char getOper()
          Returns the operation type of this Attribute.
 String getOperation()
          Returns the operation type of this Attribute as a String.
 boolean getProtected()
          Returns the protected value of this Attribute
 String getValue()
          Returns the first value, if any, as a String object.
 Object getValue(int index)
          Returns the value at the position given by index.
 Object getValueAV(int index)
          Returns the object at index.
 int getValueOper(int index)
          Returns the value operation code at a specified index as an integer.
 String getValueOperation(int index)
          Returns the operation code as a string (add, delete, unchanged) for a given index.
 Object[] getValues()
          Returns this attribute's values as an array of objects.
 Object[] getValuesAV()
          Returns this Attribute's values as an array of objects.
 Vector getValuesVector()
          Returns this Attribute's values as a Vector.
 boolean hasValue(Object value)
          Checks if a value is contained in this Attribute.
 boolean hasValueIC(String value)
          Checks if a string value is contained in this attribute.
 boolean removeValue(Object p1)
          Removes all instances of a value from the attribute's list of values.
 Object removeValueAt(int index)
          Removes a value at a given index
 void setName(String name)
          Sets this Attribute's name.
 void setOper(char operation)
          Sets the operation type of this Attribute.
 void setOperation(String operation)
          Sets the operation type of this Attribute.
 Attribute setProtected(boolean protect)
          Sets the protected value of this Attribute
 void setValue(int index, Object value)
          Sets the attribute's value at a specific position to the value specified.
 void setValue(int position, Object p2, int valueOper)
          Sets the attribute's value at a specific position to the value specified.
 void setValue(Object p1)
          Sets this Attribute's value at position 0 to the value specified.
 void setValue(Object p1, int valueOper)
          Sets this Attribute's value at position 0 to the value specified.
 void setValueOper(int index, int valueOper)
          Sets the value operation code.
 void setValueOperation(int index, String valueOper)
          Sets the value operation code for a specified index.
 void setValues(Object[] values)
          Sets the Attribute's values to the array of objects provided by values.
 void setValues(Vector values)
          Sets this Attribute's values using the Vector passed to it.
 int size()
          Returns the number of values contained in this Attribute.
 String toDeltaString()
          Returns the Delta string representation of this Attribute.
 String toString()
          Returns the string representation of this attribute.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ATTRIBUTE_REPLACE

public static final char ATTRIBUTE_REPLACE
Replace value

See Also:
Constant Field Values

ATTRIBUTE_ADD

public static final char ATTRIBUTE_ADD
Add value

See Also:
Constant Field Values

ATTRIBUTE_DELETE

public static final char ATTRIBUTE_DELETE
Delete value

See Also:
Constant Field Values

ATTRIBUTE_UNCHANGED

public static final char ATTRIBUTE_UNCHANGED
Unchanged

See Also:
Constant Field Values

ATTRIBUTE_MOD

public static final char ATTRIBUTE_MOD
Values modified

See Also:
Constant Field Values

OPER

public static final String[] OPER
Constructor Detail

Attribute

public Attribute()
Initialize this attribute with no name, no values and the operation code set to ATTRIBUTE_REPLACE.


Attribute

public Attribute(String name)
Initializes this attribute with no values and the operation code set to ATTRIBUTE_REPLACE, the name is set to name.

Parameters:
name - The attribute name

Attribute

public Attribute(String name,
                 Object value)
Initializes this attribute with operation code set to ATTRIBUTE_REPLACE, the name is set to name and the value value is added to the list of values.

Parameters:
name - The attribute name
value - The attribute value
Method Detail

clone

public Object clone()
Returns a clone of this object. The cloning is shallow and does not clone attribute values.

Overrides:
clone in class Object
Returns:
The cloned attribute

clear

public void clear()
Removes all values from this attribute and sets the operation to ATTRIBUTE_REPLACE.


hasValue

public boolean hasValue(Object value)
Checks if a value is contained in this Attribute.

Parameters:
value - The value to check for
Returns:
true if this Attribute contains the value, false if not
See Also:
contains(java.lang.Object)

hasValueIC

public boolean hasValueIC(String value)
Checks if a string value is contained in this attribute. The method converts values to their string representation before doing a case-insensitive comparison.

JavaScript example:

    if ( conn.hasValueIC("this value") ) {
      task.logmsg( "It is there" );
    }
 

Parameters:
value - The string value to check for
Returns:
true if attribute contains the value, false if not

contains

public boolean contains(Object value)
Checks if a value is contained in this Attribute.

Specified by:
contains in interface AttributeInterface
Parameters:
value - The value to check for
Returns:
true if this Attribute contains the value, false if not

getValue

public String getValue()
Returns the first value, if any, as a String object.

Specified by:
getValue in interface AttributeInterface
Returns:
The object as a String or null if attribute has no values

getValue

public Object getValue(int index)
Returns the value at the position given by index. The value is unwrapped if it is an AttributeValue object. Use getValueAV to retrieve the value as-is.

JavaScript example

 var v = conn.getAttribute("attrname").getValue ( 0 );
 task.logmsg( "Java class of v is: " + v.getClass().getName() );
 task.logmsg( "String representation: " + v.toString() );
 if ( v.getClass().getName() == "java.util.Date" ) {
   task.logmsg("Date object: " + v.getMonth();
 }
 

Specified by:
getValue in interface AttributeInterface
Parameters:
index - The position
Returns:
The Object or null if index is out of range
See Also:
size()

getValueAV

public Object getValueAV(int index)
Returns the object at index. This method does not unwrap AttributeValue objects

Specified by:
getValueAV in interface AttributeInterface
Parameters:
index - The position
Returns:
The Object at the position, or null if index too high

getValues

public Object[] getValues()
Returns this attribute's values as an array of objects. This method unwraps AttributeValue objects. The array may be empty if attribute has no values (e.g. arr.length == 0).

Specified by:
getValues in interface AttributeInterface
Returns:
An array of objects.

getValuesVector

public Vector getValuesVector()
Returns this Attribute's values as a Vector. This method unwraps AttributeValue objects.

Returns:
An array of objects.
See Also:
getValues()

getValuesAV

public Object[] getValuesAV()
Returns this Attribute's values as an array of objects. This method does not unwrap AttributeValue objects into their contained objects. The array may be empty if attribute has no values (e.g. arr.length == 0).

Returns:
An array of objects.

setValues

public void setValues(Vector values)
Sets this Attribute's values using the Vector passed to it.

Parameters:
values - The new value array (Vector)

setValues

public void setValues(Object[] values)
Sets the Attribute's values to the array of objects provided by values.

Parameters:
values - The new value array

setValue

public void setValue(Object p1)
Sets this Attribute's value at position 0 to the value specified. If the attribute has no values the value is inserted, otherwise the value at position 0 is replaced.

Specified by:
setValue in interface AttributeInterface
Parameters:
p1 - The new value

addValue

public void addValue(Object p1)
Adds a value to the attribute's list of values.

Specified by:
addValue in interface AttributeInterface
Parameters:
p1 - The new value

setValue

public void setValue(int index,
                     Object value)
Sets the attribute's value at a specific position to the value specified. If the position (index) is out of range an exception is thrown.

Specified by:
setValue in interface AttributeInterface
Parameters:
index - The position
value - The value
Throws:
ArrayIndexOutOfBoundsException - if the index was invalid.

removeValue

public boolean removeValue(Object p1)
Removes all instances of a value from the attribute's list of values.

Specified by:
removeValue in interface AttributeInterface
Parameters:
p1 - The value to remove
Returns:
true if this Attribute contained the value, false if no change

removeValueAt

public Object removeValueAt(int index)
Removes a value at a given index

Parameters:
index - The index of the value to remove
Returns:
The value at the given index, or null if index is out of bounds

getName

public String getName()
Returns this Attribute's name.

Specified by:
getName in interface AttributeInterface
Returns:
The Attribute's name

setName

public void setName(String name)
Sets this Attribute's name.

Specified by:
setName in interface AttributeInterface
Parameters:
name - The new name of this Attribute

getOper

public char getOper()
Returns the operation type of this Attribute.

Specified by:
getOper in interface AttributeInterface
Returns:
The operation type as a char

getOperation

public String getOperation()
Returns the operation type of this Attribute as a String. The operation has only been set to a meaningful value if this Attribute is part of an Entry that comes from an Iterator with Delta enabled.

Returns:
The operation type as a string. Possible values are "replace", "add", "delete", "unchanged" or "modify"

setOper

public void setOper(char operation)
Sets the operation type of this Attribute.

Specified by:
setOper in interface AttributeInterface
Parameters:
operation - The operation type as a char

setOperation

public void setOperation(String operation)
Sets the operation type of this Attribute.

Parameters:
operation - The operation type as a string

size

public int size()
Returns the number of values contained in this Attribute.

Specified by:
size in interface AttributeInterface
Returns:
The number of values

toString

public String toString()
Returns the string representation of this attribute.

Overrides:
toString in class Object
Returns:
The name and values as a structured String

toDeltaString

public String toDeltaString()
Returns the Delta string representation of this Attribute. This string representation also contains delta information, if present.

Returns:
The name and values as a structured string

setValue

public void setValue(Object p1,
                     int valueOper)
Sets this Attribute's value at position 0 to the value specified. If the attribute has no values the value is inserted, otherwise the value at position 0 is replaced.

Parameters:
p1 - The new value
valueOper - The value operation code

setValue

public void setValue(int position,
                     Object p2,
                     int valueOper)
Sets the attribute's value at a specific position to the value specified. If the position is out of range an exception is thrown.

Parameters:
position - The position
p2 - The value
valueOper - The value operation code
Throws:
ArrayIndexOutOfBoundsException - if the position was invalid.

addValue

public void addValue(Object p1,
                     int valueOper)
Adds a value to this Attribute's list of values.

Parameters:
p1 - The new value
valueOper - The value operation code

setValueOper

public void setValueOper(int index,
                         int valueOper)
Sets the value operation code. If the value is a non-AV object, a new AttributeValue object is created to hold the current value.

Parameters:
index - The value index
valueOper - The value operation code

getValueOper

public int getValueOper(int index)
Returns the value operation code at a specified index as an integer.

Parameters:
index - The value index
Returns:
The value operation code ( -1 indicates no operation code )

setValueOperation

public void setValueOperation(int index,
                              String valueOper)
Sets the value operation code for a specified index. If the value is a non-AV object, a new AttributeValue object is created to hold the current value.

Parameters:
index - The new value
valueOper - The string-version operation code

getValueOperation

public String getValueOperation(int index)
Returns the operation code as a string (add, delete, unchanged) for a given index. If the value at the index is not a delta value (e.g. AttributeValue object) then a blank string is returned.

Parameters:
index - The index

setProtected

public Attribute setProtected(boolean protect)
Sets the protected value of this Attribute

Specified by:
setProtected in interface AttributeInterface
Parameters:
protect - - If true, try to protect the Attribute values by not dumping them in log files
Returns:
this Attribute

getProtected

public boolean getProtected()
Returns the protected value of this Attribute

Specified by:
getProtected in interface AttributeInterface
Returns:
true if the values should not be dumped in log files

addValues

public Attribute addValues(Attribute attr)
Add the values in another Attribute to this Attribute. All values are added, even if they already exist.

Parameters:
attr - The Attribute from which values are collected
Returns:
this Attribute