wt.wrmf.transport
Class FlagCheckingInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended bywt.wrmf.transport.FlagCheckingInputStream
All Implemented Interfaces:
Serializable

public class FlagCheckingInputStream
extends InputStream
implements Serializable

The constructor accepts an inputstream and one or more serializable object: header and/or trailer. The size of the header/trailer (headerSize/trailSize) is calculated. It will extract the header (if any) and check it, then reserve last trailSize bytes (if any; otherwise IOException will be thrown) from the input stream and tries to verify the reserved bytes that they can be deserialized to the trailer. The constructed InputStream is equivalent to the original InputStream without the trailer.

Supported API: false

Extendable: false

See Also:
Serialized Form

Field Summary
private  SegmentedInputStream all
           
private static String CLASSNAME
           
private static TempFileDeletion deleteThread
           
private  int headerSize
           
private  String headerType
           
private  InputStream is
           
private static String RESOURCE
           
private static String TEMP_DIR
           
private  String tempFileName
           
private  int trailerSize
           
private  String trailerType
           
 
Fields inherited from class java.io.InputStream
 
Constructor Summary
FlagCheckingInputStream(InputStream is)
          Default constructor: no header and a fixed trailer.
FlagCheckingInputStream(InputStream is, Serializable header, Serializable trailer)
          

Supported API: false
 
Method Summary
private  boolean checkHeader(InputStream headerStream)
           
 void close()
           
private  void extractHeader()
           
private  void extractTrailer()
           
private  boolean isTrailerSuccessful()
           
 int read()
          

Supported API: false
 int read(byte[] buf)
           
 int read(byte[] buf, int off, int len)
           
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

trailerSize

private int trailerSize

headerSize

private int headerSize

is

private InputStream is

headerType

private String headerType

trailerType

private String trailerType

all

private SegmentedInputStream all

tempFileName

private String tempFileName

TEMP_DIR

private static String TEMP_DIR

deleteThread

private static TempFileDeletion deleteThread
Constructor Detail

FlagCheckingInputStream

public FlagCheckingInputStream(InputStream is)
                        throws IOException
Default constructor: no header and a fixed trailer. The trailer is always a type of StreamFlag and of 57 bytes.

Supported API: false

Parameters:
is -
Throws:
IOException

FlagCheckingInputStream

public FlagCheckingInputStream(InputStream is,
                               Serializable header,
                               Serializable trailer)
                        throws IOException


Supported API: false

Parameters:
is -
header -
trailer -
Throws:
IOException
Method Detail

read

public int read()
         throws IOException


Supported API: false

Returns:
int
Throws:
IOException

extractHeader

private void extractHeader()
                    throws IOException
Throws:
IOException

checkHeader

private boolean checkHeader(InputStream headerStream)

extractTrailer

private void extractTrailer()
                     throws IOException
Throws:
IOException

isTrailerSuccessful

private boolean isTrailerSuccessful()

read

public int read(byte[] buf)
         throws IOException
Throws:
IOException

read

public int read(byte[] buf,
                int off,
                int len)
         throws IOException
Throws:
IOException

close

public void close()
           throws IOException
Throws:
IOException