Class ColumnVisibility

java.lang.Object
org.apache.accumulo.core.security.ColumnVisibility

public class ColumnVisibility extends Object
Validate the column visibility is a valid expression and set the visibility for a Mutation. See ColumnVisibility(byte[]) for the definition of an expression.

The expression is a sequence of characters from the set [A-Za-z0-9_-.] along with the binary operators "&" and "|" indicating that both operands are necessary, or the either is necessary. The following are valid expressions for visibility:

 A
 A|B
 (A|B)&(C|D)
 orange|(red&yellow)
 

The following are not valid expressions for visibility:

 A|B&C
 A=B
 A|B|
 A&|B
 ()
 )
 dog|!cat
 

In addition to the base set of visibilities, any character can be used in the expression if it is quoted. If the quoted term contains '"' or '\', then escape the character with '\'. The quote(String) method can be used to properly quote and escape terms automatically. The following is an example of a quoted term:

 "A#C" & B
 
  • Constructor Details

    • ColumnVisibility

      public ColumnVisibility()
      Creates an empty visibility. Normally, elements with empty visibility can be seen by everyone. Though, one could change this behavior with filters.
      See Also:
    • ColumnVisibility

      public ColumnVisibility(String expression)
      Creates a column visibility for a Mutation.
      Parameters:
      expression - An expression of the rights needed to see this mutation. The expression syntax is defined at the class-level documentation
    • ColumnVisibility

      public ColumnVisibility(org.apache.hadoop.io.Text expression)
      Creates a column visibility for a Mutation.
      Parameters:
      expression - visibility expression
      See Also:
    • ColumnVisibility

      public ColumnVisibility(byte[] expression)
      Creates a column visibility for a Mutation from a string already encoded in UTF-8 bytes.
      Parameters:
      expression - visibility expression, encoded as UTF-8 bytes
      See Also:
  • Method Details

    • getExpression

      public byte[] getExpression()
      Accessor for the underlying byte string.
      Returns:
      byte array representation of a visibility expression
    • normalize

      public static ColumnVisibility.Node normalize(ColumnVisibility.Node root, byte[] expression)
    • normalize

      public static ColumnVisibility.Node normalize(ColumnVisibility.Node root, byte[] expression, ColumnVisibility.NodeComparator comparator)
    • stringify

      public static void stringify(ColumnVisibility.Node root, byte[] expression, StringBuilder out)
    • flatten

      public byte[] flatten()
      Generates a byte[] that represents a normalized, but logically equivalent, form of this evaluator's expression.
      Returns:
      normalized expression in byte[] form
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • equals

      public boolean equals(ColumnVisibility otherLe)
      Compares two ColumnVisibilities for string equivalence, not as a meaningful comparison of terms and conditions.
      Parameters:
      otherLe - other column visibility
      Returns:
      true if this visibility equals the other via string comparison
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getParseTree

      public ColumnVisibility.Node getParseTree()
      Gets the parse tree for this column visibility.
      Returns:
      parse tree node
    • quote

      public static String quote(String term)
      Properly quotes terms in a column visibility expression. If no quoting is needed, then nothing is done.

      Examples of using quote :

       import static org.apache.accumulo.core.security.ColumnVisibility.quote;
         .
         .
         .
       String s = quote("A#C") + "&" + quote("FOO");
       ColumnVisibility cv = new ColumnVisibility(s);
       
      Parameters:
      term - term to quote
      Returns:
      quoted term (unquoted if unnecessary)
    • quote

      public static byte[] quote(byte[] term)
      Properly quotes terms in a column visibility expression. If no quoting is needed, then nothing is done.
      Parameters:
      term - term to quote, encoded as UTF-8 bytes
      Returns:
      quoted term (unquoted if unnecessary), encoded as UTF-8 bytes
      See Also: