com.ca.commons.naming
Class DXAttribute

java.lang.Object
  |
  +--javax.naming.directory.BasicAttribute
        |
        +--com.ca.commons.naming.DXAttribute
All Implemented Interfaces:
javax.naming.directory.Attribute, java.lang.Cloneable, java.io.Serializable

public class DXAttribute
extends javax.naming.directory.BasicAttribute

This is largely a schema-aware wrapper to BasicAttribute, with some utility classes spliced on.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.naming.directory.BasicAttribute
attrID, ordered, values
 
Fields inherited from interface javax.naming.directory.Attribute
serialVersionUID
 
Constructor Summary
DXAttribute(javax.naming.directory.Attribute att)
          Make a copy of a normal, pre-existing attribute.
DXAttribute(java.lang.String ID)
          Normal constructor for an Attribute with no (current) value.
DXAttribute(java.lang.String ID, javax.naming.NamingEnumeration values)
           
DXAttribute(java.lang.String ID, java.lang.Object value)
          Normal constructor an Attribute with a single value.
 
Method Summary
 void addValues(javax.naming.NamingEnumeration values)
           
 boolean checkIsBinaryInSchema()
           
 boolean checkKnownBinaryAttributes(java.lang.String ID)
           
 javax.naming.directory.DirContext getAttributeDefinition()
          implements the interface spec.
 javax.naming.directory.DirContext getAttributeSyntaxDefinition()
          implements the interface spec.
 java.lang.String getDescription()
          Returns the attribute's 'DESC' field from the attribute schema definition, if such exists (it's an extension).
 java.lang.String getID()
           
 java.lang.String getName()
           
 java.lang.String[] getOptions()
          IF a description field has been set in the schema, and IF that description field LISTs a set of values, read 'em and return them as a string array.
 javax.naming.directory.DirContext getSchema()
          Utility method - returns the schema context in use by this attribute.
 java.lang.String getSyntaxDesc()
          Returns (and caches) the syntax description.
 java.lang.String getSyntaxOID()
           
 java.lang.Object[] getValues()
          This method gets all the values of an attribute.
 boolean hasOptions()
           
 boolean isBinary()
          Whether the attribute contains binary data; ideally found by checking Syntax, but often set by inspection of the attribute value (whether it is a Byte array).
static boolean isBinarySyntax(java.lang.String syntaxName)
           
