Package com.automation_pros.odva.endian
Class EndianNioOutput
- java.lang.Object
-
- com.automation_pros.odva.endian.EndianNioOutput
-
- All Implemented Interfaces:
EndianDataOutput
,java.io.DataOutput
public class EndianNioOutput extends java.lang.Object implements EndianDataOutput
Wrap a NIO ByteBuffer for use as either EndianDataInput or EndianDataOutput compatible with any Capsule subclass. Includes inverse skip handling for fixed-length typed reads and writes.
-
-
Constructor Summary
Constructors Constructor Description EndianNioOutput(java.nio.ByteBuffer buf)
Wrap the given bytebuffer for use in the Capsule class and any of its subclasses.EndianNioOutput(java.nio.ByteBuffer buf, int skip)
Wrap the given bytebuffer for use in the Capsule class and any of its subclasses, initializing the preliminary bytes to skip.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
checkWriteSkip(int n)
java.nio.ByteBuffer
getBuffer()
protected void
put(byte b)
int
remaining()
void
write(byte[] bytes)
void
write(byte[] bytes, int offset, int length)
void
write(int b)
void
writeBoolean(boolean b)
void
writeByte(int b)
void
writeBytes(java.lang.String s)
void
writeChar(int v)
void
writeCharLE(int v)
Little-endian counterpart towriteChar()
.void
writeChars(java.lang.String s)
void
writeCharsLE(java.lang.String s)
Little-endian counterpart towriteChars()
.void
writeDouble(double v)
void
writeDoubleLE(double v)
Little-endian counterpart towriteDouble()
.void
writeFloat(float v)
void
writeFloatLE(float f)
Little-endian counterpart towriteFloat()
.void
writeInt(int v)
void
writeIntLE(int v)
Little-endian counterpart towriteInt()
.void
writeLong(long v)
void
writeLongLE(long v)
Little-endian counterpart towriteLong()
.void
writeShort(int v)
void
writeShortLE(int v)
Little-endian counterpart towriteShort()
.void
writeUTF(java.lang.String s)
-
-
-
Constructor Detail
-
EndianNioOutput
public EndianNioOutput(java.nio.ByteBuffer buf)
Wrap the given bytebuffer for use in the Capsule class and any of its subclasses.
-
EndianNioOutput
public EndianNioOutput(java.nio.ByteBuffer buf, int skip)
Wrap the given bytebuffer for use in the Capsule class and any of its subclasses, initializing the preliminary bytes to skip.
-
-
Method Detail
-
put
protected void put(byte b) throws java.io.IOException
- Throws:
java.io.IOException
-
write
public void write(int b) throws java.io.IOException
- Specified by:
write
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
write
public void write(byte[] bytes) throws java.io.IOException
- Specified by:
write
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
write
public void write(byte[] bytes, int offset, int length) throws java.io.IOException
- Specified by:
write
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeBoolean
public void writeBoolean(boolean b) throws java.io.IOException
- Specified by:
writeBoolean
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeByte
public void writeByte(int b) throws java.io.IOException
- Specified by:
writeByte
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
checkWriteSkip
protected boolean checkWriteSkip(int n) throws java.io.IOException
- Throws:
java.io.IOException
-
writeShort
public void writeShort(int v) throws java.io.IOException
- Specified by:
writeShort
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeChar
public void writeChar(int v) throws java.io.IOException
- Specified by:
writeChar
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeInt
public void writeInt(int v) throws java.io.IOException
- Specified by:
writeInt
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeLong
public void writeLong(long v) throws java.io.IOException
- Specified by:
writeLong
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeFloat
public void writeFloat(float v) throws java.io.IOException
- Specified by:
writeFloat
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeDouble
public void writeDouble(double v) throws java.io.IOException
- Specified by:
writeDouble
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeBytes
public void writeBytes(java.lang.String s) throws java.io.IOException
- Specified by:
writeBytes
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeChars
public void writeChars(java.lang.String s) throws java.io.IOException
- Specified by:
writeChars
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeUTF
public void writeUTF(java.lang.String s) throws java.io.IOException
- Specified by:
writeUTF
in interfacejava.io.DataOutput
- Throws:
java.io.IOException
-
writeCharLE
public void writeCharLE(int v) throws java.io.IOException
Description copied from interface:EndianDataOutput
Little-endian counterpart towriteChar()
.- Specified by:
writeCharLE
in interfaceEndianDataOutput
- Throws:
java.io.IOException
-
writeCharsLE
public void writeCharsLE(java.lang.String s) throws java.io.IOException
Description copied from interface:EndianDataOutput
Little-endian counterpart towriteChars()
.- Specified by:
writeCharsLE
in interfaceEndianDataOutput
- Throws:
java.io.IOException
-
writeDoubleLE
public void writeDoubleLE(double v) throws java.io.IOException
Description copied from interface:EndianDataOutput
Little-endian counterpart towriteDouble()
.- Specified by:
writeDoubleLE
in interfaceEndianDataOutput
- Throws:
java.io.IOException
-
writeFloatLE
public void writeFloatLE(float f) throws java.io.IOException
Description copied from interface:EndianDataOutput
Little-endian counterpart towriteFloat()
.- Specified by:
writeFloatLE
in interfaceEndianDataOutput
- Throws:
java.io.IOException
-
writeShortLE
public void writeShortLE(int v) throws java.io.IOException
Description copied from interface:EndianDataOutput
Little-endian counterpart towriteShort()
.- Specified by:
writeShortLE
in interfaceEndianDataOutput
- Throws:
java.io.IOException
-
writeIntLE
public void writeIntLE(int v) throws java.io.IOException
Description copied from interface:EndianDataOutput
Little-endian counterpart towriteInt()
.- Specified by:
writeIntLE
in interfaceEndianDataOutput
- Throws:
java.io.IOException
-
writeLongLE
public void writeLongLE(long v) throws java.io.IOException
Description copied from interface:EndianDataOutput
Little-endian counterpart towriteLong()
.- Specified by:
writeLongLE
in interfaceEndianDataOutput
- Throws:
java.io.IOException
-
getBuffer
public java.nio.ByteBuffer getBuffer()
-
remaining
public int remaining() throws java.io.IOException
- Throws:
java.io.IOException
-
-