Class ColumnVisibility
java.lang.Object
org.apache.accumulo.core.security.ColumnVisibility
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
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A node in the parse tree for a visibility expression.static class
A node comparator.static enum
The node types in a parse tree for a visibility expression. -
Constructor Summary
ConstructorDescriptionCreates an empty visibility.ColumnVisibility
(byte[] expression) Creates a column visibility for a Mutation from a string already encoded in UTF-8 bytes.ColumnVisibility
(String expression) Creates a column visibility for a Mutation.ColumnVisibility
(org.apache.hadoop.io.Text expression) Creates a column visibility for a Mutation. -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
equals
(ColumnVisibility otherLe) Compares two ColumnVisibilities for string equivalence, not as a meaningful comparison of terms and conditions.byte[]
flatten()
Generates a byte[] that represents a normalized, but logically equivalent, form of this evaluator's expression.byte[]
Accessor for the underlying byte string.Gets the parse tree for this column visibility.int
hashCode()
static ColumnVisibility.Node
normalize
(ColumnVisibility.Node root, byte[] expression) static ColumnVisibility.Node
normalize
(ColumnVisibility.Node root, byte[] expression, ColumnVisibility.NodeComparator comparator) static byte[]
quote
(byte[] term) Properly quotes terms in a column visibility expression.static String
Properly quotes terms in a column visibility expression.static void
stringify
(ColumnVisibility.Node root, byte[] expression, StringBuilder out) toString()
-
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
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
-
normalize
public static ColumnVisibility.Node normalize(ColumnVisibility.Node root, byte[] expression, ColumnVisibility.NodeComparator comparator) -
stringify
-
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
-
equals
-
equals
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() -
getParseTree
Gets the parse tree for this column visibility.- Returns:
- parse tree node
-
quote
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:
-