Package com.tccc.kos.commons.util
Interface ByteOrderOutput
- All Known Implementing Classes:
BinaryMsg
,BinaryMsgOutputStream
,ByteOrderOutputStream
public interface ByteOrderOutput
Interface for operation supported by ByteOrderOutputStream. Useful in that
other objects can implement this interface and act as a facade over top of
ByteOrderOutputStream and ensure things match up.
- Since:
- 1.0
- Version:
- 2022-08-30
-
Method Summary
Modifier and TypeMethodDescriptionvoid
write
(byte[] b) Write the array of bytes.void
write
(byte[] b, int len) Write the specified array of bytes and then pad with zeros to the specified length.void
write
(byte[] b, int off, int len) Write the specified number of bytes from the array starting at the specified offset.void
write
(int b) Write a byte.void
writeBoolean
(boolean v) Write a boolean as a one byte value of 0 or 1.void
writeByte
(int v) Write a single byte to the output stream.void
writeCString
(String str) Write a variable length string as an ascii encoded C string.void
writeCString
(String str, int maxLen) Write a string as an ascii encoded, null terminated C string.void
writeCString
(String str, int maxLen, byte pad) Write a string as an ascii encoded C string.void
writeDouble
(double v) Write a double to the output stream.void
writeFloat
(float v) Write a float to the output stream.void
writeInt
(int v) Writes an int to the output stream.void
writeInt24
(int v) Writes the lower 24 bits of an int to the output stream.void
writeLong
(long v) Writes a long to the output stream.void
writeShort
(int v) Writes a short to the output stream.void
Write a short utf-8 string preceded by an 8 bit length in bytes (not characters).void
writeShortStringWithLen
(String str, int maxChars) Write a short utf-8 string preceded by an 8 bit length in bytes (not characters), limited to the specified number of characters (not bytes).void
writeStringWithLen
(String str) Write a utf-8 string preceded by a 16 bit length in bytes (not characters).
-
Method Details
-
write
Write a byte.- Parameters:
b
- the byte to write- Throws:
IOException
-
write
Write the array of bytes.- Parameters:
b
- the byte to write- Throws:
IOException
-
write
Write the specified number of bytes from the array starting at the specified offset.- Parameters:
b
- the data to writeoff
- offset to start fromlen
- number of bytes to write- Throws:
IOException
-
writeBoolean
Write a boolean as a one byte value of 0 or 1.- Parameters:
v
- the value to write- Throws:
IOException
- if there is an underlying error
-
writeByte
Write a single byte to the output stream.- Parameters:
v
- the value to write- Throws:
IOException
- if there is an underlying error
-
writeShort
Writes a short to the output stream.- Parameters:
v
- the value to write- Throws:
IOException
- if there is an underlying error
-
writeInt
Writes an int to the output stream.- Parameters:
v
- the value to write- Throws:
IOException
- if there is an underlying error
-
writeInt24
Writes the lower 24 bits of an int to the output stream.- Parameters:
v
- the value to write- Throws:
IOException
- if there is an underlying error
-
writeLong
Writes a long to the output stream.- Parameters:
v
- the value to write- Throws:
IOException
- if there is an underlying error
-
writeFloat
Write a float to the output stream.- Parameters:
v
- the value to write- Throws:
IOException
- if there is an underlying error
-
writeDouble
Write a double to the output stream.- Parameters:
v
- the value to write- Throws:
IOException
- if there is an underlying error
-
writeCString
Write a string as an ascii encoded, null terminated C string. If the string is longer than maxLen then an exception will be thrown. If the string is shorter than the string, the difference will be zero padded. This makes it easy to write strings to fixed size buffers on the native side of things.- Parameters:
str
- the string to writemaxLen
- the max length of the string- Throws:
IOException
-
writeCString
Write a string as an ascii encoded C string. The string is NOT null terminated. If the string is longer than maxLen then an exception will be thrown. If the string is shorter than the string, the difference will be padded with desired padding byte. This makes it easy to write strings to fixed size buffers on the native side of things.- Parameters:
str
- the string to writemaxLen
- the max length of the stringpad
- the padding byte to use- Throws:
IOException
-
writeCString
Write a variable length string as an ascii encoded C string. The string is null terminated. It is up to the caller to make sure the length is not a problem.- Parameters:
str
- the string to write- Throws:
IOException
-
writeStringWithLen
Write a utf-8 string preceded by a 16 bit length in bytes (not characters).- Parameters:
str
- the string to write- Throws:
IOException
-
writeShortStringWithLen
Write a short utf-8 string preceded by an 8 bit length in bytes (not characters).- Parameters:
str
- the string to write- Throws:
IOException
-
writeShortStringWithLen
Write a short utf-8 string preceded by an 8 bit length in bytes (not characters), limited to the specified number of characters (not bytes).- Parameters:
str
- the string to write- Throws:
IOException
-
write
Write the specified array of bytes and then pad with zeros to the specified length.- Parameters:
b
- the bytes to writelen
- the length to pad to- Throws:
IOException
-