com.softicar.platform.common.code.java.IdentifierReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of platform-common Show documentation
Show all versions of platform-common Show documentation
The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.
package com.softicar.platform.common.code.java;
public class IdentifierReader {
private int index;
private final String line;
private final StringBuilder identifier;
public IdentifierReader(String line) {
this.index = 0;
this.line = line;
this.identifier = new StringBuilder();
}
public String read() {
readFirstChar();
readUntilEndOfIdentifier();
return identifier.toString();
}
private void readFirstChar() {
identifier.append(line.charAt(index));
++index;
}
private void readUntilEndOfIdentifier() {
while (index < line.length() && isIdentifierPart()) {
appendChar();
}
}
private void appendChar() {
char c = line.charAt(index++);
identifier.append(c);
}
private boolean isIdentifierPart() {
char c = line.charAt(index);
return Character.isJavaIdentifierPart(c);
}
}