org.pz.platypus.plugin.pdf
Class Start

java.lang.Object
  extended by org.pz.platypus.plugin.pdf.Start
All Implemented Interfaces:
IPlugin

public class Start
extends java.lang.Object
implements IPlugin

Main line for PDF plugin. Error-handling convention: Output plugins handle all their own errors. Platypus is made aware of a problem only by the value returned from calling process(). However, it does not issue any user message(s) as a result of this.

Author:
alb

Field Summary
private  PdfCommandTable commandTable
          the command table indexed by command root
private  PdfOutfile outfile
          the outputfile we write to
private  PdfData pdfData
          contains state data for the pdf file
 
Constructor Summary
Start()
          Start() is always called first by Platypus, followed by a call to process() Any plugin initialization code should go in here.
Start(PdfOutfile newOutfile, PdfCommandTable newCommandTable)
          Constructor that is only ever used in unit testing
 
Method Summary
private  void errMsgUnrecognizedCommand(Token tok, GDD gdd)
          Output error message to logger for unrecognized command
(package private)  boolean isNextTokenCr(int currTokNumber, TokenList tokList)
          Determines if the next token in the token list is the command [cr]
 void process(GDD gdd, CommandLineArgs clArgs)
          This is the main line of the plug-in.
(package private)  int processCommand(Token tok, PdfData pdfData, int tokNum)
          Principal method for implementing command tokens
(package private)  int processCompoundCommand(GDD gdd, int startTokNumber)
          Handle compount commands.
(package private)  void processMacro(GDD gdd, Token tok, int tokNum)
          Look up the macro and insert a new token with the text right after the present token
(package private)  void processSymbol(java.lang.String filename, Token tok, int tokNum, PdfData pdd)
          Process a symbol or foreign character
(package private)  void processText(GDD gdd, java.lang.String filename, java.lang.String text)
          Process a token consisting of a text item
 void processTokens(PdfData pdfData, java.lang.String outfileName)
          Where the token stream is translated into text and actions.
(package private)  void setUpDataItems(GDD gdd)
          set up various data items needed in processing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pdfData

private PdfData pdfData
contains state data for the pdf file


outfile

private PdfOutfile outfile
the outputfile we write to


commandTable

private PdfCommandTable commandTable
the command table indexed by command root

Constructor Detail

Start

public Start()
Start() is always called first by Platypus, followed by a call to process() Any plugin initialization code should go in here.


Start

public Start(PdfOutfile newOutfile,
             PdfCommandTable newCommandTable)
Constructor that is only ever used in unit testing

Parameters:
newOutfile - the outfile for this PDF
newCommandTable - command table for this PDF
Method Detail

process

public void process(GDD gdd,
                    CommandLineArgs clArgs)
This is the main line of the plug-in. Platypus calls only the Start constructor and this method.

Specified by:
process in interface IPlugin
Parameters:
gdd - The Global Document Data
clArgs - command-line arguments in a hash map (key = argument, value = parameters)

setUpDataItems

void setUpDataItems(GDD gdd)
set up various data items needed in processing

Parameters:
gdd - the GDD

processTokens

public void processTokens(PdfData pdfData,
                          java.lang.String outfileName)
                   throws java.io.IOException
Where the token stream is translated into text and actions.

Parameters:
pdfData - state info about the PDF file
outfileName - the file being written to
Throws:
java.io.IOException - in the event the file can't be written to

isNextTokenCr

boolean isNextTokenCr(int currTokNumber,
                      TokenList tokList)
Determines if the next token in the token list is the command [cr]

Parameters:
currTokNumber - the number of the current token
tokList - the list of tokens
Returns:
true if == [cr]; false if not, or if an error occurred.

processCommand

int processCommand(Token tok,
                   PdfData pdfData,
                   int tokNum)
Principal method for implementing command tokens

Parameters:
tok - command token to process
pdfData - document state data
tokNum - the number of the token in the token list
Returns:
returns the number of tokens to skip.

errMsgUnrecognizedCommand

private void errMsgUnrecognizedCommand(Token tok,
                                       GDD gdd)
Output error message to logger for unrecognized command

Parameters:
tok - the command token
gdd - the GDD

processCompoundCommand

int processCompoundCommand(GDD gdd,
                           int startTokNumber)
Handle compount commands. Essentially, extract the individual commands and process those.

Parameters:
gdd - the GDD
startTokNumber - the number of the opening token in the compound command
Returns:
the number of tokens to skip over because they're processed here

processMacro

void processMacro(GDD gdd,
                  Token tok,
                  int tokNum)
Look up the macro and insert a new token with the text right after the present token

Parameters:
gdd - GDD data
tok - current token (the macro)
tokNum - the number of the current token

processSymbol

void processSymbol(java.lang.String filename,
                   Token tok,
                   int tokNum,
                   PdfData pdd)
             throws java.io.IOException
Process a symbol or foreign character

Parameters:
filename - name of the output file (in the event the output file is not open yet)
tok - the Token containing the symbol info
tokNum - the number of the token
pdd - the PDF document data
Throws:
java.io.IOException - if any error occurred

processText

void processText(GDD gdd,
                 java.lang.String filename,
                 java.lang.String text)
           throws java.io.IOException
Process a token consisting of a text item

Parameters:
gdd - the GDD
filename - name of the output file (in the event the output file is not open yet
text - the text to output
Throws:
java.io.IOException - if any error occurred


Copyright © 2008-10 Pacific Data Works LLC