Serializable
, Cloneable
, Attributes
public class BasicAttributes extends Object implements Attributes
BasicAttributes is either case-sensitive or case-insensitive (case-ignore). This property is determined at the time the BasicAttributes constructor is called. In a case-insensitive BasicAttributes, the case of its attribute identifiers is ignored when searching for an attribute, or adding attributes. In a case-sensitive BasicAttributes, the case is significant.
When the BasicAttributes class needs to create an Attribute, it uses BasicAttribute. There is no other dependency on BasicAttribute.
Note that updates to BasicAttributes (such as adding or removing an attribute) does not affect the corresponding representation in the directory. Updates to the directory can only be effected using operations in the DirContext interface.
A BasicAttributes instance is not synchronized against concurrent multithreaded access. Multiple threads trying to access and modify a single BasicAttributes instance should lock the object.
Constructor | Description |
---|---|
BasicAttributes() |
Constructs a new instance of Attributes. |
BasicAttributes |
Constructs a new instance of Attributes. |
BasicAttributes |
Constructs a new instance of Attributes with one attribute. |
BasicAttributes |
Constructs a new instance of Attributes with one attribute. |
Modifier and Type | Method | Description |
---|---|---|
Object |
clone() |
Creates and returns a copy of this object. |
boolean |
equals |
Determines whether this BasicAttributes is equal to another Attributes Two Attributes are equal if they are both instances of Attributes , treat the case of attribute IDs the same way, and contain the same attributes. |
Attribute |
get |
Retrieves the attribute with the given attribute id from the attribute set. |
NamingEnumeration |
getAll() |
Retrieves an enumeration of the attributes in the attribute set. |
NamingEnumeration |
getIDs() |
Retrieves an enumeration of the ids of the attributes in the attribute set. |
int |
hashCode() |
Calculates the hash code of this BasicAttributes. |
boolean |
isCaseIgnored() |
Determines whether the attribute set ignores the case of attribute identifiers when retrieving or adding attributes. |
Attribute |
put |
Adds a new attribute to the attribute set. |
Attribute |
put |
Adds a new attribute to the attribute set. |
Attribute |
remove |
Removes the attribute with the attribute id 'attrID' from the attribute set. |
int |
size() |
Retrieves the number of attributes in the attribute set. |
String |
toString() |
Generates the string representation of this attribute set. |
public BasicAttributes()
public BasicAttributes(boolean ignoreCase)
ignoreCase
is true, the character case of attribute identifiers is ignored; otherwise the case is significant.ignoreCase
- true means this attribute set will ignore the case of its attribute identifiers when retrieving or adding attributes; false means case is respected.public BasicAttributes(String attrID, Object val)
attrID
- non-null The id of the attribute to add.val
- The value of the attribute to add. If null, a null value is added to the attribute.public BasicAttributes(String attrID, Object val, boolean ignoreCase)
ignoreCase
is true, the character case of attribute identifiers is ignored; otherwise the case is significant.attrID
- non-null The id of the attribute to add. If this attribute set ignores the character case of its attribute ids, the case of attrID is ignored.val
- The value of the attribute to add. If null, a null value is added to the attribute.ignoreCase
- true means this attribute set will ignore the case of its attribute identifiers when retrieving or adding attributes; false means case is respected.public Object clone()
Object
x
, the expression: will be true, and that the expression:x.clone() != x
will bex.clone().getClass() == x.getClass()
true
, but these are not absolute requirements. While it is typically the case that: will bex.clone().equals(x)
true
, this is not an absolute requirement. By convention, the returned object should be obtained by calling super.clone
. If a class and all of its superclasses (except Object
) obey this convention, it will be the case that x.clone().getClass() == x.getClass()
.
By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone
before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone
need to be modified.
clone
in interface Attributes
clone
in class Object
public boolean isCaseIgnored()
Attributes
isCaseIgnored
in interface Attributes
public int size()
Attributes
size
in interface Attributes
public Attribute get(String attrID)
Attributes
get
in interface Attributes
attrID
- The non-null id of the attribute to retrieve. If this attribute set ignores the character case of its attribute ids, the case of attrID is ignored.public NamingEnumeration<Attribute> getAll()
Attributes
getAll
in interface Attributes
Attribute
. If attribute set has zero attributes, an empty enumeration is returned.public NamingEnumeration<String> getIDs()
Attributes
getIDs
in interface Attributes
public Attribute put(String attrID, Object val)
Attributes
put
in interface Attributes
attrID
- non-null The id of the attribute to add. If the attribute set ignores the character case of its attribute ids, the case of attrID is ignored.val
- The possibly null value of the attribute to add. If null, the attribute does not have any values.public Attribute put(Attribute attr)
Attributes
put
in interface Attributes
attr
- The non-null attribute to add. If the attribute set ignores the character case of its attribute ids, the case of attr's identifier is ignored.public Attribute remove(String attrID)
Attributes
remove
in interface Attributes
attrID
- The non-null id of the attribute to remove. If the attribute set ignores the character case of its attribute ids, the case of attrID is ignored.public String toString()
public boolean equals(Object obj)
BasicAttributes
is equal to another Attributes
Two Attributes
are equal if they are both instances of Attributes
, treat the case of attribute IDs the same way, and contain the same attributes. Each Attribute
in this BasicAttributes
is checked for equality using Object.equals()
, which may have be overridden by implementations of Attribute
). If a subclass overrides equals()
, it should override hashCode()
as well so that two Attributes
instances that are equal have the same hash code.public int hashCode()
The hash code is computed by adding the hash code of the attributes of this object. If this BasicAttributes ignores case of its attribute IDs, one is added to the hash code. If a subclass overrides hashCode()
, it should override equals()
as well so that two Attributes
instances that are equal have the same hash code.
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.naming/javax/naming/directory/BasicAttributes.html