com.openpcl.pclrenderimage.tools
Class PclParser

java.lang.Object
  extended by com.openpcl.pclrenderimage.tools.PclParser

public class PclParser
extends Object

Parse PCL

Author:
James R. Adrig Brought over from rmstools.jar. 05/08/2001 Use callbacks to fire events in caller via an Interface Description: Parse a PCL file and make callbacks when commands are found. This is more efficient than requiring the caller to 'loop'. This was converted from the very messy and incomplete Delphi code referenced below. It probably should have just been done from scratch; but it works... Delphi PCLGet @ http://techref.massmind.org/techref/language/pcl/parse.htm ============================================================================ State Description ----- ------------------------------------ 1 Not in a PCL Commamd 2 Seen an Escape: we're in a PCL Command 3 Loaded a 2 char command 4 Loaded last term of commnd 5 Loaded last term with binary data 6 Loaded a term, another term waiting 7 Loaded a term with binary data, another term waiting State Prefix Group Value Term Command Left in Buffer ----- ------ ------ ----- ---- ------------ -------------- 3 X X 4 x # X x#X 4 x X xX 4 x y # Z xy#Z 6 x y # z xy#z#Z #Z ============================================================================

Field Summary
static char scESC
           
 
Constructor Summary
PclParser(byte[] inBytes, PclCommandEvent callbackObject)
           
PclParser(String pclFileName, PclCommandEvent callbackObject)
          Construct a Parser with the filename and an object that implements 'PclCommandEvent'
 
Method Summary
 void close()
           
 byte[] GetBytesFromBuffer(int numChars)
           
 String GetCharFromBuffer()
           
 String GetNumFromBuffer()
           
 int getOneCommand()
          Returns the 'pclState': we may be waiting for more commands...
 void getPclCommands()
           
 boolean isUpperCase(String s)
          Returns true if the string consists of uppercase characters.
 void ParsePCL()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

scESC

public static char scESC
Constructor Detail

PclParser

public PclParser(String pclFileName,
                 PclCommandEvent callbackObject)
          throws FileNotFoundException
Construct a Parser with the filename and an object that implements 'PclCommandEvent'

Throws:
FileNotFoundException

PclParser

public PclParser(byte[] inBytes,
                 PclCommandEvent callbackObject)
Method Detail

close

public void close()
           throws IOException
Throws:
IOException

ParsePCL

public void ParsePCL()

getPclCommands

public void getPclCommands()
                    throws ParseException,
                           IOException
Throws:
ParseException
IOException

getOneCommand

public int getOneCommand()
                  throws ParseException,
                         IOException
Returns the 'pclState': we may be waiting for more commands... There should be a term coming up (Esc or term waiting)

Throws:
ParseException
IOException

GetCharFromBuffer

public String GetCharFromBuffer()
                         throws IOException
Throws:
IOException

GetBytesFromBuffer

public byte[] GetBytesFromBuffer(int numChars)
                          throws IOException
Throws:
IOException

GetNumFromBuffer

public String GetNumFromBuffer()
                        throws ParseException,
                               IOException
Throws:
ParseException
IOException

isUpperCase

public boolean isUpperCase(String s)
Returns true if the string consists of uppercase characters.

Parameters:
s - the input string
Returns:
true if the string consists only of uppercase characters.
See Also:
Character.isUpperCase(char).


OpenPCL http://www.openpcl.com