java.lang.Objectjavax.naming.directory.BasicAttribute
This class provides a basic implementation of the Attribute interface.
This implementation does not support the schema methods getAttributeDefinition() and getAttributeSyntaxDefinition(). They simply throw OperationNotSupportedException. Subclasses of BasicAttribute should override these methods if they support them.
The BasicAttribute class by default uses Object.equals() to determine equality of attribute values when testing for equality or when searching for values, except when the value is an array. For an array, each element of the array is checked using Object.equals(). Subclasses of BasicAttribute can make use of schema information when doing similar equality checks by overriding methods in which such use of schema is meaningful. Similarly, the BasicAttribute class by default returns the values passed to its constructor and/or manipulated using the add/remove methods. Subclasses of BasicAttribute can override get() and getAll() to get the values dynamically from the directory (or implement the Attribute interface directly instead of subclassing BasicAttribute).
Note that updates to BasicAttribute (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 DirContext interface.
A BasicAttribute instance is not synchronized against concurrent multithreaded access. Multiple threads trying to access and modify a BasicAttribute should lock the object.
Field Summary | |
---|---|
protected String |
attrID
Holds the attribute's id. |
protected boolean |
ordered
A flag for recording whether this attribute's values are ordered. |
protected Vector<Object> |
values
Holds the attribute's values. |
Constructor Summary | |
---|---|
BasicAttribute(String id)
Constructs a new instance of an unordered attribute with no value. |
|
BasicAttribute(String id,
boolean ordered)
Constructs a new instance of a possibly ordered attribute with no value. |
|
BasicAttribute(String id,
Object value)
Constructs a new instance of an unordered attribute with a single value. |
|
BasicAttribute(String id,
Object value,
boolean ordered)
Constructs a new instance of a possibly ordered attribute with a single value. |
Method Summary | |
---|---|
void |
add(int ix,
Object attrVal)
Adds an attribute value to the ordered list of attribute values. |
boolean |
add(Object attrVal)
Adds a new value to this attribute. |
void |
clear()
Removes all values from this attribute. |
Object |
clone()
Creates and returns a copy of this object. |
boolean |
contains(Object attrVal)
Determines whether a value is in this attribute. |
boolean |
equals(Object obj)
Determines whether obj is equal to this attribute. |
Object |
get()
Retrieves one of this attribute's values. |
Object |
get(int ix)
Retrieves the attribute value from the ordered list of attribute values. |
NamingEnumeration<?> |
getAll()
Retrieves an enumeration of this attribute's values. |
DirContext |
getAttributeDefinition()
Retrieves this attribute's schema definition. |
DirContext |
getAttributeSyntaxDefinition()
Retrieves the syntax definition associated with this attribute. |
String |
getID()
Retrieves the id of this attribute. |
int |
hashCode()
Calculates the hash code of this attribute. |
boolean |
isOrdered()
Determines whether this attribute's values are ordered. |
Object |
remove(int ix)
Removes an attribute value from the ordered list of attribute values. |
boolean |
remove(Object attrval)
Removes a specified value from this attribute. |
Object |
set(int ix,
Object attrVal)
Sets an attribute value in the ordered list of attribute values. |
int |
size()
Retrieves the number of values in this attribute. |
String |
toString()
Generates the string representation of this attribute. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected String attrID
protected transient Vector<Object> values
protected boolean ordered
Constructor Detail |
---|
public BasicAttribute(String id)
id
- The attribute's id. It cannot be null.public BasicAttribute(String id, Object value)
id
- The attribute's id. It cannot be null.value
- The attribute's value. If null, a null
value is added to the attribute.public BasicAttribute(String id, boolean ordered)
id
- The attribute's id. It cannot be null.ordered
- true means the attribute's values will be ordered;
false otherwise.public BasicAttribute(String id, Object value, boolean ordered)
id
- The attribute's id. It cannot be null.value
- The attribute's value. If null, a null
value is added to the attribute.ordered
- true means the attribute's values will be ordered;
false otherwise.Method Detail |
---|
public Object clone()
Object
will be true, and that the expression:
x.clone() != x
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().getClass() == x.getClass()
will be true, this is not an absolute requirement.
x.clone().equals(x)
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.
The method clone for class Object performs a specific cloning operation. First, if the class of this object does not implement the interface Cloneable, then a CloneNotSupportedException is thrown. Note that all arrays are considered to implement the interface Cloneable. 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 Object does not itself implement the interface Cloneable, so calling the clone method on an object whose class is Object will result in throwing an exception at run time.
Cloneable
public boolean equals(Object obj)
By default Object.equals() 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 Object.equals(). 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 equals(), it should also override hashCode() such that two attributes that are equal have the same hash code.
obj
- The possibly null object to check.
hashCode()
,
contains(java.lang.Object)
public int hashCode()
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 hashCode(), it should override equals() as well so that two attributes that are equal have the same hash code.
equals(java.lang.Object)
public String toString()
public NamingEnumeration<?> getAll() throws NamingException
By default, the values returned are those passed to the constructor and/or manipulated using the add/replace/remove methods. A subclass may override this to retrieve the values dynamically from the directory.
NamingException
- If a naming exception was encountered while retrieving
the values.Attribute.isOrdered()
public Object get() throws NamingException
By default, the value returned is one of those passed to the constructor and/or manipulated using the add/replace/remove methods. A subclass may override this to retrieve the value dynamically from the directory.
NamingException
- If a naming exception was encountered while retrieving
the value.public int size()
Attribute
public String getID()
Attribute
public boolean contains(Object attrVal)
By default, Object.equals() is used when comparing attrVal with this attribute's values except when attrVal is an array. For an array, each element of the array is checked using Object.equals(). A subclass may use schema information to determine equality.
attrVal
- The possibly null value to check. If null, check
whether the attribute has an attribute value whose value is null.
Object.equals(java.lang.Object)
,
equals(java.lang.Object)
public boolean add(Object attrVal)
By default, Object.equals() is used when comparing attrVal with this attribute's values except when attrVal is an array. For an array, each element of the array is checked using Object.equals(). A subclass may use schema information to determine equality.
attrVal
- The new possibly null value to add. If null, null
is added as an attribute value.
public boolean remove(Object attrval)
By default, Object.equals() is used when comparing attrVal with this attribute's values except when attrVal is an array. For an array, each element of the array is checked using Object.equals(). A subclass may use schema information to determine equality.
attrval
- The possibly null value to remove from this attribute.
If null, remove the attribute value that is null.
public void clear()
Attribute
public boolean isOrdered()
Attribute
Attribute.get(int)
,
Attribute.remove(int)
,
Attribute.add(int, java.lang.Object)
,
Attribute.set(int, java.lang.Object)
public Object get(int ix) throws NamingException
Attribute
ix
- The index of the value in the ordered list of attribute values.
0 <= ix < size().
NamingException
- If a naming exception was encountered while
retrieving the value.public Object remove(int ix)
Attribute
ix
- The index of the value to remove.
0 <= ix < size().
public void add(int ix, Object attrVal)
Attribute
ix
- The index in the ordered list of attribute values to add the new value.
0 <= ix <= size().attrVal
- The possibly null attribute value to add; if null, null is
the value added.public Object set(int ix, Object attrVal)
Attribute
ix
- The index of the value in the ordered list of attribute values.
0 <= ix < size().attrVal
- The possibly null attribute value to use.
If null, 'null' replaces the old value.
public DirContext getAttributeSyntaxDefinition() throws NamingException
This method by default throws OperationNotSupportedException. A subclass should override this method if it supports schema.
getAttributeSyntaxDefinition
in interface Attribute
OperationNotSupportedException
- If getting the schema
is not supported.
NamingException
- If a naming exception occurs while getting
the schema.public DirContext getAttributeDefinition() throws NamingException
This method by default throws OperationNotSupportedException. A subclass should override this method if it supports schema.
getAttributeDefinition
in interface Attribute
OperationNotSupportedException
- If getting the schema
is not supported.
NamingException
- If a naming exception occurs while getting
the schema.Ces informations proviennent du site de http://java.sun.com
Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :
Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.
Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.
Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.
Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.
Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.
Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.
7 mots clés dont 0 définis manuellement (plus d'information...).
Avertissement
Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.