KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > core > model > IValue


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

20
21 package org.apache.directory.ldapstudio.browser.core.model;
22
23
24 import java.io.Serializable JavaDoc;
25
26 import org.apache.directory.ldapstudio.browser.core.BrowserCoreMessages;
27 import org.apache.directory.ldapstudio.browser.core.propertypageproviders.AttributePropertyPageProvider;
28 import org.apache.directory.ldapstudio.browser.core.propertypageproviders.ConnectionPropertyPageProvider;
29 import org.apache.directory.ldapstudio.browser.core.propertypageproviders.EntryPropertyPageProvider;
30 import org.apache.directory.ldapstudio.browser.core.propertypageproviders.ValuePropertyPageProvider;
31 import org.eclipse.core.runtime.IAdaptable;
32
33
34 /**
35  * An IValue represents a value of a LDAP attribute.
36  *
37  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
38  * @version $Rev$, $Date$
39  */

40 public interface IValue extends Serializable JavaDoc, IAdaptable, ValuePropertyPageProvider, AttributePropertyPageProvider,
41     EntryPropertyPageProvider, ConnectionPropertyPageProvider
42 {
43
44     /**
45      * EmptyValue is used to indicate an empty value.
46      *
47      * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
48      * @version $Rev$, $Date$
49      */

50     interface EmptyValue
51     {
52
53         /**
54          * Gets the string value.
55          *
56          * @return the string value
57          */

58         public String JavaDoc getStringValue();
59
60
61         /**
62          * Gets the binary value.
63          *
64          * @return the binary value
65          */

66         public byte[] getBinaryValue();
67
68
69         /**
70          * Checks if is string.
71          *
72          * @return true, if is string
73          */

74         public boolean isString();
75
76
77         /**
78          * Checks if is binary.
79          *
80          * @return true, if is binary
81          */

82         public boolean isBinary();
83     }
84
85     /**
86      * This object represents the empty string value.
87      */

88     public static final EmptyValue EMPTY_STRING_VALUE = new EmptyValue()
89     {
90
91         /**
92          * {@inheritDoc}
93          */

94         public String JavaDoc toString()
95         {
96             return BrowserCoreMessages.model__empty_string_value;
97         }
98
99
100         /**
101          * {@inheritDoc}
102          */

103         public boolean isString()
104         {
105             return true;
106         }
107
108
109         /**
110          * {@inheritDoc}
111          */

112         public boolean isBinary()
113         {
114             return false;
115         }
116
117
118         /**
119          * {@inheritDoc}
120          */

121         public byte[] getBinaryValue()
122         {
123             return new byte[0];
124         }
125
126
127         /**
128          * {@inheritDoc}
129          */

130         public String JavaDoc getStringValue()
131         {
132             return ""; //$NON-NLS-1$
133
}
134     };
135
136     /**
137      * This object represents the empty binary value.
138      */

139     public static final EmptyValue EMPTY_BINARY_VALUE = new EmptyValue()
140     {
141
142         /**
143          * {@inheritDoc}
144          */

145         public String JavaDoc toString()
146         {
147             return BrowserCoreMessages.model__empty_binary_value;
148         }
149
150
151         /**
152          * {@inheritDoc}
153          */

154         public boolean isString()
155         {
156             return false;
157         }
158
159
160         /**
161          * {@inheritDoc}
162          */

163         public boolean isBinary()
164         {
165             return true;
166         }
167
168
169         /**
170          * {@inheritDoc}
171          */

172         public byte[] getBinaryValue()
173         {
174             return new byte[0];
175         }
176
177
178         /**
179          * {@inheritDoc}
180          */

181         public String JavaDoc getStringValue()
182         {
183             return ""; //$NON-NLS-1$
184
}
185     };
186
187
188     /**
189      * The attribute of this value.
190      *
191      * @return The attribute of this value, never null.
192      */

193     public abstract IAttribute getAttribute();
194
195
196     /**
197      * Gets the raw value or an EmptyValue
198      *
199      * @return The raw value or an EmptyValue, never null.
200      */

201     public abstract Object JavaDoc getRawValue();
202
203
204     /**
205      * Gets the string value of this value.
206      *
207      * If the value is binary a String with UTF-8 decoded
208      * byte[] is returned.
209      *
210      * @return the String value
211      */

212     public abstract String JavaDoc getStringValue();
213
214
215     /**
216      * Gets the binary value of this value.
217      *
218      * If the value is string a byte[] with the
219      * UTF-8 encoded String is returned.
220      *
221      * @return the binary value
222      */

223     public abstract byte[] getBinaryValue();
224
225
226     /**
227      * Returns true if the value is empty.
228      *
229      * A value is empty if its raw value is an EmptyValue.
230      *
231      * @return true if the value is empty.
232      */

233     public abstract boolean isEmpty();
234
235
236     /**
237      * Convinience method to getAttribute().isString().
238      *
239      * @return true if the values attribute is string.
240      */

241     public abstract boolean isString();
242
243
244     /**
245      * Convinience method to getAttribute().isBinary()
246      *
247      * @return true if the values attribute is binary.
248      */

249     public abstract boolean isBinary();
250
251
252     /**
253      * Returns true if this value is part of its entry's RDN.
254      *
255      * @return true if this value is part of its entry's RDN.
256      */

257     public abstract boolean isRdnPart();
258
259
260     /**
261      * Return true if the argument is also of type IValue and they are
262      * equal.
263      *
264      * IValues are equal if there entries, there attributes and there raw
265      * values are equal.
266      *
267      * @param o
268      * The value to compare, must be of type IValue
269      * @return true if the argument is equal to this.
270      */

271     public abstract boolean equals( Object JavaDoc o );
272
273 }
274
Popular Tags