org.freehep.util.io
Class TaggedInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.freehep.util.io.DecompressableInputStream
          extended by org.freehep.util.io.BitInputStream
              extended by org.freehep.util.io.ByteOrderInputStream
                  extended by org.freehep.util.io.ByteCountInputStream
                      extended by org.freehep.util.io.TaggedInputStream
All Implemented Interfaces:
Closeable, DataInput

public abstract class TaggedInputStream
extends ByteCountInputStream

Class to read Tagged blocks from a Stream. The tagged blocks (Tags) contain a tagID and a Length, so that known and unknown tags can be read and written (using the TaggedOutputStream). The stream also allows to read Actions, which again come with a actionCode and a length. A set of recognized Tags and Actions can be added to this stream. A concrete implementation of this stream should decode/read the TagHeader. All Concrete tags should be inherited from the Tag class and implement their read methods.

Version:
$Id: TaggedInputStream.java 10195 2006-12-15 20:32:24Z duns $
Author:
Mark Donszelmann, Charles Loomis

Field Summary
protected  ActionSet actionSet
          Set of actions that can be used by this Stream
protected  TagSet tagSet
          Set of tags that can be used by this Stream
 
Fields inherited from class org.freehep.util.io.ByteOrderInputStream
little
 
Fields inherited from class org.freehep.util.io.BitInputStream
BIT_MASK, FIELD_MASK, MASK_SIZE, ONES, ZERO
 
Constructor Summary
TaggedInputStream(InputStream in, TagSet tagSet, ActionSet actionSet)
          Creates a Tagged Input Stream
TaggedInputStream(InputStream in, TagSet tagSet, ActionSet actionSet, boolean littleEndian)
          Creates a Tagged Input Stream
 
Method Summary
 void addAction(Action action)
          Add action to action set.
 void addTag(Tag tag)
          Add tag to tagset
 TagHeader getTagHeader()
          Returns the currently valid TagHeader.
 Action readAction()
          Reads action.
protected abstract  ActionHeader readActionHeader()
          Decodes and returns the ActionHeader, which includes an actionCode and a length.
 Tag readTag()
          Read a tag.
protected abstract  TagHeader readTagHeader()
          Decodes and returns the TagHeader, which includes a TagID and a length.
 
Methods inherited from class org.freehep.util.io.ByteCountInputStream
getLength, popBuffer, pushBuffer, read
 
Methods inherited from class org.freehep.util.io.ByteOrderInputStream
readAsciiZString, readBoolean, readByte, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readInt, readLine, readLong, readShort, readShort, readString, readUnsignedByte, readUnsignedByte, readUnsignedInt, readUnsignedInt, readUnsignedShort, readUnsignedShort, readUTF, skipBytes
 
Methods inherited from class org.freehep.util.io.BitInputStream
byteAlign, fetchByte, readBitFlag, readFBits, readSBits, readUBits
 
Methods inherited from class org.freehep.util.io.DecompressableInputStream
skip, startDecompressing
 
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, read, read, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tagSet

protected TagSet tagSet
Set of tags that can be used by this Stream


actionSet

protected ActionSet actionSet
Set of actions that can be used by this Stream

Constructor Detail

TaggedInputStream

public TaggedInputStream(InputStream in,
                         TagSet tagSet,
                         ActionSet actionSet)
Creates a Tagged Input Stream

Parameters:
in - stream to read from
tagSet - available tag set
actionSet - available action set

TaggedInputStream

public TaggedInputStream(InputStream in,
                         TagSet tagSet,
                         ActionSet actionSet,
                         boolean littleEndian)
Creates a Tagged Input Stream

Parameters:
in - stream to read from
tagSet - available tag set
actionSet - available action set
littleEndian - true if stream is little endian
Method Detail

addTag

public void addTag(Tag tag)
Add tag to tagset

Parameters:
tag - new tag

readTagHeader

protected abstract TagHeader readTagHeader()
                                    throws IOException
Decodes and returns the TagHeader, which includes a TagID and a length.

Returns:
Decoded TagHeader
Throws:
IOException - if read fails

readTag

public Tag readTag()
            throws IOException
Read a tag.

Returns:
read tag
Throws:
IOException - if read fails

getTagHeader

public TagHeader getTagHeader()
Returns the currently valid TagHeader. Can be called durring the tag.read() method.


addAction

public void addAction(Action action)
Add action to action set.

Parameters:
action - new action

readActionHeader

protected abstract ActionHeader readActionHeader()
                                          throws IOException
Decodes and returns the ActionHeader, which includes an actionCode and a length.

Returns:
decoded ActionHeader
Throws:
IOException - if read fails

readAction

public Action readAction()
                  throws IOException
Reads action.

Returns:
read action
Throws:
IOException - if read fails


Copyright © 2000-2007 FreeHEP. All Rights Reserved.