platypus
Class Command

java.lang.Object
  extended by platypus.Command

public class Command
extends java.lang.Object

Converts command strings into actions. Mostly, it's a big switch statement, followed by many methods that perform the actions the commands prescribe.

Author:
alb

Field Summary
private  GDD gdd
          instance of the GDD singleton
private  GID gid
          instance of the GID singleton
private  Literals lits
          instance of the Literals singleton
 
Constructor Summary
Command()
          get the instances of the singletons we use here.
 
Method Summary
private  int dispatchCommand(int commandType, java.lang.String tokStr)
          Calls the routine that performs the command based on commandType
private  void doAlignment(java.lang.String alignment)
          Processes the alignment command by setting gdd_alignment to the specified value.
private  void doColumns(java.lang.String columnCommand)
          process the command to change the number of regular columns
 void doDefineMacro(java.lang.String tok)
          Defines a string to place in the macro dictionary
private  void doDump(java.lang.String tok)
          Dumps various groups of variables to console.
 void doDumpPage()
          Dump the various elements of a page in Platypus to the console.
private  void doFontBold(boolean boldOnOff)
          Turn the bold attribute of a font on or off.
private  int doFontFace(java.lang.String commandString)
          Changes the current font to a new typeface.
private  void doFontItalic(boolean italicOnOff)
          Turn the italic attribute of the current font on or off
private  int doFontSize(java.lang.String commandString)
          Changes the current font to a different size
 void doLeading(java.lang.String leadingSpec)
          set the leading based on a user-supplied value and type; e.g., 2li, 0.5in, etc.
 int doMargin(int whichMargin, java.lang.String tok)
          handles setting the page margins.
private  void doMarginMirror(boolean onOff)
          Sets the margin-mirror flag.
private  int doNewPage()
          Inserts a new page.
private  void doNewParagraph()
          Insert a new paragraph.
private  void doPageHeight(java.lang.String pageHeightStr)
          Page size is generally specified using a preset page size.
private  void doPageSize(java.lang.String pageSizeStr)
          Change the size of the page.
private  void doPageWidth(java.lang.String pageWidthStr)
          Page size is generally specified using a preset page size.
private  void doParagraphIndent(java.lang.String indentString)
          Creates a new ParaIndent (paragraph indent) structure and assigns it to the one in GDD provide no error occurred.
private  void doParagraphSkipSize(java.lang.String skipSize)
          Creates a new ParaSkip (paragraph line skip) structure, loads it with the values in the command and places it in GDD, provided no error occurred.
 void doPrintMacro(java.lang.String rawKey)
          Look up the macro and in the table and output the substitute string into text
private  void doStrikethru(boolean onOff)
          Turn strikethrough on or off.
private  void doUnderline(boolean onOff)
          Turn underline on or off.
 void FTO_doStrikethru(boolean onOff)
          FTO = for testing only.
 int process(char[] tok)
          The main switch that identifies the commands and dispatches them to the correct routine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gdd

private final GDD gdd
instance of the GDD singleton


gid

private final GID gid
instance of the GID singleton


lits

private final Literals lits
instance of the Literals singleton

Constructor Detail

Command

public Command()
get the instances of the singletons we use here.

Method Detail

process

public int process(char[] tok)
The main switch that identifies the commands and dispatches them to the correct routine

Parameters:
tok - the command string (with surrounding brackets)
Returns:
OK or the status from the command. If command invalid, returns Status.INVALID_TOKEN

dispatchCommand

private int dispatchCommand(int commandType,
                            java.lang.String tokStr)
Calls the routine that performs the command based on commandType

Parameters:
commandType - identifies which command to dispatch/perform
tokStr - needed as a parameter to some commands
Returns:
Status.OK if all went well; Status.INVALID_TOKEN if commandType not recognized. This is theoretically impossible, because of the test prior to call this method.

doAlignment

private void doAlignment(java.lang.String alignment)
Processes the alignment command by setting gdd_alignment to the specified value.

Parameters:
alignment - string from the user containing the alignment command.

doColumns

private void doColumns(java.lang.String columnCommand)
process the command to change the number of regular columns

Parameters:
columnCommand - string from the user containing the alignment command

doDefineMacro

public void doDefineMacro(java.lang.String tok)
Defines a string to place in the macro dictionary

Parameters:
tok - string containing the command with the macro name and the substitute text

doDump

