org.sourceflow.csharp
Class CSharpVariable

java.lang.Object
  extended byorg.sourceflow.CodeElement
      extended byorg.sourceflow.csharp.CSharpVariable
All Implemented Interfaces:
java.lang.Comparable

public class CSharpVariable
extends CodeElement

A class generating a C# variable declaration. The variable declaration should be placed as a member in a class.


Field Summary
static int CONST
          The const 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 READONLY
          The readonly modifier constant.
static int STATIC
          The static modifier constant.
static int VOLATILE
          The volatile modifier constant.
 
Constructor Summary
CSharpVariable(int modifiers, java.lang.String type, java.lang.String name)
          Creates a new variable with the specified modifiers, type and name.
CSharpVariable(int modifiers, java.lang.String type, java.lang.String name, java.lang.String initValue)
          Creates a new variable with the specified modifiers, type, name and initializer.
CSharpVariable(java.lang.String type, java.lang.String name)
          Creates a new variable with the specified type and name.
CSharpVariable(java.lang.String type, java.lang.String name, java.lang.String initValue)
          Creates a new variable with the specified type, name and initializer.
 
Method Summary
 void addArrayInit(java.lang.String elementValue)
          Adds initialization code for an array element value.
 void addComment(CSharpComment comment)
          Adds a comment to this variable.
 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.
 java.lang.String toString()
          Returns the variable name.
 
Methods inherited from class org.sourceflow.CodeElement
compareTo, printSeparator
 
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.

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.

See Also:
Constant Field Values

STATIC

public static final int STATIC
The static modifier constant. Cannot be combined with const.

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

CONST

public static final int CONST
The const modifier constant. Cannot be combined with static, readonly or volatile.

See Also:
Constant Field Values

READONLY

public static final int READONLY
The readonly modifier constant. Cannot be combined with const or volatile.

See Also:
Constant Field Values

VOLATILE

public static final int VOLATILE
The volatile modifier constant. Cannot be combined with const or readonly.

See Also:
Constant Field Values
Constructor Detail

CSharpVariable

public CSharpVariable(java.lang.String type,
                      java.lang.String name)
Creates a new variable with the specified type and name.

Parameters:
type - the variable type
name - the variable name

CSharpVariable

public CSharpVariable(int modifiers,
                      java.lang.String type,
                      java.lang.String name)
Creates a new variable with the specified modifiers, type and name.

Parameters:
modifiers - the modifier flags to use
type - the variable type
name - the variable name

CSharpVariable

public CSharpVariable(java.lang.String type,
                      java.lang.String name,
                      java.lang.String initValue)
Creates a new variable with the specified type, name and initializer.

Parameters:
type - the variable type
name - the variable name
initValue - the initialize value

CSharpVariable

public CSharpVariable(int modifiers,
                      java.lang.String type,
                      java.lang.String name,
                      java.lang.String initValue)
Creates a new variable with the specified modifiers, type, name and initializer.

Parameters:
modifiers - the modifier flags to use
type - the variable type
name - the variable name
initValue - the initialize value
Method Detail

toString

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

Returns:
the variable name

addComment

public void addComment(CSharpComment comment)
Adds a comment to this variable.

Parameters:
comment - the comment to add

addArrayInit

public void addArrayInit(java.lang.String elementValue)
Adds initialization code for an array element value. Each array element value added will be added last in the list of initialization values. If an init value has been specified with the constructor, it will be added first.

Parameters:
elementValue - the array element value

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

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