net.percederberg.grammatica.output
Class JavaParserGenerator

java.lang.Object
  |
  +--net.percederberg.grammatica.output.ParserGenerator
        |
        +--net.percederberg.grammatica.output.JavaParserGenerator

public class JavaParserGenerator
extends ParserGenerator

A Java parser generator. This class generates the source code files needed for a Java parser.


Field Summary
 
Fields inherited from class net.percederberg.grammatica.output.ParserGenerator
FILE_COMMENT
 
Constructor Summary
JavaParserGenerator(Grammar grammar)
          Creates a new Java parser generator.
 
Method Summary
 JavaFile createJavaFile()
          Creates a Java file in the correct base directory.
 java.lang.String getBaseName()
          Returns the Java class name prefix.
 java.lang.String getBasePackage()
          Returns the Java package where the classes will be created.
 java.lang.String getClassComment()
          Returns the Java class comment.
 CodeStyle getCodeStyle()
          Returns the Java code style to use.
 boolean getPublicAccess()
          Returns the public access flag.
 void setBaseName(java.lang.String name)
          Sets the Java class name prefix.
 void setBasePackage(java.lang.String pkg)
          Sets the Java package name where the classes will be created.
 void setPublicAccess(boolean flag)
          Sets the public access flag.
 void write()
          Writes the Java source code files.
 
Methods inherited from class net.percederberg.grammatica.output.ParserGenerator
getBaseDir, getFileComment, getGrammar, setBaseDir
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaParserGenerator

public JavaParserGenerator(Grammar grammar)
Creates a new Java parser generator.

Parameters:
grammar - the grammar to use
Method Detail

getBasePackage

public java.lang.String getBasePackage()
Returns the Java package where the classes will be created.

Returns:
the fully qualified Java package name

setBasePackage

public void setBasePackage(java.lang.String pkg)
Sets the Java package name where the classes will be created.

Parameters:
pkg - the fully qualified package name

getBaseName

public java.lang.String getBaseName()
Returns the Java class name prefix.

Returns:
the Java class name prefix

setBaseName

public void setBaseName(java.lang.String name)
Sets the Java class name prefix.

Parameters:
name - the Java class name prefix

getPublicAccess

public boolean getPublicAccess()
Returns the public access flag.

Returns:
true if the classes should have public access, or false otherwise

setPublicAccess

public void setPublicAccess(boolean flag)
Sets the public access flag.

Parameters:
flag - the new public access flag value

getCodeStyle

public CodeStyle getCodeStyle()
Returns the Java code style to use.

Returns:
the Java code style to use

getClassComment

public java.lang.String getClassComment()
Returns the Java class comment.

Returns:
the Java class comment

write

public void write()
           throws java.io.IOException
Writes the Java source code files.

Specified by:
write in class ParserGenerator
Throws:
java.io.IOException - if the files couldn't be written correctly

createJavaFile

public JavaFile createJavaFile()
Creates a Java file in the correct base directory. The package will be set if applicable.

Returns:
a new Java file