net.percederberg.grammatica.code.csharp
Class CSharpFile

java.lang.Object
  |
  +--net.percederberg.grammatica.code.CodeElement
        |
        +--net.percederberg.grammatica.code.CodeElementContainer
              |
              +--net.percederberg.grammatica.code.csharp.CSharpFile
All Implemented Interfaces:
java.lang.Comparable

public class CSharpFile
extends CodeElementContainer

A class generating a C# source code file.

Version:
1.0
Author:
Per Cederberg,

Constructor Summary
CSharpFile(java.io.File basedir, java.lang.String basename)
          Creates a new C# source code file.
 
Method Summary
 void addClass(CSharpClass c)
          Adds a class declaration to the file.
 void addComment(CSharpComment comment)
          Adds a file comment.
 void addEnumeration(CSharpEnumeration e)
          Adds an enumeration declaration to the file.
 void addNamespace(CSharpNamespace n)
          Adds a namespace declaration to the file.
 void addUsing(CSharpUsing u)
          Adds a using declaration to the file.
 int category()
          Returns a numeric category number for the code element.
 void print(java.io.PrintWriter out, CodeStyle style, int indent)
          Prints the file contents to the specified output stream.
 java.lang.String toString()
          Returns the file name.
 void writeCode(CodeStyle style)
          Writes the source code for this file.
 
Methods inherited from class net.percederberg.grammatica.code.CodeElementContainer
addElement, printContents, printSeparator
 
Methods inherited from class net.percederberg.grammatica.code.CodeElement
compareTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CSharpFile

public CSharpFile(java.io.File basedir,
                  java.lang.String basename)
Creates a new C# source code file.

Parameters:
basedir - the base output directory
basename - the base file name (without extension)
Method Detail

toString

public java.lang.String toString()
Returns the file name.

Overrides:
toString in class java.lang.Object
Returns:
the file name.

category

public int category()
Returns a numeric category number for the code element. A lower category number implies that the code element should be placed before code elements with a higher category number within a declaration.

Specified by:
category in class CodeElement
Returns:
the category number

addComment

public void addComment(CSharpComment comment)
Adds a file comment.

Parameters:
comment - the file comment to add

addUsing

public void addUsing(CSharpUsing u)
Adds a using declaration to the file.

Parameters:
u - the using declaration to add

addNamespace

public void addNamespace(CSharpNamespace n)
Adds a namespace declaration to the file.

Parameters:
n - the namespace declaration to add

addClass

public void addClass(CSharpClass c)
Adds a class declaration to the file.

Parameters:
c - the class declaration to add

addEnumeration

public void addEnumeration(CSharpEnumeration e)
Adds an enumeration declaration to the file.

Parameters:
e - the enumeration to add

writeCode

public void writeCode(CodeStyle style)
               throws java.io.IOException
Writes the source code for this file. Any previous file with this name will be overwritten.

Parameters:
style - the code style to use
Throws:
java.io.IOException - if the file could not be written properly

print

public void print(java.io.PrintWriter out,
                  CodeStyle style,
                  int indent)
Prints the file contents to the specified output stream.

Specified by:
print in class CodeElement
Parameters:
out - the output stream
style - the code style to use
indent - the indentation level