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 [12-9-2002]
Author:
dennis@brains2b.nl

Constructor Summary
MemberTemplate(int modifiers, java.lang.String type, java.lang.String name)
          Constructor
MemberTemplate(int modifiers, java.lang.String type, java.lang.String name, java.lang.Object initialValue, boolean literal)
          Constructor
MemberTemplate(java.lang.String type, java.lang.String name)
          Constructor
MemberTemplate(java.lang.String type, java.lang.String name, java.lang.Object initialValue, boolean literal)
          Constructor
 
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
 java.lang.String getObjectName(java.lang.String name)
          get the Class name without the package
 Template getParent()
          get the direct parent of this element.
 void setInitialValue(java.lang.Object initialValue)
          set the initial value for this member
 void setInitialValue(java.lang.Object initialValue, boolean literal)
          set the initial value for this member as literal
 void setParent(Template parent)
          set the direct parent of this element
 void write(java.io.PrintWriter pw, int indent)
          write the template information to the PrintWriter at the given 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 return value
name - String, the name of the method

MemberTemplate

public MemberTemplate(java.lang.String type,
                      java.lang.String name,
                      java.lang.Object initialValue,
                      boolean literal)
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
literal - boolean, use the initial value as literal instead of a String

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,
                      boolean literal)
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
literal - boolean, use the initial value as literal instead of a String
Method Detail

write

public void write(java.io.PrintWriter pw,
                  int indent)
Description copied from interface: Template
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

setInitialValue

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

setting literal to false is same as setInitialValue(Object)

Parameters:
initialValue - Object, initial value
literal - boolean, true if this is a literal

getParent

public Template getParent()
Description copied from interface: Template
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)
Description copied from interface: Template
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)
Description copied from interface: Template
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 *

getObjectName

public java.lang.String getObjectName(java.lang.String name)
Description copied from interface: Template
get the Class name without the package

Specified by:
getObjectName in interface Template
Parameters:
name - String, a classname with or without a package
Returns:
String, the classname without the package