platypus
Class CommandValue

java.lang.Object
  extended by platypus.CommandValue
Direct Known Subclasses:
FontSize, ParaIndent, ParaSkip, Strikethru

public class CommandValue
extends java.lang.Object

Class for processing commands with numeric parameters. It accepts the number/value substring, and validates the number and the units; it then converts the units to points.

Author:
alb

Field Summary
private  float amount
          amount in units
private  int lineNumber
          the line number in the input text where this was value was set/used
private  PlatyConst.unit units
          the type of units (lines, pts, inches, centimeters)
 
Constructor Summary
CommandValue()
          Creates a generic CommandValue and sets it to default values
CommandValue(float inAmount)
          Creates a CommandValue and sets it to inAmount.
CommandValue(java.lang.String s, java.lang.String commandName)
          Constructor that is passed a value+unit substring and creates a CommandValue object containing fields for value and units.
 
Method Summary
 java.lang.String dump()
          Dumps content of data items in user-friendly format.
 float getAmount()
          return the amount of units
 int getLineNumber()
          return the line number where the command was found
 PlatyConst.unit getUnits()
          return the number of units
 void setAmountInPoints(float points)
           
 java.lang.String stateError(java.lang.String s)
          Prints some kind of error message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

amount

private float amount
amount in units


units

private PlatyConst.unit units
the type of units (lines, pts, inches, centimeters)


lineNumber

private int lineNumber
the line number in the input text where this was value was set/used

Constructor Detail

CommandValue

public CommandValue()
Creates a generic CommandValue and sets it to default values


CommandValue

public CommandValue(float inAmount)
Creates a CommandValue and sets it to inAmount. Units default to points.

Parameters:
inAmount - the value of the units.

CommandValue

public CommandValue(java.lang.String s,
                    java.lang.String commandName)
Constructor that is passed a value+unit substring and creates a CommandValue object containing fields for value and units.

Parameters:
s - the unit and value substring that needs to be parsed
commandName - the command containing s. Used for error message only
Method Detail

stateError

public java.lang.String stateError(java.lang.String s)
Prints some kind of error message. Should be overwritten by implementing class.

Parameters:
s - the command string originally passed to the constructor
Returns:
a string containing the error statement, or null in case of error.

dump

public java.lang.String dump()
Dumps content of data items in user-friendly format. Should be overwritten

Returns:
a blank. Should be overwritten by subclass.

getUnits

public PlatyConst.unit getUnits()
return the number of units

Returns:
units

getAmount

public float getAmount()
return the amount of units

Returns:
amount

getLineNumber

public int getLineNumber()
return the line number where the command was found

Returns:
lineNumber

setAmountInPoints

public void setAmountInPoints(float points)


Copyright © 2006-7 Pacific Data Works LLC