static boolean isEmpty(javax.naming.directory.Attribute att)
          Does this attribute have a valid value (i.e. not null, or empty string).
 java.lang.String schemaLookup(java.lang.String schemaEntry, java.lang.String schemaAttribute)
          Utility Function: takes a schema Entry class such as 'AttributeDefinition/cn', * and returns the result of looking up a particular attribute within that (e.g.
 void setBinary(boolean bin)
          Sets the binary status of the attribute.
 void setBinaryness()
          This method examines the schema to test whether the attribute is 'binary' data.
static void setDefaultSchema(javax.naming.directory.DirContext defaultSchema)
          This sets the standard schema to use while this connection is open.
 void setName(java.lang.String newName)
          Usefull escape to allow renaming of attributes.
 void setOrdered(boolean state)
           
 void setVerboseBinary(boolean status)
           
 java.lang.String toString()
          General descriptive string: used mainly for debugging...
 void trim()
          Gets rid of null values and empty strings from the value set.
 java.lang.String unEscape(java.lang.String escapeMe)
           
 
Methods inherited from class javax.naming.directory.BasicAttribute
add, add, clear, clone, contains, equals, get, get, getAll, hashCode, isOrdered, remove, remove, set, size
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DXAttribute

public DXAttribute(java.lang.String ID)
Normal constructor for an Attribute with no (current) value.


DXAttribute

public DXAttribute(java.lang.String ID,
                   java.lang.Object value)
Normal constructor an Attribute with a single value.


DXAttribute

public DXAttribute(javax.naming.directory.Attribute att)
Make a copy of a normal, pre-existing attribute.

Parameters:
att - the attribute (e.g. BasicAttribute) to wrap.

DXAttribute

public DXAttribute(java.lang.String ID,
                   javax.naming.NamingEnumeration values)
Method Detail

addValues

public void addValues(javax.naming.NamingEnumeration values)

setDefaultSchema

public static void setDefaultSchema(javax.naming.directory.DirContext defaultSchema)
This sets the standard schema to use while this connection is open. (It may be possible in future releases to set schema on a per-Attribute basis - it is not clear yet whether this would be useful.)


setBinaryness

public void setBinaryness()
This method examines the schema to test whether the attribute is 'binary' data. In this context, 'binary' simply means 'not string'; i.e. photo, certificate, octet etc.


isEmpty

public static boolean isEmpty(javax.naming.directory.Attribute att)
Does this attribute have a valid value (i.e. not null, or empty string).


getSchema

public javax.naming.directory.DirContext getSchema()
Utility method - returns the schema context in use by this attribute.


getAttributeDefinition

public javax.naming.directory.DirContext getAttributeDefinition()
implements the interface spec.

Specified by:
getAttributeDefinition in interface javax.naming.directory.Attribute
Overrides:
getAttributeDefinition in class javax.naming.directory.BasicAttribute

checkKnownBinaryAttributes

public boolean checkKnownBinaryAttributes(java.lang.String ID)

isBinarySyntax

public static boolean isBinarySyntax(java.lang.String syntaxName)

checkIsBinaryInSchema

public boolean checkIsBinaryInSchema()

getAttributeSyntaxDefinition

public javax.naming.directory.DirContext getAttributeSyntaxDefinition()
implements the interface spec.

Specified by:
getAttributeSyntaxDefinition in interface javax.naming.directory.Attribute
Overrides:
getAttributeSyntaxDefinition in class javax.naming.directory.BasicAttribute

isBinary

public boolean isBinary()
Whether the attribute contains binary data; ideally found by checking Syntax, but often set by inspection of the attribute value (whether it is a Byte array).


setBinary

public void setBinary(boolean bin)
Sets the binary status of the attribute. Shouldn't be required any more; should be set by syntax checking.


schemaLookup

public java.lang.String schemaLookup(java.lang.String schemaEntry,
                                     java.lang.String schemaAttribute)
Utility Function: takes a schema Entry class such as 'AttributeDefinition/cn', * and returns the result of looking up a particular attribute within that (e.g. 'DESC').

Parameters:
schemaEntry - the full schema entry name to lookup, e.g. 'ClassDefinition/alias'
schemaAttribute - the attribute to look up, e.g. 'MUST'
Returns:
the value of the schema entry attribute (e.g. '2.5.4.1')

hasOptions

public boolean hasOptions()

getOptions

public java.lang.String[] getOptions()
IF a description field has been set in the schema, and IF that description field LISTs a set of values, read 'em and return them as a string array.


unEscape

public java.lang.String unEscape(java.lang.String escapeMe)

getSyntaxOID

public java.lang.String getSyntaxOID()

setName

public void setName(java.lang.String newName)
Usefull escape to allow renaming of attributes. Use with caution, since an arbitrary name may not correspond to a valid schema name.


getName

public java.lang.String getName()

getSyntaxDesc

public java.lang.String getSyntaxDesc()
Returns (and caches) the syntax description.


getDescription

public java.lang.String getDescription()
Returns the attribute's 'DESC' field from the attribute schema definition, if such exists (it's an extension). Not to be confused with the Syntax Description, which is something like "binary".


toString

public java.lang.String toString()
General descriptive string: used mainly for debugging...

Overrides:
toString in class javax.naming.directory.BasicAttribute

setVerboseBinary

public void setVerboseBinary(boolean status)

getID

public java.lang.String getID()
Specified by:
getID in interface javax.naming.directory.Attribute
Overrides:
getID in class javax.naming.directory.BasicAttribute

getValues

public java.lang.Object[] getValues()
This method gets all the values of an attribute. Useful only for multivalued attributes (use get() otherwise).

Returns:
all the values of this attribute in a String Array.

trim

public void trim()
Gets rid of null values and empty strings from the value set.


setOrdered

public void setOrdered(boolean state)