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

org.nutz.el.parse.IdentifierParse Maven / Gradle / Ivy

Go to download

Nutz, which is a collections of lightweight frameworks, each of them can be used independently

There is a newer version: 1.r.72
Show newest version
package org.nutz.el.parse;

import org.nutz.el.Parse;
import org.nutz.el.obj.AbstractObj;
import org.nutz.el.obj.IdentifierObj;

/**
 * 标识符转换
 * @author juqkai([email protected])
 *
 */
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());
            }
            if(sb.toString().equals("null")){
                return new IdentifierObj(null);
            }
            if(sb.toString().equals("true")){
                return Boolean.TRUE;
            }
            if(sb.toString().equals("false")){
                return Boolean.FALSE;
            }
            return new AbstractObj(sb.toString());
        }
        return nullobj;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy