Source Code Cross Referenced for Attribute.java in  » 6.0-JDK-Core » naming » javax » naming » directory » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » naming » javax.naming.directory 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 1999-2004 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025
026        package javax.naming.directory;
027
028        import java.util.Vector;
029        import java.util.Enumeration;
030        import java.util.NoSuchElementException;
031
032        import javax.naming.NamingException;
033        import javax.naming.NamingEnumeration;
034        import javax.naming.OperationNotSupportedException;
035
036        /**
037         * This interface represents an attribute associated with a named object.
038         *<p>
039         * In a directory, named objects can have associated with them
040         * attributes.  The <tt>Attribute</tt> interface represents an attribute associated
041         * with a named object.  An attribute contains 0 or more, possibly null, values.
042         * The attribute values can be ordered or unordered (see <tt>isOrdered()</tt>).
043         * If the values are unordered, no duplicates are allowed.
044         * If the values are ordered, duplicates are allowed.
045         *<p>
046         * The content and representation of an attribute and its values is defined by
047         * the attribute's <em>schema</em>. The schema contains information
048         * about the attribute's syntax and other properties about the attribute.
049         * See <tt>getAttributeDefinition()</tt> and
050         * <tt>getAttributeSyntaxDefinition()</tt>
051         * for details regarding how to get schema information about an attribute
052         * if the underlying directory service supports schemas.
053         *<p>
054         * Equality of two attributes is determined by the implementation class.
055         * A simple implementation can use <tt>Object.equals()</tt> to determine equality 
056         * of attribute values, while a more sophisticated implementation might
057         * make use of schema information to determine equality.
058         * Similarly, one implementation might provide a static storage
059         * structure which simply returns the values passed to its
060         * constructor, while another implementation might define <tt>get()</tt> and 
061         * <tt>getAll()</tt>.
062         * to get the values dynamically from the directory.
063         *<p>
064         * Note that updates to <tt>Attribute</tt> (such as adding or removing a
065         * value) do not affect the corresponding representation of the attribute
066         * in the directory.  Updates to the directory can only be effected
067         * using operations in the <tt>DirContext</tt> interface.
068         *
069         * @author Rosanna Lee
070         * @author Scott Seligman
071         * @version 1.19 07/05/05
072         *
073         * @see BasicAttribute
074         * @since 1.3
075         */
076        public interface Attribute extends Cloneable, java.io.Serializable {
077            /**
078             * Retrieves an enumeration of the attribute's values.
079             * The behaviour of this enumeration is unspecified
080             * if the attribute's values are added, changed,
081             * or removed while the enumeration is in progress.
082             * If the attribute values are ordered, the enumeration's items
083             * will be ordered.
084             *
085             * @return A non-null enumeration of the attribute's values.
086             * Each element of the enumeration is a possibly null Object. The object's
087             * class is the class of the attribute value. The element is null
088             * if the attribute's value is null.
089             * If the attribute has zero values, an empty enumeration 
090             * is returned.
091             * @exception NamingException
092             *		If a naming exception was encountered while retrieving
093             *		the values.
094             * @see #isOrdered
095             */
096            NamingEnumeration<?> getAll() throws NamingException;
097
098            /**
099             * Retrieves one of this attribute's values.
100             * If the attribute has more than one value and is unordered, any one of
101             * the values is returned.
102             * If the attribute has more than one value and is ordered, the
103             * first value is returned.
104             *
105             * @return A possibly null object representing one of 
106             *        the attribute's value. It is null if the attribute's value
107             *	       is null.
108             * @exception NamingException
109             *		If a naming exception was encountered while retrieving
110             *		the value.
111             * @exception java.util.NoSuchElementException
112             *		If this attribute has no values.
113             */
114            Object get() throws NamingException;
115
116            /** 
117             * Retrieves the number of values in this attribute.
118             *
119             * @return The nonnegative number of values in this attribute.
120             */
121            int size();
122
123            /**
124             * Retrieves the id of this attribute.
125             *
126             * @return The id of this attribute. It cannot be null.
127             */
128            String getID();
129
130            /**
131             * Determines whether a value is in the attribute.
132             * Equality is determined by the implementation, which may use
133             * <tt>Object.equals()</tt> or schema information to determine equality.
134             *
135             * @param attrVal The possibly null value to check. If null, check
136             *  whether the attribute has an attribute value whose value is null.
137             * @return true if attrVal is one of this attribute's values; false otherwise.
138             * @see java.lang.Object#equals
139             * @see BasicAttribute#equals
140             */
141            boolean contains(Object attrVal);
142
143            /**
144             * Adds a new value to the attribute. 
145             * If the attribute values are unordered and
146             * <tt>attrVal</tt> is already in the attribute, this method does nothing.
147             * If the attribute values are ordered, <tt>attrVal</tt> is added to the end of
148             * the list of attribute values.
149             *<p>
150             * Equality is determined by the implementation, which may use
151             * <tt>Object.equals()</tt> or schema information to determine equality.
152             *
153             * @param attrVal The new possibly null value to add. If null, null
154             *  is added as an attribute value.
155             * @return true if a value was added; false otherwise.
156             */
157            boolean add(Object attrVal);
158
159            /**
160             * Removes a specified value from the attribute.
161             * If <tt>attrval</tt> is not in the attribute, this method does nothing.
162             * If the attribute values are ordered, the first occurrence of 
163             * <tt>attrVal</tt> is removed and attribute values at indices greater 
164             * than the removed
165             * value are shifted up towards the head of the list (and their indices
166             * decremented by one).
167             *<p>
168             * Equality is determined by the implementation, which may use
169             * <tt>Object.equals()</tt> or schema information to determine equality.
170             *
171             * @param attrval The possibly null value to remove from this attribute.
172             * If null, remove the attribute value that is null.
173             * @return true if the value was removed; false otherwise.
174             */
175            boolean remove(Object attrval);
176
177            /**
178             * Removes all values from this attribute.
179             */
180            void clear();
181
182            /**
183             * Retrieves the syntax definition associated with the attribute.
184             * An attribute's syntax definition specifies the format
185             * of the attribute's value(s). Note that this is different from 
186             * the attribute value's representation as a Java object. Syntax 
187             * definition refers to the directory's notion of <em>syntax</em>.
188             *<p>
189             * For example, even though a value might be
190             * a Java String object, its directory syntax might be "Printable String"
191             * or "Telephone Number". Or a value might be a byte array, and its
192             * directory syntax is "JPEG" or "Certificate".
193             * For example, if this attribute's syntax is "JPEG",
194             * this method would return the syntax definition for "JPEG".
195             * <p>
196             * The information that you can retrieve from a syntax definition
197             * is directory-dependent.
198             *<p>
199             * If an implementation does not support schemas, it should throw
200             * OperationNotSupportedException. If an implementation does support
201             * schemas, it should define this method to return the appropriate
202             * information.
203             * @return The attribute's syntax definition. Null if the implementation
204             *	   supports schemas but this particular attribute does not have
205             *    any schema information.
206             * @exception OperationNotSupportedException If getting the schema
207             * 	is not supported.
208             * @exception NamingException If a naming exception occurs while getting
209             *		the schema.
210             */
211
212            DirContext getAttributeSyntaxDefinition() throws NamingException;
213
214            /**
215             * Retrieves the attribute's schema definition.
216             * An attribute's schema definition contains information
217             * such as whether the attribute is multivalued or single-valued,
218             * the matching rules to use when comparing the attribute's values.
219             *
220             * The information that you can retrieve from an attribute definition
221             * is directory-dependent.
222             *
223             *<p>
224             * If an implementation does not support schemas, it should throw
225             * OperationNotSupportedException. If an implementation does support
226             * schemas, it should define this method to return the appropriate
227             * information.
228             * @return This attribute's schema definition. Null if the implementation
229             *	    supports schemas but this particular attribute does not have
230             *	    any schema information.
231             * @exception OperationNotSupportedException If getting the schema
232             * 	is not supported.
233             * @exception NamingException If a naming exception occurs while getting
234             *		the schema.
235             */
236            DirContext getAttributeDefinition() throws NamingException;
237
238            /**
239             * Makes a copy of the attribute. 
240             * The copy contains the same attribute values as the original attribute:
241             * the attribute values are not themselves cloned.
242             * Changes to the copy will not affect the original and vice versa.
243             *
244             * @return A non-null copy of the attribute.
245             */
246            Object clone();
247
248            //----------- Methods to support ordered multivalued attributes
249
250            /**
251             * Determines whether this attribute's values are ordered.
252             * If an attribute's values are ordered, duplicate values are allowed.
253             * If an attribute's values are unordered, they are presented
254             * in any order and there are no duplicate values.
255             * @return true if this attribute's values are ordered; false otherwise.
256             * @see #get(int)
257             * @see #remove(int)
258             * @see #add(int, java.lang.Object)
259             * @see #set(int, java.lang.Object)
260             */
261            boolean isOrdered();
262
263            /**
264             * Retrieves the attribute value from the ordered list of attribute values.
265             * This method returns the value at the <tt>ix</tt> index of the list of
266             * attribute values.
267             * If the attribute values are unordered,
268             * this method returns the value that happens to be at that index.
269             * @param ix The index of the value in the ordered list of attribute values.
270             * 0 <= <tt>ix</tt> < <tt>size()</tt>.
271             * @return The possibly null attribute value at index <tt>ix</tt>; 
272             *   null if the attribute value is null.
273             * @exception NamingException If a naming exception was encountered while
274             * retrieving the value.
275             * @exception IndexOutOfBoundsException If <tt>ix</tt> is outside the specified range.
276             */
277            Object get(int ix) throws NamingException;
278
279            /**
280             * Removes an attribute value from the ordered list of attribute values.
281             * This method removes the value at the <tt>ix</tt> index of the list of
282             * attribute values. 
283             * If the attribute values are unordered,
284             * this method removes the value that happens to be at that index.
285             * Values located at indices greater than <tt>ix</tt> are shifted up towards
286             * the front of the list (and their indices decremented by one).
287             *
288             * @param ix The index of the value to remove.
289             * 0 <= <tt>ix</tt> < <tt>size()</tt>.
290             * @return The possibly null attribute value at index <tt>ix</tt> that was removed; 
291             *   null if the attribute value is null.
292             * @exception IndexOutOfBoundsException If <tt>ix</tt> is outside the specified range.
293             */
294            Object remove(int ix);
295
296            /**
297             * Adds an attribute value to the ordered list of attribute values.
298             * This method adds <tt>attrVal</tt> to the list of attribute values at
299             * index <tt>ix</tt>.
300             * Values located at indices at or greater than <tt>ix</tt> are 
301             * shifted down towards the end of the list (and their indices incremented 
302             * by one).
303             * If the attribute values are unordered and already have <tt>attrVal</tt>,
304             * <tt>IllegalStateException</tt> is thrown.
305             *
306             * @param ix The index in the ordered list of attribute values to add the new value.
307             * 0 <= <tt>ix</tt> <= <tt>size()</tt>.
308             * @param attrVal The possibly null attribute value to add; if null, null is
309             * the value added.
310             * @exception IndexOutOfBoundsException If <tt>ix</tt> is outside the specified range.
311             * @exception IllegalStateException If the attribute values are unordered and
312             * <tt>attrVal</tt> is one of those values.
313             */
314            void add(int ix, Object attrVal);
315
316            /**
317             * Sets an attribute value in the ordered list of attribute values.
318             * This method sets the value at the <tt>ix</tt> index of the list of
319             * attribute values to be <tt>attrVal</tt>. The old value is removed.
320             * If the attribute values are unordered,
321             * this method sets the value that happens to be at that index
322             * to <tt>attrVal</tt>, unless <tt>attrVal</tt> is already one of the values.
323             * In that case, <tt>IllegalStateException</tt> is thrown.
324             *
325             * @param ix The index of the value in the ordered list of attribute values.
326             * 0 <= <tt>ix</tt> < <tt>size()</tt>.
327             * @param attrVal The possibly null attribute value to use. 
328             * If null, 'null' replaces the old value.
329             * @return The possibly null attribute value at index ix that was replaced. 
330             *   Null if the attribute value was null.
331             * @exception IndexOutOfBoundsException If <tt>ix</tt> is outside the specified range.
332             * @exception IllegalStateException If <tt>attrVal</tt> already exists and the
333             *    attribute values are unordered.
334             */
335            Object set(int ix, Object attrVal);
336
337            /**
338             * Use serialVersionUID from JNDI 1.1.1 for interoperability.
339             */
340            static final long serialVersionUID = 8707690322213556804L;
341        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.