- java.lang.Object
-
- javax.naming.directory.BasicAttributes
-
- All Implemented Interfaces:
- Serializable, Cloneable, Attributes
public class BasicAttributes extends Object implements Attributes
This class provides a basic implementation of the Attributes interface.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:
DirContext.getAttributes(javax.naming.Name),DirContext.modifyAttributes(javax.naming.Name, int, javax.naming.directory.Attributes),DirContext.bind(javax.naming.Name, java.lang.Object, javax.naming.directory.Attributes),DirContext.rebind(javax.naming.Name, java.lang.Object, javax.naming.directory.Attributes),DirContext.createSubcontext(javax.naming.Name, javax.naming.directory.Attributes),DirContext.search(javax.naming.Name, javax.naming.directory.Attributes, java.lang.String[]), Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description BasicAttributes()Constructs 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
Methods Modifier and Type Method and Description Objectclone()Creates and returns a copy of this object.booleanequals(Object obj)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.Attributeget(String attrID)Retrieves the attribute with the given attribute id from the attribute set.NamingEnumeration<Attribute>getAll()Retrieves an enumeration of the attributes in the attribute set.NamingEnumeration<String>getIDs()Retrieves an enumeration of the ids of the attributes in the attribute set.inthashCode()Calculates the hash code of this BasicAttributes.booleanisCaseIgnored()Determines whether the attribute set ignores the case of attribute identifiers when retrieving or adding attributes.Attributeput(Attribute attr)Adds a new attribute to the attribute set.Attributeput(String attrID, Object val)Adds a new attribute to the attribute set.Attributeremove(String attrID)Removes the attribute with the attribute id 'attrID' from the attribute set.intsize()Retrieves the number of attributes in the attribute set.StringtoString()Generates the string representation of this attribute set.
-
-
-
Constructor Detail
-
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. IfignoreCaseis 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
public BasicAttributes(String attrID, Object val)
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
public BasicAttributes(String attrID, Object val, boolean ignoreCase)
Constructs a new instance of Attributes with one attribute. The attribute specified by attrID and val are added to the newly created attribute. IfignoreCaseis 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 Detail
-
clone
public Object clone()
Description copied from class:ObjectCreates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any objectx, 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 (exceptObject) obey this convention, it will be the case thatx.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.clonebefore 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 bysuper.cloneneed to be modified.The method
clonefor classObjectperforms a specific cloning operation. First, if the class of this object does not implement the interfaceCloneable, then aCloneNotSupportedExceptionis thrown. Note that all arrays are considered to implement the interfaceCloneableand that the return type of theclonemethod of an array typeT[]isT[]where T is any reference or primitive type. Otherwise, this method creates a new instance of the class of this object and initializes all its fields with exactly the contents of the corresponding fields of this object, as if by assignment; the contents of the fields are not themselves cloned. Thus, this method performs a "shallow copy" of this object, not a "deep copy" operation.The class
Objectdoes not itself implement the interfaceCloneable, so calling theclonemethod on an object whose class isObjectwill result in throwing an exception at run time.- Specified by:
clonein interfaceAttributes- Overrides:
clonein classObject- Returns:
- a clone of this instance.
- See Also:
Cloneable
-
isCaseIgnored
public boolean isCaseIgnored()
Description copied from interface:AttributesDetermines whether the attribute set ignores the case of attribute identifiers when retrieving or adding attributes.- Specified by:
isCaseIgnoredin interfaceAttributes- Returns:
- true if case is ignored; false otherwise.
-
size
public int size()
Description copied from interface:AttributesRetrieves the number of attributes in the attribute set.- Specified by:
sizein interfaceAttributes- Returns:
- The nonnegative number of attributes in this attribute set.
-
get
public Attribute get(String attrID)
Description copied from interface:AttributesRetrieves the attribute with the given attribute id from the attribute set.- Specified by:
getin 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:
Attributes.put(java.lang.String, java.lang.Object),Attributes.remove(java.lang.String)
-
getAll
public NamingEnumeration<Attribute> getAll()
Description copied from interface:AttributesRetrieves an enumeration of the attributes in the attribute set. The effects of updates to this attribute set on this enumeration are undefined.- Specified by:
getAllin 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
public NamingEnumeration<String> getIDs()
Description copied from interface:AttributesRetrieves 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:
getIDsin 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
public Attribute put(String attrID, Object val)
Description copied from interface:AttributesAdds a new attribute to the attribute set.- Specified by:
putin 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:
Attributes.remove(java.lang.String)
-
put
public Attribute put(Attribute attr)
Description copied from interface:AttributesAdds a new attribute to the attribute set.- Specified by:
putin 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:
Attributes.remove(java.lang.String)
-
remove
public Attribute remove(String attrID)
Description copied from interface:AttributesRemoves the attribute with the attribute id 'attrID' from the attribute set. If the attribute does not exist, ignore.- Specified by:
removein 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
public String 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
public boolean equals(Object obj)
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. 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.- Overrides:
equalsin classObject- Parameters:
obj- the possibly null object to compare against.- Returns:
- true If obj is equal to this BasicAttributes.
- See Also:
hashCode()
-
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 override equals() as well so that two Attributes instances that are equal have the same hash code.
- Overrides:
hashCodein classObject- Returns:
- an int representing the hash code of this BasicAttributes instance.
- See Also:
equals(java.lang.Object)
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-javax/naming/directory/basicattributes.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor dieser Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.