Class DNSet

java.lang.Object
com.isode.dsapi.util.DNSet
All Implemented Interfaces:
Iterable<DN>, Collection<DN>, Set<DN>

public class DNSet extends Object implements Set<DN>
A class which contains a set of DNs stored in memory in a very compact form (backed by a DS_DNIndex). This might be slower than a normal Set (due to conversions and JNI), but the point is more the compactness of the storage, allowing very large lists of DNs to be represented in memory.

Note that DN comparison is done without using the syntax-specific comparison routines -- instead only case-exact or case-insensitive matches are done, according to the attribute. This means that alternative textual representations of the same value (e.g. with/without insignificant spaces) will appear as different DNs in the set. It is important that DNSet is not used in situations where this would be a problem.

Since:
14.6
Author:
jp
  • Constructor Details

  • Method Details

    • size

      public int size()
      Return the size of the set. This has to iterate through the whole set to count the items.
      Specified by:
      size in interface Collection<DN>
      Specified by:
      size in interface Set<DN>
    • isEmpty

      public boolean isEmpty()
      Test whether the set is empty.
      Specified by:
      isEmpty in interface Collection<DN>
      Specified by:
      isEmpty in interface Set<DN>
    • contains

      public boolean contains(Object o)
      Test whether the set contains the given DN.
      Specified by:
      contains in interface Collection<DN>
      Specified by:
      contains in interface Set<DN>
    • iterator

      public Iterator<DN> iterator()
      Iterate through the DNs in the set. Note that this has some restrictions: that modifictions are not permitted during the iteration (not even removal), and it is not possible to have more than one simultaneous iterator.
      Specified by:
      iterator in interface Collection<DN>
      Specified by:
      iterator in interface Iterable<DN>
      Specified by:
      iterator in interface Set<DN>
    • toArray

      public Object[] toArray()
      Convert into an array.
      Specified by:
      toArray in interface Collection<DN>
      Specified by:
      toArray in interface Set<DN>
    • toArray

      public <T> T[] toArray(T[] arr)
      Convert into an array. Always throws away the argument array, so better to just use toArray().
      Specified by:
      toArray in interface Collection<DN>
      Specified by:
      toArray in interface Set<DN>
    • add

      public boolean add(DN dn)
      Add a DN to the set.
      Specified by:
      add in interface Collection<DN>
      Specified by:
      add in interface Set<DN>
    • remove

      public boolean remove(Object o)
      Remove a DN from the set.
      Specified by:
      remove in interface Collection<DN>
      Specified by:
      remove in interface Set<DN>
    • containsAll

      public boolean containsAll(Collection<?> c)
      Check whether the set contains all the provided DNs.
      Specified by:
      containsAll in interface Collection<DN>
      Specified by:
      containsAll in interface Set<DN>
    • addAll

      public boolean addAll(Collection<? extends DN> c)
      Add all the provided DNs to the set.
      Specified by:
      addAll in interface Collection<DN>
      Specified by:
      addAll in interface Set<DN>
    • retainAll

      public boolean retainAll(Collection<?> c)
      Unsupported.
      Specified by:
      retainAll in interface Collection<DN>
      Specified by:
      retainAll in interface Set<DN>
    • removeAll

      public boolean removeAll(Collection<?> c)
      Remove all DNs that match DNs in the given collection.
      Specified by:
      removeAll in interface Collection<DN>
      Specified by:
      removeAll in interface Set<DN>
    • clear

      public void clear()
      Clear the set.
      Specified by:
      clear in interface Collection<DN>
      Specified by:
      clear in interface Set<DN>
    • equals

      public boolean equals(Object o)
      We don't support comparison of sets, so only return true if this is the exact same DNSet.
      Specified by:
      equals in interface Collection<DN>
      Specified by:
      equals in interface Set<DN>
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Generate a hash.
      Specified by:
      hashCode in interface Collection<DN>
      Specified by:
      hashCode in interface Set<DN>
      Overrides:
      hashCode in class Object
    • finalize

      protected void finalize() throws Throwable
      Release any native structures associated with this object.
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • toString

      public String toString()
      Returns a String representation of the object
      Overrides:
      toString in class Object
      Returns:
      String representation of the object