Class AbstractStreamingInput
java.lang.Object
se.l4.commons.serialization.format.AbstractStreamingInput
- All Implemented Interfaces:
Closeable,AutoCloseable,StreamingInput
- Direct Known Subclasses:
BinaryInput,JsonInput
public abstract class AbstractStreamingInput extends Object implements StreamingInput
Abstract implementation of
StreamingInput to simplify common
operations such as peeking and value setting.-
Field Summary
Fields Modifier and Type Field Description protected intlevel -
Constructor Summary
Constructors Constructor Description AbstractStreamingInput() -
Method Summary
Modifier and Type Method Description Tokencurrent()Get the current token.booleangetBoolean()Get the value as a boolean.bytegetByte()Get the value as a byte.byte[]getByteArray()Get the value as a byte[] array.chargetChar()Get the value as a character.doublegetDouble()Get the value as a double.floatgetFloat()Get the value as a float.intgetInt()Get the value as an integer.longgetLong()Get the value as a long.shortgetShort()Get the value as a short.StringgetString()Get the current value as a string.ObjectgetValue()Get the current value.ValueTypegetValueType()Get the type of value the input currently has.Tokennext()Advance to the next token.Tokennext(Token expected)Advance to the next token checking that it is of a certain type.protected abstract Tokennext0()protected IOExceptionraiseException(String message)protected SerializationExceptionraiseSerializationException(String message)protected voidsetValue(boolean value)protected voidsetValue(byte value)protected voidsetValue(byte[] value)protected voidsetValue(char value)protected voidsetValue(double value)protected voidsetValue(float value)protected voidsetValue(int value)protected voidsetValue(long value)protected voidsetValue(short value)protected voidsetValue(Object value)protected voidsetValue(String value)protected voidsetValueNull()voidskip()Skip the started object, list or value.voidskipValue()If this token is aToken.KEYthis will skip its value.
-
Field Details
-
level
protected int level
-
-
Constructor Details
-
AbstractStreamingInput
public AbstractStreamingInput()
-
-
Method Details
-
next
Description copied from interface:StreamingInputAdvance to the next token.- Specified by:
nextin interfaceStreamingInput- Returns:
- Throws:
IOException
-
next0
- Throws:
IOException
-
raiseException
-
raiseSerializationException
-
next
Description copied from interface:StreamingInputAdvance to the next token checking that it is of a certain type.- Specified by:
nextin interfaceStreamingInput- Returns:
- Throws:
IOException
-
skipValue
Description copied from interface:StreamingInputIf this token is aToken.KEYthis will skip its value.- Specified by:
skipValuein interfaceStreamingInput- Throws:
IOException
-
skip
Description copied from interface:StreamingInputSkip the started object, list or value. This method should only be used when when token is eitherToken.OBJECT_START,Token.LIST_STARTorToken.VALUE. SeeStreamingInput.skipValue()for skipping reading when the current token isToken.KEY.- Specified by:
skipin interfaceStreamingInput- Throws:
IOException
-
current
Description copied from interface:StreamingInputGet the current token.- Specified by:
currentin interfaceStreamingInput- Returns:
-
getValueType
Description copied from interface:StreamingInputGet the type of value the input currently has. If thecurrent tokenis notToken.VALUEorToken.NULLthis method will raise aSerializationException.The type of value is defined by the input, and many number values can be converted.
- Specified by:
getValueTypein interfaceStreamingInput- Returns:
- current type of value
-
setValueNull
protected void setValueNull() -
setValue
-
setValue
-
setValue
protected void setValue(boolean value) -
setValue
protected void setValue(byte value) -
setValue
protected void setValue(char value) -
setValue
protected void setValue(double value) -
setValue
protected void setValue(float value) -
setValue
protected void setValue(int value) -
setValue
protected void setValue(long value) -
setValue
protected void setValue(short value) -
setValue
protected void setValue(byte[] value) -
getValue
Description copied from interface:StreamingInputGet the current value.- Specified by:
getValuein interfaceStreamingInput- Returns:
-
getString
Description copied from interface:StreamingInputGet the current value as a string.- Specified by:
getStringin interfaceStreamingInput- Returns:
-
getBoolean
public boolean getBoolean()Description copied from interface:StreamingInputGet the value as a boolean.- Specified by:
getBooleanin interfaceStreamingInput- Returns:
-
getByte
public byte getByte()Description copied from interface:StreamingInputGet the value as a byte.- Specified by:
getBytein interfaceStreamingInput- Returns:
-
getChar
public char getChar()Description copied from interface:StreamingInputGet the value as a character.- Specified by:
getCharin interfaceStreamingInput- Returns:
-
getDouble
public double getDouble()Description copied from interface:StreamingInputGet the value as a double.- Specified by:
getDoublein interfaceStreamingInput- Returns:
-
getFloat
public float getFloat()Description copied from interface:StreamingInputGet the value as a float.- Specified by:
getFloatin interfaceStreamingInput- Returns:
-
getLong
public long getLong()Description copied from interface:StreamingInputGet the value as a long.- Specified by:
getLongin interfaceStreamingInput- Returns:
-
getInt
public int getInt()Description copied from interface:StreamingInputGet the value as an integer.- Specified by:
getIntin interfaceStreamingInput- Returns:
-
getShort
public short getShort()Description copied from interface:StreamingInputGet the value as a short.- Specified by:
getShortin interfaceStreamingInput- Returns:
-
getByteArray
public byte[] getByteArray()Description copied from interface:StreamingInputGet the value as a byte[] array.- Specified by:
getByteArrayin interfaceStreamingInput- Returns:
-