com.ibm.di.entry
Class Entry

java.lang.Object
  extended by com.ibm.di.entry.Entry
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
TaskCallBlock

public class Entry
extends Object
implements Serializable

The Entry class is a container for attributes and their values. The Entry class is widely used in the IBM Tivoli Directory Integrator. In the scripting environment you use the Entry and Attribute classes by accessing the object's methods.

JavaScript Example


 // List all attributes and their values
 var conn = connector.getNextEntry();
 var attrnames = conn.getAttributeNames();
 for ( i = 0; i < attrnames.length; i++ ) {
    var attr = conn.getAttribute ( attrnames[i] );
    task.logmsg( "Attribute: name = " + attr.getName() + ", #values = " + attr.size() );
    for ( j = 0; j < attr.size(); j++ ) {
      task.logmsg( "      Value " + j + ": " + attr.getValue ( j ) );
    }
 }
 

See Also:
Serialized Form

Field Summary
static char OP_ADD
          The Entry contains an entry which is supposed to be added
static String OP_ADD2
           
static char OP_DEL
          The Entry contains an entry which is supposed to be removed
static String OP_DEL2
           
static char OP_GEN
          The Entry contains an entry with no explicit knowledge of operation
static String OP_GEN2
           
static char OP_MOD
          The Entry contains an entry which is supposed to be modified
static String OP_MOD2
           
static char OP_UNCHANGED
          The Entry contains an entry which is unchanged
static String OP_UNCHANGED2
           
 
Constructor Summary
Entry()
          Construct a new generic Entry
Entry(Hashtable table)
          Construct a new generic Entry, with data given by the provided Hashtable.
 
Method Summary
 void addAttributeValue(Object name, Object value)
          Adds a value to an attribute.
 void addAttributeValue(Object name, Object value, int op)
          Adds a value to an attribute.
 Entry clone(Entry entry)
          Returns an Entry object which is a clone of the Entry parameter.
 Attribute get(Object p1)
          Returns the Attribute object for a named attribute.
 Attribute getAttribute(Object p1)
          Returns the Attribute object for a named attribute.
 Collection getAttributeCollection()
          Returns a java.util.Collection containing attribute names in this entry.
 String[] getAttributeNames()
          Returns an array of strings containing attribute names in this entry.
 Object getObject(Object p1)
          Returns the first value in an attribute as an object.
 char getOp()
          Returns the operation field of this entry.
 String getOperation()
          Returns the operation field of this Entry.
 Object getProperty(Object propertyName)
          Returns a property value.
 String[] getPropertyNames()
          Returns a string array of the property names contained in this entry.
 String getString(Object p1)
          Returns the first value in an attribute as a String.
 boolean hasProperty(String propertyName)
          Returns true if a property named by the propertyName parameter has a value.
 void merge(Entry e)
          Convenience method that calls merge ( e, false ).
 void merge(Entry e, boolean mergevalues)
          Merges in the attributes and their values from another entry.
 void mergeAttributeValue(Attribute attr)
          Merges in the values from an attribute.
 void mergeAttributeValue(Object name, AttributeInterface attr)
          Merges the values in one attribute with the values from another attribute.
 Attribute newAttribute(String name)
          Returns an Attribute object from this Entry's list of attributes.
 Attribute newAttribute(String name, char oper)
          Returns an Attribute object from this entry's list of attributes.
 void removeAllAttributes()
          Removes all attributes from this Entry.
 void removeAttribute(Object p1)
          Removes an attribute from this Entry's list of attribute.
 void set(AttributeInterface attr)
          Deprecated. Use setAttribute instead
 void setAttribute(AttributeInterface attr)
          Adds or replaces an attribute in this Entry's list of attributes.
 void setAttribute(Object name, Object value)
          Adds or replaces an attribute in this Entry's list of attributes.
 void setAttribute(Object name, Object value, boolean protect)
          Adds or replaces an attribute in this Entry's list of attributes.
 void setOp(char operation)
          Sets the operation code for this Entry.
 void setOperation(String operation)
          Sets the operation code for this Entry.
 void setProperty(Object propertyName, Object propertyValue)
          Sets/replaces a property.
 int size()
          Returns the number of attributes present in this entry.
 String toDeltaString()
          Returns a string representation of this entry, including delta information.
 String toString()
          Returns a string representation of this entry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OP_ADD

public static final char OP_ADD
The Entry contains an entry which is supposed to be added

