org.apache.accumulo.core.security
Class ColumnVisibility

java.lang.Object
  extended by 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.


Nested Class Summary
static class ColumnVisibility.Node
           
static class ColumnVisibility.NodeComparator
           
static class ColumnVisibility.NodeType
           
 
Constructor Summary
ColumnVisibility()
          Empty visibility.
ColumnVisibility(byte[] expression)
          A convenience method for constructing from a string already encoded in UTF-8 bytes.
ColumnVisibility(String expression)
          Set the column visibility for a Mutation.
ColumnVisibility(org.apache.hadoop.io.Text expression)
          A convenience method for constructing from a string already encoded in UTF-8 bytes and contained in a Text object.
 
Method Summary
 boolean equals(ColumnVisibility otherLe)
          Compares two ColumnVisibilities for string equivalence, not as a meaningful comparison of terms and conditions.
 boolean equals(Object obj)
          See equals(ColumnVisibility)
 byte[] flatten()
          Generates a byte[] that represents a normalized, but logically equivalent, form of the supplied expression.
 byte[] getExpression()
          Accessor for the underlying byte string.
 ColumnVisibility.Node getParseTree()
           
 int hashCode()
           
static byte[] quote(byte[] term)
          A convenience method to quote terms which are already encoded as UTF-8 bytes.
static String quote(String term)
          Use to properly quote terms in a column visibility expression.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ColumnVisibility

public ColumnVisibility()
Empty visibility. Normally, elements with empty visibility can be seen by everyone. Though, one could change this behavior with filters.

See Also:
ColumnVisibility(String)

ColumnVisibility

public ColumnVisibility(String expression)
Set the column visibility for a Mutation.

Parameters:
expression - An expression of the rights needed to see this mutation. 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
 

You can use any character you like in your column visibility expression with quoting. If your quoted term contains '"' or '\' then escape them with '\'. The quote(String) method will properly quote and escape terms for you.

 "A#C"&B
 

ColumnVisibility

public ColumnVisibility(org.apache.hadoop.io.Text expression)
A convenience method for constructing from a string already encoded in UTF-8 bytes and contained in a Text object.

See Also:
ColumnVisibility(String)

ColumnVisibility

public ColumnVisibility(byte[] expression)
A convenience method for constructing from a string already encoded in UTF-8 bytes.

See Also:
ColumnVisibility(String)
Method Detail

getExpression

public byte[] getExpression()
Accessor for the underlying byte string.

Returns:
byte array representation of a visibility expression

flatten

public byte[] flatten()
Generates a byte[] that represents a normalized, but logically equivalent, form of the supplied expression.

Returns:
normalized expression in byte[] form

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
See equals(ColumnVisibility)

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.


hashCode

public int hashCode()
Overrides:
hashCode in class Object

getParseTree

public ColumnVisibility.Node getParseTree()

quote

public static String quote(String term)
Use to properly quote 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;
   .
   .
   .
 ColumnVisibility cv = new ColumnVisibility(quote("A#C") + "&" + quote("FOO"));
 


quote

public static byte[] quote(byte[] term)
A convenience method to quote terms which are already encoded as UTF-8 bytes.

See Also:
quote(String)


Copyright © 2013 Apache Accumulo Project. All Rights Reserved.