Overview | Package | Class | Use | Tree | Serialized | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## tapeutils.impl
Class SimpleByteProcessor

    java.lang.Object
      tapeutils.impl.SimpleByteProcessor

All Implemented Interfaces:
  ByteProcessor

Direct Known Subclasses:
  ZX81BASICByteProcessor

public class SimpleByteProcessor
extends java.lang.Object
implements ByteProcessor

This class provides a simple byte processor that just stores bytes.

It makes no assumption on the content of the bytes, and so does not know when a sequence of bytes is complete (other than the gap between the sequence and the next byte or end of sample).

Author:
  hldswrth

Field Summary
`protected java.util.Map` | `mByteEndMap`
`protected util.BlockSequence` | `mBytes` The bytes.
`protected int` | `mNumExpectedBytes` The expected number of bytes.
`protected SampleAnalyzer` | `mSampleAnalyzer` The sample analyzer.

Constructor Summary
`SimpleByteProcessor(SampleAnalyzer analyzer)` Construct the byte processor.
`SimpleByteProcessor(SampleAnalyzer analyzer, int numBytes)` Construct the byte processor.

Method Summary
`java.lang.String` | `checkConsistent()` Checks whether the loaded bytes are consistent.
`int` | `getByteIndex(int number)` Get the index in the sample for the given byte number.
`int` | `getByteNumber(int index)` Get the byte value at the given position in the sample.
`void` | `getByteNumber(int index, int[] pos)` Get the byte number at the given position in the sample.
`byte[]` | `getBytes()` Get the bytes.
`int` | `getByteValue(int byteNumber)` Get the byte value at the given byte number.
`void` | `initialize()` Initialize this object ready for processing a sample.
`int` | `numBytesProcessed()` Returns the number of bytes processed.
`int` | `numExpectedBytes()` Returns the number of bytes expected to be processed.
`void` | `processByte(int start, int end, int byteValue)` Process the current byte.
`int` | `undoLastByte()` Undo the last byte that was extracted..
`void` | `write(java.io.OutputStream output)` Write the bytes that have been extracted from the sample to the output stream.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### mSampleAnalyzer

    protected SampleAnalyzer mSampleAnalyzer

  The sample analyzer.

### mBytes

    protected util.BlockSequence mBytes

  The bytes.

### mByteEndMap

    protected java.util.Map mByteEndMap

### mNumExpectedBytes

    protected int mNumExpectedBytes

  The expected number of bytes.

Constructor Detail

### SimpleByteProcessor

    public SimpleByteProcessor(SampleAnalyzer analyzer)

  Construct the byte processor.

Parameters:
  `analyzer` - The sample analyzer.

### SimpleByteProcessor

    public SimpleByteProcessor(SampleAnalyzer analyzer,
                               int numBytes)

  Construct the byte processor.

Parameters:
  `analyzer` - The sample analyzer.
  `numBytes` - The number of bytes expected.

Method Detail

### initialize

    public void initialize()

  Initialize this object ready for processing a sample.

  Specified by:
    `initialize` in interface `ByteProcessor`

### processByte

    public void processByte(int start,
                            int end,
                            int byteValue)

  Process the current byte.

  Specified by:
    `processByte` in interface `ByteProcessor`
  Parameters:
    `start` - The offset of the start of the byte in the sample.
    `end` - The offset of the end of the byte in the sample.
    `byteValue` - The byte value.

### undoLastByte

    public int undoLastByte()

  Undo the last byte that was extracted..

  Specified by:
    `undoLastByte` in interface `ByteProcessor`
  Returns:
    The value of the last byte.

### write

    public void write(java.io.OutputStream output)
               throws java.io.IOException

  Write the bytes that have been extracted from the sample to the output stream.

  Specified by:
    `write` in interface `ByteProcessor`
  Parameters:
    `output` - The output stream.
  Throws:
    `java.io.IOException` - An error occurred writing to the stream.

### getBytes

    public byte[] getBytes()

  Get the bytes.

  Specified by:
    `getBytes` in interface `ByteProcessor`
  Returns:
    An array containing the byte values.

### numBytesProcessed

    public int numBytesProcessed()

  Returns the number of bytes processed.

  Specified by:
    `numBytesProcessed` in interface `ByteProcessor`
  Returns:
    The number of bytes processed.

### numExpectedBytes

    public int numExpectedBytes()

  Returns the number of bytes expected to be processed.

  Specified by:
    `numExpectedBytes` in interface `ByteProcessor`
  Returns:
    The number of bytes expected to be processed.

### getByteNumber

    public int getByteNumber(int index)

  Get the byte value at the given position in the sample.

  Specified by:
    `getByteNumber` in interface `ByteProcessor`
  Parameters:
    `index` - The index.
  Returns:
    The byte value, -1 for no value.

### getByteNumber

    public void getByteNumber(int index,
                              int[] pos)

  Get the byte number at the given position in the sample.

  Specified by:
    `getByteNumber` in interface `ByteProcessor`
  Parameters:
    `index` - The index.
    `pos` - An array which will contain the byte number and offset from the start of the byte.

### getByteIndex

    public int getByteIndex(int number)

  Get the index in the sample for the given byte number.

  Specified by:
    `getByteIndex` in interface `ByteProcessor`
  Parameters:
    `number` - The byte number.
  Returns:
    The position in the sample.

### getByteValue

    public int getByteValue(int byteNumber)

  Get the byte value at the given byte number.

  Specified by:
    `getByteValue` in interface `ByteProcessor`
  Parameters:
    `byteNumber` - The index.
  Returns:
    The byte value, -1 for no value.

### checkConsistent

    public java.lang.String checkConsistent()

  Checks whether the loaded bytes are consistent.

  Specified by:
    `checkConsistent` in interface `ByteProcessor`
  Returns:
    null if consistent, otherwise error message.

Overview | Package | Class | Use | Tree | Serialized | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD