Class 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.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.nio.ByteBuffer buf  
      protected boolean isBE  
      protected static org.slf4j.Logger sLogger  
      protected int toSkip  
    • 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 to writeChar().
      void writeChars​(java.lang.String s)  
      void writeCharsLE​(java.lang.String s)
      Little-endian counterpart to writeChars().
      void writeDouble​(double v)  
      void writeDoubleLE​(double v)
      Little-endian counterpart to writeDouble().
      void writeFloat​(float v)  
      void writeFloatLE​(float f)
      Little-endian counterpart to writeFloat().
      void writeInt​(int v)  
      void writeIntLE​(int v)
      Little-endian counterpart to writeInt().
      void writeLong​(long v)  
      void writeLongLE​(long v)
      Little-endian counterpart to writeLong().
      void writeShort​(int v)  
      void writeShortLE​(int v)
      Little-endian counterpart to writeShort().
      void writeUTF​(java.lang.String s)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • sLogger

        protected static org.slf4j.Logger sLogger
      • isBE

        protected boolean isBE
      • buf

        protected final java.nio.ByteBuffer buf
      • toSkip

        protected int toSkip
    • 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 interface java.io.DataOutput
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] bytes)
                   throws java.io.IOException
        Specified by:
        write in interface java.io.DataOutput
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] bytes,
                          int offset,
                          int length)
                   throws java.io.IOException
        Specified by:
        write in interface java.io.DataOutput
        Throws:
        java.io.IOException
      • writeBoolean

        public void writeBoolean​(boolean b)
                          throws java.io.IOException
        Specified by:
        writeBoolean in interface java.io.DataOutput
        Throws:
        java.io.IOException
      • writeByte

        public void writeByte​(int b)
                       throws java.io.IOException
        Specified by:
        writeByte in interface java.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 interface java.io.DataOutput
        Throws:
        java.io.IOException
      • writeChar

        public void writeChar​(int v)
                       throws java.io.IOException
        Specified by:
        writeChar in interface java.io.DataOutput
        Throws:
        java.io.IOException
      • writeInt

        public void writeInt​(int v)
                      throws java.io.IOException
        Specified by:
        writeInt in interface java.io.DataOutput
        Throws:
        java.io.IOException
      • writeLong

        public void writeLong​(long v)
                       throws java.io.IOException
        Specified by:
        writeLong in interface java.io.DataOutput
        Throws:
        java.io.IOException
      • writeFloat

        public void writeFloat​(float v)
                        throws java.io.IOException
        Specified by:
        writeFloat in interface java.io.DataOutput
        Throws:
        java.io.IOException
      • writeDouble

        public void writeDouble​(double v)
                         throws java.io.IOException
        Specified by:
        writeDouble in interface java.io.DataOutput
        Throws:
        java.io.IOException
      • writeBytes

        public void writeBytes​(java.lang.String s)
                        throws java.io.IOException
        Specified by:
        writeBytes in interface java.io.DataOutput
        Throws:
        java.io.IOException
      • writeChars

        public void writeChars​(java.lang.String s)
                        throws java.io.IOException
        Specified by:
        writeChars in interface java.io.DataOutput
        Throws:
        java.io.IOException
      • writeUTF

        public void writeUTF​(java.lang.String s)
                      throws java.io.IOException
        Specified by:
        writeUTF in interface java.io.DataOutput
        Throws:
        java.io.IOException
      • writeCharLE

        public void writeCharLE​(int v)
                         throws java.io.IOException
        Description copied from interface: EndianDataOutput
        Little-endian counterpart to writeChar().
        Specified by:
        writeCharLE in interface EndianDataOutput
        Throws:
        java.io.IOException
      • writeCharsLE

        public void writeCharsLE​(java.lang.String s)
                          throws java.io.IOException
        Description copied from interface: EndianDataOutput
        Little-endian counterpart to writeChars().
        Specified by:
        writeCharsLE in interface EndianDataOutput
        Throws:
        java.io.IOException
      • writeDoubleLE

        public void writeDoubleLE​(double v)
                           throws java.io.IOException
        Description copied from interface: EndianDataOutput
        Little-endian counterpart to writeDouble().
        Specified by:
        writeDoubleLE in interface EndianDataOutput
        Throws:
        java.io.IOException
      • writeFloatLE

        public void writeFloatLE​(float f)
                          throws java.io.IOException
        Description copied from interface: EndianDataOutput
        Little-endian counterpart to writeFloat().
        Specified by:
        writeFloatLE in interface EndianDataOutput
        Throws:
        java.io.IOException
      • writeShortLE

        public void writeShortLE​(int v)
                          throws java.io.IOException
        Description copied from interface: EndianDataOutput
        Little-endian counterpart to writeShort().
        Specified by:
        writeShortLE in interface EndianDataOutput
        Throws:
        java.io.IOException
      • writeIntLE

        public void writeIntLE​(int v)
                        throws java.io.IOException
        Description copied from interface: EndianDataOutput
        Little-endian counterpart to writeInt().
        Specified by:
        writeIntLE in interface EndianDataOutput
        Throws:
        java.io.IOException
      • writeLongLE

        public void writeLongLE​(long v)
                         throws java.io.IOException
        Description copied from interface: EndianDataOutput
        Little-endian counterpart to writeLong().
        Specified by:
        writeLongLE in interface EndianDataOutput
        Throws:
        java.io.IOException
      • getBuffer

        public java.nio.ByteBuffer getBuffer()
      • remaining

        public int remaining()
                      throws java.io.IOException
        Throws:
        java.io.IOException