Class DirRecord
- java.lang.Object
-
- org.bedework.util.directory.common.DirRecord
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
BasicDirRecord
public abstract class DirRecord extends Object implements Serializable
This class represents a directory record which may be built from a number of attributes, retrieved as a search result or read from some input stream.We will implement some aspects of the ldif as defined in RFC 2849 within this class. These will be related to the content vs change records. By default, a DirRecord object will be a content record. However, we will allow the creation of change type records. Having this defined here allows applications to pass around DirRecord objects without any idea of the underlying implementation.
Currently the following is implemented:
- content records Consist of a dn with an associated set of attributes with values. No attribute options are implemented. Encoded strings may be converted incorrectly (need to check locale specifics)
- change records.
- add: Implemented. Look just like content records.
- delete: Implemented. Consist of a dn only.
- all others are unimplemented.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static intchangeTypeAddstatic intchangeTypeDeletestatic intchangeTypeInvalidstatic intchangeTypeModdnstatic intchangeTypeModify
-
Constructor Summary
Constructors Constructor Description DirRecord()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddAttr(String attr, Object val)Add the attribute value to the table.NamingEnumerationattrElements(String attr)Retrieve an enumeration of the named attribute's values.booleanattrEquals(Attribute thisA, Attribute that)intattrValCompare(Object val, String attrName, boolean ignoreCase)Extract the target attribute from this record then compare the given single value with the attribute value(s).intattrValCompare(Object val, Attribute that, boolean ignoreCase)Compare the given single value with the attribute value(s).voidclear()Should be overriden to clear attributes.booleancontains(Attribute attr)Return true if the record contains all of the values of the given attribute.booleandnEquals(DirRecord that)Check dns for equalitybooleanequals(DirRecord that)Compare this with that.booleanequals(DirRecord that, String[] attrIDs)Simpler form of equals in which attributes have the same names in both records.booleanequals(DirRecord that, String[] thisAttrIDs, String[] thatAttrIDs)Compare this with that only looking at the named attributes.booleanequalsAllBut(DirRecord that, String[] attrIDs)This compares all but the named attributes allbut true => All must be equal except those on the listAttributefindAttr(String attr)Find the attribute for this record with the given name.abstract AttributesgetAttributes()StringgetAttrStr(String attr)getAttrStr - return first (or only) string value for given attributeObjectgetAttrVal(String attr)getAttrVal - return first (or only) value for given attribute "dn" is treated as an attribute name.intgetChangeType()StringgetDn()return the dn for this record.booleangetIsContent()ModificationItem[]getMods()StringgetName()return the name for this record.voidsetAttr(String attr, Object val)Set the attribute value in the table.voidsetChangeType(int val)voidsetDn(String val)Set the dn for this record.voidsetIsContent(boolean val)voidsetName(String val)Set the name for this record.
-
-
-
Field Detail
-
changeTypeInvalid
public static final int changeTypeInvalid
- See Also:
- Constant Field Values
-
changeTypeAdd
public static final int changeTypeAdd
- See Also:
- Constant Field Values
-
changeTypeDelete
public static final int changeTypeDelete
- See Also:
- Constant Field Values
-
changeTypeModify
public static final int changeTypeModify
- See Also:
- Constant Field Values
-
changeTypeModdn
public static final int changeTypeModdn
- See Also:
- Constant Field Values
-
-
Method Detail
-
getAttributes
public abstract Attributes getAttributes() throws NamingException
- Returns:
- Attributes
- Throws:
NamingException
-
findAttr
public Attribute findAttr(String attr) throws NamingException
Find the attribute for this record with the given name. Return null if not defind.- Parameters:
attr-- Returns:
- Attribute
- Throws:
NamingException
-
setAttr
public void setAttr(String attr, Object val) throws NamingException
Set the attribute value in the table. Replaces any existing value(s) This does not write back to the directory- Parameters:
attr-val-- Throws:
NamingException
-
clear
public void clear()
Should be overriden to clear attributes.
-
setName
public void setName(String val) throws NamingException
Set the name for this record.- Parameters:
val-- Throws:
NamingException
-
getName
public String getName() throws Throwable
return the name for this record.- Returns:
- String
- Throws:
Throwable
-
setDn
public void setDn(String val) throws NamingException
Set the dn for this record.- Parameters:
val-- Throws:
NamingException
-
getDn
public String getDn() throws NamingException
return the dn for this record.- Returns:
- String
- Throws:
NamingException
-
equals
public boolean equals(DirRecord that) throws NamingException
Compare this with that. Return true if they are equal.- Parameters:
that-- Returns:
- boolean
- Throws:
NamingException
-
equals
public boolean equals(DirRecord that, String[] thisAttrIDs, String[] thatAttrIDs) throws NamingException
Compare this with that only looking at the named attributes. For this method, the dns must be equal and the values of the named attributes must be equal but their names may differ. The two arrays of attrIDs must be non-null and of the same length or an exception is raised. If there are no attributes in both records they are considered equal. If there are no attributes in only one record they are unequal. Zero length attrID lists means only the dn is compared.- Parameters:
that-thisAttrIDs-thatAttrIDs-- Returns:
- boolean
- Throws:
NamingException
-
equals
public boolean equals(DirRecord that, String[] attrIDs) throws NamingException
Simpler form of equals in which attributes have the same names in both records.- Parameters:
that-attrIDs-- Returns:
- boolean
- Throws:
NamingException
-
equalsAllBut
public boolean equalsAllBut(DirRecord that, String[] attrIDs) throws NamingException
This compares all but the named attributes allbut true => All must be equal except those on the list- Parameters:
that-attrIDs-- Returns:
- boolean
- Throws:
NamingException
-
attrEquals
public boolean attrEquals(Attribute thisA, Attribute that) throws NamingException
- Parameters:
thisA-that-- Returns:
- boolean
- Throws:
NamingException
-
attrValCompare
public int attrValCompare(Object val, Attribute that, boolean ignoreCase) throws NamingException
Compare the given single value with the attribute value(s).- Parameters:
val-that-ignoreCase-- Returns:
- -2 for not equal or not present in multi-valued attribute -1 for val < that 0 for val = that 1 for val > that 2 for val present in multi-valued attr
- Throws:
NamingException
-
attrValCompare
public int attrValCompare(Object val, String attrName, boolean ignoreCase) throws NamingException
Extract the target attribute from this record then compare the given single value with the attribute value(s).- Parameters:
val-attrName-ignoreCase-- Returns:
- -2 for not equal or not present in multi-valued attribute -1 for val < that 0 for val = that 1 for val > that 2 for val present in multi-valued attr
- Throws:
NamingException
-
dnEquals
public boolean dnEquals(DirRecord that) throws NamingException
Check dns for equality- Parameters:
that-- Returns:
- boolean
- Throws:
NamingException
-
addAttr
public void addAttr(String attr, Object val) throws NamingException
Add the attribute value to the table. If an attribute already exists add it to the end of its values.- Parameters:
attr- String attribute nameval- Object value- Throws:
NamingException
-
getAttrVal
public Object getAttrVal(String attr) throws NamingException
getAttrVal - return first (or only) value for given attribute "dn" is treated as an attribute name.- Parameters:
attr- String attribute name- Returns:
- Object attribute value
- Throws:
NamingException
-
contains
public boolean contains(Attribute attr) throws NamingException
Return true if the record contains all of the values of the given attribute.- Parameters:
attr- Attribute we're looking for- Returns:
- boolean true if we found it
- Throws:
NamingException
-
attrElements
public NamingEnumeration attrElements(String attr) throws NamingException
Retrieve an enumeration of the named attribute's values. The behaviour of this enumeration is unspecified if the the attribute's values are added, changed, or removed while the enumeration is in progress. If the attribute values are ordered, the enumeration's items will be ordered. Each element of the enumeration is a possibly null Object. The object's class is the class of the attribute value. The element is null if the attribute's value is null. If the attribute has zero values, an empty enumeration is returned.- Returns:
- A non-null enumeration of the attribute's values.
- Throws:
NamingException- If a naming exception was encountered while retrieving the values.
-
getAttrStr
public String getAttrStr(String attr) throws NamingException
getAttrStr - return first (or only) string value for given attribute- Parameters:
attr- String attribute name- Returns:
- String attribute value
- Throws:
NamingException
-
getIsContent
public boolean getIsContent()
- Returns:
- boolean
-
getChangeType
public int getChangeType()
- Returns:
- int
-
getMods
public ModificationItem[] getMods() throws NamingException
- Returns:
- ModificationItem[]
- Throws:
ThrowableNamingException
-
setIsContent
public void setIsContent(boolean val)
- Parameters:
val-
-
setChangeType
public void setChangeType(int val)
- Parameters:
val-
-
-