See Also:
Constant Field Values

OP_ADD2

public static final String OP_ADD2
See Also:
Constant Field Values

OP_MOD

public static final char OP_MOD
The Entry contains an entry which is supposed to be modified

See Also:
Constant Field Values

OP_MOD2

public static final String OP_MOD2
See Also:
Constant Field Values

OP_DEL

public static final char OP_DEL
The Entry contains an entry which is supposed to be removed

See Also:
Constant Field Values

OP_DEL2

public static final String OP_DEL2
See Also:
Constant Field Values

OP_UNCHANGED

public static final char OP_UNCHANGED
The Entry contains an entry which is unchanged

See Also:
Constant Field Values

OP_UNCHANGED2

public static final String OP_UNCHANGED2
See Also:
Constant Field Values

OP_GEN

public static final char OP_GEN
The Entry contains an entry with no explicit knowledge of operation

See Also:
Constant Field Values

OP_GEN2

public static final String OP_GEN2
See Also:
Constant Field Values
Constructor Detail

Entry

public Entry()
Construct a new generic Entry


Entry

public Entry(Hashtable table)
Construct a new generic Entry, with data given by the provided Hashtable. This is used for internal purposes.

Parameters:
table - - a Hashtable representation of the
Method Detail

clone

public Entry clone(Entry entry)
Returns an Entry object which is a clone of the Entry parameter. The cloning is shallow which means that only first-level cloning of data values is performed.

Parameters:
entry - The Entry object to clone
Returns:
The cloned entry

getOp

public char getOp()
Returns the operation field of this entry. The operation field signals what should be done with this Entry. See the OP_* codes for possible return values. The field is only set to a meaningful value if the Entry comes from an Iterator with delta enabled.

Returns:
This Entry's operation code

setOp

public void setOp(char operation)
Sets the operation code for this Entry.

Parameters:
operation - The operation code

getOperation

public String getOperation()
Returns the operation field of this Entry. The operation field signals what should be done with this Entry. The method returns either
OP_ADD2 = "add"; The entry contains an entry which is supposed to be added
OP_MOD2 = "modify"; The entry contains an entry which is supposed to be modified
OP_DEL2 = "delete"; The entry contains an entry which is supposed to be removed
OP_UNCHANGED2 = "unchanged"; The entry contains an entry which is unchanged
OP_GEN2 = "generic"; The entry contains an entry with no explicit knowledge of operation
The field is only set to a meaningful value if the entry comes from an Iterator with delta enabled.

Returns:
This Entry's operation code as a String

setOperation

public void setOperation(String operation)
Sets the operation code for this Entry.

Parameters:
operation - The operation code as a String

set

public void set(AttributeInterface attr)
Deprecated. Use setAttribute instead

Adds or replaces an attribute in this Entry's list of attributes.

Parameters:
attr - An Attribute object

setAttribute

public void setAttribute(AttributeInterface attr)
Adds or replaces an attribute in this Entry's list of attributes.

Parameters:
attr - An Attribute object

setAttribute

public void setAttribute(Object name,
                         Object value)
Adds or replaces an attribute in this Entry's list of attributes.

Parameters:
name - The attribute name
value - The attribute value. If this parameter is null, then the attribute is removed.

setAttribute

public void setAttribute(Object name,
                         Object value,
                         boolean protect)
Adds or replaces an attribute in this Entry's list of attributes.

Parameters:
name - The attribute name
value - The attribute value. If this parameter is null, then the attribute is removed.
protect - If this parameter is true, do not dump the Attribute values in log files

newAttribute

public Attribute newAttribute(String name)
Returns an Attribute object from this Entry's list of attributes. If the attribute does not exist, a new one is created with no values.

Parameters:
name - The attribute name to create/return
Returns:
The Attribute object

newAttribute

public Attribute newAttribute(String name,
                              char oper)
Returns an Attribute object from this entry's list of attributes. If the attribute does not exist, a new one is created with no values.

Parameters:
name - The attribute name to create/return
oper - The new Attribute's operation code. Only used if creating a new Attribute.
Returns:
The Attribute object

addAttributeValue

public void addAttributeValue(Object name,
                              Object value)
Adds a value to an attribute. If the attribute does not exist it is created with the new value. If the attribute exists, the value is appended to the attribute's list of values. If the value Object is an Attribute, you may wish to use mergeAttributeValue instead, to get the values of the Attribute added instead of the Attribute itself as a value.

