panda.el.parse.IdentifierParse Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of panda-core Show documentation
Show all versions of panda-core Show documentation
Panda Core is the core module of Panda Framework, it contains commonly used utility classes similar to apache-commons.
package panda.el.parse;
import panda.el.Parse;
import panda.el.obj.ELObj;
/**
* 标识符转换
*/
public class IdentifierParse implements Parse {
public Object fetchItem(CharQueue exp) {
StringBuilder sb = new StringBuilder();
if (Character.isJavaIdentifierStart(exp.peek())) {
sb.append(exp.poll());
while (!exp.isEmpty() && Character.isJavaIdentifierPart(exp.peek())) {
sb.append(exp.poll());
}
String s = sb.toString();
if (s.equals("null")) {
return new ELObj(null);
}
if (s.equals("true")) {
return Boolean.TRUE;
}
if (s.equals("false")) {
return Boolean.FALSE;
}
return new ELObj(sb.toString());
}
return NULL;
}
}