net.percederberg.grammatica.code.csharp
Class CSharpClass

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

public class CSharpClass
extends net.percederberg.grammatica.code.csharp.CSharpType

A class generating a C# class declaration.


Field Summary
static int ABSTRACT
          The abstract modifier constant.
static int INTERNAL
          The internal access modifier constant.
static int NEW
          The new modifier constant.
static int PRIVATE
          The private access modifier constant.
static int PROTECTED
          The protected access modifier constant.
static int PROTECTED_INTERNAL
          The protected internal access modifier constant.
static int PUBLIC
          The public access modifier constant.
static int SEALED
          The sealed modifier constant.
 
Constructor Summary
CSharpClass(int modifiers, java.lang.String name)
          Creates a new class code generator with the specified modifiers.
CSharpClass(int modifiers, java.lang.String name, java.lang.String extendsClass)
          Creates a new class code generator with the specified access modifier that extends the specified class.
CSharpClass(int modifiers, java.lang.String name, java.lang.String[] extendClasses)
          Creates a new class code generator with the specified access modifier that extends and implements the specified classes or interfaces.
CSharpClass(java.lang.String name)
          Creates a new class code generator with a public access modifier.
 
Method Summary
 void addClass(CSharpClass member)
          Adds an inner class as a member.
 void addComment(CSharpComment comment)
          Sets the type comment.
 void addConstructor(CSharpConstructor member)
          Adds a constructor to the class.
 void addEnumeration(CSharpEnumeration member)
          Adds an enumeration as a member.
 void addMethod(CSharpMethod member)
          Adds a method to the class.
 int category()
          Returns a numeric category number for the code element.
 void print(java.io.PrintWriter out, CodeStyle style, int indent)
          Prints the class to the specified stream.
protected  void print(java.io.PrintWriter out, CodeStyle style, int indent, java.lang.String type)
          Prints the type to the specified stream.
protected  void printSeparator(java.io.PrintWriter out, CodeStyle style, CodeElement prev, CodeElement next)
          Prints the lines separating two elements.
 java.lang.String toString()
          Returns the type name.
 
Methods inherited from class net.percederberg.grammatica.code.CodeElementContainer
addElement, printContents
 
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
 

Field Detail

PUBLIC

public static final int PUBLIC
The public access modifier constant.

See Also:
Constant Field Values

PROTECTED_INTERNAL

public static final int PROTECTED_INTERNAL
The protected internal access modifier constant. May only be used when declared inside another type.

See Also:
Constant Field Values

PROTECTED

public static final int PROTECTED
The protected access modifier constant. May only be used when declared inside another type.

See Also:
Constant Field Values

INTERNAL

public static final int INTERNAL
The internal access modifier constant.

See Also:
Constant Field Values

PRIVATE

public static final int PRIVATE
The private access modifier constant. May only be used when declared inside another type.

See Also:
Constant Field Values

ABSTRACT

public static final int ABSTRACT
The abstract modifier constant.

See Also:
Constant Field Values

SEALED

public static final int SEALED
The sealed modifier constant.

See Also:
Constant Field Values

NEW

public static final int NEW
The new modifier constant. May only be used when declared inside another type.

See Also:
Constant Field Values
Constructor Detail

CSharpClass

public CSharpClass(java.lang.String name)
Creates a new class code generator with a public access modifier.

Parameters:
name - the class name

CSharpClass

public CSharpClass(int modifiers,
                   java.lang.String name)
Creates a new class code generator with the specified modifiers.

Parameters:
modifiers - the modifier flag constants
name - the class name

CSharpClass

public CSharpClass(int modifiers,
                   java.lang.String name,
                   java.lang.String extendsClass)
Creates a new class code generator with the specified access modifier that extends the specified class.

Parameters:
modifiers - the modifier flag constants
name - the class name
extendsClass - the class to extend or implement

CSharpClass

public CSharpClass(int modifiers,
                   java.lang.String name,
                   java.lang.String[] extendClasses)
Creates a new class code generator with the specified access modifier that extends and implements the specified classes or interfaces.

Parameters:
modifiers - the modifier flag constants
name - the class name
extendClasses - the classes to extend or implement
Method Detail

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

addClass

public void addClass(CSharpClass member)
Adds an inner class as a member.

Parameters:
member - the inner class to add

addEnumeration

public void addEnumeration(CSharpEnumeration member)
Adds an enumeration as a member.

Parameters:
member - the enumeration to add

addConstructor

public void addConstructor(CSharpConstructor member)
Adds a constructor to the class.

Parameters:
member - the member to add

addMethod

public void addMethod(CSharpMethod member)
Adds a method to the class.

Parameters:
member - the member to add

print

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

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

printSeparator

protected void printSeparator(java.io.PrintWriter out,
                              CodeStyle style,
                              CodeElement prev,
                              CodeElement next)
Prints the lines separating two elements.

Overrides:
printSeparator in class net.percederberg.grammatica.code.csharp.CSharpType
Parameters:
out - the output stream
style - the code style to use
prev - the previous element, or null if first
next - the next element, or null if last

toString

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

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

addComment

public void addComment(CSharpComment comment)
Sets the type comment. This method will remove any previous type comment.

Parameters:
comment - the new type comment

print

protected void print(java.io.PrintWriter out,
                     CodeStyle style,
                     int indent,
                     java.lang.String type)
Prints the type to the specified stream.

Parameters:
out - the output stream
style - the code style to use
indent - the indentation level
type - the type name