Return-Path:
+ * A basic attribute does not have any schema associated with it, and attempts
+ * to get the schema result in an
+ * The definition of
+ * 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.
+ *
+ * The
+ * A particular instance of
+ * Note that changes to the
+ * A
+ * 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.
+ * In this interface there are duplicated methods that take either a
+ * The semantics of a name in a
+ * JNDI supports two logical models of attribute storage:
+ *
+ * In this model objects that are not OperationNotSupportedException
+ * being thrown.equals
for an attribute is simply
+ * Object.equals
on the value, except for values that are collections
+ * where the definition of equals
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, Object.equals
+ * is used on each array element.BasicAttribute
does not get its values dynamically
+ * from the directory. It uses the values passed to the constructor or add and
+ * remove methods.Vector
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 BasicAttribute
instance with the
+ * supplied identifier and no values.
+ *
+ * @param id the attribute ID
+ */
+ public BasicAttribute(String id) {
+ this(id, false);
+ }
+
+ /**
+ * Constructs a BasicAttribute
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 BasicAttribute
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 BasicAttribute
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 BasicAttribute
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 BasicAttribute
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 BasicAttribute
instance is equal to the
+ * supplied object obj
.
+ * Two attributes are considered equal if they have equal identifiers,
+ * schemas and values. BasicAttribute uses no schema.
+ * Object.equals
is used to test equality of identifiers and
+ * values. For array values Object.equals
is called on every
+ * array element.obj
,
+ * 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 BasicAttribute
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 BasicAttribute
+ * 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 BasicAttribute
+ * 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 Attributes
interface.
+ * BasicAttributes
provides operations on any types of
+ * attribute. When a new attribute is created the BasicAttributes
+ * class will create a new BasicAttribute
and add it to the
+ * attribute collection.BasicAttributes
can be either
+ * case-sensitive or case-insensitive, as defined by the isCaseIgnored()
+ *
method.BasicAttributes
are local -- they do
+ * not modify the directory. The directory is only modified by API calls on the
+ * {@link DirContext} object.BasicAttributes
instance which is
+ * case-sensitive.
+ */
+ public BasicAttributes() {
+ this(false);
+ }
+
+ /**
+ * Constructs a BasicAttributes
instance which is
+ * case-sensitive if flag
is false.
+ *
+ * @param flag Inidicates whether this instance is
+ * case-insensitive.
+ */
+ public BasicAttributes(boolean flag) {
+ this.ignoreCase = flag;
+ }
+
+ /**
+ * Constructs a case-sensitive BasicAttributes
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 BasicAttributes
instance with one attribute
+ * which is case-sensitive if flag
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 BasicAttributes
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 BasicAttributes
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 BasicAttributes
instance is equal to
+ * the supplied object obj
.
+ * They are considered equal if they handle case the same way and have equal
+ * attributes. Attribute
equality is tested by calling
+ * equals
on each attribute, which may be overridden.
+ *
+ * @param obj the object to compare with
+ * @return true if this object is equal to obj
,
+ * 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 BasicAttributes
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 BasicAttributes
+ * 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 BasicAttributes
+ * 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.
+ * DirContext
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.String
+ * or Name
parameter. This is simply a convenience and the behavior of each
+ * method is identical.DirContext
is exactly equivalent to that of
+ * a name in a regular naming Context
.
+ *
DirContext
on the given name followed by application of the
+ * operation to the resulting empty DirContext
. Think of this
+ * as attributes being stored on the object itself.DirContext
followed by application
+ * of the operation on the parent DirContext
providing the name as an argument.
+ * Think of this as the attributes being stored in the parent context.DirContext
can have attributes,
+ * provided their parents are DirContext
.
+ * The directory service provider can implement either of these logical models, and the client + * is expeced to know which model it is dealing with.
+ * + * Attribute Name aliasing + *+ * 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.
+ * + * Searching and operational attributes + *+ * 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.
+ *
+ * The API calls for searching for attributes, and those for getting named attributes using
+ * a list of names are defined to interpret the null
argument to match all
+ * non-operational attributes.
+ * It is therefore possible to get a specific named attribute that is not returned in a global + * retrieval of all object attributes.
+ * + * Conditions + *
+ * Some APIs require that the name resolves to another DirContext
and not an
+ * object. In such cases, if this postcondition is not met then the method should throw
+ * a NotContextException
. Other methods can resolve to be either objects or
+ * DirContext
.
+ * Service providers must not modify collection parameters such as Attribute
,
+ * SearchControl
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.
+ * APIs that return collections are safe -- that is, the service provider will not modify + * collections that are returned to clients.
+ * + * Exceptions + *
+ * Any method may throw a NamingException
(or subclass) as defined by the
+ * exception descriptions.
+ * The new value is added to the existing attributes at that identifier + * subject to the following constraints: + *
InvalidAttributeValueException
is thrown if the attribute
+ * must have a value.AttributeInUseException
is thrown.InvalidAttributeValueException
is thrown.
+ * If the attribute does not exist then it is created with the given attribute
+ * identifier and attribute. If the value contravenes the schema, an
+ * InvalidAttributeValueException
is thrown.
+ * 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 InvalidAttributeValueException
+ * is thrown. If no value is given then all of the values are removed from
+ * the attribute.
+ * If an attribute is defined as requiring at least one value, then removing + * values results in the removal of the attribute itself.
+ */ + public static final int REPLACE_ATTRIBUTE = 2; + + /** + * Constant field indicating the removal of an attribute. + *+ * 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.
+ *
+ * If the given set of attributes is null
that should be interpreted
+ * as a request to remove all values from the existing attribute set.
+ * 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 NamingException
.
Name
to an Object
in this directory
+ * to produce a binding.
+ *
+ * This binding can have attributes, which are specified by the
+ * attributes
parameter if it is non-null. If the
+ * attributes
parameter is null and obj
is a
+ * DirContext
with attributes, the binding will have the
+ * attributes of obj
.
+ * Note that null is not a valid value for name
. Neither is
+ * the empty Name
because this is reserved to refer to the
+ * context.
+ * If name
is already bound in this DirContext
+ * this method throws a NameAlreadyBoundException
.
+ * If there are mandatory attributes for this binding in this
+ * DirContext
, and they are not specified, this method throws
+ * an InvalidAttributesException
.
+ * This method throws any NamingException
that occurs.
Object
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.
+ *
+ * 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 name
must already exist. If the attributes
+ * parameter is non-null the specified attributes are added to the
+ * new subcontext.
+ * Possible exceptions are NameAlreadyBoundException
and
+ * InvalidAttributesException
.
+ * This method throws any NamingException
that occurs.
name
.
+ * + * See note in description about operational attributes.
+ *
+ * The returned set of attributes is empty if name
has no
+ * attributes.
+ * This method throws any NamingException
that occurs.
name
+ * @throws NamingException If any occurs.
+ */
+ Attributes getAttributes(Name name) throws NamingException;
+
+ /**
+ * Gets the attributes for name
that match the strings in
+ * array as
.
+ *
+ * If any string in as
is not matched it is skipped. More
+ * attributes may be returned than the number of strings in as
+ * - see notes on attribute aliasing.
+ * This method throws any NamingException
that occurs.
name
that match
+ * the strings in array as
.
+ * @throws NamingException If any occurs.
+ */
+ Attributes getAttributes(Name name, String as[]) throws NamingException;
+
+ /**
+ * Gets all attributes of name represented by s
.
+ *
+ * @param s representive of name to be searched for attributes
+ * @return all attributes of name represented by s
+ * @throws NamingException If any occurs.
+ * @see #getAttributes(Name name)
+ */
+ Attributes getAttributes(String s) throws NamingException;
+
+ /**
+ * Gets the attributes for name represented by s
that match the strings in
+ * array as
.
+ *
+ * @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
+ * s
that match the strings in array
+ * as
.
+ * @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 name
.
+ *
+ * If name
does not support a schema this method throws an
+ * OperationNotSupportedException
.
+ * This method throws any NamingException
that occurs.
name
+ * @throws NamingException If any occurs.
+ */
+ DirContext getSchema(Name name) throws NamingException;
+
+ /**
+ * Gets the top level of the schema for name represented by s
.
+ *
+ * @param s representive of name to be searched for schema
+ * @return the top level of the schema for object name
+ * @throws NamingException If any occurs.
+ * @see #getSchema(Name name)
+ */
+ DirContext getSchema(String s) throws NamingException;
+
+ /**
+ * Gets the class definition for name
from its schema.
+ * + * 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.
+ *
+ * If name
does not support a schema this method throws an
+ * OperationNotSupportedException
.
+ * This method throws any NamingException
that occurs.
name
from
+ * its schema.
+ * @throws NamingException If any occurs.
+ */
+ DirContext getSchemaClassDefinition(Name name) throws NamingException;
+
+ /**
+ * Gets the class definition for name represented by s
from its schema.
+ *
+ * @param s the string representive of name to searched for
+ * the class definition from its schema
+ * @return the class definition for name
from
+ * its schema.
+ * @throws NamingException If any occurs.
+ * @see #getSchemaClassDefinition(Name name)
+ */
+ DirContext getSchemaClassDefinition(String s) throws NamingException;
+
+ /**
+ * Modifies the attributes of name
.
+ *
+ * Parameter i
is modification operation type and
+ * is constrained to be one of ADD_ATTRIBUTE
,
+ * REPLACE_ATTRIBUTE
, REMOVE_ATTRIBUTE
. The
+ * implementation should try to make the modifications atomic.
+ * This method throws an AttributeModificationException
if
+ * there is a problem completing the modification.
+ * This method throws any NamingException
that occurs.
name
in the order given by the
+ * array parameter amodificationitem
.
+ *
+ * The required operations are specified by the elements of
+ * modificationItems
.
+ * This method throws an AttributeModificationException
if
+ * there is a problem completing the modifications.
+ * This method throws any NamingException
that occurs.
s
.
+ *
+ * @param s name represented by s
+ * @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 s
in the
+ * order given by the array parameter modificationItems
.
+ *
+ * @param s name represented by s
+ * @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 name
to obj
.
+ *
+ * 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 obj
is an instance of
+ * DirContext
then the attributes of obj
become
+ * the only attributes of the binding. If the attributes
+ * parameter is null and obj
is not an instance of
+ * DirContext
then any attributes of the previous binding
+ * remain.
+ * If a schema defines mandatory attributes for the binding but they are not
+ * all present this method throws an InvalidAttributesException
.
+ * This method throws any NamingException
that occurs.
s
to obj
.
+ *
+ * @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 name
only, for any
+ * objects that have attributes that match the attributes
+ * parameter.
+ *
+ * This method is equivalent to passing a null as
parameter to
+ * search(Name name, Attributes attributes, String[] as)
.
+ * Objects with attributes that match the attributes
parameter
+ * are selected and all attributes are returned for selected objects.
+ * This method throws any NamingException
that occurs.
NamngEnumeration
of SearchResult
+ * @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 name
only,
+ * for any objects that have attributes that match the attributes
+ * parameter.
+ *
+ * It uses default SearchControls
. An object is selected if
+ * it has every attribute in the attributes
parameter,
+ * regardless of whether it has extra attributes. If the attributes
+ * parameter is null or empty then every object in the context is a match.
+ * The definition of attribute matching is + *
+ * Attribute ordering is ignored. If an attribute from the
+ * attributes
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
+ * Object.equals(Object obj)
, or a test defined by a schema.
+ * For each of the selected objects, this method collects and returns the
+ * attributes with identifiers listed in parameter as
. Note
+ * that these may be different to those in the attributes
+ * parameter. If a selected object does not have one of the attributes
+ * listed in as
, the missing attribute is simply skipped for
+ * that object. Attribute aliasing may mean that an attribute in the
+ * as
parameter list maps to more than one returned attribute.
+ * If parameter as
is empty, no attributes are returned, but
+ * if a
s is null all attributes are returned.
+ * The return value is an enumeration of SearchResult
objects,
+ * which is empty if no matches are found. It is not specified how subsequent
+ * changes to context specified by name
will affect an
+ * enumeration that this method returns.
+ * This method throws any NamingException
that occurs.
NamngEnumeration
of SearchResult
+ * @throws NamingException If any occurs.
+ */
+ NamingEnumeration search(Name name, Attributes attributes, String as[])
+ throws NamingException;
+
+ /**
+ * This method searches in the context specified by name
only,
+ * using the fileter specifed by parameter filter
and controlled by
+ * searchControls
.
+ *
+ *
+ * The parameter filter
is an RFC2254 filter. It may contain
+ * variables such as "{N}", which refer to element N of the objs
+ * array.
+ * The "{N}" variables can be used in place of "attr", "value", or
+ * "matchingrule" from RFC2254 section 4. If an "{N}" variable refers to a
+ * String
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 String
. The result of giving invalid
+ * variable substitutions is not specified.
+ * If searchControls
is null, the default SearchControls
+ * object is used: i.e. the object created by the no-args SearchControls()
+ * constructor.
+ * The return value is an enumeration of SearchResult
objects.
+ * The object names used may be relative to the context specified in the
+ * name
parameter, or a URL string. If the name
+ * context itself is referred to in the results, the empty string is used.
+ * It is not specified how subsequent changes to context specified by
+ * name
will affect an enumeration that this method returns.
+ * If an "{N}" variable in s
references a position outside the
+ * bounds of array objs
this method will throw an
+ * ArrayIndexOutOfBoundsException
.
+ * If searchControls
is invalid this method will throw
+ * InvalidSearchControlsException
.
+ * If the filter specified by filter
and objs
is
+ * invalid this method will throw an InvalidSearchFilterException
.
+ * This method throws any NamingException
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 NamingEnumeration
of SearchResult
+ * @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 name
only,
+ * using the fileter specifed by parameter filter
and controlled by
+ * searchControls
.
+ *
+ * This method can throw InvalidSearchFilterException
InvalidSearchControlsException
, NamingException
.
NamingEnumeration
of SearchResult
+ * @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 name
+ * only, for any objects that have attributes that match the
+ * attributes
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 NamingEnumeration
of SearchResult
+ * @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
+ * name
only, for any objects that have attributes that match
+ * the attributes
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 NamingEnumeration
of SearchResult
+ * @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
+ * name
only, using the fileter specifed by parameter
+ * filter
and controlled by searchControls
.
+ *
+ * @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 NamngEnumeration
of SearchResult
+ * @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
+ * name
only, using the fileter specifed by parameter
+ * filter
and controlled by searchControls
.
+ *
+ * @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 NamingEnumeration
of SearchResult
+ * @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.
+ *
+ *
+ * The InitialDirContext
behavior is defined by the specification
+ * for javax.naming.InitialContext
.
InitialDirContext
with no environment
+ * properties.
+ *
+ * @throws NamingException
+ * If failed to a construct new instance.
+ */
+ public InitialDirContext() throws NamingException {
+ super();
+ }
+
+ /**
+ * Constructs a new InitialDirContext
instance with no
+ * environment properties. A mechanism for subclass constructors
+ * to construct a new InitialDirContext
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 init
+ * 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 InitialDirContext
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.
+ *
+ * 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
+ * InvalidAttributeIdentifierException
.
+ * All fields are initialized to null.
+ */ + public InvalidAttributeIdentifierException() { + super(); + } + + /** + * Constructs anInvalidAttributeIdentifierException
+ * instance using the supplied text of the message.
+ * + * All fields are initialized to null.
+ * + * @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. + *
+ * 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 InvalidAttributeValueException
.
+ * 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.
+ *
+ * The serialization and synchonization specification for NamingException
+ * applies equally to this class.
+ * All fields are initialized to null.
+ */ + public InvalidAttributeValueException() { + super(); + } + + /** + * Constructs anInvalidAttributeValueException
instance
+ * using the supplied text of the message.
+ * + * All fields are initialized to null.
+ * + * @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. + *+ * Examples include schema restrictions for attributes such as specific values + * required, attributes that must be set exclusively of others, and so on.
+ *+ * The list of invalid cases is defined by the directory service provider.
+ * + * @see NamingException + * + */ +public class InvalidAttributesException extends NamingException { + + /* + * ------------------------------------------------------------------- + * Constants + * ------------------------------------------------------------------- + */ + + private static final long serialVersionUID = 0x24301a12642c8465L; + + /* + * ------------------------------------------------------------------- + * Constructors + * ------------------------------------------------------------------- + */ + + /** + * Default constructor. + *+ * All fields are initialized to null.
+ */ + public InvalidAttributesException() { + super(); + } + + /** + * Constructs anInvalidAttributesException
instance using
+ * the supplied text of the message.
+ * + * All fields are initialized to null.
+ * + * @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 theSearchControls
for a given search are
+ * invalid.
+ * + * For example, the search controls would be invlaid if the scope is not + * one of the defined class constants.
+ * + * + */ +public class InvalidSearchControlsException extends NamingException { + + /* + * ------------------------------------------------------------------- + * Constants + * ------------------------------------------------------------------- + */ + + /* Serialization information - start. */ + private static final long serialVersionUID = 0xb8e38210910fe94fL; + /* Serialization information - end. */ + + /* + * ------------------------------------------------------------------- + * Constructors + * ------------------------------------------------------------------- + */ + + /** + * Default constructor. + *+ * All fields are initialized to null.
+ */ + public InvalidSearchControlsException() { + super(); + } + + /** + * Constructs anInvalidSearchControlsException
instance
+ * using the supplied text of the message.
+ * + * All fields are initialized to null.
+ * + * @param s message about the problem + */ + public InvalidSearchControlsException(String s) { + super(s); + } + +} + +