本文整理汇总了Java中org.mozilla.javascript.Token.NUMBER属性的典型用法代码示例。如果您正苦于以下问题:Java Token.NUMBER属性的具体用法?Java Token.NUMBER怎么用?Java Token.NUMBER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.mozilla.javascript.Token
的用法示例。
在下文中一共展示了Token.NUMBER属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isTrivial
public static boolean isTrivial (String formula) {
// No formulas, just one constant or one variable.
final ArrayList<AstNode> result = new ArrayList<AstNode>();
parseIntoTree(formula).visit(new NodeVisitor(){
@Override
public boolean visit(AstNode node) {
if(node.depth()>1){
result.add(node);
return false;
}
return true;
}
});
if(result.size()>0){
switch (result.get(0).getType()) {
case Token.NUMBER: return true;
case Token.NAME: return true;
case Token.STRING: return true;
default: return false;
}
}
return false;
}
示例2: safeGetString
protected static String safeGetString(AstNode node){
if(node.getType() == Token.STRING){
StringLiteral sl = (StringLiteral)node;
return sl.getValue();
}else if(node.getType()==Token.NUMBER){
NumberLiteral nl = (NumberLiteral)node;
return nl.getValue();
}else{
return node.getString();
}
}
示例3: getDirectColRefExpr
/**
* if the Node is row Node, return true
*
* @param refNode
* @return
*/
private static boolean getDirectColRefExpr( Node refNode, boolean mode )
{
assert ( refNode.getType( ) == Token.GETPROP || refNode.getType( ) == Token.GETELEM );
Node rowName = refNode.getFirstChild( );
assert ( rowName != null );
if ( rowName.getType( ) != Token.NAME )
return false;
String str = rowName.getString( );
assert ( str != null );
if ( mode && !str.equals( STRING_ROW ) )
return false;
else if ( !mode && !str.equals( STRING_DATASET_ROW ) )
return false;
Node rowColumn = rowName.getNext( );
assert ( rowColumn != null );
if ( refNode.getType( ) == Token.GETPROP
&& rowColumn.getType( ) == Token.STRING )
{
return true;
}
else if ( refNode.getType( ) == Token.GETELEM )
{
if ( rowColumn.getType( ) == Token.NUMBER
|| rowColumn.getType( ) == Token.STRING )
return true;
}
return false;
}
示例4: getDirectColRefExpr
/**
* if the Node is row Node, return true
*
* @param refNode
* @return
*/
private static boolean getDirectColRefExpr( Node refNode )
{
assert ( refNode.getType( ) == Token.GETPROP || refNode.getType( ) == Token.GETELEM );
Node rowName = refNode.getFirstChild( );
assert ( rowName != null );
if ( rowName.getType( ) != Token.NAME )
return false;
String str = rowName.getString( );
assert ( str != null );
if ( !str.equals( STRING_ROW ) )
return false;
Node rowColumn = rowName.getNext( );
assert ( rowColumn != null );
if ( refNode.getType( ) == Token.GETPROP
&& rowColumn.getType( ) == Token.STRING )
{
return true;
}
else if ( refNode.getType( ) == Token.GETELEM )
{
if ( rowColumn.getType( ) == Token.NUMBER
|| rowColumn.getType( ) == Token.STRING )
return true;
}
return false;
}
示例5: processChild
/**
* process child node
*
* @param parent
* @param child
* @param tree
* @param columnExprList
* @throws BirtException
*/
private void processChild( Node child, ScriptNode tree,
List columnExprList ) throws BirtException
{
switch ( child.getType( ) )
{
case Token.NUMBER :
case Token.STRING :
case Token.NULL :
case Token.TRUE :
case Token.FALSE :
break;
case Token.GETPROP :
case Token.GETELEM :
case Token.SETPROP :
case Token.SETELEM :
{
compileDirectColRefExpr( child, tree, columnExprList );
break;
}
case Token.CALL :
compileAggregateExpr( child, tree, columnExprList );
break;
default :
compileComplexExpr( child, tree, columnExprList );
}
}
示例6: compileComplexExpr
/**
* compile the complex expression
*
* @param complexNode
* @throws BirtException
*/
private void compileComplexExpr( Node complexNode, ScriptNode tree,
List columnExprList ) throws BirtException
{
Node child = complexNode.getFirstChild( );
while ( child != null )
{
if ( child.getType( ) == Token.FUNCTION )
{
int index = getFunctionIndex( child.getString( ), tree );
compileFunctionNode( tree.getFunctionNode( index ),
tree,
columnExprList );
}
// keep reference to next child, since subsequent steps could
// lose
// the reference to it
Node nextChild = child.getNext( );
// do not include constants into the sub-expression list
if ( child.getType( ) == Token.NUMBER
|| child.getType( ) == Token.STRING
|| child.getType( ) == Token.TRUE
|| child.getType( ) == Token.FALSE
|| child.getType( ) == Token.NULL )
{
processChild( child, tree, columnExprList );
child = nextChild;
continue;
}
processChild( child, tree, columnExprList );
child = nextChild;
}
}
示例7: compileDirectColRefExpr
protected CompiledExpression compileDirectColRefExpr( Node parent, Node refNode,
Node grandFather, boolean customerChecked, Context context )
throws DataException
{
// if it's a GETPROP or GETELEM with row on the left side,
// and either a STRING or NUMBER on the right side, then it's
// a direct column reference
assert ( refNode.getType( ) == Token.GETPROP || refNode.getType( ) == Token.GETELEM );
Node rowName = refNode.getFirstChild( );
assert ( rowName != null );
if ( rowName.getType( ) != Token.NAME )
return null;
String str = rowName.getString( );
assert ( str != null );
if ( !str.equals( rowIndicator ) )
return null;
Node rowColumn = rowName.getNext( );
assert ( rowColumn != null );
if ( refNode.getType( ) == Token.GETPROP
&& rowColumn.getType( ) == Token.STRING )
{
if ( ScriptConstants.OUTER_RESULT_KEYWORD.equals( rowColumn.getString( ) )
|| ScriptConstants.ROW_NUM_KEYWORD.equals( rowColumn.getString( ) )
|| "0".equals( rowColumn.getString( ) ) )
return null;
return new ColumnReferenceExpression( getDataSetMode( )
? STRING_ROW : STRING_DATASETROW, rowColumn.getString( ) );
}
if ( refNode.getType( ) == Token.GETELEM )
{
if ( rowColumn.getType( ) == Token.NUMBER )
{
if ( 0 == rowColumn.getDouble( ) )
return null;
return new ColumnReferenceExpression( getDataSetMode( )
? STRING_ROW : STRING_DATASETROW,
(int) rowColumn.getDouble( ) );
}
else if ( rowColumn.getType( ) == Token.STRING )
{
if ( "_rownum".equals( rowColumn.getString( ) ) )
return null;
return new ColumnReferenceExpression( getDataSetMode( )
? STRING_ROW : STRING_DATASETROW, rowColumn.getString( ) );
}
}
// right side is not a STRING or a NUMBER, which is what is needed for
// a direct column reference. so it could be something
// like row[getColumnIndex()] and that would be a complex expression
return null;
}
示例8: processChild
/**
*
* returns the compiled expression from processing a child node
*
* @param context
* @param customerChecked
* @param parent
* @param child
* @return
* @throws DataException
*/
protected CompiledExpression processChild( Context context,
boolean customerChecked, Node parent, Node child, Node grandFather )
throws DataException
{
CompiledExpression compiledExpr = null;
switch ( child.getType( ) )
{
case Token.NUMBER :
compiledExpr = new ConstantExpression( child.getDouble( ) );
break;
case Token.STRING :
compiledExpr = new ConstantExpression( child.getString( ) );
break;
case Token.NULL :
compiledExpr = new ConstantExpression( );
break;
case Token.TRUE :
compiledExpr = new ConstantExpression( true );
break;
case Token.FALSE :
compiledExpr = new ConstantExpression( false );
break;
case Token.GETPROP :
{
ConstantExpression ce = AggregationConstantsUtil.getConstantExpression( child );
if ( ce != null )
{
compiledExpr = ce;
break;
}
}
case Token.GETELEM :
compiledExpr = compileDirectColRefExpr( parent,
child,
grandFather,
customerChecked,
context );
break;
case Token.CALL :
{
compiledExpr = compileAggregateExpr( context, parent, child );
break;
}
}
if ( compiledExpr == null )
compiledExpr = compileComplexExpr( context, child, customerChecked );
return compiledExpr;
}
示例9: compileColRefExpr
/**
* Check if the expression is a direct column reference type. If so, returns
* an instance of DirectColRefExpr that represents it; otherwise returns
* null.
*
* @param refNode
* @param customerChecked
* @return
* @throws DataException
*/
protected ColumnReferenceExpression compileColRefExpr( Node refNode,
boolean customerChecked ) throws DataException
{
// if it's a GETPROP or GETELEM with row on the left side,
// and either a STRING or NUMBER on the right side, then it's
// a direct column reference
assert ( refNode.getType( ) == Token.GETPROP || refNode.getType( ) == Token.GETELEM );
Node rowName = refNode.getFirstChild( );
assert ( rowName != null );
if ( rowName.getType( ) != Token.NAME )
return null;
String str = rowName.getString( );
assert ( str != null );
if ( !str.equals( rowIndicator ) )
return null;
Node rowColumn = rowName.getNext( );
assert ( rowColumn != null );
if ( refNode.getType( ) == Token.GETPROP
&& rowColumn.getType( ) == Token.STRING )
{
return new ColumnReferenceExpression(
this.isDataSetMode ? STRING_ROW : STRING_DATASETROW,
rowColumn.getString());
}
if ( refNode.getType( ) == Token.GETELEM )
{
if ( rowColumn.getType( ) == Token.NUMBER )
{
return new ColumnReferenceExpression(
this.isDataSetMode ? STRING_ROW : STRING_DATASETROW,
(int) rowColumn.getDouble());
}
else if ( rowColumn.getType( ) == Token.STRING )
{
return new ColumnReferenceExpression(
this.isDataSetMode ? STRING_ROW : STRING_DATASETROW,
rowColumn.getString());
}
}
// right side is not a STRING or a NUMBER, which is what is needed for
// a direct column reference. so it could be something
// like row[getColumnIndex()] and that would be a complex expression
return null;
}