org.brains2b.typewriter
Class TryTemplate

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

public class TryTemplate
extends ContentTemplate

Create a Try statement.

Version:
0.12 [26-07-2006]
Author:
dennis@brains2b.nl

Field Summary
 
Fields inherited from class org.brains2b.typewriter.ContentTemplate
m_content
 
Constructor Summary
TryTemplate(java.lang.Class exceptionClass)
          Constructor for TryTemplate.
TryTemplate(java.lang.String exceptionClassName)
          Constructor for TryTemplate.
 
Method Summary
 ExceptionTemplate createException(java.lang.String exceptionClassName)
          create a new Exception for this Try statement.
 BlockTemplate createFinally()
          create a finally block for this Exception
 ExceptionTemplate getDefaultException()
          get the Exception this Try statement was created with
 void write(java.io.PrintWriter writer, int indent)
          write the TryStatement to the PrintWriter.
 
Methods inherited from class org.brains2b.typewriter.ContentTemplate
addImport, addText, createFor, createIf, createTry, createWhile, getContent, getParent, makeInstance, makeInstance, makeInstance, setContent, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TryTemplate

public TryTemplate(java.lang.Class exceptionClass)
Constructor for TryTemplate.

Parameters:
exceptionClass - Class, the class for the Exception this try should catch. You can add more Exceptions by using createException(String)
See Also:
createException(java.lang.String)

TryTemplate

public TryTemplate(java.lang.String exceptionClassName)
Constructor for TryTemplate.

Parameters:
exceptionClassName - String, a String representing the complete class name, including package of the Exception this try should catch. You can add more Exceptions by using createException(String)
See Also:
createException(java.lang.String)
Method Detail

write

public void write(java.io.PrintWriter writer,
                  int indent)
write the TryStatement to the PrintWriter.

Specified by:
write in interface Template
Overrides:
write in class ContentTemplate
See Also:
Template.write(PrintWriter, int)

getDefaultException

public ExceptionTemplate getDefaultException()
get the Exception this Try statement was created with

Returns:
ExceptionTemplate

createException

public ExceptionTemplate createException(java.lang.String exceptionClassName)
create a new Exception for this Try statement. This Exception will be added in a list of catch Statements for this try. Exceptions will be added to the catch blocks in order they where added. Starting with the the one this Try statement was created for.

Parameters:
exceptionClassName - String, the fully qualified class name of this Exception
Returns:
ExceptionTemplate

createFinally

public BlockTemplate createFinally()
create a finally block for this Exception

Returns:
BlockTemplate, the finally block