Parameters:
name - The attribute name
value - The value to append

addAttributeValue

public void addAttributeValue(Object name,
                              Object value,
                              int op)
Adds a value to an attribute. If the attribute does not exist it is created with the new value. If the attribute exists, the value is appended to the attribute's list of values.

Parameters:
name - The attribute name
value - The value to append
op - The attribute value operation, AV_UNCHANGED = 0, AV_ADD = 1, AV_DELETE = 2

mergeAttributeValue

public void mergeAttributeValue(Object name,
                                AttributeInterface attr)
Merges the values in one attribute with the values from another attribute. All values from attr are added, even if they already exist.

Parameters:
name - The name of the attribute into which values are merged
attr - The attribute (e.g. entry.getAttribute("xxx")) from which values are collected

mergeAttributeValue

public void mergeAttributeValue(Attribute attr)
Merges in the values from an attribute. All values from attr are added, even if they already exist. The name of attr will be used to determine which Attribute should get the new values.

Parameters:
attr - The attribute (e.g. entry.getAttribute("xxx")) from which we get the name and values

get

public Attribute get(Object p1)
Returns the Attribute object for a named attribute.

Parameters:
p1 - The attribute name
Returns:
The Attribute object or null if the attribute does not exist

getAttribute

public Attribute getAttribute(Object p1)
Returns the Attribute object for a named attribute.

Parameters:
p1 - The attribute name
Returns:
The Attribute object or null if the attribute does not exist

getAttributeNames

public String[] getAttributeNames()
Returns an array of strings containing attribute names in this entry.

Returns:
The attribute names in this entry as an array

getAttributeCollection

public Collection getAttributeCollection()
Returns a java.util.Collection containing attribute names in this entry.

Returns:
The attribute names in this entry as a java.util.Collection object

getString

public String getString(Object p1)
Returns the first value in an attribute as a String. If the attribute does not exist or the attribute does not have any values then null is returned.

Parameters:
p1 - The attribute name
Returns:
The string value or null

getObject

public Object getObject(Object p1)
Returns the first value in an attribute as an object. If the attribute does not exist or the attribute does not have any values then null is returned.

Parameters:
p1 - The attribute name
Returns:
The object value or null

removeAttribute

public void removeAttribute(Object p1)
Removes an attribute from this Entry's list of attribute.

Parameters:
p1 - The name of the attribute to remove

removeAllAttributes

public void removeAllAttributes()
Removes all attributes from this Entry.


size

public int size()
Returns the number of attributes present in this entry.

Returns:
Number of attributes contained in this entry

toString

public String toString()
Returns a string representation of this entry.

Overrides:
toString in class Object
Returns:
All attribute names and values as a structured string

toDeltaString

public String toDeltaString()
Returns a string representation of this entry, including delta information.

Returns:
All attribute names and values as a structured string, and also delta information if present.

getProperty

public Object getProperty(Object propertyName)
Returns a property value.

Parameters:
propertyName - The name of the property
Returns:
The property's value or null if no such property exists

setProperty

public void setProperty(Object propertyName,
                        Object propertyValue)
Sets/replaces a property.

Parameters:
propertyName - The name of the property
propertyValue - The named property's value

hasProperty

public boolean hasProperty(String propertyName)
Returns true if a property named by the propertyName parameter has a value.

Returns:
True if such property exists

getPropertyNames

public String[] getPropertyNames()
Returns a string array of the property names contained in this entry.

Returns:
Array of strings with property names

merge

public void merge(Entry e)
Convenience method that calls merge ( e, false ).

Parameters:
e - The entry from which attributes are collected

merge

public void merge(Entry e,
                  boolean mergevalues)
Merges in the attributes and their values from another entry. After the operation this entry contains all the attributes combined. For attributes with the same name, the result will be the attributes from the other entry if mergevalues is false. Properties are copied from the e entry and overwrite any existing properties.

Example: This entry contains these attributes Name Values a 1 b 1, 2 The other entry contains these attributes Name Values b 3 c 4 After the merge, mergevalues=FALSE, this entry will contain Name Values a 1 b 3 c 4 After the merge, mergevalues=TRUE, this entry will contain Name Values a 1 b 1, 2, 3 c 4

Parameters:
e - The entry from which attributes are collected
mergevalues - if false replace values, if true add values