You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2006/03/15 15:57:17 UTC

svn commit: r386087 [6/45] - in /incubator/harmony/enhanced/classlib/trunk: make/ make/patternsets/ modules/jndi/ modules/jndi/META-INF/ modules/jndi/make/ modules/jndi/make/common/ modules/jndi/src/ modules/jndi/src/main/ modules/jndi/src/main/java/ m...

Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/BasicAttribute.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/BasicAttribute.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/BasicAttribute.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/BasicAttribute.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,522 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package javax.naming.directory;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.lang.reflect.Array;
+import java.util.Enumeration;
+import java.util.NoSuchElementException;
+import java.util.Vector;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.OperationNotSupportedException;
+
+/**
+ * A simple attribute of a directory entry.
+ * <p>
+ * A basic attribute does not have any schema associated with it, and attempts
+ * to get the schema result in an <code>OperationNotSupportedException</code>
+ * being thrown.</p>
+ * <p>
+ * The definition of <code>equals</code> for an attribute is simply <code>
+ * Object.equals</code> on the value, except for values that are collections 
+ * where the definition of <code>equals</code> is an equivalence test (i.e. the 
+ * collection contains the same number of elements, and each has an equal 
+ * element in the other collection). For an array, <code>Object.equals</code>
+ * is used on each array element.</p>
+ * <p>
+ * Note that updates to a basic attribute do not update the directory itself --
+ * updates to a directory are only possible through the {@link DirContext}
+ * interface. <code>BasicAttribute</code> does not get its values dynamically 
+ * from the directory. It uses the values passed to the constructor or add and
+ * remove methods.</p>
+ * 
+ * @see Attribute
+ * 
+ */
+public class BasicAttribute implements Attribute {
+
+    /*
+     * -------------------------------------------------------------------
+     * Constants
+     * -------------------------------------------------------------------
+     */
+
+    /*
+     * This constant is used during deserialization to check the J2SE version
+     * which created the serialized object.
+     */
+    static final long serialVersionUID = 0x5d95d32a668565beL; //J2SE 1.4.2
+
+    /*
+     * -------------------------------------------------------------------
+     * Instance variables
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * The attribute identifier. 
+     * It is initialized by the public constructors and is required to be not
+     * null.
+     * 
+     * @serial
+     */
+    protected String attrID;
+
+    /**
+     * Flag showing whether the values of the attribute are ordered.
+     * 
+     * @serial 
+     */
+    protected boolean ordered;
+
+    /**
+     * <code>Vector</code> containing the attribute's values. 
+     * This is initialized by the public constructor and is required to be not 
+     * null.
+     */
+    protected transient Vector values = new Vector();
+
+    /*
+     * -------------------------------------------------------------------
+     * Constructors
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Constructs an unordered <code>BasicAttribute</code> instance with the 
+     * supplied identifier and no values.
+     * 
+     * @param id            the attribute ID
+     */
+    public BasicAttribute(String id) {
+        this(id, false);
+    }
+
+    /**
+     * Constructs a <code>BasicAttribute</code> instance with the supplied 
+     * identifier and no values. 
+     * The supplied flag controls whether the values will be ordered or not.
+     * 
+     * @param id            the attribute ID
+     * @param flag          Indicates whether the values are ordered or not.
+     */
+    public BasicAttribute(String id, boolean flag) {
+        attrID = id;
+        ordered = flag;
+    }
+
+    /**
+     * Constructs an unordered <code>BasicAttribute</code> instance with the 
+     * supplied identifier and one value.
+     *  
+     * @param id            the attribute ID
+     * @param val           the first attribute value
+     */
+    public BasicAttribute(String id, Object val) {
+        this(id, val, false);
+    }
+
+    /**
+     * Constructs a <code>BasicAttribute</code> instance with the supplied 
+     * identifier and one value. 
+     * The supplied flag controls whether the values will be ordered or not.
+     * 
+     * @param id            the attribute ID
+     * @param val           the first attribute value
+     * @param flag          Indicates whether the values are ordered or not.
+     */
+    public BasicAttribute(String id, Object val, boolean flag) {
+        this(id, flag);
+        values.add(val);
+    }
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods
+     * -------------------------------------------------------------------
+     */
+
+    /*
+     * Determine whether two values belonging to the two array classes
+     * respectively are possible to be equal.
+     */
+    private boolean compareValueClasses(Class c1, Class c2) {
+        if ((c1.getName().startsWith("[L") || c1.getName().startsWith("[[")) && //$NON-NLS-1$ //$NON-NLS-2$
+            (c2.getName().startsWith("[L") || c2.getName().startsWith("[["))) { //$NON-NLS-1$ //$NON-NLS-2$
+            /*
+             * If both Class are array of Object or array of array, the compare 
+             * result is true, even if their class name may not be the same.
+             */
+            return true;
+        } else if (c1.getName().equals(c2.getName())){
+            /*
+             * Otherwise, at least one of them must be array of basic types. If
+             * both Class have the same Class name, the compare result is true.
+             */
+            return true;
+        } else {
+            /*
+             * Otherwise, the compare result is false
+             */
+            return false;
+        }
+    }
+
+    /*
+     * Determine whether the two valuess are equal with each other, considering
+     * the possibility that they might be both arrays so that each element of 
+     * them has to be compared. 
+     */
+    private boolean compareValues(Object obj1, Object obj2) {
+        if (null == obj1 && null == obj2) {
+            // If both are null, they are considered equal.
+            return true;
+        } else if (null != obj1 && null != obj2) {
+            if (obj1.getClass().isArray() && obj2.getClass().isArray()) {
+                /*
+                 * If both are array, compare each element if it is possible
+                 * that they might be equal.
+                 */ 
+                if (compareValueClasses(obj1.getClass(), obj2.getClass())) {
+                    int i = Array.getLength(obj1);
+                    Object val1;
+                    Object val2;
+                                        
+                    // Compare each element of the two arrays
+                    if (Array.getLength(obj2) == i) {
+                        // Do the compare only if their lengths are equal
+                        for (i--; i >= 0; i--) {
+                            val1 = Array.get(obj1, i);
+                            val2 = Array.get(obj2, i);
+                            if (null == val1
+                                ? null != val2
+                                : !val1.equals(val2)) {
+                                /*
+                                 * If any of their elements at the same position
+                                 * are not equal,they are not equal.
+                                 */
+                                return false;
+                            }
+                        }
+                        // If all elements are equal, they are equal
+                        return true;
+                    }
+					// Not equal if different length
+					return false;
+                }
+				// Not equal if this can be inferred from their class names
+				return false;
+            }
+			// If not both of them are array, do a normal "equals"
+			return obj1.equals(obj2);
+        } else {
+            // Not equal if only one of them is null
+            return false;
+        }
+    }
+
+    /*
+     * Get the hash code of an attribute value, which might be an array whose 
+     * hash code is the sum of all its element. Base types are converted into
+     * corresponding wrapper class objects.     
+     */
+    private int hashCodeOfValue(Object obj) {
+        int hashcode = 0;
+
+        if (null != obj) {
+            // If the object is an array, sum up the hashcode of all elements.
+            if (obj.getClass().isArray()) {
+                Object element = null;
+                // Sum up the hashcode of all elements
+                for (int i = Array.getLength(obj) - 1; i >= 0; i--) {
+                    element = Array.get(obj, i);
+                    if (null != element) {
+                        hashcode += element.hashCode();
+                    }
+                }
+            } else {
+                // Otherwise, simply get the hashcode of the given object.
+                hashcode = obj.hashCode();
+            }
+        }
+
+        return hashcode;
+    }
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods of Interface Attribute
+     * -------------------------------------------------------------------
+     */
+
+    public void add(int index, Object val) {
+        if (ordered) {
+            values.add(index, val);
+        } else {
+            if (contains(val)) {
+                throw new IllegalStateException("Value already exists."); //$NON-NLS-1$
+            }
+			values.add(index, val);
+        }
+    }
+
+    public boolean add(Object val) {
+        if (ordered) {
+            return values.add(val); // always true
+        }
+		if (contains(val)) {
+		    return false;
+		}
+		return values.add(val); // always true
+    }
+
+    public void clear() {
+        values.clear();
+    }
+
+    public Object clone() {
+        try {
+            BasicAttribute attr = (BasicAttribute) super.clone();
+            attr.values = (Vector) this.values.clone();
+            return attr;
+        } catch (CloneNotSupportedException e) {
+            throw new InternalError("Failed to clone object of BasicAttribute class."); //$NON-NLS-1$
+        }
+    }
+
+    public boolean contains(Object val) {
+        Enumeration e = this.values.elements();
+
+        while (e.hasMoreElements()) {
+            if (compareValues(e.nextElement(), val)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public Object get() throws NamingException {
+        if (0 == values.size()) {
+            throw new NoSuchElementException("No values available."); //$NON-NLS-1$
+        }
+		return values.get(0);
+    }
+
+    public Object get(int index) throws NamingException {
+        return values.get(index);
+    }
+
+    public NamingEnumeration getAll() throws NamingException {
+        return new BasicNamingEnumeration(values.elements());
+    }
+
+    public DirContext getAttributeDefinition() throws NamingException {
+        throw new OperationNotSupportedException("BasicAttribute does not support this operation."); //$NON-NLS-1$
+    }
+
+    public DirContext getAttributeSyntaxDefinition() throws NamingException {
+        throw new OperationNotSupportedException("BasicAttribute does not support this operation."); //$NON-NLS-1$
+    }
+
+    public String getID() {
+        return attrID;
+    }
+
+    public boolean isOrdered() {
+        return ordered;
+    }
+
+    public Object remove(int index) {
+        return values.remove(index);
+    }
+
+    public boolean remove(Object val) {
+        int total = this.values.size();
+
+        for (int i = 0; i < total; i++) {
+            if (compareValues(this.values.get(i), val)) {
+                this.values.remove(i);
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public Object set(int index, Object val) {
+        if (!ordered && contains(val)) {
+            throw new IllegalStateException("Value already exists."); //$NON-NLS-1$
+        }
+        return values.set(index, val);
+    }
+
+    public int size() {
+        return values.size();
+    }
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods override parent class Object
+     * -------------------------------------------------------------------
+     */
+
+    /*
+     * Serialization of the <code>BasicAttribute</code> class is as follows:
+     *      attribute identifier (String)
+     *      ordered flag (boolean)
+     *      number of values (int)
+     *      list of value objects
+     */
+    private void readObject(ObjectInputStream ois)
+        throws IOException, ClassNotFoundException {
+        int size;
+
+        ois.defaultReadObject();
+        size = ois.readInt();
+        this.values = new Vector();
+        for (int i = 0; i < size; i++) {
+            this.values.add(ois.readObject());
+        }
+    }
+
+    /*
+     * Serialization of the <code>BasicAttribute</code> class is as follows:
+     *      attribute identifier (String)
+     *      ordered flag (boolean)
+     *      number of values (int)
+     *      list of value objects
+     */
+    private void writeObject(ObjectOutputStream oos) throws IOException {
+        oos.defaultWriteObject();
+        oos.writeInt(this.values.size());
+        for (Enumeration e = this.values.elements(); e.hasMoreElements();) {
+            oos.writeObject(e.nextElement());
+        }
+    }
+
+    /**
+     * Returns true if this <code>BasicAttribute</code> instance is equal to the
+     * supplied object <code>obj</code>.
+     * Two attributes are considered equal if they have equal identifiers, 
+     * schemas and values. BasicAttribute uses no schema.
+     * <p>
+     * <code>Object.equals</code> is used to test equality of identifiers and 
+     * values. For array values <code>Object.equals</code> is called on every 
+     * array element.</p>
+     *
+     * @param obj           the object to be compared with
+     * @return              true if this object is equal to <code>obj</code>,
+     *                      otherwise false
+     */
+    public boolean equals(Object obj) {
+        if (obj instanceof BasicAttribute) {
+            BasicAttribute a = (BasicAttribute) obj;
+
+            if (!this.attrID.equals(a.attrID)) {
+                // Not equal if different ID
+                return false;
+            } else if (this.ordered != a.ordered) {
+                // Not equal if different order definition
+                return false;
+            } else if (this.values.size() != a.values.size()) {
+                // Not equal if different numbers of values
+                return false;
+            } else if (this.ordered) {
+                // Otherwise, if both ordered, compare each value
+                Enumeration e1 = this.values.elements();
+                Enumeration e2 = a.values.elements();
+
+                while (e1.hasMoreElements()) {
+                    if (!compareValues(e1.nextElement(), e2.nextElement())) {
+                        // Not equal if one of the values are not equal
+                        return false;
+                    }
+                }
+                // Equal only if all the values are equal
+                return true;
+            } else {
+                /*
+                 * Otherwise (i.e., both unordered), see whether containing the
+                 * equal set of values.
+                 */
+                Enumeration e = this.values.elements();
+
+                while (e.hasMoreElements()) {
+                    if (!a.contains(e.nextElement())) {
+                        return false;
+                    }
+                }
+                return true;
+            }
+        }
+        // Not equal if not instance of BasicAttribute
+        return false;
+    }
+
+    /**
+     * Returns the hashcode for this <code>BasicAttribute</code> instance.
+     * The result is calculated by summing the hashcodes for the identifier
+     * and each of the values, except for array values, where the hashcodes
+     * for each array element are summed.
+     * 
+     * @return              the hashcode of this <code>BasicAttribute</code>
+     *                      instance
+     */
+    public int hashCode() {
+        Object o;
+        int i = attrID.hashCode();
+        Enumeration e = this.values.elements();
+
+        while (e.hasMoreElements()) {
+            o = e.nextElement();
+            if (null != o) {
+                i += hashCodeOfValue(o);
+            }
+        }
+
+        return i;
+    }
+
+    /**
+     * Returns the string representation of this <code>BasicAttribute</code>
+     * instance.
+     * The result contains the ID and the string representation of each value.
+     * 
+     * @return              the string representation of this object
+     */
+    public String toString() {
+        Enumeration e = this.values.elements();
+        String s = "Attribute ID: " + this.attrID; //$NON-NLS-1$
+        s += "\nAttribute values: "; //$NON-NLS-1$
+
+        if (!e.hasMoreElements()) {
+            s += "This Attribute does not have any values."; //$NON-NLS-1$
+        } else {
+            s += e.nextElement();
+            while (e.hasMoreElements()) {
+                s += "," + e.nextElement(); //$NON-NLS-1$
+            }
+        }
+        return s + "\n"; //$NON-NLS-1$
+    }
+
+}
+
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/BasicAttributes.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/BasicAttributes.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/BasicAttributes.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/BasicAttributes.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,336 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package javax.naming.directory;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Map;
+import java.util.Vector;
+import java.util.Iterator;
+import java.util.Hashtable;
+import java.util.Enumeration;
+import javax.naming.NamingEnumeration;
+
+/**
+ * A simple implementation of the <code>Attributes</code> interface.
+ * <p>
+ * The <code>BasicAttributes</code> provides operations on any types of 
+ * attribute. When a new attribute is created the <code>BasicAttributes</code>
+ * class will create a new <code>BasicAttribute</code> and add it to the 
+ * attribute collection.</p>
+ * <p>
+ * A particular instance of <code>BasicAttributes</code> can be either 
+ * case-sensitive or case-insensitive, as defined by the <code>isCaseIgnored()
+ * </code> method.</p>
+ * <p>
+ * Note that changes to the <code>BasicAttributes</code> are local -- they do
+ * not modify the directory. The directory is only modified by API calls on the
+ * {@link DirContext} object.</p>
+ *
+ * @see Attributes
+ * 
+ */
+public class BasicAttributes implements Attributes {
+
+    /*
+     * -------------------------------------------------------------------
+     * Constants
+     * -------------------------------------------------------------------
+     */
+
+    /*
+     * This constant is used during deserialization to check the J2SE version 
+     * which created the serialized object.
+     */
+    static final long serialVersionUID = 0x451d18d6a95539d8L; //J2SE 1.4.2
+
+    /*
+     * -------------------------------------------------------------------
+     * Instance variables
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Flag indicating whether the case of attribute identifier is ignored.
+     * 
+     * @serial
+     */ 
+    private boolean ignoreCase;
+
+    // A map, Id => Attribute
+    private transient Hashtable attrMap = new Hashtable();
+
+    /*
+     * -------------------------------------------------------------------
+     * Constructors
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Constructs a <code>BasicAttributes</code> instance which is 
+     * case-sensitive.
+     */
+    public BasicAttributes() {
+        this(false);
+    }
+
+    /**
+     * Constructs a <code>BasicAttributes</code> instance which is 
+     * case-sensitive if <code>flag</code> is false.
+     * 
+     * @param flag          Inidicates whether this instance is 
+     *                      case-insensitive.
+     */
+    public BasicAttributes(boolean flag) {
+        this.ignoreCase = flag;
+    }
+
+    /**
+     * Constructs a case-sensitive <code>BasicAttributes</code> instance 
+     * with one attribute.
+     * 
+     * @param attrId        the ID of the first attribute
+     * @param attrObj       the value of the first attribute
+     */
+    public BasicAttributes(String attrId, Object attrObj) {
+        this(attrId, attrObj, false);
+    }
+
+    /**
+     * Constructs a <code>BasicAttributes</code> instance with one attribute
+     * which is case-sensitive if <code>flag</code> is false.
+     * 
+     * @param attrId        the ID of the first attribute
+     * @param attrObj       the value of the first attribute
+     * @param flag          Inidicates whether this instance is 
+     *                      case-insensitive.
+     */
+    public BasicAttributes(String attrId, Object attrObj, boolean flag) {
+        this.ignoreCase = flag;
+        this.attrMap.put(convertId(attrId),
+            new BasicAttribute(attrId, attrObj));
+    }
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods
+     * -------------------------------------------------------------------
+     */
+    
+    /*
+     * Convert an attribute ID to lower case if this attribute collection is
+     * case-insensitive.
+     */ 
+    private String convertId(String id) {
+        return ignoreCase ? id.toLowerCase() : id;
+    }
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods of Interface Attributes
+     * -------------------------------------------------------------------
+     */
+
+    public Attribute get(String id) {
+        return (Attribute) attrMap.get(convertId(id));
+    }
+
+    public NamingEnumeration getAll() {
+        return new BasicNamingEnumeration(attrMap.elements());
+    }
+
+    public NamingEnumeration getIDs() {
+        if (ignoreCase) {
+            Enumeration e = this.attrMap.elements();
+            Vector v = new Vector(attrMap.size());
+
+            while (e.hasMoreElements()) {
+                v.add(((Attribute) e.nextElement()).getID());
+            }
+
+            return new BasicNamingEnumeration(v.elements());
+        }
+		return new BasicNamingEnumeration(this.attrMap.keys());
+    }
+
+    public boolean isCaseIgnored() {
+        return ignoreCase;
+    }
+
+    public Attribute put(Attribute attribute) {
+        String id = convertId(attribute.getID());
+        return (Attribute) attrMap.put(id, attribute);
+    }
+
+    public Attribute put(String id, Object obj) {
+        return put(new BasicAttribute(id, obj));
+    }
+
+    public Attribute remove(String id) {
+        return (Attribute) attrMap.remove(convertId(id));
+    }
+
+    public int size() {
+        return attrMap.size();
+    }
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods override parent class Object
+     * -------------------------------------------------------------------
+     */
+
+    /*
+     * Serialization of the <code>BasicAttributes</code> class is as follows:
+     *      ignore attribute case (boolean)
+     *      number of attributes (int)
+     *      list of attribute objects
+     */
+    private void readObject(ObjectInputStream ois)
+        throws IOException, ClassNotFoundException {
+        int size;
+
+        ois.defaultReadObject();
+        size = ois.readInt();
+        attrMap = new Hashtable();
+        for (int i = 0; i < size; i++) {
+            BasicAttribute attr = (BasicAttribute) ois.readObject();
+            attrMap.put(convertId(attr.getID()), attr);
+        }
+    }
+
+    /*
+     * Serialization of the <code>BasicAttributes</code> class is as follows:
+     *      ignore attribute case (boolean)
+     *      number of attributes (int)
+     *      list of attribute objects
+     */
+    private void writeObject(ObjectOutputStream oos) throws IOException {
+        oos.defaultWriteObject();
+        oos.writeInt(attrMap.size());
+        for (Enumeration enumeration = attrMap.elements(); enumeration.hasMoreElements();) {
+            oos.writeObject(enumeration.nextElement());
+        }
+    }
+
+    /**
+     * Returns a deep copy of this attribute collection.
+     * The returned copy contains the same attribute objects. The attribute
+     * objects are not cloned.
+     *
+     * @return              a deep copy of this attribute collection
+     */
+    public Object clone() {
+        try {
+            BasicAttributes c = (BasicAttributes) super.clone();
+            c.attrMap = (Hashtable) this.attrMap.clone();
+            return c;
+        } catch (CloneNotSupportedException e) {
+            throw new InternalError("Failed to clone object of BasicAttributes class."); //$NON-NLS-1$
+        }
+    }
+
+    /**
+     * Returns true if this <code>BasicAttributes</code> instance is equal to 
+     * the supplied object <code>obj</code>.
+     * They are considered equal if they handle case the same way and have equal
+     * attributes. <code>Attribute</code> equality is tested by calling <code>
+     * equals</code> on each attribute, which may be overridden.
+     * 
+     * @param obj           the object to compare with
+     * @return              true if this object is equal to <code>obj</code>,
+     *                      otherwise false
+     */
+    public boolean equals(Object obj) {
+        if (!(obj instanceof Attributes)) {
+            return false;
+        }
+
+        // compare case & size
+        Attributes o = (Attributes) obj;
+        if (isCaseIgnored() != o.isCaseIgnored() || size() != o.size()) {
+            return false;
+        }
+
+        // compare each attribute
+        Iterator it = attrMap.entrySet().iterator();
+        while (it.hasNext()) {
+            Map.Entry e = (Map.Entry) it.next();
+            if (!e.getValue().equals(o.get((String) e.getKey()))) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    /**
+     * Returns the hashcode for this <code>BasicAttributes</code> instance.
+     * The result is calculated by summing the hashcodes of all attributes,
+     * incremented by one if this instance is not case-sensitive.
+     * 
+     * @return              the hashcode of this <code>BasicAttributes</code>
+     *                      instance
+     */
+    public int hashCode() {
+        Enumeration e = attrMap.elements();
+        int i = (ignoreCase ? 1 : 0);
+
+        while (e.hasMoreElements()) {
+            i += e.nextElement().hashCode();
+        }
+
+        return i;
+    }
+
+    /**
+     * Returns the string representation of this <code>BasicAttributes</code>
+     * instance.
+     * The result contains the attribute identifiers and values' string
+     * representations.
+     * 
+     * @return              the string representation of this object
+     */
+    public String toString() {
+        String s = null;
+        Iterator it = attrMap.entrySet().iterator();
+        Map.Entry e = null;
+        
+        if (it.hasNext()) {
+            // If there are one or more attributes, print them all.
+            e = (Map.Entry) it.next();
+            s = "{\n"; //$NON-NLS-1$
+            s += (String) e.getKey();
+            s += "=" + e.getValue().toString(); //$NON-NLS-1$
+            while (it.hasNext()) {
+                e = (Map.Entry) it.next();
+                s += "; "; //$NON-NLS-1$
+                s += (String) e.getKey();
+                s += "=" + e.getValue().toString(); //$NON-NLS-1$
+            }
+            s += "}\n"; //$NON-NLS-1$
+        } else {
+            // Otherwise, print an indication that no attributes are stored.
+            s = "This Attributes does not have any attributes.\n"; //$NON-NLS-1$
+        }
+        return s;
+    }
+
+}
+
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/BasicNamingEnumeration.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/BasicNamingEnumeration.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/BasicNamingEnumeration.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/BasicNamingEnumeration.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,79 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.naming.directory;
+
+import java.util.Enumeration;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+
+/**
+ * a simple implementation of NamingEnumeration
+ * 
+ */
+class BasicNamingEnumeration implements NamingEnumeration {
+
+    /*
+     * -----------------------------------
+     * Fields
+     * -----------------------------------
+     */
+
+    private Enumeration enumeration;
+
+    /*
+   	 * -----------------------------------
+     * Constructors
+     * -----------------------------------
+     */
+
+    /**
+     * default constructor
+     * @param e			wrapped enumeration
+     */
+    public BasicNamingEnumeration(Enumeration e) {
+        this.enumeration = e;
+    }
+
+	/*
+	 * -----------------------------------
+	 * Methods of interface NamingEnumeration
+	 * -----------------------------------
+	 */
+
+    public Object next() throws NamingException {
+        return enumeration.nextElement();
+    }
+
+    public boolean hasMore() throws NamingException {
+        return enumeration.hasMoreElements();
+    }
+
+    public void close() throws NamingException {
+    	// Does nothing.
+    }
+
+    public boolean hasMoreElements() {
+        return enumeration.hasMoreElements();
+    }
+
+    public Object nextElement() {
+        return enumeration.nextElement();
+    }
+
+}
+
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/DirContext.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/DirContext.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/DirContext.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/DirContext.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,686 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package javax.naming.directory;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.ModificationItem;
+import javax.naming.directory.SearchControls;
+
+/**
+ * This is the main interface to a directory service.
+ * <p>
+ * A <code>DirContext</code> is the interface through which a client interacts with a
+ * particular concrete directory service provider. The API provides methods for
+ * searching, reading and writing attributes of directory entries.</p>
+ * <p>
+ * The name of a directory entry is taken as relative to the context receiving the
+ * method invocation. Names cannot be null and the empty name has a special
+ * meaning of the context itself.</p>
+ * <p>
+ * In this interface there are duplicated methods that take either a <code>String</code>
+ * or <code>Name</code> parameter.  This is simply a convenience and the behavior of each
+ * method is identical.</p>
+ * <p>
+ * The semantics of a name in a <code>DirContext</code> is exactly equivalent to that of
+ * a name in a regular naming <code>Context</code>.</p>
+ * 
+ * <em>Attribute storage models</em>
+ * <p>
+ * JNDI supports two logical models of attribute storage:
+ * <ul>
+ * <li>Type A : where an attribute operation on a named object is equivalent to a lookup
+ *      in the <code>DirContext</code> on the given name followed by application of the
+ *      operation to the resulting empty <code>DirContext</code>.  Think of this
+ *      as attributes being stored on the object itself.</li>
+ * <li>Type B : where an attribute operation on a named object is equivalent to a lookup
+ *      on that name in the <em>parent</em> <code>DirContext</code> followed by application
+ *      of the operation on the parent <code>DirContext</code> providing the name as an argument.
+ *      Think of this as the attributes being stored in the parent context.<p>
+ *      In this model objects that are not <code>DirContext</code> can have attributes,
+ *      provided their parents are <code>DirContext</code>.</li>
+ * </ul></p>
+ * <p>
+ * The directory service provider can implement either of these logical models, and the client
+ * is expeced to know which model it is dealing with.</p>
+ * 
+ * <em>Attribute Name aliasing</em>
+ * <p>
+ * Directory service providers are free to implement attribute name alising.  If the service
+ * employs alising then the list of attribute names that are returned as a result of API
+ * calls to get a named attribute, or search for a set of attributes may include attributes
+ * whose name was not in the search list.  Implmentations should not rely on the preservation
+ * of attribute names.</p>
+ * 
+ * <em>Searching and operational attributes</em>
+ * <p>
+ * Some directory service providers support "operational attributes" on objects.  These are
+ * attributes that are computed by the provider, or have other special semantics to the
+ * directory service.  The directory service defines which attributes are operational.</p>
+ * <p>
+ * The API calls for searching for attributes, and those for getting named attributes using
+ * a list of names are defined to interpret the <code>null</code> argument to match all
+ * non-operational attributes.</p>
+ * <p>
+ * It is therefore possible to get a specific named attribute that is not returned in a global
+ * retrieval of all object attributes.</p>
+ * 
+ * <em>Conditions</em>
+ * <p>
+ * Some APIs require that the name resolves to another <code>DirContext</code> and not an
+ * object.  In such cases, if this postcondition is not met then the method should throw
+ * a <code>NotContextException</code>.  Other methods can resolve to be either objects or
+ * <code>DirContext</code>.</p>
+ * <p>
+ * Service providers must not modify collection parameters such as <code>Attribute</code>,
+ * <code>SearchControl</code> or arrays. Similarly, clients are expected not to modify
+ * the collections while the service provider iterates over such collections -- the service
+ * provider should be given exclusive control of the collection until the method returns.</p>
+ * <p>
+ * APIs that return collections are safe -- that is, the service provider will not modify
+ * collections that are returned to clients.</p>
+ * 
+ * <em>Exceptions</em>
+ * <p>
+ * Any method may throw a <code>NamingException</code> (or subclass) as defined by the
+ * exception descriptions.</p>
+ * 
+ * 
+ */
+public interface DirContext extends Context {
+
+    /*
+     * -------------------------------------------------------------------
+     * Constants
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Constant value indicating the addition of an attribute. 
+     * <p>
+     * The new value is added to the existing attributes at that identifier
+     * subject to the following constraints:
+     * <ol>
+     *  <li>If the attribute is being created and the value is empty, an
+     * <code>InvalidAttributeValueException</code> is thrown if the attribute
+     * must have a value.</li>
+     * <li>If the attribute already exists with a single value and the schema
+     * requires that the attribute can only have a single value, an
+     * <code>AttributeInUseException</code> is thrown.</li>
+     * <li>If the attribute is being created with a multi-value and the schema
+     * requires that the attribute can only have a single value, an
+     * <code>InvalidAttributeValueException</code> is thrown.</li>
+     * </ol></p>
+     */
+    public static final int ADD_ATTRIBUTE = 1;
+
+    /**
+     * Constant value indicating the replacement of an attribute value.
+     * <p>
+     * If the attribute does not exist then it is created with the given attribute
+     * identifier and attribute.  If the value contravenes the schema, an <code>
+     * InvalidAttributeValueException</code> is thrown.</p>
+     * <p>
+     * If the attribute exists then all of its values are replaced by the given
+     * values.  If the attribute is defined to take a single value and the new
+     * value is a multi-value then an <code>InvalidAttributeValueException</code>
+     * is thrown.  If no value is given then all of the values are removed from
+     * the attribute.</p>
+     * <p>
+     * If an attribute is defined as requiring at least one value, then removing
+     * values results in the removal of the attribute itself.</p>
+     */
+    public static final int REPLACE_ATTRIBUTE = 2;
+
+    /**
+     * Constant field indicating the removal of an attribute.
+     * <p>
+     * If the attribute exists then the resulting values of the attribute is
+     * the set of values given by removing all values in the given set from
+     * the existing attribute set.</p>
+     * <p>
+     * If the given set of attributes is <code>null</code> that should be interpreted
+     * as a request to remove all values from the existing attribute set.</p>
+     * <p>
+     * If the attribute does not exist, or a value in the given set does not
+     * appear in the existing attribute set then the service provider is free to
+     * either ignore the fact it does not exist, or throw a <code>NamingException</code>.</p>
+     */
+    public static final int REMOVE_ATTRIBUTE = 3;
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Binds a <code>Name</code> to an <code>Object</code> in this directory 
+     * to produce a binding. 
+     * 
+     * <p>This binding can have attributes, which are specified by the 
+     * <code>attributes</code> parameter if it is non-null. If the 
+     * <code>attributes</code>  parameter is null and <code>obj</code> is a 
+     * <code>DirContext</code> with attributes, the binding will have the 
+     * attributes of <code>obj</code>.</p>
+     * <p>
+     * Note that null is not a valid value for <code>name</code>. Neither is 
+     * the empty <code>Name</code> because this is reserved to refer to the 
+     * context.</p>
+     * <p>
+     * If <code>name</code> is already bound in this <code>DirContext</code> 
+     * this method throws a <code>NameAlreadyBoundException</code>.</p>
+     * <p>
+     * If there are mandatory attributes for this binding in this 
+     * <code>DirContext</code>, and they are not specified, this method throws 
+     * an <code>InvalidAttributesException</code>.</p>
+     * <p>
+     * This method throws any <code>NamingException</code> that occurs.</p>
+     * 
+     * @param name				the name to be bound
+     * @param obj				the object to be bound
+     * @param attributes		the attributes of this binding, can be null 
+     * @throws NamingException	If any occurs.
+     */
+    void bind(Name name, Object obj, Attributes attributes)
+        throws NamingException;
+
+    /**
+     * Binds a string name to an <code>Object</code> in this directory 
+     * to produce a binding. 
+     * 
+     * @param s					the string representive of name to be bound
+     * @param obj				the object to be bound
+     * @param attributes		the attributes of this binding, can be null 
+     * @throws NamingException	thrown if any occurs
+     * @see #bind(Name name, Object obj, Attributes attributes)
+     */
+    void bind(String s, Object obj, Attributes attributes)
+        throws NamingException;
+
+    /**
+     * Creates and binds a new subcontext.
+     * <p>
+     * The new subcontext might not be an immediate subcontext of this one. If 
+     * it is not an immediate subcontext, all the intervening subcontexts 
+     * specified in <code>name</code> must already exist. If the attributes 
+     * parameter is non-null the specified attributes are added to the
+     * new subcontext.</p>
+     * <p>
+     * Possible exceptions are <code>NameAlreadyBoundException</code> and
+     * <code>InvalidAttributesException</code>.</p>
+     * <p>
+     * This method throws any <code>NamingException</code> that occurs.</p>
+     * 
+     * @param name				the name bound to the new subcontext
+     * @param attributes		the attributes of the new subcontxt, can be null
+     * @return 					the new subcontext
+     * @throws NamingException  If any occurs.
+     */
+    DirContext createSubcontext(Name name, Attributes attributes)
+        throws NamingException;
+
+    /**
+     * Creates and binds a new subcontext.
+     * 
+     * @param s  				the string representive of name bound to the new subcontext
+     * @param attributes		the attributes of the new subcontxt, can be null
+     * @return 					the new subcontext
+     * @throws NamingException  If any occurs.
+     * @see #createSubcontext(Name n, Attributes attributes)
+     */
+    DirContext createSubcontext(String s, Attributes attributes)
+        throws NamingException;
+
+    /**
+     * Gets all attributes of <code>name</code>. 
+     * <p>
+     * See note in description about operational attributes.</p>  
+     * <p>
+     * The returned set of attributes is empty if <code>name</code> has no
+     * attributes.</p>
+     * <p>
+     * This method throws any <code>NamingException</code> that occurs.</p>
+     * 
+     * @param name				name to be searched for attributes
+     * @return					all attributes of <code>name</code>	
+     * @throws NamingException  If any occurs.	
+     */
+    Attributes getAttributes(Name name) throws NamingException;
+
+    /**
+     * Gets the attributes for <code>name</code> that match the strings in 
+     * array <code>as</code>. 
+     * <p>
+     * If any string in <code>as</code> is not matched it is skipped. More 
+     * attributes may be returned than the number of strings in <code>as</code> 
+     * - see notes on attribute aliasing.</p>
+     * <p>
+     * This method throws any <code>NamingException</code> that occurs.</p>
+     * 
+     * @param name				name to be searched for attributes		
+     * @param as				the array of strings to match atrrbiutes
+     * @return					all attributes for <code>name</code> that match 
+     * 							the strings in array <code>as</code>. 
+     * @throws NamingException  If any occurs.
+     */
+    Attributes getAttributes(Name name, String as[]) throws NamingException;
+
+    /**
+     * Gets all attributes of name represented by <code>s</code>.
+     * 
+     * @param s					representive of name to be searched for attributes
+     * @return					all attributes of name represented by <code>s</code>
+     * @throws NamingException  If any occurs.	
+     * @see #getAttributes(Name name)
+     */
+    Attributes getAttributes(String s) throws NamingException;
+
+    /**
+     * Gets the attributes for name represented by <code>s</code> that match the strings in 
+     * array <code>as</code>. 
+     * 
+     * @param s					representive of name to be searched for attributes
+     * @param as				the array of strings to match atrrbiutes
+     * @return					all attributes for name represented by 
+     * 							<code>s</code> that match the strings in array 
+     * 							<code>as</code>. 
+     * @throws NamingException  If any occurs.
+     * @see #getAttributes(Name name, String[] as)
+     */
+    Attributes getAttributes(String s, String as[]) throws NamingException;
+
+    /**
+     * Gets the top level of the schema for object <code>name</code>.
+     * <p>
+     * If <code>name</code> does not support a schema this method throws an
+     * <code>OperationNotSupportedException</code>.</p>
+     * <p>
+     * This method throws any <code>NamingException</code> that occurs.</p>
+     * 
+     * @param name				the object to be searched for schema 
+     * @return					the top level of the schema for object <code>name</code>
+     * @throws NamingException  If any occurs.
+     */
+    DirContext getSchema(Name name) throws NamingException;
+
+    /**
+     * Gets the top level of the schema for name represented by <code>s</code>.
+     * 
+     * @param s					representive of name to be searched for schema 
+     * @return					the top level of the schema for object <code>name</code>
+     * @throws NamingException  If any occurs.
+     * @see #getSchema(Name name)
+     */
+    DirContext getSchema(String s) throws NamingException;
+
+    /**
+     * Gets the class definition for <code>name</code> from its schema. 
+     * <p>
+     * A class definition from a schema specifies a type and its mandatory and 
+     * optional attributes. Note that the term "class" here refers to the 
+     * general concept of a data type, not a Java class.</p>
+     * <p>
+     * If <code>name</code> does not support a schema this method throws an
+     * <code>OperationNotSupportedException</code>.</p>
+     * <p>
+     * This method throws any <code>NamingException</code> that occurs.</p>
+     * 
+     * @param name				the name to searched for the class definition 
+     * 							from its schema
+     * @return					the class definition for <code>name</code> from 
+     * 							its schema.
+     * @throws NamingException  If any occurs.
+     */
+    DirContext getSchemaClassDefinition(Name name) throws NamingException;
+
+    /**
+     * Gets the class definition for name represented by <code>s</code> from its schema. 
+     * 
+     * @param s					the string representive of name to searched for 
+     * 							the class definition from its schema
+     * @return					the class definition for <code>name</code> from 
+     * 							its schema.
+     * @throws NamingException  If any occurs.
+     * @see #getSchemaClassDefinition(Name name)
+     */
+    DirContext getSchemaClassDefinition(String s) throws NamingException;
+
+    /**
+     * Modifies the attributes of <code>name</code>. 
+     * <p> 
+     * Parameter <code>i</code> is modification operation type and  
+     * is constrained to be one of <code>ADD_ATTRIBUTE</code>, 
+     * <code>REPLACE_ATTRIBUTE</code>, <code>REMOVE_ATTRIBUTE</code>. The 
+     * implementation should try to make the modifications atomic.</p>
+     * <p>
+     * This method throws an <code>AttributeModificationException</code> if 
+     * there is a problem completing the modification.</p>
+     * <p>
+     * This method throws any <code>NamingException<code> that occurs.</p>
+     * 
+     * @param name				the name which attributes will be modified
+     * @param i					the modification operation type
+     * @param attributes		the modified attributes
+     * @throws NamingException  If any occurs.
+     */
+    void modifyAttributes(Name name, int i, Attributes attributes)
+        throws NamingException;
+
+    /**
+     * Modifies the attributes of <code>name</code> in the order given by the 
+     * array parameter <code>amodificationitem</code>. 
+     * <p>
+     * The required operations are specified by the elements of 
+     * <code>modificationItems</code>.</p>
+     * <p>
+     * This method throws an <code>AttributeModificationException</code> if 
+     * there is a problem completing the modifications.</p>
+     * <p>
+     * This method throws any <code>NamingException</code> that occurs.</p>
+     * 
+     * @param name				the name which attributes will be modified
+     * @param modificationItems the array of modification item
+     * @throws NamingException  If any occurs.
+     */
+    void modifyAttributes(Name name, ModificationItem[] modificationItems)
+        throws NamingException;
+
+    /**
+     * Modifies the attributes of name represented by <code>s</code>. 
+     * 
+     * @param s					name represented by <code>s</code>
+     * @param i					the modification operation type
+     * @param attributes		the modified attributes
+     * @throws NamingException  If any occurs.
+     * @see #modifyAttributes(Name name, int i, Attributes attributes)
+     */
+    void modifyAttributes(String s, int i, Attributes attributes)
+        throws NamingException;
+
+    /**
+     * Modifies the attributes of name represented by <code>s</code> in the 
+     * order given by the array parameter <code>modificationItems</code>. 
+     * 
+     * @param s					name represented by <code>s</code>
+     * @param modificationItems the array of modification item
+     * @throws NamingException  If any occurs.
+     * @see #modifyAttributes(Name name, ModificationItem[] modificationItems)
+     */
+    void modifyAttributes(String s, ModificationItem[] modificationItems)
+        throws NamingException;
+
+    /**
+     * Rebinds <code>name</code> to <code>obj</code>. 
+     * <p>
+     * If the attributes parameter is non-null, the attributes it
+     * specifies become the only attributes of the binding. If the attributes
+     * parameter is null but <code>obj</code> is an instance of 
+     * <code>DirContext</code> then the attributes of <code>obj</code> become 
+     * the only attributes of the binding. If the <code>attributes</code> 
+     * parameter is null and <code>obj</code> is not an instance of 
+     * <code>DirContext</code> then any attributes of the previous binding 
+     * remain.</p>
+     * <p>
+     * If a schema defines mandatory attributes for the binding but they are not
+     * all present this method throws an <code>InvalidAttributesException</code>.</p>
+     * <p>
+     * This method throws any <code>NamingException</code> that occurs.</p>
+     * 
+     * @param name				the name to be bound
+     * @param obj				the object to be bound
+     * @param attributes		the attributes of the binding
+     * @throws NamingException  If any occurs.
+     */
+    void rebind(Name name, Object obj, Attributes attributes)
+        throws NamingException;
+
+    /**
+     * Rebinds name represented by <code>s</code> to <code>obj</code>. 
+     * 
+     * @param s					the string representive of name to be bound
+     * @param obj				the object to be bound
+     * @param attributes		the attributes of the binding
+     * @throws NamingException  If any occurs.
+     * @see #rebind(Name name, Object o, Attributes attributes)
+     */
+    void rebind(String s, Object obj, Attributes attributes)
+        throws NamingException;
+
+    /**
+     * Searches in the context specified by <code>name</code> only, for any 
+     * objects that have attributes that match the <code>attributes</code> 
+     * parameter. 
+     * <p>
+     * This method is equivalent to passing a null <code>as</code> parameter to 
+     * <code>search(Name name, Attributes attributes, String[] as)</code>. 
+     * Objects with attributes that match the <code>attributes</code> parameter 
+     * are selected and all attributes are returned for selected objects.</p>
+     * <p>
+     * This method throws any <code>NamingException</code> that occurs.</p>
+     * 
+     * @param name				the name specifies the context to be searched
+     * @param attributes		the attributes to be matched when search 
+     * @return					<code>NamngEnumeration</code> of <code>SearchResult</code>
+     * @throws NamingException  If any occurs.
+     * @see #search(Name name, Attributes attributes, String[] as)
+     */
+    NamingEnumeration search(Name name, Attributes attributes)
+        throws NamingException;
+
+    /**
+     * This method searches in the context specified by <code>name</code> only, 
+     * for any objects that have attributes that match the <code>attributes</code> 
+     * parameter. 
+     * 
+     * <p>It uses default <code>SearchControls</code>. An object is selected if 
+     * it has every attribute in the <code>attributes</code> parameter, 
+     * regardless of whether it has extra attributes. If the <code>attributes</code> 
+     * parameter is null or empty then every object in the context is a match.</p>
+     * <p>
+     * The definition of attribute matching is
+     * <ol> 
+     * <li>both attributes have the same identifier;</li> 
+     * <li>all values of the attribute from the attributes parameter are
+     * found in the attribute from the target object.</li> 
+     * </ol></p>
+     * <p>
+     * Attribute ordering is ignored. If an attribute from the 
+     * <code>attributes</code> parameter has no values it is matched by any 
+     * attribute that has the same identifier. The definition of attribute value 
+     * equality is left to the directory service - it could be 
+     * <code>Object.equals(Object obj)</code>, or a test defined by a schema.</p>
+     * <p>
+     * For each of the selected objects, this method collects and returns the
+     * attributes with identifiers listed in parameter <code>as</code>. Note 
+     * that these may be different to those in the <code>attributes</code> 
+     * parameter. If a selected object does not have one of the attributes 
+     * listed in <code>as</code>, the missing attribute is simply skipped for 
+     * that object. Attribute aliasing may mean that an attribute in the 
+     * <code>as</code> parameter list maps to more than one returned attribute. 
+     * If parameter <code>as</code> is empty, no attributes are returned, but 
+     * if <code>a</code>s is null all attributes are returned.</p>
+     * <p>
+     * The return value is an enumeration of <code>SearchResult</code> objects, 
+     * which is empty if no matches are found. It is not specified how subsequent 
+     * changes to context specified by <code>name</code> will affect an 
+     * enumeration that this method returns.</p>
+     * <p>
+     * This method throws any <code>NamingException</code> that occurs.</p>
+     * 
+     * @param name				the name specifies the context to be searched
+     * @param attributes		the attributes to be matched when search 
+     * @param as				the array of string representive of attributes to be returned
+     * @return					<code>NamngEnumeration</code> of <code>SearchResult</code>
+     * @throws NamingException  If any occurs.
+     */
+    NamingEnumeration search(Name name, Attributes attributes, String as[])
+        throws NamingException;
+
+    /**
+     * This method searches in the context specified by <code>name</code> only, 
+     * using the fileter specifed by parameter <code>filter</code> and controlled by
+     * <code>searchControls</code>.
+     * 
+     * <p>
+     * The parameter <code>filter</code> is an RFC2254 filter. It may contain 
+     * variables such as "{N}", which refer to element N of the <code>objs</code> 
+     * array.</p>
+     * <p>
+     * The "{N}" variables can be used in place of "attr", "value", or
+     * "matchingrule" from RFC2254 section 4. If an "{N}" variable refers to a
+     * <code>String</code> object, that string becomes part of the filter string, 
+     * but with any special characters escaped as defined by RFC 2254. The 
+     * directory service implementation decides how to interpret filter arguments 
+     * with types other than <code>String</code>. The result of giving invalid 
+     * variable substitutions is not specified.</p>
+     * <p>
+     * If <code>searchControls</code> is null, the default <code>SearchControls</code>
+     * object is used: i.e. the object created by the no-args <code>SearchControls()</code> 
+     * constructor.</p>
+     * <p>
+     * The return value is an enumeration of <code>SearchResult</code> objects. 
+     * The object names used may be relative to the context specified in the 
+     * <code>name</code> parameter, or a URL string. If the <code>name</code> 
+     * context itself is referred to in the results, the empty string is used. 
+     * It is not specified how subsequent changes to context specified by
+     * <code>name</code> will affect an enumeration that this method returns.</p>
+     * <p>
+     * If an "{N}" variable in <code>s</code> references a position outside the 
+     * bounds of array <code>objs</code> this method will throw an 
+     * <code>ArrayIndexOutOfBoundsException</code>.</p>
+     * <p>
+     * If <code>searchControls</code> is invalid this method will throw
+     * <code>InvalidSearchControlsException</code>.</p>
+     * <p>
+     * If the filter specified by <code>filter</code> and <code>objs</code> is 
+     * invalid this method will throw an <code>InvalidSearchFilterException</code>.</p>
+     * <p>
+     * This method throws any <code>NamingException</code> that occurs.
+     * 
+     * @param name				the name specifies the context to be searched
+     * @param filter			the search filter
+     * @param objs				array of objects refered by search filter
+     * @param searchControls 	the search controls
+     * @return					<code>NamingEnumeration</code> of <code>SearchResult</code>
+     * @throws NamingException  If any occurs.
+     * @see SearchControls
+     */
+    NamingEnumeration search(
+        Name name,
+        String filter,
+        Object[] objs,
+        SearchControls searchControls)
+        throws NamingException;
+
+    /**
+     * This method searches in the context specified by <code>name</code> only, 
+     * using the fileter specifed by parameter <code>filter</code> and controlled by
+     * <code>searchControls</code>.
+     * <p>
+     * This method can throw <code>InvalidSearchFilterException<c/ode>,
+     * <code>InvalidSearchControlsException</code>, <code>NamingException</code>.</p>
+     * 
+     * @param name				the name specifies the context to be searched
+     * @param filter			the search filter
+     * @param searchControls 	the search controls
+     * @return					<code>NamingEnumeration</code> of <code>SearchResult</code>
+     * @throws NamingException  If any occurs.
+     * @see #search(Name, String, Object[], SearchControls)
+     */
+    NamingEnumeration search(
+        Name name,
+        String filter,
+        SearchControls searchControls)
+        throws NamingException;
+
+    /**
+     * Searches in the context specified by name represented by <code>name</code> 
+     * only, for any objects that have attributes that match the 
+     * <code>attributes</code> parameter. 
+     * 
+     * @param name				the string representive of name which specifies 
+     * 							the context to be searched
+     * @param attributes		the attributes to be matched when search 
+     * @return					<code>NamingEnumeration</code> of <code>SearchResult</code>
+     * @throws NamingException  If any occurs.
+     * @see #search(Name, Attributes)
+     */
+    NamingEnumeration search(String name, Attributes attributes)
+        throws NamingException;
+
+    /**
+     * This method searches in the context specified by name represented by 
+     * <code>name</code> only, for any objects that have attributes that match
+     * the <code>attributes</code> parameter. 
+     * 
+     * @param name				the string representive of name which specifies 
+     * 							the context to be searched
+     * @param attributes		the attributes to be matched when search 
+     * @param as				the array of string representive of attributes to be returned
+     * @return					<code>NamingEnumeration</code> of <code>SearchResult</code>
+     * @throws NamingException  If any occurs.
+     * @see #search(Name, Attributes, String[])
+     */
+    NamingEnumeration search(String name, Attributes attributes, String as[])
+        throws NamingException;
+
+    /**
+     * This method searches in the context specified by name represented by 
+     * <code>name</code> only,  using the fileter specifed by parameter 
+     * <code>filter</code> and controlled by <code>searchControls</code>.
+     * 
+     * @param name				the string representive of name which specifies 
+     * 							the context to be searched
+     * @param filter			the search filter
+     * @param objs				array of objects refered by search filter
+     * @param searchControls 	the search controls
+     * @return					<code>NamngEnumeration</code> of <code>SearchResult</code>
+     * @throws NamingException  If any occurs.
+     * @see #search(Name, String, Object[], SearchControls)
+     */
+    NamingEnumeration search(
+        String name,
+        String filter,
+        Object[] objs,
+        SearchControls searchControls)
+        throws NamingException;
+
+    /**
+     * This method searches in the context specified by name represented by 
+     * <code>name</code> only,  using the fileter specifed by parameter 
+     * <code>filter</code> and controlled by <code>searchControls</code>.
+     * 
+     * @param name				the string representive of name which specifies 
+     * 							the context to be searched
+     * @param filter			the search filter
+     * @param searchControls 	the search controls
+     * @return					<code>NamingEnumeration</code> of <code>SearchResult</code>
+     * @throws NamingException  If any occurs.
+     * @see #search(Name, String, SearchControls)
+     */
+    NamingEnumeration search(
+        String name,
+        String filter,
+        SearchControls searchControls)
+        throws NamingException;
+
+}
+
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/InitialDirContext.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/InitialDirContext.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/InitialDirContext.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/InitialDirContext.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,286 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.naming.directory;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.Name;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.NoInitialContextException;
+import javax.naming.NotContextException;
+
+/**
+ * This is the root context for directory service operations.
+ * 
+ * <p>
+ * The <code>InitialDirContext</code> behavior is defined by the specification
+ * for <code>javax.naming.InitialContext</code>.</p>
+ * 
+ * 
+ */
+public class InitialDirContext extends InitialContext implements DirContext {
+
+    /*
+     * -------------------------------------------------------------------
+     * Constructors
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Constructs a new <code>InitialDirContext</code> with no environment 
+     * properties.
+     * 
+     * @throws NamingException
+     * 						If failed to a construct new instance.
+     */
+    public InitialDirContext() throws NamingException {
+        super();
+    }
+
+    /**
+     * Constructs a new <code>InitialDirContext</code> instance with no 
+     * environment properties. A mechanism for subclass constructors 
+     * to construct a new <code>InitialDirContext</code> instance before all 
+     * environment parameters are known. 
+     * 
+     * @param flag			If flag is true, the new instance is created but 
+     * 						not initialized. In this case the subclass
+     * 						constructor is expected to call <code>init</code>
+     *                      after the environment parameters are known. If flag
+     *                      is false, a new instance is created and initialized
+     *                      with no environment parameters.
+     * @throws NamingException
+     * 						If failed to construct new instance.
+     */
+    protected InitialDirContext(boolean flag) throws NamingException {
+    	super(flag);
+    }
+
+    /**
+     * Constructs a new <code>InitialDirContext</code> instance with 
+     * environment properties.
+     * 
+     * @param hashtable		Contains the enironment parameters. This constructor 
+     * 						will not change the hashtable or keep a reference to 
+     * 						it. The hashtable parameter may be null.
+     * @throws NamingException
+     * 						If failed to construct a new instance.
+     * @see InitialContext
+     */
+    public InitialDirContext(Hashtable hashtable) throws NamingException {
+    	super(hashtable);
+    }
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods
+     * -------------------------------------------------------------------
+     */
+
+    private DirContext getURLOrDefaultInitDirCtx(Name name)
+        throws NamingException {
+        return castToDirContext(super.getURLOrDefaultInitCtx(name));
+    }
+
+    /*
+     * Try to cast the default context to DirContext.
+     */
+    private DirContext castToDirContext(Context ctx)
+        throws NoInitialContextException, NotContextException {
+        if (ctx instanceof DirContext) {
+            return (DirContext) ctx;
+        } else if (null == ctx) {
+            throw new NoInitialContextException("Cannot create initial context."); //$NON-NLS-1$
+        } else {
+            throw new NotContextException("DirContext object is required."); //$NON-NLS-1$
+        }
+    }
+
+    private DirContext getURLOrDefaultInitDirCtx(String name)
+        throws NamingException {
+        return castToDirContext(super.getURLOrDefaultInitCtx(name));
+    }
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods of interface DirContext
+     * -------------------------------------------------------------------
+     */
+
+    public void bind(Name name, Object obj, Attributes attributes)
+        throws NamingException {
+        getURLOrDefaultInitDirCtx(name).bind(name, obj, attributes);
+    }
+
+    public void bind(String s, Object obj, Attributes attributes)
+        throws NamingException {
+        getURLOrDefaultInitDirCtx(s).bind(s, obj, attributes);
+    }
+
+    public DirContext createSubcontext(Name name, Attributes attributes)
+        throws NamingException {
+        return getURLOrDefaultInitDirCtx(name).createSubcontext(
+            name,
+            attributes);
+    }
+
+    public DirContext createSubcontext(String s, Attributes attributes)
+        throws NamingException {
+        return getURLOrDefaultInitDirCtx(s).createSubcontext(s, attributes);
+    }
+
+    public Attributes getAttributes(Name name) throws NamingException {
+        return getURLOrDefaultInitDirCtx(name).getAttributes(name);
+    }
+
+    public Attributes getAttributes(Name name, String[] as)
+        throws NamingException {
+        return getURLOrDefaultInitDirCtx(name).getAttributes(name, as);
+    }
+
+    public Attributes getAttributes(String s) throws NamingException {
+        return getURLOrDefaultInitDirCtx(s).getAttributes(s);
+    }
+
+    public Attributes getAttributes(String s, String[] as)
+        throws NamingException {
+        return getURLOrDefaultInitDirCtx(s).getAttributes(s, as);
+    }
+
+    public DirContext getSchema(Name name) throws NamingException {
+        return getURLOrDefaultInitDirCtx(name).getSchema(name);
+    }
+
+    public DirContext getSchema(String s) throws NamingException {
+        return getURLOrDefaultInitDirCtx(s).getSchema(s);
+    }
+
+    public DirContext getSchemaClassDefinition(Name name)
+        throws NamingException {
+        return getURLOrDefaultInitDirCtx(name).getSchemaClassDefinition(name);
+    }
+
+    public DirContext getSchemaClassDefinition(String s)
+        throws NamingException {
+        return getURLOrDefaultInitDirCtx(s).getSchemaClassDefinition(s);
+    }
+
+    public void modifyAttributes(Name name, int i, Attributes attributes)
+        throws NamingException {
+        getURLOrDefaultInitDirCtx(name).modifyAttributes(name, i, attributes);
+    }
+
+    public void modifyAttributes(
+        Name name,
+        ModificationItem[] modificationItems)
+        throws NamingException {
+        getURLOrDefaultInitDirCtx(name).modifyAttributes(
+            name,
+            modificationItems);
+    }
+
+    public void modifyAttributes(String s, int i, Attributes attributes)
+        throws NamingException {
+        getURLOrDefaultInitDirCtx(s).modifyAttributes(s, i, attributes);
+    }
+
+    public void modifyAttributes(
+        String s,
+        ModificationItem[] modificationItems)
+        throws NamingException {
+        getURLOrDefaultInitDirCtx(s).modifyAttributes(s, modificationItems);
+
+    }
+
+    public void rebind(Name name, Object obj, Attributes attributes)
+        throws NamingException {
+        getURLOrDefaultInitDirCtx(name).rebind(name, obj, attributes);
+    }
+
+    public void rebind(String s, Object obj, Attributes attributes)
+        throws NamingException {
+        getURLOrDefaultInitDirCtx(s).rebind(s, obj, attributes);
+    }
+
+    public NamingEnumeration search(Name name, Attributes attributes)
+        throws NamingException {
+        return getURLOrDefaultInitDirCtx(name).search(name, attributes);
+    }
+
+    public NamingEnumeration search(
+        Name name,
+        Attributes attributes,
+        String[] as)
+        throws NamingException {
+        return getURLOrDefaultInitDirCtx(name).search(name, attributes, as);
+    }
+
+    public NamingEnumeration search(
+        Name name,
+        String filter,
+        Object[] objs,
+        SearchControls searchControls)
+        throws NamingException {
+        return getURLOrDefaultInitDirCtx(name).search(
+            name,
+            filter,
+            objs,
+            searchControls);
+    }
+
+    public NamingEnumeration search(
+        Name name,
+        String filter,
+        SearchControls searchcontrols)
+        throws NamingException {
+        return getURLOrDefaultInitDirCtx(name).search(name, filter, searchcontrols);
+    }
+
+    public NamingEnumeration search(String name, Attributes attributes)
+        throws NamingException {
+        return getURLOrDefaultInitDirCtx(name).search(name, attributes);
+    }
+
+    public NamingEnumeration search(
+        String name,
+        Attributes attributes,
+        String[] as)
+        throws NamingException {
+        return getURLOrDefaultInitDirCtx(name).search(name, attributes, as);
+    }
+
+    public NamingEnumeration search(
+        String name,
+        String filter,
+        Object[] objs,
+        SearchControls searchControls)
+        throws NamingException {
+        return getURLOrDefaultInitDirCtx(name).search(name, filter, objs, searchControls);
+    }
+
+    public NamingEnumeration search(
+        String name,
+        String filter,
+        SearchControls searchControls)
+        throws NamingException {
+        return getURLOrDefaultInitDirCtx(name).search(name, filter, searchControls);
+    }
+}
+
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/InvalidAttributeIdentifierException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/InvalidAttributeIdentifierException.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/InvalidAttributeIdentifierException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/InvalidAttributeIdentifierException.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,72 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ 
+ package javax.naming.directory;
+
+import javax.naming.NamingException;
+
+/**
+ * Thrown when the identifier part of an attribute is invalid.
+ * <p>
+ * Directory service providers may restrict the characteristics of the attribute
+ * identifier.  If an attempt is made to set the attribute with an invalid
+ * attribute the provider will throw an 
+ * <code>InvalidAttributeIdentifierException</code>.</p>
+ * 
+ * 
+ */
+public class InvalidAttributeIdentifierException extends NamingException {
+	
+	/*
+	 * -------------------------------------------------------------------
+	 * Constants
+	 * -------------------------------------------------------------------
+	 */	
+
+	/* Serialization information - start. */
+	private static final long serialVersionUID = 0x829668e5be4a058dL;
+	/* Serialization information - end. */
+	
+	/*
+	 * -------------------------------------------------------------------
+	 * Constructors
+	 * -------------------------------------------------------------------
+	 */	
+	
+	/**
+	 * Default constructor. 
+	 * <p>
+	 * All fields are initialized to null.</p>
+	 */	 	
+	public InvalidAttributeIdentifierException() {
+		super();
+	}
+
+	/**
+	 * Constructs an <code>InvalidAttributeIdentifierException</code> 
+     * instance using the supplied text of the message.
+	 * <p>
+	 * All fields are initialized to null.</p>
+	 * 
+	 * @param s				message about the problem
+	 */
+	public InvalidAttributeIdentifierException(String s) {
+		super(s);
+	}
+
+}
+
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/InvalidAttributeValueException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/InvalidAttributeValueException.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/InvalidAttributeValueException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/InvalidAttributeValueException.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,79 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ package javax.naming.directory;
+
+import javax.naming.NamingException;
+
+/**
+ * Thrown when the value part of an attribute is invalid.
+ * <p>
+ * Directory service providers may restrict the characteristics of the attribute
+ * value.  If an attempt is made to set the attribute with an invalid attribute
+ * value the provider will throw an <code>InvalidAttributeValueException</code>.</p>
+ * <p>
+ * Examples include attempting to set a value on an attribute that doesn't take 
+ * a value, attempting to set multiple values on an attribute that only takes a 
+ * single value, attempting to clear a value on an attribute that must have a 
+ * value, and so on.</p> 
+ * <p>
+ * The serialization and synchonization specification for <code>NamingException</code>
+ * applies equally to this class.</p>
+ * 
+ * @see NamingException
+ * 
+ */
+public class InvalidAttributeValueException extends NamingException {
+
+	/*
+	 * -------------------------------------------------------------------
+	 * Constants
+	 * -------------------------------------------------------------------
+	 */
+	 
+	/* Serialization information - start. */
+	private static final long serialVersionUID = 0x7903d78afec63b03L;
+	/* Serialization information - end. */
+
+	/*
+	 * -------------------------------------------------------------------
+	 * Constructors
+	 * -------------------------------------------------------------------
+	 */
+	 	
+	/**
+	 * Default constructor. 
+	 * <p>
+	 * All fields are initialized to null.</p>
+	 */	 		
+	public InvalidAttributeValueException() {
+		super();
+	}
+
+	/**
+	 * Constructs an <code>InvalidAttributeValueException</code> instance 
+     * using the supplied text of the message.
+	 * <p>
+	 * All fields are initialized to null.</p>
+	 * 
+	 * @param s				message about the problem
+	 */
+	public InvalidAttributeValueException(String s) {
+		super(s);
+	}
+
+}
+
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/InvalidAttributesException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/InvalidAttributesException.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/InvalidAttributesException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/InvalidAttributesException.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,70 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ package javax.naming.directory;
+
+import javax.naming.NamingException;
+
+/**
+ * Thrown when an attempt is made to set attributes that are invalid for
+ * the entry they are being targetted.
+ * <p>
+ * Examples include schema restrictions for attributes such as specific values
+ * required, attributes that must be set exclusively of others, and so on.</p>
+ * <p>
+ * The list of invalid cases is defined by the directory service provider.</p>
+ * 
+ * @see NamingException
+ * 
+ */
+public class InvalidAttributesException extends NamingException {
+
+	/*
+	 * -------------------------------------------------------------------
+	 * Constants
+	 * -------------------------------------------------------------------
+	 */
+
+	private static final long serialVersionUID = 0x24301a12642c8465L;
+
+	/*
+	 * -------------------------------------------------------------------
+	 * Constructors
+	 * -------------------------------------------------------------------
+	 */
+	
+	/**
+	 * Default constructor. 
+	 * <p>
+	 * All fields are initialized to null.</p>
+	 */		
+	public InvalidAttributesException() {
+		super();
+	}
+
+	/**
+	 * Constructs an <code>InvalidAttributesException</code> instance using 
+     * the supplied text of the message.
+	 * <p>
+	 * All fields are initialized to null.</p>
+	 * 
+	 * @param s				message about the problem
+	 */ 
+	public InvalidAttributesException(String s) {
+		super(s);
+	}
+}
+
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/InvalidSearchControlsException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/InvalidSearchControlsException.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/InvalidSearchControlsException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/InvalidSearchControlsException.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,70 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.naming.directory;
+
+import javax.naming.NamingException;
+
+/**
+ * Thrown when the <code>SearchControls</code> for a given search are
+ * invalid.
+ * <p>
+ * For example, the search controls would be invlaid if the scope is not
+ * one of the defined class constants.</p> 
+ * 
+ * 
+ */
+public class InvalidSearchControlsException extends NamingException {
+	
+	/*
+	 * -------------------------------------------------------------------
+	 * Constants
+	 * -------------------------------------------------------------------
+	 */	
+
+	/* Serialization information - start. */
+	private static final long serialVersionUID = 0xb8e38210910fe94fL;
+	/* Serialization information - end. */
+	
+	/*
+	 * -------------------------------------------------------------------
+	 * Constructors
+	 * -------------------------------------------------------------------
+	 */	
+	
+	/**
+	 * Default constructor. 
+	 * <p>
+	 * All fields are initialized to null.</p>
+	 */	 	
+	public InvalidSearchControlsException() {
+		super();
+	}
+	
+	/**
+	 * Constructs an <code>InvalidSearchControlsException</code> instance 
+     * using the supplied text of the message.
+	 * <p>
+	 * All fields are initialized to null.</p>
+	 * 
+	 * @param s				message about the problem
+	 */
+	public InvalidSearchControlsException(String s) {
+		super(s);
+	}
+
+}
+
+