2362N/A * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * This interface represents an attribute associated with a named object. 0N/A * In a directory, named objects can have associated with them 0N/A * attributes. The <tt>Attribute</tt> interface represents an attribute associated 0N/A * with a named object. An attribute contains 0 or more, possibly null, values. 0N/A * The attribute values can be ordered or unordered (see <tt>isOrdered()</tt>). 0N/A * If the values are unordered, no duplicates are allowed. 0N/A * If the values are ordered, duplicates are allowed. 0N/A * The content and representation of an attribute and its values is defined by 0N/A * the attribute's <em>schema</em>. The schema contains information 0N/A * about the attribute's syntax and other properties about the attribute. 0N/A * See <tt>getAttributeDefinition()</tt> and 0N/A * <tt>getAttributeSyntaxDefinition()</tt> 0N/A * for details regarding how to get schema information about an attribute 0N/A * if the underlying directory service supports schemas. 0N/A * Equality of two attributes is determined by the implementation class. 0N/A * A simple implementation can use <tt>Object.equals()</tt> to determine equality 0N/A * of attribute values, while a more sophisticated implementation might 0N/A * make use of schema information to determine equality. 0N/A * Similarly, one implementation might provide a static storage 0N/A * structure which simply returns the values passed to its 0N/A * constructor, while another implementation might define <tt>get()</tt> and 0N/A * <tt>getAll()</tt>. 0N/A * to get the values dynamically from the directory. 0N/A * Note that updates to <tt>Attribute</tt> (such as adding or removing a 0N/A * value) do not affect the corresponding representation of the attribute 0N/A * in the directory. Updates to the directory can only be effected 0N/A * using operations in the <tt>DirContext</tt> interface. 0N/A * @author Rosanna Lee 0N/A * @author Scott Seligman 0N/A * @see BasicAttribute 0N/A * Retrieves an enumeration of the attribute's values. 0N/A * The behaviour of this enumeration is unspecified 0N/A * if the attribute's values are added, changed, 0N/A * or removed while the enumeration is in progress. 0N/A * If the attribute values are ordered, the enumeration's items 0N/A * @return A non-null enumeration of the attribute's values. 0N/A * Each element of the enumeration is a possibly null Object. The object's 0N/A * class is the class of the attribute value. The element is null 0N/A * if the attribute's value is null. 0N/A * If the attribute has zero values, an empty enumeration 0N/A * @exception NamingException 0N/A * If a naming exception was encountered while retrieving 0N/A * Retrieves one of this attribute's values. 0N/A * If the attribute has more than one value and is unordered, any one of 0N/A * the values is returned. 0N/A * If the attribute has more than one value and is ordered, the 0N/A * first value is returned. 0N/A * @return A possibly null object representing one of 0N/A * the attribute's value. It is null if the attribute's value 0N/A * @exception NamingException 0N/A * If a naming exception was encountered while retrieving 0N/A * @exception java.util.NoSuchElementException 0N/A * If this attribute has no values. 0N/A * Retrieves the number of values in this attribute. 0N/A * @return The nonnegative number of values in this attribute. 0N/A * Retrieves the id of this attribute. 0N/A * @return The id of this attribute. It cannot be null. 0N/A * Determines whether a value is in the attribute. 0N/A * Equality is determined by the implementation, which may use 0N/A * <tt>Object.equals()</tt> or schema information to determine equality. 0N/A * @param attrVal The possibly null value to check. If null, check 0N/A * whether the attribute has an attribute value whose value is null. 0N/A * @return true if attrVal is one of this attribute's values; false otherwise. 0N/A * @see java.lang.Object#equals 0N/A * @see BasicAttribute#equals 0N/A * Adds a new value to the attribute. 0N/A * If the attribute values are unordered and 0N/A * <tt>attrVal</tt> is already in the attribute, this method does nothing. 0N/A * If the attribute values are ordered, <tt>attrVal</tt> is added to the end of 0N/A * the list of attribute values. 0N/A * Equality is determined by the implementation, which may use 0N/A * <tt>Object.equals()</tt> or schema information to determine equality. 0N/A * @param attrVal The new possibly null value to add. If null, null 0N/A * is added as an attribute value. 0N/A * @return true if a value was added; false otherwise. 0N/A * Removes a specified value from the attribute. 0N/A * If <tt>attrval</tt> is not in the attribute, this method does nothing. 0N/A * If the attribute values are ordered, the first occurrence of 0N/A * <tt>attrVal</tt> is removed and attribute values at indices greater 0N/A * value are shifted up towards the head of the list (and their indices 0N/A * decremented by one). 0N/A * Equality is determined by the implementation, which may use 0N/A * <tt>Object.equals()</tt> or schema information to determine equality. 0N/A * @param attrval The possibly null value to remove from this attribute. 0N/A * If null, remove the attribute value that is null. 0N/A * @return true if the value was removed; false otherwise. 0N/A * Removes all values from this attribute. 0N/A * Retrieves the syntax definition associated with the attribute. 0N/A * An attribute's syntax definition specifies the format 0N/A * of the attribute's value(s). Note that this is different from 0N/A * the attribute value's representation as a Java object. Syntax 0N/A * definition refers to the directory's notion of <em>syntax</em>. 0N/A * For example, even though a value might be 0N/A * a Java String object, its directory syntax might be "Printable String" 0N/A * or "Telephone Number". Or a value might be a byte array, and its 0N/A * directory syntax is "JPEG" or "Certificate". 0N/A * For example, if this attribute's syntax is "JPEG", 0N/A * this method would return the syntax definition for "JPEG". 0N/A * The information that you can retrieve from a syntax definition 0N/A * is directory-dependent. 0N/A * If an implementation does not support schemas, it should throw 0N/A * OperationNotSupportedException. If an implementation does support 0N/A * schemas, it should define this method to return the appropriate 0N/A * @return The attribute's syntax definition. Null if the implementation 0N/A * supports schemas but this particular attribute does not have 0N/A * any schema information. 0N/A * @exception OperationNotSupportedException If getting the schema 0N/A * @exception NamingException If a naming exception occurs while getting 0N/A * Retrieves the attribute's schema definition. 0N/A * An attribute's schema definition contains information 0N/A * such as whether the attribute is multivalued or single-valued, 0N/A * the matching rules to use when comparing the attribute's values. 0N/A * The information that you can retrieve from an attribute definition 0N/A * is directory-dependent. 0N/A * If an implementation does not support schemas, it should throw 0N/A * OperationNotSupportedException. If an implementation does support 0N/A * schemas, it should define this method to return the appropriate 0N/A * @return This attribute's schema definition. Null if the implementation 0N/A * supports schemas but this particular attribute does not have 0N/A * any schema information. 0N/A * @exception OperationNotSupportedException If getting the schema 0N/A * @exception NamingException If a naming exception occurs while getting 0N/A * Makes a copy of the attribute. 0N/A * The copy contains the same attribute values as the original attribute: 0N/A * the attribute values are not themselves cloned. 0N/A * Changes to the copy will not affect the original and vice versa. 0N/A * @return A non-null copy of the attribute. 0N/A //----------- Methods to support ordered multivalued attributes 0N/A * Determines whether this attribute's values are ordered. 0N/A * If an attribute's values are ordered, duplicate values are allowed. 0N/A * If an attribute's values are unordered, they are presented 0N/A * in any order and there are no duplicate values. 0N/A * @return true if this attribute's values are ordered; false otherwise. 0N/A * @see #add(int, java.lang.Object) 0N/A * @see #set(int, java.lang.Object) 0N/A * Retrieves the attribute value from the ordered list of attribute values. 0N/A * This method returns the value at the <tt>ix</tt> index of the list of 0N/A * If the attribute values are unordered, 0N/A * this method returns the value that happens to be at that index. 0N/A * @param ix The index of the value in the ordered list of attribute values. 0N/A * 0 <= <tt>ix</tt> < <tt>size()</tt>. 0N/A * @return The possibly null attribute value at index <tt>ix</tt>; 0N/A * null if the attribute value is null. 0N/A * @exception NamingException If a naming exception was encountered while 0N/A * retrieving the value. 0N/A * @exception IndexOutOfBoundsException If <tt>ix</tt> is outside the specified range. 0N/A * Removes an attribute value from the ordered list of attribute values. 0N/A * This method removes the value at the <tt>ix</tt> index of the list of 0N/A * If the attribute values are unordered, 0N/A * this method removes the value that happens to be at that index. 0N/A * Values located at indices greater than <tt>ix</tt> are shifted up towards 0N/A * the front of the list (and their indices decremented by one). 0N/A * @param ix The index of the value to remove. 0N/A * 0 <= <tt>ix</tt> < <tt>size()</tt>. 0N/A * @return The possibly null attribute value at index <tt>ix</tt> that was removed; 0N/A * null if the attribute value is null. 0N/A * @exception IndexOutOfBoundsException If <tt>ix</tt> is outside the specified range. 0N/A * Adds an attribute value to the ordered list of attribute values. 0N/A * This method adds <tt>attrVal</tt> to the list of attribute values at 0N/A * index <tt>ix</tt>. 0N/A * Values located at indices at or greater than <tt>ix</tt> are 0N/A * shifted down towards the end of the list (and their indices incremented 0N/A * If the attribute values are unordered and already have <tt>attrVal</tt>, 0N/A * <tt>IllegalStateException</tt> is thrown. 0N/A * @param ix The index in the ordered list of attribute values to add the new value. 0N/A * 0 <= <tt>ix</tt> <= <tt>size()</tt>. 0N/A * @param attrVal The possibly null attribute value to add; if null, null is 0N/A * @exception IndexOutOfBoundsException If <tt>ix</tt> is outside the specified range. 0N/A * @exception IllegalStateException If the attribute values are unordered and 0N/A * <tt>attrVal</tt> is one of those values. 0N/A * Sets an attribute value in the ordered list of attribute values. 0N/A * This method sets the value at the <tt>ix</tt> index of the list of 0N/A * attribute values to be <tt>attrVal</tt>. The old value is removed. 0N/A * If the attribute values are unordered, 0N/A * this method sets the value that happens to be at that index 0N/A * to <tt>attrVal</tt>, unless <tt>attrVal</tt> is already one of the values. 0N/A * In that case, <tt>IllegalStateException</tt> is thrown. 0N/A * @param ix The index of the value in the ordered list of attribute values. 0N/A * 0 <= <tt>ix</tt> < <tt>size()</tt>. 0N/A * @param attrVal The possibly null attribute value to use. 0N/A * If null, 'null' replaces the old value. 0N/A * @return The possibly null attribute value at index ix that was replaced. 0N/A * Null if the attribute value was null. 0N/A * @exception IndexOutOfBoundsException If <tt>ix</tt> is outside the specified range. 0N/A * @exception IllegalStateException If <tt>attrVal</tt> already exists and the 0N/A * attribute values are unordered. 0N/A * Use serialVersionUID from JNDI 1.1.1 for interoperability.