1 20 21 package org.apache.directory.ldapstudio.browser.core.model; 22 23 24 import java.io.Serializable ; 25 26 import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifControlLine; 27 28 29 41 public class Control implements Serializable  42 { 43 44 45 private static final long serialVersionUID = -1289018814649849178L; 46 47 50 public static final Control SUBENTRIES_CONTROL = new Control( "Subentries Control", "1.3.6.1.4.1.4203.1.10.1", 51 false, new byte[] 52 { 0x01, 0x01, ( byte ) 0xFF } ); 53 54 55 private String name; 56 57 58 private String oid; 59 60 61 private boolean critical; 62 63 64 private transient byte[] controlValue; 65 66 67 70 public Control() 71 { 72 } 73 74 75 83 public Control( String name, String oid, boolean critical, byte[] controlValue ) 84 { 85 super(); 86 this.name = name == null ? "" : name; 87 this.oid = oid; 88 this.critical = critical; 89 this.controlValue = controlValue; 90 } 91 92 93 98 public byte[] getControlValue() 99 { 100 return controlValue; 101 } 102 103 104 109 public String getOid() 110 { 111 return oid; 112 } 113 114 115 120 public boolean isCritical() 121 { 122 return critical; 123 } 124 125 126 131 public String getName() 132 { 133 return name; 134 } 135 136 137 140 public String toString() 141 { 142 143 if ( oid == null ) 144 { 145 return ""; 146 } 147 148 LdifControlLine line = LdifControlLine.create( getOid(), isCritical() ? " true" : " false", getControlValue() ); 149 String s = line.toRawString(); 150 s = s.substring( line.getRawControlSpec().length(), s.length() ); 151 s = s.substring( line.getRawControlType().length(), s.length() ); 152 s = s.substring( 0, s.length() - line.getRawNewLine().length() ); 153 154 156 return s; 157 } 158 159 160 165 public void setControlValue( byte[] controlValue ) 166 { 167 this.controlValue = controlValue; 168 } 169 170 171 176 public void setCritical( boolean critical ) 177 { 178 this.critical = critical; 179 } 180 181 182 187 public void setName( String name ) 188 { 189 this.name = name; 190 } 191 192 193 198 public void setOid( String oid ) 199 { 200 this.oid = oid; 201 } 202 203 204 207 public boolean equals( Object obj ) 208 { 209 if ( obj == null || !( obj instanceof Control ) ) 210 { 211 return false; 212 } 213 Control other = ( Control ) obj; 214 215 return this.toString().equals( other.toString() ); 216 } 217 218 } 219 | Popular Tags |