use of org.apache.hadoop.hbase.hbtop.field.FieldValue in project hbase by apache.
the class RecordFilter method parse.
/*
* Parse a filter string and build a RecordFilter instance.
*/
public static RecordFilter parse(String filterString, List<Field> fields, boolean ignoreCase) {
int index = 0;
boolean not = isNot(filterString);
if (not) {
index += 1;
}
StringBuilder fieldString = new StringBuilder();
while (filterString.length() > index && filterString.charAt(index) != '<' && filterString.charAt(index) != '>' && filterString.charAt(index) != '=') {
fieldString.append(filterString.charAt(index++));
}
if (fieldString.length() == 0 || filterString.length() == index) {
return null;
}
Field field = getField(fields, fieldString.toString());
if (field == null) {
return null;
}
StringBuilder operatorString = new StringBuilder();
while (filterString.length() > index && (filterString.charAt(index) == '<' || filterString.charAt(index) == '>' || filterString.charAt(index) == '=')) {
operatorString.append(filterString.charAt(index++));
}
Operator operator = getOperator(operatorString.toString());
if (operator == null) {
return null;
}
String value = filterString.substring(index);
FieldValue fieldValue = getFieldValue(field, value);
if (fieldValue == null) {
return null;
}
return new RecordFilter(ignoreCase, not, field, operator, fieldValue);
}
Aggregations