Interface PortableReader


public interface PortableReader
Provides means for reading portable fields from binary data in the form of java primitives, arrays of java primitives, nested portable fields and array of portable fields.
  • Method Details

    • getVersion

      int getVersion()
      Returns:
      global version of portable classes
    • hasField

      boolean hasField​(@Nonnull String fieldName)
      Parameters:
      fieldName - name of the field (does not support nested paths)
      Returns:
      true if field exist in this class.
    • getFieldNames

      @Nonnull Set<String> getFieldNames()
      Returns:
      set of field names on this portable class
    • getFieldType

      @Nonnull FieldType getFieldType​(@Nonnull String fieldName)
      Parameters:
      fieldName - name of the field
      Returns:
      field type of given fieldName
      Throws:
      IllegalArgumentException - if the field does not exist.
    • getFieldClassId

      int getFieldClassId​(@Nonnull String fieldName)
      Parameters:
      fieldName - name of the field
      Returns:
      classId of given field
    • readInt

      int readInt​(@Nonnull String fieldName) throws IOException
      Parameters:
      fieldName - name of the field
      Returns:
      the int value read
      Throws:
      IOException - in case of any exceptional case
    • readLong

      long readLong​(@Nonnull String fieldName) throws IOException
      Parameters:
      fieldName - name of the field
      Returns:
      the long value read
      Throws:
      IOException - in case of any exceptional case
    • readUTF

      @Nullable @Deprecated String readUTF​(@Nonnull String fieldName) throws IOException
      Deprecated.
      for the sake of better naming. Use readString(String) instead
      Parameters:
      fieldName - name of the field
      Returns:
      the utf string value read
      Throws:
      IOException - in case of any exceptional case
    • readString

      @Nullable String readString​(@Nonnull String fieldName) throws IOException
      Parameters:
      fieldName - name of the field
      Returns:
      the string value read
      Throws:
      IOException - in case of any exceptional case
    • readBoolean

      boolean readBoolean​(@Nonnull String fieldName) throws IOException
      Parameters:
      fieldName - name of the field
      Returns:
      the boolean value read
      Throws:
      IOException - in case of any exceptional case
    • readByte

      byte readByte​(@Nonnull String fieldName) throws IOException
      Parameters:
      fieldName - name of the field
      Returns:
      the byte value read
      Throws:
      IOException - in case of any exceptional case
    • readChar

      char readChar​(@Nonnull String fieldName) throws IOException
      Parameters:
      fieldName - name of the field
      Returns:
      the char value read
      Throws:
      IOException - in case of any exceptional case
    • readDouble

      double readDouble​(@Nonnull String fieldName) throws IOException
      Parameters:
      fieldName - name of the field
      Returns:
      the double value read
      Throws:
      IOException - in case of any exceptional case
    • readFloat

      float readFloat​(@Nonnull String fieldName) throws IOException
      Parameters:
      fieldName - name of the field
      Returns:
      the float value read
      Throws:
      IOException - in case of any exceptional case
    • readShort

      short readShort​(@Nonnull String fieldName) throws IOException
      Parameters:
      fieldName - name of the field
      Returns:
      the short value read
      Throws:
      IOException - in case of any exceptional case
    • readPortable

      @Nullable <P extends Portable> P readPortable​(@Nonnull String fieldName) throws IOException
      Type Parameters:
      P - the type of the portable read
      Parameters:
      fieldName - name of the field
      Returns:
      the portable value read
      Throws:
      IOException - in case of any exceptional case
    • readDecimal

      @Nullable BigDecimal readDecimal​(@Nonnull String fieldName) throws IOException
      Reads a decimal which is arbitrary precision and scale floating-point number to BigDecimal
      Parameters:
      fieldName - name of the field
      Returns:
      the BigDecimal value read
      Throws:
      IOException - in case of any exceptional case
    • readTime

      @Nullable LocalTime readTime​(@Nonnull String fieldName) throws IOException
      Reads a time field consisting of hour, minute, seconds and nanos parts to LocalTime
      Parameters:
      fieldName - name of the field
      Returns:
      the LocalTime value read
      Throws:
      IOException - in case of any exceptional case
    • readDate

      @Nullable LocalDate readDate​(@Nonnull String fieldName) throws IOException
      Reads a date field consisting of year, month of the year and day of the month to LocalDate
      Parameters:
      fieldName - name of the field
      Returns:
      the LocalDate value read
      Throws:
      IOException - in case of any exceptional case
    • readTimestamp

      @Nullable LocalDateTime readTimestamp​(@Nonnull String fieldName) throws IOException
      Reads a timestamp field consisting of year, month of the year, day of the month, hour, minute, seconds, nanos parts to LocalDateTime
      Parameters:
      fieldName - name of the field
      Returns:
      the LocalDateTime value read
      Throws:
      IOException - in case of any exceptional case
    • readTimestampWithTimezone

      @Nullable OffsetDateTime readTimestampWithTimezone​(@Nonnull String fieldName) throws IOException
      Reads a timestamp with timezone field consisting of year, month of the year, day of the month, offset seconds, hour, minute, seconds, nanos parts to OffsetDateTime
      Parameters:
      fieldName - name of the field
      Returns:
      the OffsetDateTime value read
      Throws:
      IOException - in case of any exceptional case
    • readByteArray

      @Nullable byte[] readByteArray​(@Nonnull String fieldName) throws IOException
      Parameters:
      fieldName - name of the field
      Returns:
      the byte array value read
      Throws:
      IOException - in case of any exceptional case
    • readBooleanArray

      @Nullable boolean[] readBooleanArray​(@Nonnull String fieldName) throws IOException
      Parameters:
      fieldName - name of the field
      Returns:
      the boolean array value read
      Throws:
      IOException - in case of any exceptional case
    • readCharArray

      @Nullable char[] readCharArray​(@Nonnull String fieldName) throws IOException
      Parameters:
      fieldName - name of the field
      Returns:
      the char array value read
      Throws:
      IOException - in case of any exceptional case
    • readIntArray

      @Nullable int[] readIntArray​(@Nonnull String fieldName) throws IOException
      Parameters:
      fieldName - name of the field
      Returns:
      the int array value read
      Throws:
      IOException - in case of any exceptional case
    • readLongArray

      @Nullable long[] readLongArray​(@Nonnull String fieldName) throws IOException
      Parameters:
      fieldName - name of the field
      Returns:
      the long array value read
      Throws:
      IOException - in case of any exceptional case
    • readDoubleArray

      @Nullable double[] readDoubleArray​(@Nonnull String fieldName) throws IOException
      Parameters:
      fieldName - name of the field
      Returns:
      the double array value read
      Throws:
      IOException - in case of any exceptional case
    • readFloatArray

      @Nullable float[] readFloatArray​(@Nonnull String fieldName) throws IOException
      Parameters:
      fieldName - name of the field
      Returns:
      the float array value read
      Throws:
      IOException - in case of any exceptional case
    • readShortArray

      short[] readShortArray​(@Nonnull String fieldName) throws IOException
      Parameters:
      fieldName - name of the field
      Returns:
      the short array value read
      Throws:
      IOException - in case of any exceptional case
    • readUTFArray

      @Nullable @Deprecated String[] readUTFArray​(@Nonnull String fieldName) throws IOException
      Deprecated.
      for the sake of better naming. Use readStringArray(String) instead
      Parameters:
      fieldName - name of the field
      Returns:
      the String array value read
      Throws:
      IOException - in case of any exceptional case
    • readStringArray

      @Nullable String[] readStringArray​(@Nonnull String fieldName) throws IOException
      Parameters:
      fieldName - name of the field
      Returns:
      the String array value read
      Throws:
      IOException - in case of any exceptional case
    • readPortableArray

      @Nullable Portable[] readPortableArray​(@Nonnull String fieldName) throws IOException
      Parameters:
      fieldName - name of the field
      Returns:
      the portable array read
      Throws:
      IOException - in case of any exceptional case
    • readDecimalArray

      @Nullable BigDecimal[] readDecimalArray​(@Nonnull String fieldName) throws IOException
      Reads an array of Decimal's to BigDecimal[]
      Parameters:
      fieldName - name of the field
      Returns:
      the BigDecimal array read
      Throws:
      IOException - in case of any exceptional case
      See Also:
      readDecimal(String)
    • readTimeArray

      @Nullable LocalTime[] readTimeArray​(@Nonnull String fieldName) throws IOException
      Reads an array of Time's to LocalTime[]
      Parameters:
      fieldName - name of the field
      Returns:
      the LocalTime array read
      Throws:
      IOException - in case of any exceptional case
      See Also:
      readTime(String)
    • readDateArray

      @Nullable LocalDate[] readDateArray​(@Nonnull String fieldName) throws IOException
      Reads an array of Date's to LocalDate[]
      Parameters:
      fieldName - name of the field
      Returns:
      the LocalDate array read
      Throws:
      IOException - in case of any exceptional case
      See Also:
      readDate(String)
    • readTimestampArray

      @Nullable LocalDateTime[] readTimestampArray​(@Nonnull String fieldName) throws IOException
      Reads an array of Timestamp's to LocalDateTime[]
      Parameters:
      fieldName - name of the field
      Returns:
      the LocalDateTime array read
      Throws:
      IOException - in case of any exceptional case
      See Also:
      readTimestamp(String)
    • readTimestampWithTimezoneArray

      @Nullable OffsetDateTime[] readTimestampWithTimezoneArray​(@Nonnull String fieldName) throws IOException
      Reads an array of TimestampWithTimezone's to OffsetDateTime[]
      Parameters:
      fieldName - name of the field
      Returns:
      the OffsetDateTime array read
      Throws:
      IOException - in case of any exceptional case
      See Also:
      readTimestampWithTimezone(String)
    • getRawDataInput

      @Nonnull ObjectDataInput getRawDataInput() throws IOException
      PortableWriter.getRawDataOutput().

      Note that portable fields can not be read after this method is called. If this happens, an IOException will be thrown.

      Returns:
      rawDataInput
      Throws:
      IOException - in case of any exceptional case