Class SdkDataWriter
java.lang.Object
io.getlime.security.powerauth.lib.cmd.util.config.SdkDataWriter
- All Implemented Interfaces:
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 -
Method Summary
Modifier and TypeMethodDescriptionintReturns maximum supported value which can be serialized as a counter.byte[]Returns serialized data.voidreset()Resets data writer object to its initial state.voidwriteByte(byte b) Writes one byte to the stream.booleanwriteCount(int count) Writes a count to the stream in optimized binary format.voidwriteData(byte[] bytes) Writes number of bytes in byte range and actual data to the stream.voidwriteRaw(byte[] bytes) Writes only the content of byte range to the data stream.voidwriteString(String str) Writes number of characters in string and actual content of string to the data stream.
-
Constructor Details
-
SdkDataWriter
public SdkDataWriter()
-
-
Method Details
-
reset
public void reset()Description copied from interface:DataWriterResets data writer object to its initial state.- Specified by:
resetin interfaceDataWriter
-
writeByte
public void writeByte(byte b) Description copied from interface:DataWriterWrites one byte to the stream.- Specified by:
writeBytein interfaceDataWriter- Parameters:
b- Byte to write.
-
writeData
public void writeData(byte[] bytes) Description copied from interface:DataWriterWrites number of bytes in byte range and actual data to the stream. The size of range must not exceed value returned fromDataWriter.getMaxCount()method.- Specified by:
writeDatain interfaceDataWriter- Parameters:
bytes- Bytes to write.
-
writeString
Description copied from interface:DataWriterWrites number of characters in string and actual content of string to the data stream. The length of string must not exceed value returned fromDataWriter.getMaxCount()method.- Specified by:
writeStringin interfaceDataWriter- Parameters:
str- String to write.
-
writeRaw
public void writeRaw(byte[] bytes) Description copied from interface:DataWriterWrites only the content of byte range to the data stream. Unlike theDataWriter.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:
writeRawin interfaceDataWriter- Parameters:
bytes- Data bytes.
-
writeCount
public boolean writeCount(int count) Description copied from interface:DataWriterWrites a count to the stream in optimized binary format. The count parameter must be less or equal than value returned fromDataWriter.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:
writeCountin interfaceDataWriter- Parameters:
count- Count value to write.- Returns:
- whether write succeeded
-
getSerializedData
public byte[] getSerializedData()Description copied from interface:DataWriterReturns serialized data.- Specified by:
getSerializedDatain interfaceDataWriter- Returns:
- Serialized data.
-
getMaxCount
public int getMaxCount()Description copied from interface:DataWriterReturns 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:
getMaxCountin interfaceDataWriter- Returns:
- Maximum count value.
-