dochelper
Class DocumentSection

java.lang.Object
  extended by dochelper.DocumentSection

public class DocumentSection
extends java.lang.Object

The class DocumentSection implements the member classes in DocHelper can use to encapsulate content.


Field Summary
private  java.lang.String end
          Document Sections: Start.
private static int END_LEN
          Length of ||END||.
 java.util.Map params
          Params for the docsection.
private  java.lang.String start
          Document Sections: Start.
private static int START_LEN
          Length of ||START||.
 
Constructor Summary
DocumentSection(java.io.File docRef)
          Create an instance of DocumentSection using a reference to a sfile.
DocumentSection(java.io.File docRef, java.util.Map params)
          Create an instance of DocumentSection using a reference to a file.
DocumentSection(java.lang.String start, java.lang.String end)
          Create a DocumentSection instance using literal Values.
 
Method Summary
private  java.lang.String applyParams(java.lang.String in)
          For the key set within the params Map, this method will look for $[key] within in and replace it with the return of params.get([key]);
 java.lang.String getEND()
          Get the End of this Document Section
 java.lang.String getSTART()
          Get the Start of the Document Section
 void setParams(java.util.Map params)
          Set the parameters Map for this document section.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

start

private final java.lang.String start
Document Sections: Start.


end

private final java.lang.String end
Document Sections: Start.


START_LEN

private static final int START_LEN
Length of ||START||.

See Also:
Constant Field Values

END_LEN

private static final int END_LEN
Length of ||END||.

See Also:
Constant Field Values

params

public java.util.Map params
Params for the docsection. Parameters may be passed to a Document Section object in order to define "hooks" that may be replaced with parameter values. The Start and End sections may need to contain specific information that may be provided by the object that is utilizing this DocSection like: Filename, Tablename, path, etc. For a key set within the params Map, a Document section will look for $[key] within its text (start or end) and replace it with the return of params.get([key]);

Constructor Detail

DocumentSection

public DocumentSection(java.lang.String start,
                       java.lang.String end)
Create a DocumentSection instance using literal Values.

Parameters:
start - a String that will be the start of this Document Section
end - a String that will be the end of this Document Section

DocumentSection

public DocumentSection(java.io.File docRef)
                throws java.io.FileNotFoundException,
                       java.io.IOException
Create an instance of DocumentSection using a reference to a sfile. The Format of the file must be : ||START|| Content (may be multiline) ||END|| Content (may be multiline)

Parameters:
docRef - File reference of template to use.
Throws:
java.lang.Exception
java.io.FileNotFoundException
java.io.IOException

DocumentSection

public DocumentSection(java.io.File docRef,
                       java.util.Map params)
                throws java.lang.Exception
Create an instance of DocumentSection using a reference to a file. The Format of the file must be : ||START|| Content (may be multiline) ||END|| Content (may be multiline)

Parameters:
docRef - File reference of template to use.
params - a Map that hold the dynamic values to replace within the start and end sections
Throws:
java.lang.Exception
Method Detail

setParams

public void setParams(java.util.Map params)
Set the parameters Map for this document section.

Parameters:
params - The parameter map used for this document section.

getSTART

public java.lang.String getSTART()
Get the Start of the Document Section

Returns:
Start section of this Document Section

getEND

public java.lang.String getEND()
Get the End of this Document Section

Returns:
the End Section

applyParams

private java.lang.String applyParams(java.lang.String in)
For the key set within the params Map, this method will look for $[key] within in and replace it with the return of params.get([key]);

Parameters:
in - String to be processed
Returns:
result of replacement