-
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
AbstractStructuredReader
public interface StructuredReader extends AutoCloseable
Interface for a reader to parse astructured formatsuch as JSON or XML.- Since:
- 1.0.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classStructuredReader.StateEnum with the possible states of aStructuredReader.
-
Method Summary
-
-
-
Method Detail
-
readName
String readName()
- Returns:
- the name of the current property or element.
-
readStartObject
boolean readStartObject()
- Returns:
trueif pointing to the start of an object,falseotherwise.- See Also:
StructuredWriter.writeStartObject()
-
readStartArray
boolean readStartArray()
- Returns:
trueif pointing to the start of an object,falseotherwise.- See Also:
StructuredWriter.writeStartArray()
-
readValue
Object readValue()
Generic method to read and unmarshall a value supporting only the build in typesBoolean,String, andNumber.- Returns:
- the unmarsahlled value. May be
null.
-
readValue
Object readValue(boolean recursive)
-
readObject
void readObject(Map<String,Object> map)
This method may be called if thecurrent stateisStructuredReader.State.START_OBJECTto read the object into the givenMap. After the call of this method thestatewill point to thenextone after the correspondingStructuredReader.State.END_OBJECT.- Parameters:
map- theMapwhere to add the properties. UnlikereadValue(boolean)this allows you to choose theMapimplementation.
-
readArray
void readArray(Collection<Object> array)
This method may be called called if thecurrent stateisStructuredReader.State.START_ARRAYto read the array into the givenCollection. After the call of this method thestatewill point to thenextone after the correspondingStructuredReader.State.END_ARRAY.- Parameters:
array- theCollectionwhere to add thevalues.
-
readValue
default <V> V readValue(Class<V> type)
Generic method to read and unmarshall a value.
ATTENTION:
This generic method only exists as convenience method for thereadValueAs*methods. It therefore only supports standard Java value types as described inio.github.mmm.marshall. For other types it will throw anIllegalArgumentException.- Type Parameters:
V- type of the value to read.- Parameters:
type-Classreflecting the value to read.- Returns:
- the unmarsahlled value. May be
null.
-
readValueAsString
String readValueAsString()
- Returns:
- reads the value as
String. - See Also:
readValue(Class)
-
readValueAsBoolean
Boolean readValueAsBoolean()
- Returns:
- reads the value as
Boolean. - See Also:
readValue(Class)
-
readValueAsInteger
Integer readValueAsInteger()
- Returns:
- reads the value as
Integer. - See Also:
readValue(Class)
-
readValueAsLong
Long readValueAsLong()
- Returns:
- reads the value as
Long. - See Also:
readValue(Class)
-
readValueAsDouble
Double readValueAsDouble()
- Returns:
- reads the value as
Double. - See Also:
readValue(Class)
-
readValueAsFloat
Float readValueAsFloat()
- Returns:
- reads the value as
Float. - See Also:
readValue(Class)
-
readValueAsShort
Short readValueAsShort()
- Returns:
- reads the value as
Short. - See Also:
readValue(Class)
-
readValueAsByte
Byte readValueAsByte()
- Returns:
- reads the value as
Byte. - See Also:
readValue(Class)
-
readValueAsBigInteger
BigInteger readValueAsBigInteger()
- Returns:
- reads the value as
BigInteger. - See Also:
readValue(Class)
-
readValueAsBigDecimal
BigDecimal readValueAsBigDecimal()
- Returns:
- reads the value as
BigDecimal. - See Also:
readValue(Class)
-
skipValue
void skipValue()
Skips the current value. Should be called afterreadName().- If currently at
start of object, skip that entire object. - If currently at
start of array, skip the entire array. - If currently at a
single value, skip that value.
- If currently at
-
isDone
boolean isDone()
- Returns:
trueif all data has been read and the end of the stream has been reached,falseotherwise.
-
getState
StructuredReader.State getState()
- Returns:
- the current state of this reader.
-
next
StructuredReader.State next()
Proceeds to the nextStructuredReader.Stateskipping the current information.- Returns:
- the new
StructuredReader.State.
-
close
void close()
- Specified by:
closein interfaceAutoCloseable
-
-