org.extex.ocpware.type
Class OcpProgram

java.lang.Object
  extended by org.extex.ocpware.type.OcpProgram
All Implemented Interfaces:
java.io.Serializable

public class OcpProgram
extends java.lang.Object
implements java.io.Serializable

This class represents a compiled omega program.

The ΩCP File Format

Version:
$Revision:5975 $
Author:
Gerd Neugebauer
See Also:
Serialized Form

Constructor Summary
OcpProgram()
          Creates a new object.
 
Method Summary
 void addState(int[] t)
          Add a state.
 void addTable(int[] t)
          Add a table.
 int[] getCode(int state)
          Getter for a state's code.
 int getInput()
          Getter for the number of input bytes.
 int getLength()
          Getter for the length.
 int getOutput()
          Getter for output.
 java.util.List<int[]> getStates()
          Getter for states.
 int[] getTable(int i)
          Getter for a table.
 java.util.List<int[]> getTables()
          Getter for tables.
static OcpProgram load(java.io.InputStream stream)
          Load an OCP program from an input stream.
 void save(java.io.OutputStream stream)
          Save an OCP program to an output stream.
 void setInput(int input)
          Setter for input.
 void setOutput(int output)
          Setter for output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OcpProgram

public OcpProgram()
Creates a new object.

Method Detail

load

public static OcpProgram load(java.io.InputStream stream)
                       throws java.io.IOException
Load an OCP program from an input stream.

Parameters:
stream - the input stream
Returns:
the program
Throws:
java.io.IOException - in case of an IO error

addState

public void addState(int[] t)
Add a state.

Parameters:
t - the state to add

addTable

public void addTable(int[] t)
              throws java.lang.IndexOutOfBoundsException
Add a table.

Parameters:
t - the table to add
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= tables.size()).

getCode

public int[] getCode(int state)
              throws java.lang.IndexOutOfBoundsException
Getter for a state's code.

Parameters:
state - the state
Returns:
the code
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= states.size()).

getInput

public int getInput()
Getter for the number of input bytes.

Returns:
the number of input bytes

getLength

public int getLength()
Getter for the length.

Returns:
the length

getOutput

public int getOutput()
Getter for output.

Returns:
the output

getStates

public java.util.List<int[]> getStates()
Getter for states.

Returns:
the states

getTables

public java.util.List<int[]> getTables()
Getter for tables.

Returns:
the tables

getTable

public int[] getTable(int i)
Getter for a table.

Parameters:
i - the index
Returns:
the table

save

public void save(java.io.OutputStream stream)
          throws java.io.IOException
Save an OCP program to an output stream.

Parameters:
stream - the output stream
Throws:
java.io.IOException - in case of an IO error

setInput

public void setInput(int input)
Setter for input.

Parameters:
input - the input to set

setOutput

public void setOutput(int output)
Setter for output.

Parameters:
output - the output to set