FileDocCategorySizeDatePackage
JQLAST.javaAPI DocGlassfish v2 API9262Fri May 04 22:35:06 BST 2007com.sun.jdo.spi.persistence.support.sqlstore.query.jqlc

JQLAST

public class JQLAST extends CommonAST
This class represents a node in the intermediate representation (AST) used by the query compiler. It provides - line info - column info - type info (object of class util.type.Type): the semantic analysis calculates the type of an expression and adds this info to each node. - RetrieveDesc info - value: this allows to add an arbitrary value to a node. This is used in compile time calulation of constant expression.
author
Michael Bouschen
version
0.1

Fields Summary
private static char
SEPARATOR
private static String
INDENT
protected int
line
protected int
column
protected com.sun.jdo.spi.persistence.support.sqlstore.query.util.type.Type
jqlType
protected com.sun.jdo.spi.persistence.support.sqlstore.RetrieveDesc
rd
protected Object
value
Constructors Summary
public JQLAST()


     
    
    
public JQLAST(int type, String text, com.sun.jdo.spi.persistence.support.sqlstore.query.util.type.Type jqlType)

        initialize(type, text, jqlType);
    
public JQLAST(int type, String text, com.sun.jdo.spi.persistence.support.sqlstore.query.util.type.Type jqlType, Object value)

        initialize(type, text, jqlType, value);
    
public JQLAST(Token t)

        initialize(t);
    
public JQLAST(JQLAST ast)

        initialize(ast);
    
Methods Summary
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 com.sun.jdo.spi.persistence.support.sqlstore.query.util.type.TypegetJQLType()

        return jqlType;
    
public intgetLine()

        return line;
    
public com.sun.jdo.spi.persistence.support.sqlstore.RetrieveDescgetRetrieveDesc()

        return rd;
    
public static java.lang.StringgetRetrieveDescRepr(com.sun.jdo.spi.persistence.support.sqlstore.RetrieveDesc rd)
Returns a string representation of the spceified RetrieveDesc.

        StringBuffer buf = new StringBuffer();
        buf.append("RD:"); //NOI18N
        if (rd == null)
        {
            buf.append("null"); //NOI18N
        }
        else
        {
            String pcClassName = rd.getPersistenceCapableClass().toString();
            if (pcClassName.startsWith("class ")) //NOI18N
                buf.append(pcClassName.substring(6));
            else
                buf.append(pcClassName);
            buf.append("@"); //NOI18N
            buf.append(System.identityHashCode(rd));
        }
        return buf.toString();
    
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 (JQLAST node = (JQLAST)this.getFirstChild(); 
             node != null; 
             node = (JQLAST)node.getNextSibling()) {
            repr.append(node.getTreeRepr(level+1));
        }
        return repr.toString();
    
public java.lang.ObjectgetValue()

        return value;
    
public voidinitialize(int type, java.lang.String text, com.sun.jdo.spi.persistence.support.sqlstore.query.util.type.Type jqlType, java.lang.Object value)

        setType(type);
        setText(text);
        setJQLType(jqlType);
        setValue(value);
    
public voidinitialize(persistence.antlr.collections.AST ast)

        initialize((JQLAST)ast);
    
public voidinitialize(com.sun.jdo.spi.persistence.support.sqlstore.query.jqlc.JQLAST ast)

        setType(ast.getType());
        setText(ast.getText());
        setLine(ast.getLine());
        setColumn(ast.getColumn());
        setJQLType(ast.getJQLType());
        setValue(ast.getValue());
        setRetrieveDesc(ast.getRetrieveDesc());
        setValue(ast.getValue());
    
public voidinitialize(int type)

        setType(type);
    
public voidinitialize(int type, java.lang.String text)

        setType(type);
        setText(text);
    
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, com.sun.jdo.spi.persistence.support.sqlstore.query.util.type.Type jqlType)

        setType(type);
        setText(text);
        setJQLType(jqlType);
    
public voidsetColumn(int column)

        this.column = column;
    
public voidsetJQLType(com.sun.jdo.spi.persistence.support.sqlstore.query.util.type.Type jqlType)

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

        this.line = line;
    
public voidsetRetrieveDesc(com.sun.jdo.spi.persistence.support.sqlstore.RetrieveDesc rd)

        this.rd = rd;
    
public voidsetValue(java.lang.Object value)

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

return
a string representation of the object.

        StringBuffer repr = new StringBuffer();
		Object jqlType = getJQLType();
        RetrieveDesc rd = getRetrieveDesc();
        // 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(jqlType);
        // RetrieveDesc info
        repr.append(", "); //NOI18N
        repr.append(getRetrieveDescRepr(rd));
        repr.append("]"); //NOI18N
        return repr.toString();