本文整理汇总了Java中org.mozilla.javascript.Token.NAME属性的典型用法代码示例。如果您正苦于以下问题:Java Token.NAME属性的具体用法?Java Token.NAME怎么用?Java Token.NAME使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.mozilla.javascript.Token
的用法示例。
在下文中一共展示了Token.NAME属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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 );
}
示例4: visit
public boolean visit(AstNode node) {
int tt = node.getType();
String name = Token.typeToName(tt);
buffer.append(node.getAbsolutePosition()).append("\t");
buffer.append(makeIndent(node.depth()));
buffer.append(name).append(" ");
buffer.append(node.getPosition()).append(" ");
buffer.append(node.getLength());
if (tt == Token.NAME) {
buffer.append(" ").append(((Name)node).getIdentifier());
}
buffer.append("\n");
return true; // process kids
}
示例5: visit
@Override
public boolean visit(AstNode node) {
int tt = node.getType();
String name = Token.typeToName(tt);
buffer.append(node.getAbsolutePosition()).append("\t");
buffer.append(makeIndent(node.depth()));
buffer.append(name).append(" ");
buffer.append(node.getPosition()).append(" ");
buffer.append(node.getLength());
if (tt == Token.NAME) {
buffer.append(" ").append(((Name)node).getIdentifier());
}
buffer.append("\n");
return true; // process kids
}
示例6: compileDirectColRefExpr
/**
* compile column reference expression
*
* @param refNode
* @throws BirtException
*/
private void compileDirectColRefExpr( Node refNode, ScriptNode tree,
List columnExprList ) throws BirtException
{
assert ( refNode.getType( ) == Token.GETPROP
|| refNode.getType( ) == Token.GETELEM
|| refNode.getType( ) == Token.SETELEM || refNode.getType( ) == Token.SETPROP );
Node rowName = refNode.getFirstChild( );
assert ( rowName != null );
if ( rowName.getType( ) != Token.NAME )
{
if ( refNode.getType( ) == Token.GETPROP
|| refNode.getType( ) == Token.GETELEM
|| refNode.getType( ) == Token.SETELEM
|| refNode.getType( ) == Token.SETPROP )
{
compileOuterColRef( refNode, tree, columnExprList );
compileRowPositionRef( refNode, tree, columnExprList );
return;
}
compileComplexExpr( refNode, tree, columnExprList );
return;
}
else
compileSimpleColumnRefExpr( refNode, tree, columnExprList );
}
示例7: visit
@Override
public boolean visit(AstNode node) {
if( Token.NAME == node.getType()){
if(node.getParent().getType() == Token.CALL){
FunctionCall parent = (FunctionCall)node.getParent();
if(parent.getTarget()==node){
resultSoFar.add(safeGetString(node));
}
}
}
return true;
}
示例8: visit
@Override
public boolean visit(AstNode node) {
int tt = node.getType();
String name = Token.typeToName(tt);
buffer.append(node.getAbsolutePosition()).append("\t");
buffer.append(makeIndent(node.depth()));
buffer.append(name).append(" ");
buffer.append(node.getPosition()).append(" ");
buffer.append(node.getLength());
if (tt == Token.NAME) {
buffer.append(" ").append(((Name)node).getIdentifier());
}
buffer.append("\n");
return true; // process kids
}
示例9: 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;
}
示例10: 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;
}
示例11: 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;
}
示例12: 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;
}
示例13: JavaScriptIdentifier
JavaScriptIdentifier(String value, ScriptOrFnScope declaredScope) {
super(Token.NAME, value);
this.declaredScope = declaredScope;
}
示例14: 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;
}
示例15: JavaScriptIdentifier
JavaScriptIdentifier(String value, ScriptOrFnScope declaredScope,
boolean normalVar) {
super(Token.NAME, value);
this.declaredScope = declaredScope;
this.normalVar = normalVar;
}