net.percederberg.grammatica.code.csharp
Class CSharpMethod

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

public class CSharpMethod
extends CodeElement

A class generating a C# method declaration.

Version:
1.0
Author:
Per Cederberg,

Field Summary
static int ABSTRACT
          The abstract modifier constant.
static int EXTERN
          The extern modifier constant.
static int INTERNAL
          The internal access modifier constant.
static int NEW
          The new modifier constant.
static int OVERRIDE
          The override 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.
static int STATIC
          The static modifier constant.
static int VIRTUAL
          The virtual modifier constant.
 
Constructor Summary
CSharpMethod(int modifiers, java.lang.String name, java.lang.String args, java.lang.String returnType)
          Creates a new method with the specified arguments.
CSharpMethod(java.lang.String name)
          Creates a new method with the specified name.
CSharpMethod(java.lang.String name, java.lang.String args)
          Creates a new method with the specified name and arguments.
CSharpMethod(java.lang.String name, java.lang.String args, java.lang.String returnType)
          Creates a new method with the specified arguments.
 
Method Summary
 void addCode(java.lang.String codeLines)
          Adds one or more lines of actual code.
 void addComment(CSharpComment comment)
          Sets a comment for this method.
 boolean canPrintCode()
          Checks if the method source code can the printed.
 int category()
          Returns a numeric category number for the code element.
 void print(java.io.PrintWriter out, CodeStyle style, int indent)
          Prints the code element to the specified output stream.
 void setPrintCode(boolean value)
          Sets the print code flag.
 
Methods inherited from class net.percederberg.grammatica.code.CodeElement
compareTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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.

See Also:
Constant Field Values

PROTECTED

public static final int PROTECTED
The protected access modifier constant.

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. Cannot be combined with virtual, override, or abstract.

See Also:
Constant Field Values

STATIC

public static final int STATIC
The static modifier constant. Cannot be combined with virtual, override, or abstract.

See Also:
Constant Field Values

NEW

public static final int NEW
The new modifier constant. Cannot be combined with override.

See Also:
Constant Field Values

VIRTUAL

public static final int VIRTUAL
The virtual modifier constant. Cannot be combined with private, static, override, or abstract.

See Also:
Constant Field Values

SEALED

public static final int SEALED
The sealed modifier constant. Cannot be combined with abstract.

See Also:
Constant Field Values

OVERRIDE

public static final int OVERRIDE
The override modifier constant. Cannot be combined with private, static, virtual, or new.

See Also:
Constant Field Values

ABSTRACT

public static final int ABSTRACT
The abstract modifier constant. Cannot be combined with private, static, virtual, sealed, or extern.

See Also:
Constant Field Values

EXTERN

public static final int EXTERN
The extern modifier constant. Cannot be combined with abstract.

See Also:
Constant Field Values
Constructor Detail

CSharpMethod

public CSharpMethod(java.lang.String name)
Creates a new method with the specified name. The method will not take any arguments and will return void.

Parameters:
name - the method name

CSharpMethod

public CSharpMethod(java.lang.String name,
                    java.lang.String args)
Creates a new method with the specified name and arguments. The method will return void.

Parameters:
name - the method name
args - the argument list, excluding parenthesis

CSharpMethod

public CSharpMethod(java.lang.String name,
                    java.lang.String args,
                    java.lang.String returnType)
Creates a new method with the specified arguments.

Parameters:
name - the method name
args - the argument list, excluding parenthesis
returnType - the return type

CSharpMethod

public CSharpMethod(int modifiers,
                    java.lang.String name,
                    java.lang.String args,
                    java.lang.String returnType)
Creates a new method with the specified arguments.

Parameters:
modifiers - the modifier flags to use
name - the method name
args - the argument list, excluding parenthesis
returnType - the return type
Method Detail

addCode

public void addCode(java.lang.String codeLines)
Adds one or more lines of actual code.

Parameters:
codeLines - the lines of Java code to add

addComment

public void addComment(CSharpComment comment)
Sets a comment for this method.

Parameters:
comment - the new method comment

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

canPrintCode

public boolean canPrintCode()
Checks if the method source code can the printed. This method will return false if the method is abstract or if the print code flag is set to false.

Returns:
true if method source code can be printed, or false otherwise

setPrintCode

public void setPrintCode(boolean value)
Sets the print code flag.

Parameters:
value - the new print code flag value

print

public void print(java.io.PrintWriter out,
                  CodeStyle style,
                  int indent)
Prints the code element 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