1 7 8 package javax.naming.directory; 9 10 23 24 29 30 public class ModificationItem implements java.io.Serializable { 31 36 private int mod_op; 37 42 private Attribute attr; 43 44 54 public ModificationItem(int mod_op, Attribute attr) { 55 switch (mod_op) { 56 case DirContext.ADD_ATTRIBUTE: 57 case DirContext.REPLACE_ATTRIBUTE: 58 case DirContext.REMOVE_ATTRIBUTE: 59 if (attr == null) 60 throw new IllegalArgumentException ("Must specify non-null attribute for modification"); 61 62 this.mod_op = mod_op; 63 this.attr = attr; 64 break; 65 66 default: 67 throw new IllegalArgumentException ("Invalid modification code " + mod_op); 68 } 69 } 70 71 78 public int getModificationOp() { 79 return mod_op; 80 } 81 82 86 public Attribute getAttribute() { 87 return attr; 88 } 89 90 98 public String toString() { 99 switch (mod_op) { 100 case DirContext.ADD_ATTRIBUTE: 101 return ("Add attribute: " + attr.toString()); 102 103 case DirContext.REPLACE_ATTRIBUTE: 104 return ("Replace attribute: " + attr.toString()); 105 106 case DirContext.REMOVE_ATTRIBUTE: 107 return ("Remove attribute: " + attr.toString()); 108 } 109 return ""; } 111 112 115 private static final long serialVersionUID = 7573258562534746850L; 116 } 117 118 | Popular Tags |