java.lang.Object
io.getlime.security.powerauth.lib.cmd.util.config.SdkDataWriter
All Implemented Interfaces:
DataWriter

public class SdkDataWriter extends Object implements DataWriter
Data writer implementation for PowerAuth mobile SDK, see: https://github.com/wultra/powerauth-mobile-sdk/blob/develop/src/PowerAuth/utils/DataWriter.cpp
Author:
Roman Strobl, roman.strobl@wultra.com
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns maximum supported value which can be serialized as a counter.
    byte[]
    Returns serialized data.
    void
    Resets data writer object to its initial state.
    void
    writeByte(byte b)
    Writes one byte to the stream.
    boolean
    writeCount(int count)
    Writes a count to the stream in optimized binary format.
    void
    writeData(byte[] bytes)
    Writes number of bytes in byte range and actual data to the stream.
    void
    writeRaw(byte[] bytes)
    Writes only the content of byte range to the data stream.
    void
    Writes number of characters in string and actual content of string to the data stream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SdkDataWriter

      public SdkDataWriter()
  • Method Details

    • reset

      public void reset()
      Description copied from interface: DataWriter
      Resets data writer object to its initial state.
      Specified by:
      reset in interface DataWriter
    • writeByte

      public void writeByte(byte b)
      Description copied from interface: DataWriter
      Writes one byte to the stream.
      Specified by:
      writeByte in interface DataWriter
      Parameters:
      b - Byte to write.
    • writeData

      public void writeData(byte[] bytes)
      Description copied from interface: DataWriter
      Writes number of bytes in byte range and actual data to the stream. The size of range must not exceed value returned from DataWriter.getMaxCount() method.
      Specified by:
      writeData in interface DataWriter
      Parameters:
      bytes - Bytes to write.
    • writeString

      public void writeString(String str)
      Description copied from interface: DataWriter
      Writes number of characters in string and actual content of string to the data stream. The length of string must not exceed value returned from DataWriter.getMaxCount() method.
      Specified by:
      writeString in interface DataWriter
      Parameters:
      str - String to write.
    • writeRaw

      public void writeRaw(byte[] bytes)
      Description copied from interface: DataWriter
      Writes only the content of byte range to the data stream. Unlike the DataWriter.writeData(byte[]), this method doesn't store number of bytes as a size marker. It's up to you, how you determine the size of sequence during the data reading.
      Specified by:
      writeRaw in interface DataWriter
      Parameters:
      bytes - Data bytes.
    • writeCount

      public boolean writeCount(int count)
      Description copied from interface: DataWriter
      Writes a count to the stream in optimized binary format. The count parameter must be less or equal than value returned from DataWriter.getMaxCount() method. You should prefer this method for counter-type values over the writing 32-bit or 64-bit values to the stream, because it usually produces a shorter byte streams. For example, if count value is lesser than 128, then just one byte is serialized.
      Specified by:
      writeCount in interface DataWriter
      Parameters:
      count - Count value to write.
      Returns:
      whether write succeeded
    • getSerializedData

      public byte[] getSerializedData()
      Description copied from interface: DataWriter
      Returns serialized data.
      Specified by:
      getSerializedData in interface DataWriter
      Returns:
      Serialized data.
    • getMaxCount

      public int getMaxCount()
      Description copied from interface: DataWriter
      Returns maximum supported value which can be serialized as a counter. The returned value is the same for all supported platforms and CPU architectures.
      Specified by:
      getMaxCount in interface DataWriter
      Returns:
      Maximum count value.