de.dante.dviware.type
Class AbstractDviCode

java.lang.Object
  extended byde.dante.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: 1.5 $
Author:
Gerd Neugebauer

Field Summary
 
Fields inherited from interface de.dante.dviware.type.DviCode
POP, PUSH, W0, X0, Y0, Z0
 
Constructor Summary
protected AbstractDviCode()
          Creates a new object.
 
Method Summary
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  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 de.dante.dviware.type.DviCode
getName, write
 

Constructor Detail

AbstractDviCode

protected AbstractDviCode()
Creates a new object.

Method Detail

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

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

variant

protected 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

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