java.lang.Object
org.bedework.carddav.server.dirHandlers.ldap.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()
      Returns:
      Attributes
    • findAttr

      public Attribute findAttr(String attr)
      Find the attribute for this record with the given name.
      Parameters:
      attr - name
      Returns:
      Attribute
    • setAttr

      public void setAttr(String attr, Object val)
      Set the attribute value in the table. Replaces any existing value(s) This does not write back to the directory
      Parameters:
      attr - name
      val - and value
    • clear

      public void clear()
      Should be overriden to clear attributes.
    • setName

      public void setName(String val)
      Set the name for this record.
      Parameters:
      val - name
    • getName

      public String getName()
      return the name for this record.
      Returns:
      String
    • setDn

      public void setDn(String val)
      Set the dn for this record.
      Parameters:
      val - the dn for this record.
    • getDn

      public String getDn()
      return the dn for this record.
      Returns:
      String
    • equals

      public boolean equals(DirRecord that)
      Compare this with that. Return true if they are equal.
      Parameters:
      that - DirRecord
      Returns:
      boolean
    • equals

      public boolean equals(DirRecord that, String[] thisAttrIDs, String[] thatAttrIDs)
      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
    • equals

      public boolean equals(DirRecord that, String[] attrIDs)
      Simpler form of equals in which attributes have the same names in both records.
      Parameters:
      that -
      attrIDs -
      Returns:
      boolean
    • equalsAllBut

      public boolean equalsAllBut(DirRecord that, String[] attrIDs)
      This compares all but the named attributes allbut true => All must be equal except those on the list
      Parameters:
      that -
      attrIDs -
      Returns:
      boolean
    • attrEquals

      public boolean attrEquals(Attribute thisA, Attribute that)
      Parameters:
      thisA -
      that -
      Returns:
      boolean
    • attrValCompare

      public int attrValCompare(Object val, Attribute that, boolean ignoreCase)
      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
    • attrValCompare

      public int attrValCompare(Object val, String attrName, boolean ignoreCase)
      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
    • dnEquals

      public boolean dnEquals(DirRecord that)
      Check dns for equality
      Parameters:
      that - other dn
      Returns:
      boolean
    • addAttr

      public void addAttr(String attr, Object val)
      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
    • getAttrVal

      public Object getAttrVal(String attr)
      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
    • contains

      public boolean contains(Attribute attr)
      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
    • attrElements

      public NamingEnumeration<?> attrElements(String attr)
      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.

      Parameters:
      attr -
      Returns:
      NamingEnumeration
    • getAttrStr

      public String getAttrStr(String attr)
      getAttrStr - return first (or only) string value for given attribute
      Parameters:
      attr - String attribute name
      Returns:
      String attribute value
    • getIsContent

      public boolean getIsContent()
      Returns:
      boolean
    • getChangeType

      public int getChangeType()
      Returns:
      int
    • getMods

      public ModificationItem[] getMods()
      Returns:
      ModificationItem[]
    • setIsContent

      public void setIsContent(boolean val)
      Parameters:
      val - true if is content
    • setChangeType

      public void setChangeType(int val)
      Parameters:
      val -