All Downloads are FREE. Search and download functionalities are using the official Maven repository.

panda.el.parse.IdentifierParse Maven / Gradle / Ivy

Go to download

Panda Core is the core module of Panda Framework, it contains commonly used utility classes similar to apache-commons.

There is a newer version: 1.8.0
Show newest version
package 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;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy