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.codec;
21
22
23 import org.apache.directory.api.ldap.codec.api.LdapConstants;
24 import org.apache.directory.api.ldap.model.entry.*;
25 import org.apache.directory.api.util.Strings;
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 public class AttributeValueAssertion
43 {
44
45
46
47
48 private String attributeDesc;
49
50
51 private Value<?> assertionValue;
52
53
54
55
56
57
58
59
60 public static String dumpObject( Object object )
61 {
62 if ( object != null )
63 {
64 if ( object instanceof String )
65 {
66 return ( String ) object;
67 }
68 else if ( object instanceof byte[] )
69 {
70 return Strings.dumpBytes( ( byte[] ) object );
71 }
72 else if ( object instanceof StringValue )
73 {
74 return ( ( StringValue ) object ).getValue();
75 }
76 else if ( object instanceof BinaryValue )
77 {
78 return Strings.dumpBytes( ( ( BinaryValue ) object ).getValue() );
79 }
80 else
81 {
82 return "<unknown type>";
83 }
84 }
85 else
86 {
87 return "";
88 }
89 }
90
91
92
93
94
95
96
97
98
99
100 public Value<?> getAssertionValue()
101 {
102 return assertionValue;
103 }
104
105
106
107
108
109
110
111 public void setAssertionValue( Value<?> assertionValue )
112 {
113 this.assertionValue = assertionValue;
114 }
115
116
117
118
119
120
121
122 public String getAttributeDesc()
123 {
124 return attributeDesc;
125 }
126
127
128
129
130
131
132
133 public void setAttributeDesc( String attributeDesc )
134 {
135 this.attributeDesc = attributeDesc;
136 }
137
138
139
140
141
142
143
144
145 public String toString( String tabs )
146 {
147 StringBuffer sb = new StringBuffer();
148
149 sb.append( tabs ).append( "AttributeValueAssertion\n" );
150 sb.append( tabs ).append( " Assertion description : '" );
151 sb.append( attributeDesc != null ? attributeDesc : "null" );
152 sb.append( "'\n" );
153 sb.append( tabs ).append( " Assertion value : '" ).append( dumpObject( assertionValue ) ).append( "'\n" );
154
155 return sb.toString();
156 }
157
158
159
160
161
162
163
164
165
166 public String toStringRFC2254( int filterType )
167 {
168 StringBuffer sb = new StringBuffer();
169
170 sb.append( attributeDesc );
171
172 switch ( filterType )
173 {
174 case LdapConstants.EQUALITY_MATCH_FILTER:
175 sb.append( '=' );
176 break;
177
178 case LdapConstants.LESS_OR_EQUAL_FILTER:
179 sb.append( "<=" );
180 break;
181
182 case LdapConstants.GREATER_OR_EQUAL_FILTER:
183 sb.append( ">=" );
184 break;
185
186 case LdapConstants.APPROX_MATCH_FILTER:
187 sb.append( "~=" );
188 break;
189 }
190
191 sb.append( dumpObject( assertionValue ) );
192
193 return sb.toString();
194 }
195
196
197
198
199
200
201
202 public String toString()
203 {
204 return toString( "" );
205 }
206 }