本文整理汇总了Java中org.mozilla.javascript.Token.STRING属性的典型用法代码示例。如果您正苦于以下问题:Java Token.STRING属性的具体用法?Java Token.STRING怎么用?Java Token.STRING使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.mozilla.javascript.Token
的用法示例。
在下文中一共展示了Token.STRING属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getScriptObjectName
/**
*
* @param n
* @param objectName
* @return
*/
private static String getScriptObjectName( Node n, String objectName )
{
if ( n == null )
return null;
String result = null;
if ( n.getType( ) == Token.NAME )
{
if ( objectName.equals( n.getString( ) ) )
{
Node dimNameNode = n.getNext( );
if ( dimNameNode == null
|| dimNameNode.getType( ) != Token.STRING )
return null;
return dimNameNode.getString( );
}
}
result = getScriptObjectName( n.getFirstChild( ), objectName );
if ( result == null )
result = getScriptObjectName( n.getLastChild( ), objectName );
return result;
}
示例3: getConstantExpression
/**
* Return the Constant Expression referred by the total constants.
* @param child
* @return
*/
public static ConstantExpression getConstantExpression( Node child )
{
if ( child.getFirstChild( ).getType( ) == Token.NAME
&& child.getFirstChild( ).getString( ).equalsIgnoreCase( TOTAL )
&& child.getLastChild( ).getType( ) == Token.STRING )
{
String property = child.getLastChild( ).getString( );
if ( CURRENT_GROUP.equalsIgnoreCase( property )
|| OVERALL.equalsIgnoreCase( property ) )
return new ConstantExpression( property.toUpperCase( ) );
if ( NO_FILTER.equalsIgnoreCase( property ) )
return new ConstantExpression();
}
return null;
}
示例4: compileOuterColRef
/**
* compile outer column expression
* @param refNode
* @param tree
* @param columnExprList
* @throws BirtException
*/
private void compileOuterColRef( Node refNode, ScriptNode tree,
List columnExprList ) throws BirtException
{
int level = compileOuterColRefExpr( refNode );
if ( level == -1 )
{
compileComplexExpr( refNode, tree, columnExprList );
}
else
{
Node nextNode = refNode.getLastChild( );
if ( nextNode.getType( ) == Token.STRING )
{
ColumnBinding info = new ColumnBinding( nextNode.getString( ),
"",
level );
columnExprList.add( info );
}
}
return;
}
示例5: getScriptObjectName
/**
*
* @param n
* @param objectName
* @return
*/
private static void getScriptObjectName( Node n, String objectName, Set nameSet )
{
if ( n == null )
return;
String result = null;
if ( n.getType( ) == Token.NAME )
{
if ( objectName.equals( n.getString( ) ) )
{
Node dimNameNode = n.getNext( );
if ( dimNameNode == null
|| dimNameNode.getType( ) != Token.STRING )
return;
nameSet.add( dimNameNode.getString( ) );
}
}
getScriptObjectName( n.getFirstChild( ), objectName, nameSet );
getScriptObjectName( n.getNext( ), objectName, nameSet );
getScriptObjectName( n.getLastChild( ), objectName, nameSet );
}
示例6: visit
@Override
public boolean visit(AstNode node) {
switch (node.getType()) {
case Token.GETPROP: // foo.bar (firstChild="foo", lastChild="bar")
PropertyGet propertyGet = (PropertyGet)node;
int propType = propertyGet.getProperty().getType();
if(propertyGet.getTarget().getType()==Token.NAME
&& (propType == Token.STRING || propType == Token.NAME)
&& objectName.equals(safeGetString(propertyGet.getTarget()))
){
resultSoFar.add(safeGetString(propertyGet.getProperty()));
}
break;
case Token.GETELEM: // foo["bar"]
ElementGet elemGet = (ElementGet)node;
int elemType = elemGet.getElement().getType();
if(elemGet.getTarget().getType()==Token.NAME
&& (elemType == Token.STRING || elemType==Token.NAME)
&& objectName.equals(safeGetString(elemGet.getTarget()))
){
resultSoFar.add(safeGetString(elemGet.getElement()));
}
break;
default:
break;
}
return true;
}
示例7: 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();
}
}
示例8: getScriptObjectName
/**
*
* @param n
* @param objectName
* @return
*/
private static String getScriptObjectName( Node n, String objectName )
{
if ( n == null )
return null;
String result = null;
if ( n.getType( ) == Token.NAME )
{
if ( objectName.equals( n.getString( ) ) )
{
Node dimNameNode = n.getNext( );
if ( dimNameNode == null
|| dimNameNode.getType( ) != Token.STRING )
return null;
return dimNameNode.getString( );
}
}
result = getScriptObjectName( n.getFirstChild( ), objectName );
if ( result == null )
result = getScriptObjectName( n.getLastChild( ), objectName );
if ( result == null )
result = getScriptObjectName( n.getNext(), objectName );
return result;
}
示例9: getAggregationFunction
/**
* An aggregation expression in the form of Total.xxx for example Total.sum(
* row.x ) This means the first child is a GETPROP node, and its left child
* is "Total" and its right child is "sum"
*
* @param callNode
* @return @throws
* DataException
*/
protected IAggrFunction getAggregationFunction( Node callNode )
throws DataException
{
Node firstChild = callNode.getFirstChild( );
if ( firstChild.getType( ) != Token.GETPROP )
return null;
Node getPropLeftChild = firstChild.getFirstChild( );
if ( getPropLeftChild.getType( ) != Token.NAME
|| !getPropLeftChild.getString( ).equals( TOTAL ) )
return null;
Node getPropRightChild = firstChild.getLastChild( );
if ( getPropRightChild.getType( ) != Token.STRING )
return null;
String aggrFuncName = getPropRightChild.getString( );
IAggrFunction agg = AggregationManager.getInstance( )
.getAggregation( aggrFuncName );
if ( agg == null )
{
// Aggr function name after Total is invalid; this will eventuall
// cause
// an error. Report error now
throw new DataException( ResourceConstants.INVALID_TOTAL_NAME,
aggrFuncName );
}
return agg;
}
示例10: 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;
}
示例11: 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;
}
示例12: 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 );
}
}
示例13: compileRowPositionRef
/**
* compile row position expression
* @param refNode
* @param tree
* @param columnExprList
* @throws BirtException
*/
private void compileRowPositionRef( Node refNode, ScriptNode tree,
List columnExprList ) throws BirtException
{
Node rowFirstNode = refNode.getFirstChild( );
if ( rowFirstNode.getType( ) == Token.GETELEM
|| rowFirstNode.getType( ) == Token.SETELEM )
{
Node rowNode = rowFirstNode.getFirstChild( );
if ( rowNode != null
&& rowNode.getType( ) == Token.NAME
&& rowNode.getString( ).equals( ROWS_0_INDICATOR ) )
{
Node rowColumn = rowNode.getNext( );
if ( rowColumn.getDouble( ) == 0.0 )
{
rowColumn = rowFirstNode.getNext( );
if ( rowColumn.getType( ) == Token.STRING
&& ( refNode.getType( ) == Token.GETELEM || refNode.getType( ) == Token.SETELEM ) )
{
ColumnBinding binding = new ColumnBinding( rowColumn.getString( ),
ExpressionUtil.createJSDataSetRowExpression( rowColumn.getString( ) ),
1 );
columnExprList.add( binding );;
}
}
}
}
}
示例14: 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;
}
}
示例15: findFeaturePathsUnder
protected static Set<String> findFeaturePathsUnder(Node node, List<String> pathSoFar) {
Set<String> resultSoFar = new TreeSet<String>();
switch (node.getType()) {
case Token.NAME: // e.g. the x in x + 42
if (pathSoFar != null) {
pathSoFar.add(node.getString());
} else {
resultSoFar.add(node.getString());
}
break;
case Token.STRING:
if (pathSoFar != null) {
pathSoFar.add(node.getString());
}
break;
case Token.GETPROP: // e.g. foo.bar
boolean topLevel = pathSoFar == null;
if (topLevel) {
pathSoFar = new ArrayList<String>();
}
for (Node child = node.getFirstChild(); child != null; child = child.getNext()) {
resultSoFar.addAll(findFeaturePathsUnder(child, pathSoFar));
}
if (topLevel) {
resultSoFar.add(getPathString(pathSoFar));
}
return resultSoFar;
case Token.SETNAME: // Left-hand variable being written: x in x = y;
case Token.VAR:
case Token.CALL:
// ignore the left side and process the right side now
resultSoFar.addAll(findFeaturePathsWithinRightSide(node));
break;
default:
break;
}
// Now do the nested subexpressions, for all cases that said break instead of return.
for (Node child = node.getFirstChild(); child != null; child = child.getNext()) {
resultSoFar.addAll(findFeaturePathsUnder(child, pathSoFar));
}
return resultSoFar;
}