Package nl.basjes.modbus.schema.utils
Object ByteConversions
-
- All Implemented Interfaces:
public class ByteConversions
-
-
Field Summary
Fields Modifier and Type Field Description public final static ByteConversionsINSTANCE
-
Method Summary
-
-
Method Detail
-
bytesToHexString
final String bytesToHexString(ByteArray bytes)
-
bytesToSeparatedHexString
final String bytesToSeparatedHexString(ByteArray bytes, String separator)
-
bytesToSeparatedIntegerString
final String bytesToSeparatedIntegerString(ByteArray bytes, String separator)
-
bytesToSeparatedTwoByteHexString
final String bytesToSeparatedTwoByteHexString(ByteArray bytes, String separator)
-
bytesToHexStringList
final List<String> bytesToHexStringList(ByteArray bytes)
-
bytesToTwoByteHexStringList
final List<String> bytesToTwoByteHexStringList(ByteArray bytes)
-
splitStringBySize
final List<String> splitStringBySize(String str, Integer size)
-
hexStringToBytes
final ByteArray hexStringToBytes(String input)
-
hexStringToBytes
final Array<ByteArray> hexStringToBytes(List<String> input)
-
allAreOfSize
final Boolean allAreOfSize(Array<ByteArray> arrayOfByteArrays, Integer size)
Determine if all provided byte arrays are the allowed size
- Parameters:
arrayOfByteArrays- The array of byte arrayssize- The allowed size- Returns:
true if all arrays are of an allowed size
-
arrayOfByteArraysContains
final Boolean arrayOfByteArraysContains(Array<ByteArray> arrayOfByteArrays, ByteArray bytes)
-
bytesToString
final String bytesToString(ByteArray bytes)
Convert the provided byte array to a String using UTF8 The ONLY reason for having custom code here is that the standard Java implementation simply replaces bad characters with "something". I want to terminate on the first bad character.
- Parameters:
bytes- An array of bytes to be converted- Returns:
An instance of String or null if the input was null.
-
stringToBytes
final ByteArray stringToBytes(String value)
-
shortToBytes
final ByteArray shortToBytes(Short input)
-
bytesToShort
final Short bytesToShort(ByteArray bytes)
-
integerToBytes
final ByteArray integerToBytes(Integer input)
-
bytesToInteger
final Integer bytesToInteger(ByteArray bytes)
-
longToBytes
final ByteArray longToBytes(Long input)
-
bytesToLong
final Long bytesToLong(ByteArray bytes)
-
floatToBytes
final ByteArray floatToBytes(Float value)
-
bytesToFloat
final Float bytesToFloat(ByteArray bytes)
-
doubleToBytes
final ByteArray doubleToBytes(Double value)
-
bytesToDouble
final Double bytesToDouble(ByteArray bytes)
-
-
-
-