org.extex.dviware.type
Class AbstractDviCode

java.lang.Object
  extended by org.extex.dviware.type.AbstractDviCode
All Implemented Interfaces:
DviCode
Direct Known Subclasses:
DviBop, DviDown, DviEop, DviFnt, DviFntDef, DviPop, DviPostamble, DviPreamble, DviPush, DviPutChar, DviPutRule, DviRight, DviSetChar, DviSetRule, DviW, DviW0, DviX, DviX0, DviXxx, DviY, DviY0, DviZ, DviZ0

public abstract class AbstractDviCode
extends java.lang.Object
implements DviCode

This is an abstract base class for DVI instructions.

Version:
$Revision: 5428 $
Author:
Gerd Neugebauer

Field Summary
protected static int ONE_BYTE_MASK
          The constant ONE_BYTE_MASK contains the bit mask for a single byte.
protected static int THREE_BYTE_MASK
          The constant THREE_BYTE_MASK contains the bit mask for a triple byte.
protected static int TWO_BYTE_MASK
          The constant TWO_BYTE_MASK contains the bit mask for a double byte.
 
Fields inherited from interface org.extex.dviware.type.DviCode
POP, PUSH, W0, X0, Y0, Z0
 
Constructor Summary
protected AbstractDviCode(java.lang.String name)
          Creates a new object.
 
Method Summary
 java.lang.String getName()
          Getter for name.
protected  int opcode(int baseOpcode, int value, java.io.OutputStream stream)
          Write an opcode and some unsigned value to the output stream.
protected  int opcodeSigned(int baseOpcode, int value, java.io.OutputStream stream)
          Write an opcode and some signed value to the output stream.
protected static java.lang.String variant(int value)
          Determine which variant of a DVI instruction is needed for the operand.
protected static void write2(java.io.OutputStream stream, int value)
          Write two bytes to the output stream.
protected  void write3(java.io.OutputStream stream, int value)
          Write three bytes to the output stream.
protected  void write4(java.io.OutputStream stream, int value)
          Write four bytes to the output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.extex.dviware.type.DviCode
write
 

Field Detail

ONE_BYTE_MASK

protected static final int ONE_BYTE_MASK
The constant ONE_BYTE_MASK contains the bit mask for a single byte.

See Also:
Constant Field Values

THREE_BYTE_MASK

protected static final int THREE_BYTE_MASK
The constant THREE_BYTE_MASK contains the bit mask for a triple byte.

See Also:
Constant Field Values

TWO_BYTE_MASK

protected static final int TWO_BYTE_MASK
The constant TWO_BYTE_MASK contains the bit mask for a double byte.

See Also:
Constant Field Values
Constructor Detail

AbstractDviCode

protected AbstractDviCode(java.lang.String name)
Creates a new object.

Parameters:
name - the name of the dvi instruction
Method Detail

variant

protected static java.lang.String variant(int value)
Determine which variant of a DVI instruction is needed for the operand.

Parameters:
value - the unsigned value
Returns:
the variant

write2

protected static void write2(java.io.OutputStream stream,
                             int value)
                      throws java.io.IOException
Write two bytes to the output stream.

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

getName

public java.lang.String getName()
Getter for name.

Specified by:
getName in interface DviCode
Returns:
the name

opcode

protected int opcode(int baseOpcode,
                     int value,
                     java.io.OutputStream stream)
              throws java.io.IOException
Write an opcode and some unsigned value to the output stream. The value determines the exact opcode. If the value fits in one byte then the base opcode is used. If two bytes are needed then 1 is added. If two bytes are needed then 2 is added. Finally if all four bytes are needed then 3 is added to the base opcode.

Parameters:
baseOpcode - the opcode
value - the value
stream - the output stream to write to
Returns:
the number of bytes written
Throws:
java.io.IOException - in case of an error

opcodeSigned

protected int opcodeSigned(int baseOpcode,
                           int value,
                           java.io.OutputStream stream)
                    throws java.io.IOException
Write an opcode and some signed value to the output stream. The value determines the exact opcode. If the value fits in one byte then the base opcode is used. If two bytes are needed then 1 is added. If two bytes are needed then 2 is added. Finally if all four bytes are needed then 3 is added to the base opcode.

Parameters:
baseOpcode - the opcode
value - the value
stream - the output stream to write to
Returns:
the number of bytes written
Throws:
java.io.IOException - in case of an error

write3

protected void write3(java.io.OutputStream stream,
                      int value)
               throws java.io.IOException
Write three bytes to the output stream.

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

write4

protected void write4(java.io.OutputStream stream,
                      int value)
               throws java.io.IOException
Write four bytes to the output stream.

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