gr.uoa.di.madgik.grs.record.field.mediation
Class MediatingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by gr.uoa.di.madgik.grs.record.field.mediation.MediatingInputStream
All Implemented Interfaces:
java.io.Closeable

public class MediatingInputStream
extends java.io.InputStream

This class extends the InputStream providing a utility by which a client can access the payload of a Field without needing to take actions depending on whether the full payload of the field is locally available or it is transfered using a transport directive of IBuffer.TransportDirective.Partial. Its function makes sure that additional payload is requested whenever more data is requested. To avoid unnecessary data traffic, additional payload requests are made whenever the client needs to access more data than what is already available. If a client knows beforehand that he is going to need the full payload of the field, an alternative would be to make a request through Field.makeAvailable() to make sure the full payload is available once the invocation is completed. The amount of data that is transfered and made available on every request is subject to the specific FieldDefinition and more particularly to the value set using FieldDefinition.setChunkSize(int). If the data is already available, then no remote request is needed or performed.

Author:
gpapanikos

Method Summary
 int available()
          
 void close()
          
 void mark(int readlimit)
          
 boolean markSupported()
          
 int read()
          
 int read(byte[] b)
          
 int read(byte[] b, int off, int len)
          
 void reset()
          
 long skip(long n)
          
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

markSupported

public boolean markSupported()

Overrides:
markSupported in class java.io.InputStream
See Also:
InputStream.markSupported()

mark

public void mark(int readlimit)

Overrides:
mark in class java.io.InputStream
See Also:
InputStream.mark(int)

close

public void close()
           throws java.io.IOException

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException
See Also:
InputStream.close()

available

public int available()
              throws java.io.IOException

Overrides:
available in class java.io.InputStream
Throws:
java.io.IOException
See Also:
InputStream.available()

read

public int read()
         throws java.io.IOException

Before forwarding the request to the underlying InputStream, it is checked if there is one byte available in the underlying InputStream and if there isn't, a request for more data is send

Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException
See Also:
InputStream.read()

read

public int read(byte[] b)
         throws java.io.IOException

Before forwarding the request to the underlying InputStream, it is checked if there are b.length bytes available in the underlying InputStream and if there aren't, a request for more data is send

Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException
See Also:
InputStream.read(byte[])

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException

Before forwarding the request to the underlying InputStream, it is checked if there are len bytes available in the underlying InputStream and if there aren't, a request for more data is send

Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException
See Also:
InputStream.read(byte[], int, int)

reset

public void reset()
           throws java.io.IOException

Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException
See Also:
InputStream.reset()

skip

public long skip(long n)
          throws java.io.IOException

Overrides:
skip in class java.io.InputStream
Throws:
java.io.IOException
See Also:
InputStream.skip(long)