API Overview API Index Package Overview Direct link to this page
JDK 1.6
  javax.naming.directory. ModificationItem View Javadoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116

/*
 * @(#)ModificationItem.java	1.9 05/11/17
 *
 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

package javax.naming.directory;

/**
  * This class represents a modification item.
  * It consists of a modification code and an attribute on which to operate.
  *<p>
  * 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.9 05/11/17
  * @since 1.3
  */

/*
  *<p>
  * The serialized form of a ModificationItem object consists of the
  * modification op (and int) and the corresponding Attribute.
*/

public class ModificationItem implements java.io.Serializable {
    /**
     * Contains an integer identify the modification
     * to be performed.
     * @serial
     */
    private int mod_op;
    /**
     * Contains the attribute identifying
     * the attribute and/or its value to be applied for the modification.
     * @serial 
     */
    private 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.
      */
    public ModificationItem(int mod_op, Attribute attr) {
	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);
	}
    }

    /**
      * 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
      */
    public int getModificationOp() {
	return mod_op;
    }

    /**
      * Retrieves the attribute associated with this modification item.
      * @return The non-null attribute to use for the modification.
      */
    public Attribute getAttribute() {
	return attr;
    }

    /**
      * 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.
      */
    public String toString() {
	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
    }

    /**
     * Use serialVersionUID from JNDI 1.1.1 for interoperability
     */
    private static final long serialVersionUID = 7573258562534746850L;
}

Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar