Back to project page NexusData.
The source code is released under:
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCT...
If you think the Android project NexusData listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.github.dkharrat.nexusdata.predicate.parser; /*w ww.j av a2s. c o m*/ import com.github.dkharrat.nexusdata.predicate.ConstantExpression; import com.github.dkharrat.nexusdata.predicate.Expression; import static com.github.dkharrat.nexusdata.predicate.parser.PredicateParser.TokenType; public class ConstantParselet implements PrefixParselet<TokenType,Expression<?>> { @Override public Expression<?> parse(Parser<TokenType,Expression<?>> parser, Token<TokenType> token) { String valueStr = token.getText(); Object value; if (valueStr.equalsIgnoreCase("true")) { value = true; } else if (valueStr.equalsIgnoreCase("false")) { value = false; } else if (valueStr.equalsIgnoreCase("null")) { value = null; } else if (valueStr.startsWith("\"")) { value = valueStr.substring(1,valueStr.length()-1); // remove quotes from string } else { value = Integer.parseInt(valueStr); } return new ConstantExpression(value); } }