SMILA (incubation) API documentation

org.eclipse.smila.ipc.json
Class JsonStreamReader

java.lang.Object
  extended by org.eclipse.smila.ipc.json.JsonStreamReader
All Implemented Interfaces:
IpcStreamReader

public class JsonStreamReader
extends java.lang.Object
implements IpcStreamReader

IPC reader implementation for the JSON protocol.

Author:
aweber

Method Summary
 void close()
          Closes the reader and the underlying stream.
 void closeWithoutStream()
          Closes the reader but NOT the underlying stream.
 boolean currentBoolValue()
          Returns the current token value as boolean value.
 double currentDoubleValue()
          Returns the current token value as double value.
 long currentLongValue()
          Returns the current token value as long value.
 java.lang.String currentStringValue()
          Returns the current token value as string.
 java.io.InputStream getStream()
          Not supported by this implementation, so this always throws an UnsupportedOperationException.
 boolean nextBoolValue()
          Shortcut for nextToken() + currentBoolValue().
 double nextDoubleValue()
          Shortcut for nextToken() + currentDoubleValue().
 long nextLongValue()
          Shortcut for nextToken() + currentLongValue().
 java.lang.String nextStringValue()
          Shortcut for nextToken() + currentStringValue().
 IpcToken nextToken()
          Returns the next token.
<T> T
readObject(java.lang.Class<T> type)
          read object of desired class from JSON stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

close

public void close()
           throws java.io.IOException
Closes the reader and the underlying stream.

Specified by:
close in interface IpcStreamReader
Throws:
java.io.IOException - any error

closeWithoutStream

public void closeWithoutStream()
                        throws java.io.IOException
Closes the reader but NOT the underlying stream.

Specified by:
closeWithoutStream in interface IpcStreamReader
Throws:
java.io.IOException - any error

currentBoolValue

public boolean currentBoolValue()
                         throws java.io.IOException
Returns the current token value as boolean value.

Specified by:
currentBoolValue in interface IpcStreamReader
Returns:
current token value as boolean
Throws:
java.io.IOException - any error

currentDoubleValue

public double currentDoubleValue()
                          throws java.io.IOException
Returns the current token value as double value.

Specified by:
currentDoubleValue in interface IpcStreamReader
Returns:
current token value as double
Throws:
java.io.IOException - any error

currentLongValue

public long currentLongValue()
                      throws java.io.IOException
Returns the current token value as long value.

Specified by:
currentLongValue in interface IpcStreamReader
Returns:
current token value as long value
Throws:
java.io.IOException - any error

currentStringValue

public java.lang.String currentStringValue()
                                    throws java.io.IOException
Returns the current token value as string.

Specified by:
currentStringValue in interface IpcStreamReader
Returns:
current token value as string
Throws:
java.io.IOException - any error

nextBoolValue

public boolean nextBoolValue()
                      throws java.io.IOException
Shortcut for nextToken() + currentBoolValue().

Specified by:
nextBoolValue in interface IpcStreamReader
Returns:
next token value as boolean.
Throws:
java.io.IOException - any error.

nextDoubleValue

public double nextDoubleValue()
                       throws java.io.IOException
Shortcut for nextToken() + currentDoubleValue().

Specified by:
nextDoubleValue in interface IpcStreamReader
Returns:
next token value as double
Throws:
java.io.IOException - any error

nextLongValue

public long nextLongValue()
                   throws java.io.IOException
Shortcut for nextToken() + currentLongValue().

Specified by:
nextLongValue in interface IpcStreamReader
Returns:
next token value as long
Throws:
java.io.IOException - any error

nextStringValue

public java.lang.String nextStringValue()
                                 throws java.io.IOException
Shortcut for nextToken() + currentStringValue().

Specified by:
nextStringValue in interface IpcStreamReader
Returns:
next token value as string
Throws:
java.io.IOException - any error

nextToken

public IpcToken nextToken()
                   throws java.io.IOException
Returns the next token.

Specified by:
nextToken in interface IpcStreamReader
Returns:
next token
Throws:
java.io.IOException - any error

readObject

public <T> T readObject(java.lang.Class<T> type)
             throws java.io.IOException
read object of desired class from JSON stream.

Type Parameters:
T - desired class.
Parameters:
type - desired class.
Returns:
instance of desired class.
Throws:
java.io.IOException - parse error.

getStream

public java.io.InputStream getStream()
Not supported by this implementation, so this always throws an UnsupportedOperationException. We have no access to internal stream here, stream is wrapped in Jackson implementation.

Specified by:
getStream in interface IpcStreamReader
Returns:
nothing. always throws an exception.

SMILA (incubation) API documentation