use of java.text.CharacterIterator in project jdk8u_jdk by JetBrains.
the class RuleBasedBreakIterator method last.
/**
* Sets the current iteration position to the end of the text.
* (i.e., the CharacterIterator's ending offset).
* @return The text's past-the-end offset.
*/
@Override
public int last() {
CharacterIterator t = getText();
// I'm not sure why, but t.last() returns the offset of the last character,
// rather than the past-the-end offset
t.setIndex(t.getEndIndex());
return t.getIndex();
}
use of java.text.CharacterIterator in project gradle by gradle.
the class StartScriptTemplateBindingFactory method escapeWindowsJvmOpt.
private String escapeWindowsJvmOpt(String jvmOpts) {
boolean wasOnBackslash = false;
StringBuilder escapedJvmOpt = new StringBuilder();
CharacterIterator it = new StringCharacterIterator(jvmOpts);
// - use a state machine rather than regexps
for (char ch = it.first(); ch != CharacterIterator.DONE; ch = it.next()) {
String repl = Character.toString(ch);
if (ch == '%') {
repl = "%%";
} else if (ch == '"') {
repl = (wasOnBackslash ? '\\' : "") + "\\\"";
}
wasOnBackslash = ch == '\\';
escapedJvmOpt.append(repl);
}
return escapedJvmOpt.toString();
}
use of java.text.CharacterIterator in project intellij-community by JetBrains.
the class StubBuildingVisitor method parseClassSignature.
private ClassInfo parseClassSignature(String signature) throws ClsFormatException {
ClassInfo result = new ClassInfo();
CharacterIterator iterator = new StringCharacterIterator(signature);
result.typeParameters = SignatureParsing.parseTypeParametersDeclaration(iterator, myMapping);
result.superName = SignatureParsing.parseTopLevelClassRefSignature(iterator, myMapping);
while (iterator.current() != CharacterIterator.DONE) {
String name = SignatureParsing.parseTopLevelClassRefSignature(iterator, myMapping);
if (name == null)
throw new ClsFormatException();
if (result.interfaceNames == null)
result.interfaceNames = ContainerUtil.newSmartList();
result.interfaceNames.add(name);
}
return result;
}
use of java.text.CharacterIterator in project Gradle-demo by Arisono.
the class JsonValidator method literal.
private boolean literal(String text) {
CharacterIterator ci = new StringCharacterIterator(text);
char t = ci.first();
if (c != t)
return false;
int start = col;
boolean ret = true;
for (t = ci.next(); t != CharacterIterator.DONE; t = ci.next()) {
if (t != nextCharacter()) {
ret = false;
break;
}
}
nextCharacter();
if (!ret)
error("literal " + text, start);
return ret;
}
use of java.text.CharacterIterator in project intellij-community by JetBrains.
the class RestTitle method getName.
@Nullable
public String getName() {
final String text = getNode().getText().trim();
if (text.length() < 2)
return null;
final char adorn = text.charAt(text.length() - 2);
final CharacterIterator it = new StringCharacterIterator(text);
int finish = 0;
for (char ch = it.last(); ch != CharacterIterator.DONE; ch = it.previous()) {
if (ch != adorn) {
finish = it.getIndex();
break;
}
}
int start = 0;
if (text.charAt(0) == adorn) {
for (char ch = it.first(); ch != CharacterIterator.DONE; ch = it.next()) {
if (ch != adorn) {
start = it.getIndex() + 1;
break;
}
}
}
if (finish <= 0 || start < 0)
return null;
return text.substring(start, finish).trim();
}
Aggregations