- All Implemented Interfaces:
Serializable
,Cloneable
,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.
- Since:
- 1.3
- See Also:
-
Constructor Summary
ConstructorDescriptionConstructs a new instance of Attributes.BasicAttributes
(boolean ignoreCase) Constructs a new instance of Attributes.BasicAttributes
(String attrID, Object val) Constructs a new instance of Attributes with one attribute.BasicAttributes
(String attrID, Object val, boolean ignoreCase) Constructs a new instance of Attributes with one attribute. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Makes a copy of the attribute set.boolean
Determines whether thisBasicAttributes
is equal to anotherAttributes
TwoAttributes
are equal if they are both instances ofAttributes
, treat the case of attribute IDs the same way, and contain the same attributes.Retrieves the attribute with the given attribute id from the attribute set.getAll()
Retrieves an enumeration of the attributes in the attribute set.getIDs()
Retrieves an enumeration of the ids of the attributes in the attribute set.int
hashCode()
Calculates the hash code of this BasicAttributes.boolean
Determines whether the attribute set ignores the case of attribute identifiers when retrieving or adding attributes.Adds a new attribute to the attribute set.Adds a new attribute to the attribute set.Removes the attribute with the attribute id 'attrID' from the attribute set.int
size()
Retrieves the number of attributes in the attribute set.toString()
Generates the string representation of this attribute set.
-
Constructor Details
-
BasicAttributes
public BasicAttributes()Constructs a new instance of Attributes. The character case of attribute identifiers is significant when subsequently retrieving or adding attributes. -
BasicAttributes
public BasicAttributes(boolean ignoreCase) Constructs a new instance of Attributes. IfignoreCase
is true, the character case of attribute identifiers is ignored; otherwise the case is significant.- Parameters:
ignoreCase
- true means this attribute set will ignore the case of its attribute identifiers when retrieving or adding attributes; false means case is respected.
-
BasicAttributes
Constructs a new instance of Attributes with one attribute. The attribute specified by attrID and val are added to the newly created attribute. The character case of attribute identifiers is significant when subsequently retrieving or adding attributes.- Parameters:
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.
-
BasicAttributes
Constructs a new instance of Attributes with one attribute. The attribute specified by attrID and val are added to the newly created attribute. IfignoreCase
is true, the character case of attribute identifiers is ignored; otherwise the case is significant.- Parameters:
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.
-
-
Method Details
-
clone
Description copied from interface:Attributes
Makes a copy of the attribute set. The new set contains the same attributes as the original set: the attributes are not themselves cloned. Changes to the copy will not affect the original and vice versa.- Specified by:
clone
in interfaceAttributes
- Overrides:
clone
in classObject
- Returns:
- A non-null copy of this attribute set.
- See Also:
-
isCaseIgnored
public boolean isCaseIgnored()Description copied from interface:Attributes
Determines whether the attribute set ignores the case of attribute identifiers when retrieving or adding attributes.- Specified by:
isCaseIgnored
in interfaceAttributes
- Returns:
- true if case is ignored; false otherwise.
-
size
public int size()Description copied from interface:Attributes
Retrieves the number of attributes in the attribute set.- Specified by:
size
in interfaceAttributes
- Returns:
- The nonnegative number of attributes in this attribute set.
-
get
Description copied from interface:Attributes
Retrieves the attribute with the given attribute id from the attribute set.- Specified by:
get
in interfaceAttributes
- Parameters:
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.- Returns:
- The attribute identified by attrID; null if not found.
- See Also:
-
getAll
Description copied from interface:Attributes
Retrieves an enumeration of the attributes in the attribute set. The effects of updates to this attribute set on this enumeration are undefined.- Specified by:
getAll
in interfaceAttributes
- Returns:
- A non-null enumeration of the attributes in this attribute set.
Each element of the enumeration is of class
Attribute
. If attribute set has zero attributes, an empty enumeration is returned.
-
getIDs
Description copied from interface:Attributes
Retrieves an enumeration of the ids of the attributes in the attribute set. The effects of updates to this attribute set on this enumeration are undefined.- Specified by:
getIDs
in interfaceAttributes
- Returns:
- A non-null enumeration of the attributes' ids in this attribute set. Each element of the enumeration is of class String. If attribute set has zero attributes, an empty enumeration is returned.
-
put
Description copied from interface:Attributes
Adds a new attribute to the attribute set.- Specified by:
put
in interfaceAttributes
- Parameters:
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.- Returns:
- The Attribute with attrID that was previous in this attribute set; null if no such attribute existed.
- See Also:
-
put
Description copied from interface:Attributes
Adds a new attribute to the attribute set.- Specified by:
put
in interfaceAttributes
- Parameters:
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.- Returns:
- The Attribute with the same ID as attr that was previous in this attribute set; null if no such attribute existed.
- See Also:
-
remove
Description copied from interface:Attributes
Removes the attribute with the attribute id 'attrID' from the attribute set. If the attribute does not exist, ignore.- Specified by:
remove
in interfaceAttributes
- Parameters:
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.- Returns:
- The Attribute with the same ID as attrID that was previous in the attribute set; null if no such attribute existed.
-
toString
Generates the string representation of this attribute set. The string consists of each attribute identifier and the contents of each attribute. The contents of this string is useful for debugging and is not meant to be interpreted programmatically. -
equals
Determines whether thisBasicAttributes
is equal to anotherAttributes
TwoAttributes
are equal if they are both instances ofAttributes
, treat the case of attribute IDs the same way, and contain the same attributes. EachAttribute
in thisBasicAttributes
is checked for equality usingObject.equals()
, which may have be overridden by implementations ofAttribute
). If a subclass overridesequals()
, it should overridehashCode()
as well so that twoAttributes
instances that are equal have the same hash code. -
hashCode
public int hashCode()Calculates the hash code of this BasicAttributes.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 overrideequals()
as well so that twoAttributes
instances that are equal have the same hash code.
-