public class PofBufferReader extends PofHelper implements PofReader
PofReader
implementation that reads POF-encoded data from a
BufferInput
.Modifier and Type | Class and Description |
---|---|
static class |
PofBufferReader.IdentityHolder |
static class |
PofBufferReader.UserTypeReader
The UserTypeReader implementation is a contextually-aware PofReader
whose purpose is to advance through the properties of a value of a
specified user type.
|
PofHelper.ReadableEntrySetMap, PofHelper.WriteableEntrySetMap
Base.LoggingWriter, Base.StackFrame
Modifier and Type | Field and Description |
---|---|
protected LongArray |
m_arrayRefs
Lazily-constructed mapping of identities to references.
|
protected PofContext |
m_ctx
The PofContext to use to realize user data types as Java objects.
|
protected ReadBuffer.BufferInput |
m_in
The BufferInput containing the POF stream.
|
BIGDECIMAL_ZERO, BIGINTEGER_MAX_LONG, BIGINTEGER_MIN_LONG, BINARY_EMPTY, BOOLEAN_ARRAY_EMPTY, BYTE_ARRAY_EMPTY, CHAR_ARRAY_EMPTY, COLLECTION_EMPTY, DOUBLE_ARRAY_EMPTY, FLOAT_ARRAY_EMPTY, INT_ARRAY_EMPTY, LONG_ARRAY_EMPTY, OBJECT_ARRAY_EMPTY, SHORT_ARRAY_EMPTY
LOG_ALWAYS, LOG_DEBUG, LOG_ERR, LOG_INFO, LOG_MAX, LOG_MIN, LOG_QUIET, LOG_WARN, POWER_0, POWER_G, POWER_K, POWER_M, POWER_T, UNIT_D, UNIT_H, UNIT_M, UNIT_MS, UNIT_NS, UNIT_S, UNIT_US
J_BIG_DECIMAL, J_BIG_INTEGER, J_BINARY, J_BOOLEAN, J_BOOLEAN_ARRAY, J_BYTE, J_BYTE_ARRAY, J_CHAR_ARRAY, J_CHARACTER, J_COLLECTION, J_DATE, J_DATETIME, J_DOUBLE, J_DOUBLE_ARRAY, J_FLOAT, J_FLOAT_ARRAY, J_INT_ARRAY, J_INTEGER, J_LOCAL_DATE, J_LOCAL_DATETIME, J_LOCAL_TIME, J_LONG, J_LONG_ARRAY, J_MAP, J_NULL, J_OBJECT_ARRAY, J_OFFSET_DATETIME, J_OFFSET_TIME, J_QUAD, J_RAW_DATE, J_RAW_DATETIME, J_RAW_DAY_TIME_INTERVAL, J_RAW_TIME, J_RAW_TIME_INTERVAL, J_RAW_YEAR_MONTH_INTERVAL, J_SHORT, J_SHORT_ARRAY, J_SPARSE_ARRAY, J_STRING, J_TIME, J_TIMESTAMP, J_USER_TYPE, J_ZONED_DATETIME, MAX_DECIMAL128_SCALE, MAX_DECIMAL128_UNSCALED, MAX_DECIMAL32_SCALE, MAX_DECIMAL32_UNSCALED, MAX_DECIMAL64_SCALE, MAX_DECIMAL64_UNSCALED, MIN_DECIMAL128_SCALE, MIN_DECIMAL32_SCALE, MIN_DECIMAL64_SCALE, T_ARRAY, T_BOOLEAN, T_CHAR, T_CHAR_STRING, T_COLLECTION, T_DATE, T_DATETIME, T_DAY_TIME_INTERVAL, T_DECIMAL128, T_DECIMAL32, T_DECIMAL64, T_FLOAT128, T_FLOAT32, T_FLOAT64, T_IDENTITY, T_INT128, T_INT16, T_INT32, T_INT64, T_MAP, T_OCTET, T_OCTET_STRING, T_REFERENCE, T_SPARSE_ARRAY, T_TIME, T_TIME_INTERVAL, T_UNIFORM_ARRAY, T_UNIFORM_COLLECTION, T_UNIFORM_KEYS_MAP, T_UNIFORM_MAP, T_UNIFORM_SPARSE_ARRAY, T_UNKNOWN, T_YEAR_MONTH_INTERVAL, V_BOOLEAN_FALSE, V_BOOLEAN_TRUE, V_COLLECTION_EMPTY, V_FP_NAN, V_FP_NEG_INFINITY, V_FP_POS_INFINITY, V_INT_0, V_INT_1, V_INT_10, V_INT_11, V_INT_12, V_INT_13, V_INT_14, V_INT_15, V_INT_16, V_INT_17, V_INT_18, V_INT_19, V_INT_2, V_INT_20, V_INT_21, V_INT_22, V_INT_3, V_INT_4, V_INT_5, V_INT_6, V_INT_7, V_INT_8, V_INT_9, V_INT_NEG_1, V_REFERENCE_NULL, V_STRING_ZERO_LENGTH
Modifier | Constructor and Description |
---|---|
protected |
PofBufferReader() |
|
PofBufferReader(ReadBuffer.BufferInput in,
PofContext ctx)
Construct a new PofBufferReader that will read a POF stream from the
passed BufferInput object.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
advanceTo(int iProp)
Advance through the POF stream until the specified property is found.
|
protected void |
complete(int iProp)
Register the completion of the parsing of a value.
|
PofReader |
createNestedPofReader(int iProp)
Obtain a PofReader that can be used to read a set of properties from a
single property of the current user type.
|
protected LongArray |
ensureReferenceRegistry()
Obtain the registry for identity-reference pairs, creating it if
necessary.
|
protected PofBufferReader |
getParentParser()
If this parser is contextually within a user type, obtain the parser
which created this parser in order to parse the user type.
|
PofContext |
getPofContext()
Return the PofContext object used by this PofReader to deserialize user
types from a POF stream.
|
int |
getUserTypeId()
Determine the user type that is currently being parsed.
|
int |
getVersionId()
Determine the version identifier of the user type that is currently
being parsed.
|
protected Object |
lookupIdentity(int nId)
Look up the specified identity and return the object to which it
refers.
|
<T> T[] |
readArray(int iProp,
IntFunction<T[]> supplier)
Read an array of values.
|
protected Object |
readAsObject(int nType)
Read a POF value as an Object.
|
protected Object[] |
readAsObjectArray(int nType,
Object[] ao)
Read a POF value as an Object array.
|
protected <T> T[] |
readAsTypedObjectArray(int nType,
IntFunction<T[]> factory)
Read a POF value as an Object array.
|
protected Object |
readAsUniformObject(int nType)
Read a POF value in a uniform array/map as an Object.
|
BigDecimal |
readBigDecimal(int iProp)
Read a BigDecimal from the POF stream.
|
BigInteger |
readBigInteger(int iProp)
Read a BigInteger from the POF stream.
|
Binary |
readBinary(int iProp)
Read a Binary from the POF stream.
|
protected static Binary |
readBinary(ReadBuffer.BufferInput in)
Read a Binary object from the specified BufferInput in an optimal way,
depending on the existence of an enclosing ReadBuffer.
|
boolean |
readBoolean(int iProp)
Read a boolean property from the POF stream.
|
boolean[] |
readBooleanArray(int iProp)
Read a boolean[] property from the POF stream.
|
byte |
readByte(int iProp)
Read a byte property from the POF stream.
|
byte[] |
readByteArray(int iProp)
Read a byte[] property from the POF stream.
|
char |
readChar(int iProp)
Read a char property from the POF stream.
|
char[] |
readCharArray(int iProp)
Read a char[] property from the POF stream.
|
<T,C extends Collection<T>> |
readCollection(int iProp,
C coll)
Read a Collection of object values from the POF stream.
|
Date |
readDate(int iProp)
Read a java.util.Date from the POF stream.
|
double |
readDouble(int iProp)
Read a double property from the POF stream.
|
double[] |
readDoubleArray(int iProp)
Read a double[] property from the POF stream.
|
float |
readFloat(int iProp)
Read a float property from the POF stream.
|
float[] |
readFloatArray(int iProp)
Read a float[] property from the POF stream.
|
int |
readInt(int iProp)
Read a int property from the POF stream.
|
int[] |
readIntArray(int iProp)
Read a int[] property from the POF stream.
|
LocalDate |
readLocalDate(int iProp)
Read a java.time.LocalDate from the POF stream.
|
LocalDateTime |
readLocalDateTime(int iProp)
Read a java.time.LocalDateTime from the POF stream.
|
LocalTime |
readLocalTime(int iProp)
Read a java.time.LocalTime from the POF stream.
|
long |
readLong(int iProp)
Read a long property from the POF stream.
|
long[] |
readLongArray(int iProp)
Read a long[] property from the POF stream.
|
LongArray |
readLongArray(int iProp,
LongArray array)
Read a LongArray of object values.
|
<K,V,M extends Map<K,V>> |
readMap(int iProp,
M map)
Read a Map of key/value pairs from the POF stream.
|
<T> T |
readObject(int iProp)
Read a property of any type, including a user type, from the POF
stream.
|
Object[] |
readObjectArray(int iProp,
Object[] ao)
Read an array of object values.
|
OffsetDateTime |
readOffsetDateTime(int iProp)
Read a java.time.OffsetDateTime from the POF stream.
|
OffsetTime |
readOffsetTime(int iProp)
Read a java.time.OffsetTime from the POF stream.
|
RawDate |
readRawDate(int iProp)
Read a RawDate from the POF stream.
|
RawDateTime |
readRawDateTime(int iProp)
Read a RawDateTime from the POF stream.
|
RawDayTimeInterval |
readRawDayTimeInterval(int iProp)
Read a RawDayTimeInterval from the POF stream.
|
RawQuad |
readRawQuad(int iProp)
Read a RawQuad from the POF stream.
|
RawTime |
readRawTime(int iProp)
Read a RawTime from the POF stream.
|
RawTimeInterval |
readRawTimeInterval(int iProp)
Read a RawTimeInterval from the POF stream.
|
RawYearMonthInterval |
readRawYearMonthInterval(int iProp)
Read a RawYearMonthInterval from the POF stream.
|
Binary |
readRemainder()
Read all remaining indexed properties of the current user type from the
POF stream.
|
short |
readShort(int iProp)
Read a short property from the POF stream.
|
short[] |
readShortArray(int iProp)
Read a short[] property from the POF stream.
|
String |
readString(int iProp)
Read a String from the POF stream.
|
protected void |
registerIdentity(int nId,
Object oValue)
Register the passed value with the passed identity.
|
void |
registerIdentity(Object o)
Register an identity for a newly created user type instance.
|
void |
setPofContext(PofContext ctx)
Configure the PofContext object used by this PofReader to deserialize
user types from a POF stream.
|
calcDecimalSize, checkDate, checkDayTimeInterval, checkDecimalRange, checkElementCount, checkReferenceRange, checkTime, checkTimeInterval, checkTimeZone, checkType, checkYearMonthInterval, convertNumber, convertToDate, decodeTinyInt, encodeTinyInt, formatDate, formatTime, formatTime, getJavaTypeId, getPofTypeId, isIntrinsicPofType, readAsBigDecimal, readAsBigInteger, readAsChar, readAsDouble, readAsFloat, readAsInt, readAsLong, readAsQuad, readBigDecimal, readBigInteger, readChar, readLocalDate, readLocalDateTime, readLocalTime, readOffsetDateTime, readOffsetTime, readQuad, readRawDate, readRawTime, resizeArray, skipPackedInts, skipUniformValue, skipValue, writeBigDecimal, writeBigInteger, writeDate, writeTime
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
readZonedDateTime
protected ReadBuffer.BufferInput m_in
protected PofContext m_ctx
protected LongArray m_arrayRefs
public PofBufferReader(ReadBuffer.BufferInput in, PofContext ctx)
in
- a BufferInput objectctx
- the PofContextprotected PofBufferReader()
public boolean readBoolean(int iProp) throws IOException
readBoolean
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic byte readByte(int iProp) throws IOException
readByte
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic char readChar(int iProp) throws IOException
readChar
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic short readShort(int iProp) throws IOException
readShort
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic int readInt(int iProp) throws IOException
readInt
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic long readLong(int iProp) throws IOException
readLong
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic float readFloat(int iProp) throws IOException
readFloat
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic double readDouble(int iProp) throws IOException
readDouble
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic boolean[] readBooleanArray(int iProp) throws IOException
readBooleanArray
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic byte[] readByteArray(int iProp) throws IOException
readByteArray
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic char[] readCharArray(int iProp) throws IOException
readCharArray
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic short[] readShortArray(int iProp) throws IOException
readShortArray
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic int[] readIntArray(int iProp) throws IOException
readIntArray
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic long[] readLongArray(int iProp) throws IOException
readLongArray
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic float[] readFloatArray(int iProp) throws IOException
readFloatArray
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic double[] readDoubleArray(int iProp) throws IOException
readDoubleArray
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic BigInteger readBigInteger(int iProp) throws IOException
readBigInteger
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic RawQuad readRawQuad(int iProp) throws IOException
readRawQuad
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic BigDecimal readBigDecimal(int iProp) throws IOException
readBigDecimal
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic Binary readBinary(int iProp) throws IOException
readBinary
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic String readString(int iProp) throws IOException
readString
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic Date readDate(int iProp) throws IOException
readDate
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic LocalDate readLocalDate(int iProp) throws IOException
PofReader
readLocalDate
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic LocalDateTime readLocalDateTime(int iProp) throws IOException
PofReader
readLocalDateTime
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic LocalTime readLocalTime(int iProp) throws IOException
PofReader
readLocalTime
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic OffsetDateTime readOffsetDateTime(int iProp) throws IOException
PofReader
readOffsetDateTime
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic OffsetTime readOffsetTime(int iProp) throws IOException
PofReader
readOffsetTime
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic RawDate readRawDate(int iProp) throws IOException
RawDate
class
contains the raw date information that was carried in the POF stream.readRawDate
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic RawTime readRawTime(int iProp) throws IOException
RawTime
class
contains the raw time information that was carried in the POF stream,
including raw timezone information.readRawTime
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic RawDateTime readRawDateTime(int iProp) throws IOException
RawDateTime
class contains the raw date and time information that was
carried in the POF stream, including raw timezone information.readRawDateTime
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic RawYearMonthInterval readRawYearMonthInterval(int iProp) throws IOException
RawYearMonthInterval
class contains the raw year-month interval
information that was carried in the POF stream.readRawYearMonthInterval
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic RawTimeInterval readRawTimeInterval(int iProp) throws IOException
RawTimeInterval
class contains the raw time interval information that
was carried in the POF stream.readRawTimeInterval
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic RawDayTimeInterval readRawDayTimeInterval(int iProp) throws IOException
RawDayTimeInterval
class contains the raw year-month interval
information that was carried in the POF stream.readRawDayTimeInterval
in interface PofReader
iProp
- the property index to readIOException
- if an I/O error occurspublic Object[] readObjectArray(int iProp, Object[] ao) throws IOException
readObjectArray
in interface PofReader
iProp
- the property index to readao
- the optional array to use to store the values, or to use
as a typed template for creating an array to store the
values, following the documentation for
Collection.toArray()
IOException
- if an I/O error occurspublic <T> T[] readArray(int iProp, IntFunction<T[]> supplier) throws IOException
readArray
in interface PofReader
T
- the value typeiProp
- the property index to readsupplier
- the supplier to use to create the array, typically an
array constructor reference (i.e. String[]::new
)IOException
- if an I/O error occurspublic LongArray readLongArray(int iProp, LongArray array) throws IOException
readLongArray
in interface PofReader
iProp
- the property index to readarray
- the optional LongArray object to use to store the valuesIOException
- if an I/O error occurspublic <T,C extends Collection<T>> C readCollection(int iProp, C coll) throws IOException
readCollection
in interface PofReader
T
- the object value typeC
- the collection typeiProp
- the property index to readcoll
- the optional Collection to use to store the valuesIOException
- if an I/O error occurspublic <K,V,M extends Map<K,V>> M readMap(int iProp, M map) throws IOException
readMap
in interface PofReader
K
- the key typeV
- the value typeM
- the map typeiProp
- the property index to readmap
- the optional Map to initializeIOException
- if an I/O error occurspublic PofContext getPofContext()
getPofContext
in interface PofReader
public void setPofContext(PofContext ctx)
Note: this is an advanced method that should be used with care. For example, if this method is being used to switch to another PofContext mid-POF stream, it is important to eventually restore the original PofContext. For example:
PofContext ctxOrig = reader.getPofContext(); try { // switch to another PofContext PofContext ctxNew = ...; reader.setContext(ctxNew); // read POF data using the reader } finally { // restore the original PofContext reader.setPofContext(ctxOrig); }
setPofContext
in interface PofReader
ctx
- the new PofContext; must not be nullpublic <T> T readObject(int iProp) throws IOException
readObject
in interface PofReader
T
- the object typeiProp
- the property index to readIOException
- if an I/O error occurspublic int getUserTypeId()
getUserTypeId
in interface PofReader
public int getVersionId()
getVersionId
in interface PofReader
public void registerIdentity(Object o)
If identity/reference types are enabled, an identity is used to uniquely identify a user type instance within a POF stream. The identity immediately proceeds the instance value in the POF stream and can be used later in the stream to reference the instance.
PofSerializer implementations must call this method with the user type instance instantiated during deserialization prior to reading any properties of the instance which are user type instances themselves.
registerIdentity
in interface PofReader
o
- the object to register the identity forPofSerializer.deserialize(PofReader)
public PofReader createNestedPofReader(int iProp) throws IOException
createNestedPofReader
in interface PofReader
iProp
- the property index to read fromIOException
- if an I/O error occurspublic Binary readRemainder() throws IOException
Subsequent calls to the various readXYZ methods of this interface will fail after this method is called.
readRemainder
in interface PofReader
IOException
- if an I/O error occursprotected boolean advanceTo(int iProp) throws IOException
iProp
- the index of the property to advance toIllegalStateException
- if the POF stream has already advanced
past the desired propertyIOException
- if an I/O error occursprotected void complete(int iProp) throws IOException
iProp
- the property indexIOException
- if an I/O error occursprotected PofBufferReader getParentParser()
protected LongArray ensureReferenceRegistry()
protected void registerIdentity(int nId, Object oValue)
nId
- the identity within the POF stream of the objectoValue
- the object to associate with the passed identityIllegalArgumentException
- if the specified identity is already
registered with a different objectprotected Object lookupIdentity(int nId) throws IOException
nId
- the identityIOException
- if the requested identity is not registeredprotected Object readAsObject(int nType) throws IOException
nType
- the type identifier of the valueIOException
- if an I/O error occursprotected Object readAsUniformObject(int nType) throws IOException
nType
- the type identifier of the valueIOException
- if an I/O error occursprotected Object[] readAsObjectArray(int nType, Object[] ao) throws IOException
nType
- the type identifier of the valueao
- the optional array to use to store the values, or to use
as a typed template for creating an array to store the
values, following the documentation for
Collection.toArray()
IOException
- if an I/O error occursprotected <T> T[] readAsTypedObjectArray(int nType, IntFunction<T[]> factory) throws IOException
T
- the identifier typenType
- the type identifier of the valuefactory
- the optional factory to use to initialize the arrayIOException
- if an I/O error occursprotected static Binary readBinary(ReadBuffer.BufferInput in) throws IOException
in
- a BufferInput to read fromIOException
- if an I/O error occurs