ifc.bim.openecg.jtools.jparser
Class SectGen

java.lang.Object
  |
  +--ifc.bim.openecg.jtools.jparser.SectGen
Direct Known Subclasses:
Sect000, Sect001, Sect002, Sect003, Sect004, Sect005, Sect006, Sect007, Sect008, Sect009, Sect010, Sect011

public class SectGen
extends java.lang.Object

The structure of a generic section, with methods to load header and data part from a file


Field Summary
 byte[] data
          Stores the section's data part
 SectHeader head
          Stores the section's header
 int indx
          The start index for reading operations
 java.util.logging.Logger log
          Log error and info messages produced during the section's load operation
 
Constructor Summary
SectGen()
          Constructs a SectGen with an anonymous logger
SectGen(java.util.logging.Logger log)
          Constructs a SectGen that uses a specific logger
 
Method Summary
 void Load(javax.imageio.stream.FileImageOutputStream fHandle, int idx)
          Retrieves the header and data part of the section from the specified FileImageOutputStream starting at index "idx" and stores them in the "head" and "data" variables.
 void Parse(int lNum)
          An empty method to be overridden by classes that extends this one.
 void PrnInfo()
          An empty method to be overridden by classes that extends this one.
 byte readByte()
          Reads a byte from "data" starting at index "indx", and returns it as a byte value.
 void readFully(byte[] dest)
          Reads "dest.len" bytes from "data" starting at index "idx", and stores them into "dest".
 int readInt()
          Reads four bytes from "data" starting at index "indx", and (conceptually) concatenates them according to Little Endian byte order, and returns the result as an int value.
 short readShort()
          Reads two bytes from "data" starting at index "indx", and (conceptually) concatenates them according to Little Endian byte order, and returns the result as a short value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

head

public SectHeader head
Stores the section's header


data

public byte[] data
Stores the section's data part


log

public java.util.logging.Logger log
Log error and info messages produced during the section's load operation


indx

public int indx
The start index for reading operations

Constructor Detail

SectGen

public SectGen()
Constructs a SectGen with an anonymous logger


SectGen

public SectGen(java.util.logging.Logger log)
Constructs a SectGen that uses a specific logger

Parameters:
log - the logger to be used
Method Detail

readByte

public byte readByte()
Reads a byte from "data" starting at index "indx", and returns it as a byte value.

Returns:
A byte value
Throws:
java.lang.IndexOutOfBoundsException - if the index "idx" is greater tha the array length.

readShort

public short readShort()
Reads two bytes from "data" starting at index "indx", and (conceptually) concatenates them according to Little Endian byte order, and returns the result as a short value.

Returns:
A short value
Throws:
java.lang.IndexOutOfBoundsException - if the end of the array is reached before all bytes are read.

readInt

public int readInt()
Reads four bytes from "data" starting at index "indx", and (conceptually) concatenates them according to Little Endian byte order, and returns the result as an int value.

Returns:
An int value
Throws:
java.lang.IndexOutOfBoundsException - if the end of the array is reached before all bytes are read.

readFully

public void readFully(byte[] dest)
Reads "dest.len" bytes from "data" starting at index "idx", and stores them into "dest". If the end of the "data" array is reached, an EOFException will be thrown.

Parameters:
dest - an array of bytes
Throws:
java.lang.IndexOutOfBoundsException - if the stream reaches the end before reading all the bytes. Bytes already read are stored anyway.

Load

public void Load(javax.imageio.stream.FileImageOutputStream fHandle,
                 int idx)
          throws java.lang.Exception
Retrieves the header and data part of the section from the specified FileImageOutputStream starting at index "idx" and stores them in the "head" and "data" variables.

Parameters:
fHandle - a FileImageInputStream pointing at the source file
idx - an int representing the index of the first byte of the section in the source file.
Throws:
java.lang.Exception - if the operation fails

Parse

public void Parse(int lNum)
           throws java.lang.Exception
An empty method to be overridden by classes that extends this one.

Parameters:
lNum - total number of leads stored in the SCP-ECG record (irrilevant for some sections)
Throws:
java.lang.Exception - if any error occurs

PrnInfo

public void PrnInfo()
An empty method to be overridden by classes that extends this one.