*
Metamerge logo
Search

Advanced Search
*
*
*
* HOME DOCUMENTS & RESOURCES DOWNLOADS EARLY TECH ACCESS SUPPORT FAQ KNOWN ISSUES OLD VERSIONS
*

 

The Attribute Object

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 case inensitive.

If the Attribute was populated with Connector values by the attribute map, the values will of the same data-type that the Connector supplied.

Check the javadocs for a full description of the Attribute Object

Methods

Function Description
addValue ( obj ) Adds obj to attribute's list of values
clear () Remove all values from this attribute
contains ( obj ) Returns true if this attribute contains a value equal to obj
hasValue ( obj ) Returns true if this attribute holds a value equal to obj
hasValueIC ( str ) Returns true if this attribute holds a string value equal to str. Comparison is case insensitive.
getName () Return this attribute's name
getValue () Returns the first value in this attribute as string (or NULL if attribute has no values)
getValue ( int ) Returns the nth value in this attribute or NULL if int is higher than the number of values. Values are numbered from zero and up so the first value is getValue ( 0 ).

The object returned is of the same type as was inserted: It could for example be a java.util.Date. getValue(0).getClass().getName() will get you the class of the first attribute value. 

getValues () Returns an array with the values in this attribute.
setName ( str ) Sets this attribute's name
setValue ( obj ) Adds value obj if attribute has no values or replaces the first value with obj.
setValue ( int, obj ) Replaces the value at position int with obj.
toString () Returns a string representation of this value on the form name:value

Examples

Creating a new Attribute object

    var attr = system.newAttribute("AttributeName");

This example will create an Attribute object with name "AttributeName" and assign 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.

Adding values to an 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.

Scanning Attribute's values

    var values = attr.getValues();
    for (i=0; i<values.length; i++) {
        task.logmsg("Value " + i + " --> " + values[i]);
    }

This example will process any attribute object, whether it holds single or multiple values. In reality, there is no difference between single and multiple value attributes. Every attribute may hold zero, one or more values - a single value attribute is therefore merely an "underloaded" multiple values attribute.

See Also

Entry Object

 

 

*
  Metamerge Integrator version 4.6 ©Copyright Metamerge AS 2000-2002 Last edited 2002-04-30 contact us