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:
  • Field Details

  • Constructor Details

    • DirRecord

      public DirRecord()
  • Method Details

    • 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 name
      val - 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:
      Throwable
      NamingException
    • setIsContent

      public void setIsContent(boolean val)
      Parameters:
      val -
    • setChangeType

      public void setChangeType(int val)
      Parameters:
      val -