2362N/A * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * Class HashAttributeSet provides an <code>AttributeSet</code> 0N/A * implementation with characteristics of a hash map. 0N/A * @author Alan Kaminsky 0N/A * The interface of which all members of this attribute set must be an 0N/A * instance. It is assumed to be interface {@link Attribute Attribute} 0N/A * or a subinterface thereof. 0N/A * A HashMap used by the implementation. 0N/A * The serialised form doesn't include this instance variable. 0N/A * Write the instance to a stream (ie serialize the object) 0N/A * The serialized form of an attribute set explicitly writes the 0N/A * number of attributes in the set, and each of the attributes. 0N/A * This does not guarantee equality of serialized forms since 0N/A * the order in which the attributes are written is not defined. 0N/A * Reconstitute an instance from a stream that is, deserialize it). 0N/A * Construct a new, empty attribute set. 0N/A * Construct a new attribute set, 0N/A * initially populated with the given attribute. 0N/A * @param attribute Attribute value to add to the set. 0N/A * @exception NullPointerException 0N/A * (unchecked exception) Thrown if <CODE>attribute</CODE> is null. 0N/A * Construct a new attribute set, 0N/A * initially populated with the values from the 0N/A * given array. The new attribute set is populated by 0N/A * adding the elements of <CODE>attributes</CODE> array to the set in 0N/A * sequence, starting at index 0. Thus, later array elements may replace 0N/A * earlier array elements if the array contains duplicate attribute 0N/A * values or attribute categories. 0N/A * @param attributes Array of attribute values to add to the set. 0N/A * If null, an empty attribute set is constructed. 0N/A * @exception NullPointerException 0N/A * (unchecked exception) Thrown if any element of 0N/A * <CODE>attributes</CODE> is null. 0N/A * Construct a new attribute set, 0N/A * initially populated with the values from the given set. 0N/A * @param attributes Set of attributes from which to initialise this set. 0N/A * If null, an empty attribute set is constructed. 0N/A * Construct a new, empty attribute set, where the members of 0N/A * the attribute set are restricted to the given interface. 0N/A * @param interfaceName The interface of which all members of this 0N/A * attribute set must be an instance. It is assumed to 0N/A * be interface {@link Attribute Attribute} or a 0N/A * subinterface thereof. 0N/A * @exception NullPointerException if interfaceName is null. 0N/A * Construct a new attribute set, initially populated with the given 0N/A * attribute, where the members of the attribute set are restricted to the 0N/A * @param attribute Attribute value to add to the set. 0N/A * @param interfaceName The interface of which all members of this 0N/A * attribute set must be an instance. It is assumed to 0N/A * be interface {@link Attribute Attribute} or a 0N/A * subinterface thereof. 0N/A * @exception NullPointerException 0N/A * (unchecked exception) Thrown if <CODE>attribute</CODE> is null. 0N/A * @exception NullPointerException if interfaceName is null. 0N/A * @exception ClassCastException 0N/A * (unchecked exception) Thrown if <CODE>attribute</CODE> is not an 0N/A * instance of <CODE>interfaceName</CODE>. 0N/A * Construct a new attribute set, where the members of the attribute 0N/A * set are restricted to the given interface. 0N/A * The new attribute set is populated 0N/A * by adding the elements of <CODE>attributes</CODE> array to the set in 0N/A * sequence, starting at index 0. Thus, later array elements may replace 0N/A * earlier array elements if the array contains duplicate attribute 0N/A * values or attribute categories. 0N/A * @param attributes Array of attribute values to add to the set. If 0N/A * null, an empty attribute set is constructed. 0N/A * @param interfaceName The interface of which all members of this 0N/A * attribute set must be an instance. It is assumed to 0N/A * be interface {@link Attribute Attribute} or a 0N/A * subinterface thereof. 0N/A * @exception NullPointerException 0N/A * (unchecked exception) Thrown if any element of 0N/A * <CODE>attributes</CODE> is null. 0N/A * @exception NullPointerException if interfaceName is null. 0N/A * @exception ClassCastException 0N/A * (unchecked exception) Thrown if any element of 0N/A * <CODE>attributes</CODE> is not an instance of 0N/A * <CODE>interfaceName</CODE>. 0N/A for (
int i =
0; i < n; ++ i) {
0N/A * Construct a new attribute set, initially populated with the 0N/A * values from the given set where the members of the attribute 0N/A * set are restricted to the given interface. 0N/A * @param attributes set of attribute values to initialise the set. If 0N/A * null, an empty attribute set is constructed. 0N/A * @param interfaceName The interface of which all members of this 0N/A * attribute set must be an instance. It is assumed to 0N/A * be interface {@link Attribute Attribute} or a 0N/A * subinterface thereof. 0N/A * @exception ClassCastException 0N/A * (unchecked exception) Thrown if any element of 0N/A * <CODE>attributes</CODE> is not an instance of 0N/A * <CODE>interfaceName</CODE>. 0N/A for (
int i =
0; i < n; ++ i) {
0N/A * Returns the attribute value which this attribute set contains in the 0N/A * given attribute category. Returns <tt>null</tt> if this attribute set 0N/A * does not contain any attribute value in the given attribute category. 0N/A * @param category Attribute category whose associated attribute value 0N/A * is to be returned. It must be a 0N/A * {@link java.lang.Class Class} 0N/A * that implements interface {@link Attribute 0N/A * @return The attribute value in the given attribute category contained 0N/A * in this attribute set, or <tt>null</tt> if this attribute set 0N/A * does not contain any attribute value in the given attribute 0N/A * @throws NullPointerException 0N/A * (unchecked exception) Thrown if the <CODE>category</CODE> is null. 0N/A * @throws ClassCastException 0N/A * (unchecked exception) Thrown if the <CODE>category</CODE> is not a 0N/A * {@link java.lang.Class Class} that implements interface {@link 0N/A * Attribute Attribute}. 0N/A * Adds the specified attribute to this attribute set if it is not 0N/A * already present, first removing any existing in the same 0N/A * attribute category as the specified attribute value. 0N/A * @param attribute Attribute value to be added to this attribute set. 0N/A * @return <tt>true</tt> if this attribute set changed as a result of the 0N/A * call, i.e., the given attribute value was not already a 0N/A * member of this attribute set. 0N/A * @throws NullPointerException 0N/A * (unchecked exception) Thrown if the <CODE>attribute</CODE> is null. 0N/A * @throws UnmodifiableSetException 0N/A * (unchecked exception) Thrown if this attribute set does not support 0N/A * the <CODE>add()</CODE> operation. 0N/A * Removes any attribute for this category from this attribute set if 0N/A * present. If <CODE>category</CODE> is null, then 0N/A * <CODE>remove()</CODE> does nothing and returns <tt>false</tt>. 0N/A * @param category Attribute category to be removed from this 0N/A * @return <tt>true</tt> if this attribute set changed as a result of the 0N/A * call, i.e., the given attribute category had been a member of 0N/A * this attribute set. 0N/A * @throws UnmodifiableSetException 0N/A * (unchecked exception) Thrown if this attribute set does not 0N/A * support the <CODE>remove()</CODE> operation. 0N/A * Removes the specified attribute from this attribute set if 0N/A * present. If <CODE>attribute</CODE> is null, then 0N/A * <CODE>remove()</CODE> does nothing and returns <tt>false</tt>. 0N/A * @param attribute Attribute value to be removed from this attribute set. 0N/A * @return <tt>true</tt> if this attribute set changed as a result of the 0N/A * call, i.e., the given attribute value had been a member of 0N/A * this attribute set. 0N/A * @throws UnmodifiableSetException 0N/A * (unchecked exception) Thrown if this attribute set does not 0N/A * support the <CODE>remove()</CODE> operation. 0N/A * Returns <tt>true</tt> if this attribute set contains an 0N/A * attribute for the specified category. 0N/A * @param category whose presence in this attribute set is 0N/A * @return <tt>true</tt> if this attribute set contains an attribute 0N/A * value for the specified category. 0N/A * Returns <tt>true</tt> if this attribute set contains the given 0N/A * @param attribute value whose presence in this attribute set is 0N/A * @return <tt>true</tt> if this attribute set contains the given 0N/A * Adds all of the elements in the specified set to this attribute. 0N/A * The outcome is the same as if the 0N/A * {@link #add(Attribute) <CODE>add(Attribute)</CODE>} 0N/A * operation had been applied to this attribute set successively with 0N/A * each element from the specified set. 0N/A * The behavior of the <CODE>addAll(AttributeSet)</CODE> 0N/A * operation is unspecified if the specified set is modified while 0N/A * the operation is in progress. 0N/A * If the <CODE>addAll(AttributeSet)</CODE> operation throws an exception, 0N/A * the effect on this attribute set's state is implementation dependent; 0N/A * elements from the specified set before the point of the exception may 0N/A * or may not have been added to this attribute set. 0N/A * @param attributes whose elements are to be added to this attribute 0N/A * @return <tt>true</tt> if this attribute set changed as a result of the 0N/A * @throws UnmodifiableSetException 0N/A * (Unchecked exception) Thrown if this attribute set does not 0N/A * support the <tt>addAll(AttributeSet)</tt> method. 0N/A * @throws NullPointerException 0N/A * (Unchecked exception) Thrown if some element in the specified 0N/A * set is null, or the set is null. 0N/A * @see #add(Attribute) 0N/A * Returns the number of attributes in this attribute set. If this 0N/A * attribute set contains more than <tt>Integer.MAX_VALUE</tt> elements, 0N/A * returns <tt>Integer.MAX_VALUE</tt>. 0N/A * @return The number of attributes in this attribute set. 0N/A * @return the Attributes contained in this set as an array, zero length 0N/A * if the AttributeSet is empty. 0N/A * Removes all attributes from this attribute set. 0N/A * @throws UnmodifiableSetException 0N/A * (unchecked exception) Thrown if this attribute set does not support 0N/A * the <CODE>clear()</CODE> operation. 0N/A * Returns true if this attribute set contains no attributes. 0N/A * @return true if this attribute set contains no attributes. 0N/A * Compares the specified object with this attribute set for equality. 0N/A * Returns <tt>true</tt> if the given object is also an attribute set and 0N/A * the two attribute sets contain the same attribute category-attribute 0N/A * value mappings. This ensures that the 0N/A * <tt>equals()</tt> method works properly across different 0N/A * implementations of the AttributeSet interface. 0N/A * @param object to be compared for equality with this attribute set. 0N/A * @return <tt>true</tt> if the specified object is equal to this 0N/A * Returns the hash code value for this attribute set. 0N/A * The hash code of an attribute set is defined to be the sum 0N/A * of the hash codes of each entry in the AttributeSet. 0N/A * This ensures that <tt>t1.equals(t2)</tt> implies that 0N/A * <tt>t1.hashCode()==t2.hashCode()</tt> for any two attribute sets 0N/A * <tt>t1</tt> and <tt>t2</tt>, as required by the general contract of 0N/A * {@link java.lang.Object#hashCode() <CODE>Object.hashCode()</CODE>}. 0N/A * @return The hash code value for this attribute set.