FileDocCategorySizeDatePackage
EJBQLAST.javaAPI DocGlassfish v2 API7221Fri May 04 22:34:50 BST 2007com.sun.jdo.spi.persistence.support.ejb.ejbqlc

EJBQLAST

public class EJBQLAST extends CommonAST implements Cloneable
An instance of this class represents a node of the intermediate representation (AST) used by the query compiler. It stores per node:
  • token type info
  • token text
  • line info
  • column info
  • type info the semantic analysis calculates the type of an expression and adds this info to each node.
author
Michael Bouschen

Fields Summary
private static char
SEPARATOR
private static String
INDENT
protected int
line
The line info
protected int
column
The column info
protected transient Object
typeInfo
The type info
Constructors Summary
public EJBQLAST()
No args constructor.


        
      
public EJBQLAST(int type, String text, Object typeInfo)
Constructor taking token type, text and type info.

        initialize(type, text, typeInfo);
    
public EJBQLAST(EJBQLAST ast)
Copy constructor.

        initialize(ast);
    
Methods Summary
protected java.lang.Objectclone()
Creates and returns a copy of this object. The returned EJBQLAST shares the same state as this object, meaning the fields type, text, line, column, and typeInfo have the same values. But it is not bound to any tree structure, thus the child is null and the sibling is null.

return
a clone of this instance.

        EJBQLAST clone = (EJBQLAST)super.clone();
        clone.setFirstChild(null);
        clone.setNextSibling(null);
        return clone;
    
public intgetColumn()

        return column;
    
private java.lang.StringgetIndent(int level)
Returns the indent specified by level.

        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < level; i++) {
            buf.append(INDENT);
        }
        return buf.toString();
    
public intgetLine()

        return line;
    
public java.lang.StringgetTreeRepr(java.lang.String title)
Returns a full string representation of this JQLAST. The returned string starts with the specified title string, followed by the string representation of this ast, followed by the string representation of the child ast nodes of this ast. The method dumps each ast node on a separate line. Child ast nodes are indented. The method calls toString to dump a single node w/o children.

return
string representation of this ast including children.

        return title + this.getTreeRepr(0);
    
private java.lang.StringgetTreeRepr(int level)
Helper method for getTreeRepr.

        StringBuffer repr = new StringBuffer();
        // current node
        repr.append(SEPARATOR);
        repr.append(getIndent(level));
        repr.append(this.toString());
        // handle children
        for (EJBQLAST node = (EJBQLAST)this.getFirstChild(); 
             node != null; 
             node = (EJBQLAST)node.getNextSibling()) {
            repr.append(node.getTreeRepr(level+1));
        }
        return repr.toString();
    
public java.lang.ObjectgetTypeInfo()

        return typeInfo;
    
public voidinitialize(persistence.antlr.Token t)

        setType(t.getType());
        setText(t.getText());
        setLine(t.getLine());
        setColumn(t.getColumn());
    
public voidinitialize(int type, java.lang.String text, java.lang.Object typeInfo)

        setType(type);
        setText(text);
        setTypeInfo(typeInfo);
    
public voidinitialize(persistence.antlr.collections.AST _ast)

        EJBQLAST ast = (EJBQLAST)_ast;
        setType(ast.getType());
        setText(ast.getText());
        setLine(ast.getLine());
        setColumn(ast.getColumn());
        setTypeInfo(ast.getTypeInfo());
    
public voidsetColumn(int column)

        this.column = column;
    
public voidsetLine(int line)

        this.line = line;
    
public voidsetTypeInfo(java.lang.Object typeInfo)

        this.typeInfo = typeInfo;
    
public java.lang.StringtoString()
Returns a string representation of this EJBQLAST w/o child ast nodes.

return
a string representation of the object.

        Object typeInfo = getTypeInfo();
        StringBuffer repr = new StringBuffer();
        // token text
        repr.append((getText() == null ? "null" : getText())); //NOI18N
        repr.append(" ["); //NOI18N
        // token type
        repr.append(getType());
        // line/column info
        repr.append(", ("); //NOI18N
        repr.append(getLine() + "/" + getColumn()); //NOI18N
        repr.append(")"); //NOI18N
        // type info
        repr.append(", "); //NOI18N
        repr.append(typeInfo);
        repr.append("]"); //NOI18N
        return repr.toString();