private void doDump(java.lang.String tok)
Dumps various groups of variables to console. Used for debugging.

Parameters:
tok - the string containing the dump command and associated parameter.

doDumpPage

public void doDumpPage()
Dump the various elements of a page in Platypus to the console.


doFontBold

private void doFontBold(boolean boldOnOff)
Turn the bold attribute of a font on or off.

Parameters:
boldOnOff - Whether it's on (true) or off (false)

doFontFace

private int doFontFace(java.lang.String commandString)
Changes the current font to a new typeface. (Size and other features are unchanged)

Parameters:
commandString - the command string containing the name of the new typeface
Returns:
Status.OK, if all went well. Otherwise the appropriate error code.

doFontItalic

private void doFontItalic(boolean italicOnOff)
Turn the italic attribute of the current font on or off

Parameters:
italicOnOff - whether it's to be turned on (true) or off (false)

doFontSize

private int doFontSize(java.lang.String commandString)
Changes the current font to a different size

Parameters:
commandString - the command in which the new font size was specified [fsize:xxx]
Returns:
Status.OK if all went well, otherwise a Status-based error code

doLeading

public void doLeading(java.lang.String leadingSpec)
set the leading based on a user-supplied value and type; e.g., 2li, 0.5in, etc.

Parameters:
leadingSpec - the string as specified by the user

doMargin

public int doMargin(int whichMargin,
                    java.lang.String tok)
handles setting the page margins. Margin sizes are checked for reasonableness

Parameters:
whichMargin - specifies top, bottom, left, or right margin
tok - the actual command string from which we get the margin size
Returns:
Status.OK if all went well; else descriptive error value

doMarginMirror

private void doMarginMirror(boolean onOff)
Sets the margin-mirror flag. When set, it tells Platypus that the margins on left and right pages are reflections of each other. This is used only when right and left margins are of different sizes. When they are the same size, all pages are printed the same, so there is no concept of mirrored pages.

Parameters:
onOff - boolean indicating whether on or off

doNewPage

private int doNewPage()
Inserts a new page.

Returns:
Status.OK, if all went well. Otherwise the appropriate error code.

doNewParagraph

private void doNewParagraph()
Insert a new paragraph. Note: the new paragraph will be added on next text write. however, if the current paragraph has already been flushed,(so, iTPara = null ), then we write out a single space and flush it to the PDF file as the new paragraph.


doPageHeight

private void doPageHeight(java.lang.String pageHeightStr)
Page size is generally specified using a preset page size. However, users can specify their own custom length, should they choose to.

Parameters:
pageHeightStr - the specified page width

doPageSize

private void doPageSize(java.lang.String pageSizeStr)
Change the size of the page. Must be done before the document has been opened, which occurs when the first text is written to the OutfilePdf.

Parameters:
pageSizeStr - the command string containing the page size

doPageWidth

private void doPageWidth(java.lang.String pageWidthStr)
Page size is generally specified using a preset page size. However, users can specify their own custom width, should they choose to.

Parameters:
pageWidthStr - the specified page width

doParagraphIndent

private void doParagraphIndent(java.lang.String indentString)
Creates a new ParaIndent (paragraph indent) structure and assigns it to the one in GDD provide no error occurred. If one did occur, this command is simply ignored.

Parameters:
indentString - the string containing the command to set the paragraph indent

doParagraphSkipSize

private void doParagraphSkipSize(java.lang.String skipSize)
Creates a new ParaSkip (paragraph line skip) structure, loads it with the values in the command and places it in GDD, provided no error occurred. On error, an error message is logged and the command is skipped.

Parameters:
skipSize - command string as specified by the user.

doPrintMacro

public void doPrintMacro(java.lang.String rawKey)
Look up the macro and in the table and output the substitute string into text

Parameters:
rawKey - macro in []'s whose text must be looked up and printed

doStrikethru

private void doStrikethru(boolean onOff)
Turn strikethrough on or off. When set to on, set default strikethru height from baseline.

Parameters:
onOff - value set

doUnderline

private void doUnderline(boolean onOff)
Turn underline on or off. When set to on, set default strikethru height from baseline.

Parameters:
onOff - value set to Status.O

FTO_doStrikethru

public void FTO_doStrikethru(boolean onOff)
FTO = for testing only. Enables testing of private method. Testing ONLY

Parameters:
onOff - see this.doStrikethru() for details.


Copyright © 2006-7 Pacific Data Works LLC