1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.api.ldap.model.message.controls;
21
22
23 import org.apache.directory.api.ldap.model.message.Control;
24
25
26
27
28
29
30
31
32
33
34 public abstract class AbstractControl implements Control
35 {
36
37 private String oid;
38
39
40 private boolean criticality = false;
41
42
43
44
45
46
47
48 public AbstractControl( String oid )
49 {
50 this.oid = oid;
51 }
52
53
54
55
56
57
58
59
60 public AbstractControl( String oid, boolean criticality )
61 {
62 this.oid = oid;
63 this.criticality = criticality;
64 }
65
66
67
68
69
70
71
72 public String getOid()
73 {
74 return oid == null ? "" : oid;
75 }
76
77
78
79
80
81
82
83 public boolean isCritical()
84 {
85 return criticality;
86 }
87
88
89
90
91
92
93
94 public void setCritical( boolean criticality )
95 {
96 this.criticality = criticality;
97 }
98
99
100
101
102
103 public int hashCode()
104 {
105 int h = 17;
106 h = h * 37 + ( criticality ? 1 : 0 );
107 h = h * 37 + ( oid == null ? 0 : oid.hashCode() );
108
109 return h;
110 }
111
112
113
114
115
116 public boolean equals( Object o )
117 {
118 if ( o == this )
119 {
120 return true;
121 }
122
123 if ( o == null )
124 {
125 return false;
126 }
127
128 if ( !( o instanceof Control ) )
129 {
130 return false;
131 }
132
133 Control otherControl = ( Control ) o;
134
135 if ( !oid.equalsIgnoreCase( otherControl.getOid() ) )
136 {
137 return false;
138 }
139
140 return criticality == otherControl.isCritical();
141 }
142
143
144
145
146
147 public String toString()
148 {
149 StringBuffer sb = new StringBuffer();
150
151 sb.append( " " ).append( getClass().getSimpleName() ).append( " " );
152 sb.append( "Control\n" );
153 sb.append( " Type OID : '" ).append( oid ).append( "'\n" );
154 sb.append( " Criticality : '" ).append( criticality ).append( "'\n" );
155
156 sb.append( "'\n" );
157
158 return sb.toString();
159 }
160 }