An attribute object is usually contained in Entry objects. An attribute is a named object with associated values. Each value in the attribute corresponds to a Java object of some type. Attribute names are not case-sensitive, and cannot contain a slash ( / ) as part of the name. Remember that some of the Connectors for example, those accessing a database, might consider other characters as unsuitable. If you can, try to stick to alphanumeric characters in attribute names.
If the attribute was populated with Connector values by the attribute map, the values are of the same datatype that the Connector supplied.
For more information, see the Javadocs material included in the installation package (the com.ibm.di.entry.Attribute class).
var attr = system.newAttribute("AttributeName");
This example creates an attribute object with name AttributeName and assigns it to the attr variable. Note that upon initial creation, the attribute holds no value. Now, through the attr variable you can access and interact with the newly created attribute.
attr.addValue("value 1");
attr.addValue("value 2");
This example adds the string values "value 1" and "value 2" to the attr attribute, thereby creating a multiple values attribute. Consecutive calls to addValue(obj) add values in the same order in the attribute.
var values = attr.getValues();
for (i=0; i<values.length; i++) {
task.logmsg("Value " + i + " --> " + values[i]);
}
This example processes any attribute object, whether it holds single or multiple values. In reality, there is no difference between single and multiple-value attributes. Every attribute can hold zero, one or more values. A single-value attribute is therefore merely an underloaded multiple-values attribute.