Class SimpleACIRule

All Implemented Interfaces:
Serializable, Cloneable, Iterable<SimpleACIRule.Tuple>, Collection<SimpleACIRule.Tuple>, List<SimpleACIRule.Tuple>, RandomAccess

public class SimpleACIRule extends ArrayList<SimpleACIRule.Tuple>
Representation a rule, which is a list of ACI tuples without role or area information. Note, however, that these rule tuples do include some area-related filters: objectclass filters (refinements) and also a flag that indicates that the rule only applies to the user's own entry.

The fields of this class may be accessed directly. There are also methods available to simplify access to some of the fields.

Since:
15.0
Author:
jp
See Also:
  • Field Details

    • label

      public String label
      Label of this rule.
    • note

      public String note
      Note to explain intended usage of rule, or ""
    • isGrant

      public boolean isGrant
      Are these grant rules (true) or deny rules (false)?
    • ORDER

      public static final Comparator<SimpleACIRule> ORDER
      Comparator to order SimpleACIRules by label.
  • Constructor Details

    • SimpleACIRule

      public SimpleACIRule(String label, boolean isGrant)
      Construct a rule with the given label and grant/deny status.
      Parameters:
      label - Name of rule
      isGrant - Is this a grant rule (true) or deny rule (false)?
  • Method Details

    • setNote

      public void setNote(String note)
      Set the note. This tidies the note before putting it into 'note', stripping off spaces and tabs at the beginnings or ends of lines.
      Parameters:
      note - Note to set, or "". Should never be null.
    • addTuple

      public SimpleACIRule.Tuple addTuple(String label)
      Add a new tuple to the list of tuples making up the rule, with the given label.
      Parameters:
      label - Name of tuple
      Returns:
      The new SimpleACIRule.Tuple created
    • setOriginal

      public void setOriginal(SimpleACIRule rule)
      Change the original SimpleACIRule used to support hasChanges().
    • getOriginal

      public SimpleACIRule getOriginal()
      Get the original SimpleACIRule associated with this role.
    • hasChanges

      public boolean hasChanges()
      Test whether there have been changes compared to the original rule. The rule is sorted internally to allow the comparison. If the original rule was not set, this method returns false.
      Returns:
      TRUE if there have been changes compared to the original rule; FALSE otherwise or if the original rule was not set.
    • equals

      public boolean equals(Object o)
      Test whether two rules are identical. The sort() method should have been called on both SimpleACIRule instances first or else the comparison may fail due to ordering issues.
      Specified by:
      equals in interface Collection<SimpleACIRule.Tuple>
      Specified by:
      equals in interface List<SimpleACIRule.Tuple>
      Overrides:
      equals in class ArrayList<SimpleACIRule.Tuple>
      Parameters:
      o - Object to compare to
      Returns:
      Test result
    • contentsHashCode

      public int contentsHashCode()
      Generate a hashcode which is based on the contents (as tested by contentsEqual()) and is not dependent on the order of the rules or the name.
      Returns:
      Hash code
    • hashCode

      public int hashCode()
      Generate a hashcode which is based on both the contents and the name.
      Specified by:
      hashCode in interface Collection<SimpleACIRule.Tuple>
      Specified by:
      hashCode in interface List<SimpleACIRule.Tuple>
      Overrides:
      hashCode in class ArrayList<SimpleACIRule.Tuple>
      Returns:
      Hash code
    • contentsEqual

      public boolean contentsEqual(SimpleACIRule bb)
      Test whether the contents of two rules is identical; that is, that all the data is the same apart from the labels. The sort() method should have been called on both SimpleACIRule instances first or else the comparison may fail due to ordering issues.
      Parameters:
      bb - SimpleACIRule to compare to
      Returns:
      Test result
    • sort

      public void sort()
      Sort the rule tuples into a consistent order. If all SimpleACIRule instances are sorted, then .equals() and .contentEqual() will work consistently even if the tuples were originally loaded in a different order. Otherwise comparisons are sensitive to the loading order.
    • dumpXML

      public void dumpXML(com.isode.util.XMLOutput out) throws IOException
      Dump rule as XML.
      Throws:
      IOException
    • loadXML

      public static SimpleACIRule loadXML(com.isode.util.XMLInput in)
      Try to load up SimpleACIRule from XML. Returns null if not found.
    • copyFrom

      public void copyFrom(SimpleACIRule rule)
      Copy data from the given rule.
      Parameters:
      rule - Rule to copy data from, must not be null.
    • deepCopy

      public SimpleACIRule deepCopy()
      Copy the rule, but not the 'original' references. This is cheap slow code -- it copies the tuples by converting them via XML. It could perhaps be improved if there was ever a need to do a lot of copying.
    • toString

      public String toString()
      Debugging dump.
      Overrides:
      toString in class AbstractCollection<SimpleACIRule.Tuple>
      Returns:
      Debugging dump