/** * Creates a new evaluator for the given collection of authorizations. * Each authorization string is escaped before handling, and the original * strings are unchanged. * * @param authorizations authorizations object */ public VisibilityEvaluator(Authorizations authorizations) { this.auths = escape((Authorizations) authorizations); }
/** * Creates a new evaluator for the given collection of authorizations. * Each authorization string is escaped before handling, and the original * strings are unchanged. * * @param authorizations authorizations object */ public VisibilityEvaluator(Authorizations authorizations) { this.auths = escape((Authorizations) authorizations); }
/** * Properly quotes terms in a column visibility expression. If no quoting is needed, then nothing is done. * * @param term term to quote, encoded as UTF-8 bytes * @return quoted term (unquoted if unnecessary), encoded as UTF-8 bytes * @see #quote(String) */ public static byte[] quote(byte[] term) { boolean needsQuote = false; for (int i = 0; i < term.length; i++) { if (!Authorizations.isValidAuthChar(term[i])) { needsQuote = true; break; } } if (!needsQuote) return term; return VisibilityEvaluator.escape(term, true); } }
/** * Properly quotes terms in a column visibility expression. If no quoting is needed, then nothing is done. * * @param term term to quote, encoded as UTF-8 bytes * @return quoted term (unquoted if unnecessary), encoded as UTF-8 bytes * @see #quote(String) */ public static byte[] quote(byte[] term) { boolean needsQuote = false; for (int i = 0; i < term.length; i++) { if (!Authorizations.isValidAuthChar(term[i])) { needsQuote = true; break; } } if (!needsQuote) return term; return VisibilityEvaluator.escape(term, true); } }
/** * Creates a new {@link Authorizations} object with escaped forms of the * authorizations in the given object. * * @param auths original authorizations * @return authorizations object with escaped authorization strings * @see #escape(byte[], boolean) */ static Authorizations escape(Authorizations auths) { ArrayList<byte[]> retAuths = new ArrayList<byte[]>(auths.getAuthorizations().size()); for (byte[] auth : auths.getAuthorizations()) retAuths.add(escape(auth, false)); return new Authorizations(retAuths); }
/** * Creates a new {@link Authorizations} object with escaped forms of the * authorizations in the given object. * * @param auths original authorizations * @return authorizations object with escaped authorization strings * @see #escape(byte[], boolean) */ static Authorizations escape(Authorizations auths) { ArrayList<byte[]> retAuths = new ArrayList<byte[]>(auths.getAuthorizations().size()); for (byte[] auth : auths.getAuthorizations()) retAuths.add(escape(auth, false)); return new Authorizations(retAuths); }