output.java
Enum State

java.lang.Object
  extended by java.lang.Enum<State>
      extended by output.java.State
All Implemented Interfaces:
Serializable, Comparable<State>

public enum State
extends Enum<State>

The state of a CodeBuilder object. What state the builder is in constrains the scopes that can be begun; for instance, a method cannot be defined immediately within another.

The valid state transitions can be summarized thus:

Also, any state can transition to COMMENT, but COMMENT cannot transition to any other state. (This reflects the fact that a comment can appear anywhere but cannot contain anything but plain text.)

When a scope is closed using a method such as CodeBuilder.finishClass(), the builder reverts to its previous state, following one of the above transitions in reverse.


Enum Constant Summary
BLOCK
          Anything within curly braces in the body of a method.
CLASS
          Any class declaration (top-level, inner, local, etc.).
COMMENT
          Text within a multiline comment (either JavaDoc or plain).
METHOD
          The body of a method.
TOPLEVEL
          The top level of the file, containing the package statement, import statements, and classes.
 
Method Summary
static State valueOf(String name)
          Returns the enum constant of this type with the specified name.
static State[] values()
          Returns an array containing the constants of this enum type, in the order they're declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

TOPLEVEL

public static final State TOPLEVEL
The top level of the file, containing the package statement, import statements, and classes.

Cannot be contained; can contain only CLASS and COMMENT scopes.


CLASS

public static final State CLASS
Any class declaration (top-level, inner, local, etc.).

Can be contained by any scope; can contain CLASS, METHOD, and COMMENT scopes.


METHOD

public static final State METHOD
The body of a method. Also refers to static blocks in classes (since they are valid when and only when methods are).

Can be contained only by a CLASS scope; can contain CLASS, BLOCK, and COMMENT scopes.


BLOCK

public static final State BLOCK
Anything within curly braces in the body of a method.

Can be contained either by a METHOD scope or by another BLOCK scope. Can contain CLASS, BLOCK, and COMMENT scopes.


COMMENT

public static final State COMMENT
Text within a multiline comment (either JavaDoc or plain).

Cannot contain other scopes.

Method Detail

values

public static final State[] values()
Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants as follows:
for(State c : State.values())
        System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they're declared

valueOf

public static State valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name