org.wso2.carbon.registry.core.jdbc.utils
Class VersionInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.wso2.carbon.registry.core.jdbc.utils.VersionInputStream
All Implemented Interfaces:
java.io.Closeable

public class VersionInputStream
extends java.io.InputStream

This is an implementation of an input stream, wrapping the version list content written to the database. This stream is capable of serializing a list of versions into a stream of bytes. The byte stream will then be stored on the database, and will be much more optimal than storing them one by one.

The version retriever can read through such a stream of bytes and obtain the list of versions.

See Also:
VersionRetriever

Constructor Summary
VersionInputStream(java.util.List<java.lang.Long> versionList)
          Creates a version input stream from the given list of versions.
 
Method Summary
 int available()
          Method to check whether anymore bytes are left to read.
 int read()
          Reads the stream one by one.
 
Methods inherited from class java.io.InputStream
close, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VersionInputStream

public VersionInputStream(java.util.List<java.lang.Long> versionList)
Creates a version input stream from the given list of versions.

Parameters:
versionList - list of versions.
Method Detail

read

public int read()
         throws java.io.IOException
Reads the stream one by one.

Specified by:
read in class java.io.InputStream
Returns:
the value to be read.
Throws:
java.io.IOException - if an error occurs.

available

public int available()
              throws java.io.IOException
Method to check whether anymore bytes are left to read.

Overrides:
available in class java.io.InputStream
Returns:
the number of versions to be read.
Throws:
java.io.IOException - if an error occurs.


Copyright © 2011 WSO2 Inc. All Rights Reserved.