FileDocCategorySizeDatePackage
GrammarFile.javaAPI DocGlassfish v2 API2495Wed Aug 30 15:34:16 BST 2006persistence.antlr.preprocessor

GrammarFile

public class GrammarFile extends Object
Stores header action, grammar preamble, file options, and list of grammars in the file

Fields Summary
protected String
fileName
protected String
headerAction
protected IndexedVector
options
protected IndexedVector
grammars
protected boolean
expanded
protected Tool
tool
Constructors Summary
public GrammarFile(Tool tool, String f)


         
        fileName = f;
        grammars = new IndexedVector();
        this.tool = tool;
    
Methods Summary
public voidaddGrammar(persistence.antlr.preprocessor.Grammar g)

        grammars.appendElement(g.getName(), g);
    
public voidaddHeaderAction(java.lang.String a)

        headerAction += a + System.getProperty("line.separator");
    
public voidgenerateExpandedFile()

        if (!expanded) {
            return;	// don't generate if nothing got expanded
        }
        String expandedFileName = nameForExpandedGrammarFile(this.getName());

        // create the new grammar file with expanded grammars
        PrintWriter expF = tool.openOutputFile(expandedFileName);
        expF.println(toString());
        expF.close();
    
public persistence.antlr.collections.impl.IndexedVectorgetGrammars()

        return grammars;
    
public java.lang.StringgetName()

        return fileName;
    
public java.lang.StringnameForExpandedGrammarFile(java.lang.String f)

        if (expanded) {
            // strip path to original input, make expanded file in current dir
            return "expanded" + tool.fileMinusPath(f);
        }
        else {
            return f;
        }
    
public voidsetExpanded(boolean exp)

        expanded = exp;
    
public voidsetOptions(persistence.antlr.collections.impl.IndexedVector o)

        options = o;
    
public java.lang.StringtoString()

        String h = headerAction == null ? "" : headerAction;
        String o = options == null ? "" : Hierarchy.optionsToString(options);

        StringBuffer s = new StringBuffer(10000); s.append(h); s.append(o);
        for (Enumeration e = grammars.elements(); e.hasMoreElements();) {
            Grammar g = (Grammar)e.nextElement();
            s.append(g.toString());
        }
        return s.toString();