org.brains2b.typewriter
Class MemberTemplate

java.lang.Object
  extended byorg.brains2b.typewriter.MemberTemplate
All Implemented Interfaces:
Template

public class MemberTemplate
extends java.lang.Object
implements Template

Template for creating a Member in a class

Version:
0.10.1 [04-05-2006]
Author:
dennis@brains2b.nl

Constructor Summary
MemberTemplate(int modifiers, java.lang.String type, java.lang.String name)
          Constructor Make a member with the given name and type and with the given access.
MemberTemplate(int modifiers, java.lang.String type, java.lang.String name, java.lang.Object initialValue)
          Constructor Make a member with the given name and type and with the given access and initial value.
MemberTemplate(java.lang.String type, java.lang.String name)
          Constructor Make a private member with the given name and type
MemberTemplate(java.lang.String type, java.lang.String name, java.lang.Object initialValue)
          Constructor Make a private member with the given name and type
 
Method Summary
 void addImport(java.lang.String name)
          add an String as import to the top class of this element
 java.lang.Object getInitialValue()
          get the initial value for this member
 Template getParent()
          get the direct parent of this element.

This can be the class, method, try element or loop elements

 java.lang.String getType()
           
 void setInitialValue(java.lang.Object initialValue)
          set the initial value for this member
 void setParent(Template parent)
          (non-Javadoc) set the direct parent of this element

The parent can be the class, method, try element or loop elements

 void setType(java.lang.String type)
           
 void write(java.io.PrintWriter pw, int indent)
          write the template information to the PrintWriter at the given indention.

Indention is multiplied by 4 to supply the spaces for the indention.

 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemberTemplate

public MemberTemplate(java.lang.String type,
                      java.lang.String name)
Constructor

Make a private member with the given name and type

Parameters:
type - String, representation of the type
name - String, the name of the method

MemberTemplate

public MemberTemplate(java.lang.String type,
                      java.lang.String name,
                      java.lang.Object initialValue)
Constructor

Make a private member with the given name and type

Parameters:
type - String, representation of the return value
name - String, the name of the method
initialValue - Object, the initial value for this method, supply a Literal object for a String or char that should be used as a Literal value

MemberTemplate

public MemberTemplate(int modifiers,
                      java.lang.String type,
                      java.lang.String name)
Constructor

Make a member with the given name and type and with the given access.

Parameters:
modifiers - int, sum of the modifiers to use for this method
type - String, representation of the return value
name - String, the name of the method

MemberTemplate

public MemberTemplate(int modifiers,
                      java.lang.String type,
                      java.lang.String name,
                      java.lang.Object initialValue)
Constructor

Make a member with the given name and type and with the given access and initial value.

Parameters:
modifiers - int, sum of the modifiers to use for this method
type - String, representation of the return value
name - String, the name of the method
initialValue - Object, the initial value for this method, supply a Literal object for a String or char that should be used as a Literal value
Method Detail

write

public void write(java.io.PrintWriter pw,
                  int indent)
write the template information to the PrintWriter at the given indention.

Indention is multiplied by 4 to supply the spaces for the indention.

Specified by:
write in interface Template
Parameters:
pw - PrintWriter, an initialized PrintWriter to write this element of the Class to
indent - int, the indention for this element.

Value is multiplied by four to give the number of spaces used for indention


getInitialValue

public java.lang.Object getInitialValue()
get the initial value for this member

Returns:
Object

setInitialValue

public void setInitialValue(java.lang.Object initialValue)
set the initial value for this member

Parameters:
initialValue - Object, the initial value for this member, supply a Literal object for a String or char that should be used as a Literal value
See Also:
Literal

getParent

public Template getParent()
get the direct parent of this element.

This can be the class, method, try element or loop elements

Specified by:
getParent in interface Template
Returns:
Template, the parent of this element

setParent

public void setParent(Template parent)
(non-Javadoc) set the direct parent of this element

The parent can be the class, method, try element or loop elements

Specified by:
setParent in interface Template
Parameters:
parent - Template, the parent of this element

addImport

public void addImport(java.lang.String name)
add an String as import to the top class of this element

Specified by:
addImport in interface Template
Parameters:
name - String, the fully qualified class name. Could be used to enter the complete package by adding *

getType

public java.lang.String getType()
Returns:
get the type of Loop (DO|WHILE|FOR).

setType

public void setType(java.lang.String type)
Parameters:
type - The type of Loop to set (DO|WHILE|FOR).