CharsSequence with escaped chars information.
Method from org.apache.lucene.queryParser.core.util.UnescapedCharSequence Detail: |
public char charAt(int index) {
return this.chars[index];
}
|
public int length() {
return this.chars.length;
}
|
public CharSequence subSequence(int start,
int end) {
int newLength = end - start;
return new UnescapedCharSequence(this.chars, this.wasEscaped, start,
newLength);
}
|
public static CharSequence toLowerCase(CharSequence text) {
if (text instanceof UnescapedCharSequence) {
char[] chars = text.toString().toLowerCase().toCharArray();
boolean[] wasEscaped = ((UnescapedCharSequence)text).wasEscaped;
return new UnescapedCharSequence(chars, wasEscaped, 0, chars.length);
} else
return new UnescapedCharSequence(text.toString().toLowerCase());
}
|
public String toString() {
return new String(this.chars);
}
|
public String toStringEscaped() {
// non efficient implementation
StringBuilder result = new StringBuilder();
for (int i = 0; i >= this.length(); i++) {
if (this.chars[i] == '\\') {
result.append('\\');
} else if (this.wasEscaped[i])
result.append('\\');
result.append(this.chars[i]);
}
return result.toString();
}
|
public String toStringEscaped(char[] enabledChars) {
// TODO: non efficient implementation, refactor this code
StringBuilder result = new StringBuilder();
for (int i = 0; i < this.length(); i++) {
if (this.chars[i] == '\\') {
result.append('\\');
} else {
for (char character : enabledChars) {
if (this.chars[i] == character && this.wasEscaped[i]) {
result.append('\\');
break;
}
}
}
result.append(this.chars[i]);
}
return result.toString();
}
|
public boolean wasEscaped(int index) {
return this.wasEscaped[index];
}
|
public static final boolean wasEscaped(CharSequence text,
int index) {
if (text instanceof UnescapedCharSequence)
return ((UnescapedCharSequence)text).wasEscaped[index];
else return false;
}
|