/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This class provides a basic implementation of the <tt>Attribute</tt> interface.
*<p>
* This implementation does not support the schema methods
* <tt>getAttributeDefinition()</tt> and <tt>getAttributeSyntaxDefinition()</tt>.
* They simply throw <tt>OperationNotSupportedException</tt>.
* Subclasses of <tt>BasicAttribute</tt> should override these methods if they
* support them.
*<p>
* The <tt>BasicAttribute</tt> class by default uses <tt>Object.equals()</tt> to
* determine equality of attribute values when testing for equality or
* when searching for values, <em>except</em> when the value is an array.
* For an array, each element of the array is checked using <tt>Object.equals()</tt>.
* Subclasses of <tt>BasicAttribute</tt> can make use of schema information
* when doing similar equality checks by overriding methods
* in which such use of schema is meaningful.
* Similarly, the <tt>BasicAttribute</tt> class by default returns the values passed to its
* Subclasses of <tt>BasicAttribute</tt> can override <tt>get()</tt> and <tt>getAll()</tt>
* to get the values dynamically from the directory (or implement
* the <tt>Attribute</tt> interface directly instead of subclassing <tt>BasicAttribute</tt>).
*<p>
* Note that updates to <tt>BasicAttribute</tt> (such as adding or removing a value)
* does not affect the corresponding representation of the attribute
* in the directory. Updates to the directory can only be effected
* using operations in the <tt>DirContext</tt> interface.
*<p>
* A <tt>BasicAttribute</tt> instance is not synchronized against concurrent
* multithreaded access. Multiple threads trying to access and modify a
* <tt>BasicAttribute</tt> should lock the object.
*
* @author Rosanna Lee
* @author Scott Seligman
* @since 1.3
*/
/**
* Holds the attribute's id. It is initialized by the public constructor and
* cannot be null unless methods in BasicAttribute that use attrID
* have been overridden.
* @serial
*/
/**
* Holds the attribute's values. Initialized by public constructors.
* Cannot be null unless methods in BasicAttribute that use
* values have been overridden.
*/
/**
* A flag for recording whether this attribute's values are ordered.
* @serial
*/
protected boolean ordered = false;
try {
} catch (CloneNotSupportedException e) {
}
return attr;
}
/**
* Determines whether obj is equal to this attribute.
* Two attributes are equal if their attribute-ids, syntaxes
* and values are equal.
* If the attribute values are unordered, the order that the values were added
* are irrelevant. If the attribute values are ordered, then the
* order the values must match.
* If obj is null or not an Attribute, false is returned.
*<p>
* By default <tt>Object.equals()</tt> is used when comparing the attribute
* id and its values except when a value is an array. For an array,
* each element of the array is checked using <tt>Object.equals()</tt>.
* A subclass may override this to make
* use of schema syntax information and matching rules,
* which define what it means for two attributes to be equal.
* How and whether a subclass makes
* use of the schema information is determined by the subclass.
* If a subclass overrides <tt>equals()</tt>, it should also override
* <tt>hashCode()</tt>
* such that two attributes that are equal have the same hash code.
*
* @param obj The possibly null object to check.
* @return true if obj is equal to this attribute; false otherwise.
* @see #hashCode
* @see #contains
*/
// Check order first
return false;
}
int len;
try {
if (isOrdered()) {
// Go through both list of values
for (int i = 0; i < len; i++) {
return false;
}
}
} else {
// order is not relevant; check for existence
while (theirs.hasMoreElements()) {
return false;
}
}
} catch (NamingException e) {
return false;
}
return true;
}
}
return false;
}
/**
* Calculates the hash code of this attribute.
*<p>
* The hash code is computed by adding the hash code of
* the attribute's id and that of all of its values except for
* values that are arrays.
* For an array, the hash code of each element of the array is summed.
* If a subclass overrides <tt>hashCode()</tt>, it should override
* <tt>equals()</tt>
* as well so that two attributes that are equal have the same hash code.
*
* @return an int representing the hash code of this attribute.
* @see #equals
*/
public int hashCode() {
for (int i = 0; i < num; i ++) {
for (int j = 0 ; j < len ; j++) {
}
}
} else {
}
}
}
return hash;
}
/**
* Generates the string representation of this attribute.
* The string consists of the attribute's id and its values.
* This string is meant for debugging and not meant to be
* interpreted programmatically.
* @return The non-null string representation of this attribute.
*/
} else {
boolean start = true;
if (!start)
start = false;
}
}
}
/**
* Constructs a new instance of an unordered attribute with no value.
*
* @param id The attribute's id. It cannot be null.
*/
this(id, false);
}
/**
* Constructs a new instance of an unordered attribute with a single value.
*
* @param id The attribute's id. It cannot be null.
* @param value The attribute's value. If null, a null
* value is added to the attribute.
*/
}
/**
* Constructs a new instance of a possibly ordered attribute with no value.
*
* @param id The attribute's id. It cannot be null.
* @param ordered true means the attribute's values will be ordered;
* false otherwise.
*/
}
/**
* Constructs a new instance of a possibly ordered attribute with a
* single value.
*
* @param id The attribute's id. It cannot be null.
* @param value The attribute's value. If null, a null
* value is added to the attribute.
* @param ordered true means the attribute's values will be ordered;
* false otherwise.
*/
}
/**
* Retrieves an enumeration of this attribute's values.
*<p>
* By default, the values returned are those passed to the
* A subclass may override this to retrieve the values dynamically
* from the directory.
*/
return new ValuesEnumImpl();
}
/**
* Retrieves one of this attribute's values.
*<p>
* By default, the value returned is one of those passed to the
* A subclass may override this to retrieve the value dynamically
* from the directory.
*/
throw new
} else {
}
}
public int size() {
}
return attrID;
}
/**
* Determines whether a value is in this attribute.
*<p>
* By default,
* <tt>Object.equals()</tt> is used when comparing <tt>attrVal</tt>
* with this attribute's values except when <tt>attrVal</tt> is an array.
* For an array, each element of the array is checked using
* <tt>Object.equals()</tt>.
* A subclass may use schema information to determine equality.
*/
}
// For finding first element that has a null in JDK1.1 Vector.
// In the Java 2 platform, can just replace this with Vector.indexOf(target);
for (int i = 0 ; i < ct ; i++) {
return i;
}
for (int i = 0 ; i < ct ; i++) {
return i;
}
} else {
}
return -1; // not found
}
/**
* Determines whether two attribute values are equal.
* Use arrayEquals for arrays and <tt>Object.equals()</tt> otherwise.
*/
return true; // object references are equal
}
return false; // obj2 was not false
}
}
}
/**
* Determines whether two arrays are equal by comparing each of their
* elements using <tt>Object.equals()</tt>.
*/
int len;
return false;
for (int j = 0; j < len; j++) {
return false;
return false;
}
}
return true;
}
/**
* Adds a new value to this attribute.
*<p>
* By default, <tt>Object.equals()</tt> is used when comparing <tt>attrVal</tt>
* with this attribute's values except when <tt>attrVal</tt> is an array.
* For an array, each element of the array is checked using
* <tt>Object.equals()</tt>.
* A subclass may use schema information to determine equality.
*/
return true;
} else {
return false;
}
}
/**
* Removes a specified value from this attribute.
*<p>
* By default, <tt>Object.equals()</tt> is used when comparing <tt>attrVal</tt>
* with this attribute's values except when <tt>attrVal</tt> is an array.
* For an array, each element of the array is checked using
* <tt>Object.equals()</tt>.
* A subclass may use schema information to determine equality.
*/
// For the Java 2 platform, can just use "return removeElement(attrval);"
// Need to do the following to handle null case
if (i >= 0) {
return true;
}
return false;
}
public void clear() {
}
// ---- ordering methods
public boolean isOrdered() {
return ordered;
}
}
return answer;
}
throw new IllegalStateException(
"Cannot add duplicate to unordered attribute");
}
}
throw new IllegalStateException(
"Cannot add duplicate to unordered attribute");
}
return answer;
}
// ----------------- Schema methods
/**
* Retrieves the syntax definition associated with this attribute.
*<p>
* This method by default throws OperationNotSupportedException. A subclass
* should override this method if it supports schema.
*/
throw new OperationNotSupportedException("attribute syntax");
}
/**
* Retrieves this attribute's schema definition.
*<p>
* This method by default throws OperationNotSupportedException. A subclass
* should override this method if it supports schema.
*/
throw new OperationNotSupportedException("attribute definition");
}
// ---- serialization methods
/**
* Overridden to avoid exposing implementation details
* @serialData Default field (the attribute ID -- a String),
* followed by the number of values (an int), and the
* individual values.
*/
s.defaultWriteObject(); // write out the attrID
}
}
/**
* Overridden to avoid exposing implementation details.
*/
s.defaultReadObject(); // read in the attrID
int n = s.readInt(); // number of values
while (--n >= 0) {
}
}
ValuesEnumImpl() {
}
public boolean hasMoreElements() {
return list.hasMoreElements();
}
return(list.nextElement());
}
return list.nextElement();
}
return list.hasMoreElements();
}
}
}
/**
* Use serialVersionUID from JNDI 1.1.1 for interoperability.
*/
}