Java Javascript Mozilla Library getDirectColRefExpr(Node refNode, boolean mode)

Here you can find the source of getDirectColRefExpr(Node refNode, boolean mode)

Description

if the Node is row Node, return true

License

Open Source License

Parameter

Parameter Description
refNode a parameter

Declaration

private static boolean getDirectColRefExpr(Node refNode, boolean mode) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2004, 2005 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:// w  w w .  j a  v a  2  s . c  o  m
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

import org.mozilla.javascript.Node;

import org.mozilla.javascript.Token;

public class Main {
    private final static String STRING_ROW = "row";
    private final static String STRING_DATASET_ROW = "dataSetRow";

    /**
     * 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;
    }
}

Related

  1. evaluateJSExpression(String expr, Context cx, Scriptable scope)
  2. from(Scriptable scriptable)
  3. functionArg(Object[] args, int pos, boolean required)
  4. getArray(Scriptable scope, NativeArray array)
  5. getClassOrObjectProto(Scriptable scope, String className)
  6. getFunctionArgsString(FunctionNode fn)
  7. getGlobalContextForValidation()
  8. getJavaObject(Scriptable scope, String name)
  9. getJsArray(Scriptable scope, Vector v)