FileDocCategorySizeDatePackage
ModificationItem.javaAPI DocJava SE 5 API3479Fri Aug 26 14:57:40 BST 2005javax.naming.directory

ModificationItem

public class ModificationItem extends Object implements Serializable
This class represents a modification item. It consists of a modification code and an attribute on which to operate.

A ModificationItem instance is not synchronized against concurrent multithreaded access. Multiple threads trying to access and modify a single ModificationItem instance should lock the object.

author
Rosanna Lee
author
Scott Seligman
version
1.8 03/12/19
since
1.3

Fields Summary
private int
mod_op
Contains an integer identify the modification to be performed.
private Attribute
attr
Contains the attribute identifying the attribute and/or its value to be applied for the modification.
private static final long
serialVersionUID
Use serialVersionUID from JNDI 1.1.1 for interoperability
Constructors Summary
public ModificationItem(int mod_op, Attribute attr)
Creates a new instance of ModificationItem.

param
mod_op Modification to apply. It must be one of: DirContext.ADD_ATTRIBUTE DirContext.REPLACE_ATTRIBUTE DirContext.REMOVE_ATTRIBUTE
param
attr The non-null attribute to use for modification.
exception
IllegalArgumentException If attr is null, or if mod_op is not one of the ones specified above.

	switch (mod_op) {
	case DirContext.ADD_ATTRIBUTE:
	case DirContext.REPLACE_ATTRIBUTE:
	case DirContext.REMOVE_ATTRIBUTE:
	    if (attr == null)
		throw new IllegalArgumentException("Must specify non-null attribute for modification");
		
	    this.mod_op = mod_op;
	    this.attr = attr;
	    break;

	default:
	    throw new IllegalArgumentException("Invalid modification code " + mod_op);
	}
    
Methods Summary
public javax.naming.directory.AttributegetAttribute()
Retrieves the attribute associated with this modification item.

return
The non-null attribute to use for the modification.

	return attr;
    
public intgetModificationOp()
Retrieves the modification code of this modification item.

return
The modification code. It is one of: DirContext.ADD_ATTRIBUTE DirContext.REPLACE_ATTRIBUTE DirContext.REMOVE_ATTRIBUTE

	return mod_op;
    
public java.lang.StringtoString()
Generates the string representation of this modification item, which consists of the modification operation and its related attribute. The string representation is meant for debugging and not to be interpreted programmatically.

return
The non-null string representation of this modification item.

	switch (mod_op) {
	case DirContext.ADD_ATTRIBUTE:
	    return ("Add attribute: " + attr.toString());
	    
	case DirContext.REPLACE_ATTRIBUTE:
	    return ("Replace attribute: " + attr.toString());

	case DirContext.REMOVE_ATTRIBUTE:
	    return ("Remove attribute: " + attr.toString());
	}
	return "";	// should never happen