Rename token class "protected" to "quoted".

More in line with remaining nomenclature.

Stresses syntactic over semantic meaning.
This commit is contained in:
Jens Wille 2017-01-26 15:22:53 +01:00
parent b41479bf7f
commit 1331ad631e
3 changed files with 9 additions and 9 deletions

View file

@ -128,7 +128,7 @@ public class FilterGenerator implements Visitor {
case ALL: { case ALL: {
String field = arg1.toString(); String field = arg1.toString();
String value = arg2 != null ? arg2.toString() : ""; String value = arg2 != null ? arg2.toString() : "";
boolean phrase = arg2 instanceof Token && ((Token) arg2).isProtected(); boolean phrase = arg2 instanceof Token && ((Token) arg2).isQuoted();
if (phrase) { if (phrase) {
builder.startArray("and"); builder.startArray("and");
QuotedStringTokenizer qst = new QuotedStringTokenizer(value); QuotedStringTokenizer qst = new QuotedStringTokenizer(value);
@ -144,7 +144,7 @@ public class FilterGenerator implements Visitor {
break; break;
} }
case ANY: { case ANY: {
boolean phrase = arg2 instanceof Token && ((Token) arg2).isProtected(); boolean phrase = arg2 instanceof Token && ((Token) arg2).isQuoted();
String field = arg1.toString(); String field = arg1.toString();
String value = arg2 != null ? arg2.toString() : ""; String value = arg2 != null ? arg2.toString() : "";
if (phrase) { if (phrase) {

View file

@ -197,7 +197,7 @@ public class QueryGenerator implements Visitor {
String field = arg1.toString(); String field = arg1.toString();
String value = arg2 != null ? arg2.toString() : ""; String value = arg2 != null ? arg2.toString() : "";
if (tok2 != null) { if (tok2 != null) {
if (tok2.isProtected()) { if (tok2.isQuoted()) {
builder.startObject("match_phrase") builder.startObject("match_phrase")
.startObject(field) .startObject(field)
.field("query", tok2.getString()) .field("query", tok2.getString())
@ -264,7 +264,7 @@ public class QueryGenerator implements Visitor {
String from = null; String from = null;
String to = null; String to = null;
if (tok2 != null) { if (tok2 != null) {
if (!tok2.isProtected()) { if (!tok2.isQuoted()) {
throw new IllegalArgumentException("range within: unable to derive range from a non-phrase: " + value); throw new IllegalArgumentException("range within: unable to derive range from a non-phrase: " + value);
} }
if (tok2.getStringList().size() != 2) { if (tok2.getStringList().size() != 2) {

View file

@ -22,7 +22,7 @@ public class Token implements Node {
public enum TokenClass { public enum TokenClass {
NORMAL, ALL, WILDCARD, BOUNDARY, PROTECTED NORMAL, ALL, WILDCARD, BOUNDARY, QUOTED
} }
private TokenType type; private TokenType type;
@ -60,12 +60,12 @@ public class Token implements Node {
} }
if (this.value != null) { if (this.value != null) {
// protected? // quoted?
if (value.startsWith("\"") && value.endsWith("\"")) { if (value.startsWith("\"") && value.endsWith("\"")) {
this.stringvalue = value; this.stringvalue = value;
this.value = value.substring(1, value.length() - 1).replaceAll("\\\\\"", "\""); this.value = value.substring(1, value.length() - 1).replaceAll("\\\\\"", "\"");
this.values = parseQuot(this.value); this.values = parseQuot(this.value);
tokenClass.add(TokenClass.PROTECTED); tokenClass.add(TokenClass.QUOTED);
} }
// wildcard? // wildcard?
if (this.value.indexOf('*') >= 0 || this.value.indexOf('?') >= 0) { if (this.value.indexOf('*') >= 0 || this.value.indexOf('?') >= 0) {
@ -182,8 +182,8 @@ public class Token implements Node {
return sb.toString(); return sb.toString();
} }
public boolean isProtected() { public boolean isQuoted() {
return tokenClass.contains(TokenClass.PROTECTED); return tokenClass.contains(TokenClass.QUOTED);
} }
public boolean isBoundary() { public boolean isBoundary() {