Show / Hide Table of Contents

    Class ByteBuffer

    A buffer for bytes.

    A byte buffer can be created in either one of the following ways:

    • Allocate(Int32) a new byte array and create a buffer based on it
    • AllocateDirect(Int32) a memory block and create a direct buffer based on it
    • Wrap(Byte[]) an existing byte array to create a new buffer

    Inheritance
    System.Object
    Buffer
    ByteBuffer
    Implements
    System.IComparable<ByteBuffer>
    Inherited Members
    Buffer.Capacity
    Buffer.Clear()
    Buffer.Flip()
    Buffer.HasRemaining
    Buffer.IsReadOnly
    Buffer.Limit
    Buffer.SetLimit(Int32)
    Buffer.Mark()
    Buffer.Position
    Buffer.SetPosition(Int32)
    Buffer.Remaining
    Buffer.Reset()
    Buffer.Rewind()
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    Namespace: Lucene.Net.Support.IO
    Assembly: Lucene.Net.dll
    Syntax
    public abstract class ByteBuffer : Buffer, IComparable<ByteBuffer>

    Properties

    | Improve this Doc View Source

    Array

    Returns the byte array which this buffer is based on, if there is one.

    Declaration
    public byte[] Array { get; }
    Property Value
    Type Description
    System.Byte[]

    the byte array which this buffer is based on.

    Exceptions
    Type Condition
    ReadOnlyBufferException

    if this buffer is based on a read-only array.

    System.InvalidOperationException

    if this buffer is not based on an array.

    | Improve this Doc View Source

    ArrayOffset

    Returns the offset of the byte array which this buffer is based on, if there is one.

    The offset is the index of the array which corresponds to the zero position of the buffer.

    Declaration
    public int ArrayOffset { get; }
    Property Value
    Type Description
    System.Int32
    Exceptions
    Type Condition
    ReadOnlyBufferException

    if this buffer is based on a read-only array.

    System.InvalidOperationException

    if this buffer is not based on an array.

    | Improve this Doc View Source

    HasArray

    Indicates whether this buffer is based on a byte array and provides read/write access.

    Declaration
    public bool HasArray { get; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    IsDirect

    Indicates whether this buffer is direct.

    Declaration
    public abstract bool IsDirect { get; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    Order

    Returns the byte order used by this buffer when converting bytes from/to other primitive types.

    The default byte order of byte buffer is always BIG_ENDIAN.

    Declaration
    public ByteOrder Order { get; set; }
    Property Value
    Type Description
    ByteOrder
    | Improve this Doc View Source

    ProtectedArray

    Child class implements this method to realize Array.

    Declaration
    protected abstract byte[] ProtectedArray { get; }
    Property Value
    Type Description
    System.Byte[]
    See Also
    Array
    | Improve this Doc View Source

    ProtectedArrayOffset

    Child class implements this method to realize ArrayOffset.

    Declaration
    protected abstract int ProtectedArrayOffset { get; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    ProtectedHasArray

    Child class implements this method to realize HasArray.

    Declaration
    protected abstract bool ProtectedHasArray { get; }
    Property Value
    Type Description
    System.Boolean

    Methods

    | Improve this Doc View Source

    Allocate(Int32)

    Creates a byte buffer based on a newly allocated byte array.

    Declaration
    public static ByteBuffer Allocate(int capacity)
    Parameters
    Type Name Description
    System.Int32 capacity

    the capacity of the new buffer

    Returns
    Type Description
    ByteBuffer

    The created byte buffer.

    Exceptions
    Type Condition
    System.ArgumentException

    If the capacity < 0.

    | Improve this Doc View Source

    AllocateDirect(Int32)

    Creates a direct byte buffer based on a newly allocated memory block. (NOT IMPLEMENTED IN LUCENE.NET)

    Declaration
    public static ByteBuffer AllocateDirect(int capacity)
    Parameters
    Type Name Description
    System.Int32 capacity

    the capacity of the new buffer

    Returns
    Type Description
    ByteBuffer

    The new byte buffer

    Exceptions
    Type Condition
    System.ArgumentException

    If the capacity < 0.

    | Improve this Doc View Source

    AsInt64Buffer()

    Returns a long buffer which is based on the remaining content of this byte buffer.

    The new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by eight, and its mark is not set. The new buffer's read-only property and byte order are the same as this buffer's. The new buffer is direct if this byte buffer is direct.

    The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the other. The two buffer's position, limit and mark are independent.

    Declaration
    public abstract Int64Buffer AsInt64Buffer()
    Returns
    Type Description
    Int64Buffer

    a long buffer which is based on the content of this byte buffer.

    | Improve this Doc View Source

    AsReadOnlyBuffer()

    Returns a read-only buffer that shares its content with this buffer.

    The returned buffer is guaranteed to be a new instance, even if this buffer is read-only itself. The new buffer's position, limit, capacity and mark are the same as this buffer.

    The new buffer shares its content with this buffer, which means this buffer's change of content will be visible to the new buffer. The two buffer's position, limit and mark are independent.

    Declaration
    public abstract ByteBuffer AsReadOnlyBuffer()
    Returns
    Type Description
    ByteBuffer

    a read-only version of this buffer.

    | Improve this Doc View Source

    Compact()

    Compacts this byte buffer.

    The remaining bytes will be moved to the head of the buffer, starting from position zero. Then the position is set to Remaining; the limit is set to capacity; the mark is cleared.

    Declaration
    public abstract ByteBuffer Compact()
    Returns
    Type Description
    ByteBuffer

    this buffer.

    Exceptions
    Type Condition
    ReadOnlyBufferException

    if no changes may be made to the contents of this buffer.

    | Improve this Doc View Source

    CompareTo(ByteBuffer)

    Compares the remaining bytes of this buffer to another byte buffer's remaining bytes.

    Declaration
    public virtual int CompareTo(ByteBuffer otherBuffer)
    Parameters
    Type Name Description
    ByteBuffer otherBuffer

    another byte buffer.

    Returns
    Type Description
    System.Int32

    a negative value if this is less than other; 0 if this equals to other; a positive value if this is greater than other.

    | Improve this Doc View Source

    Duplicate()

    Returns a duplicated buffer that shares its content with this buffer.

    The duplicated buffer's position, limit, capacity and mark are the same as this buffer's. The duplicated buffer's read-only property and byte order are the same as this buffer's too.

    The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the other. The two buffer's position, limit and mark are independent.

    Declaration
    public abstract ByteBuffer Duplicate()
    Returns
    Type Description
    ByteBuffer

    a duplicated buffer that shares its content with this buffer.

    | Improve this Doc View Source

    Equals(Object)

    Checks whether this byte buffer is equal to another object.

    If other is not a byte buffer then false is returned. Two byte buffers are equal if and only if their remaining bytes are exactly the same. Position, limit, capacity and mark are not considered.

    Declaration
    public override bool Equals(object other)
    Parameters
    Type Name Description
    System.Object other

    the object to compare with this byte buffer.

    Returns
    Type Description
    System.Boolean

    true if this byte buffer is equal to other, false otherwise.

    Overrides
    System.Object.Equals(System.Object)
    | Improve this Doc View Source

    Get()

    Returns the byte at the current position and increases the position by 1.

    Declaration
    public abstract byte Get()
    Returns
    Type Description
    System.Byte

    the byte at the current position.

    Exceptions
    Type Condition
    BufferUnderflowException

    if the position is equal or greater than limit.

    | Improve this Doc View Source

    Get(Byte[])

    Reads bytes from the current position into the specified byte array and increases the position by the number of bytes read.

    Calling this method has the same effect as Get(dest, 0, dest.Length).

    Declaration
    public virtual ByteBuffer Get(byte[] dest)
    Parameters
    Type Name Description
    System.Byte[] dest

    the destination byte array.

    Returns
    Type Description
    ByteBuffer

    this buffer.

    Exceptions
    Type Condition
    BufferUnderflowException

    if dest.Length is greater than Remaining.

    | Improve this Doc View Source

    Get(Byte[], Int32, Int32)

    Reads bytes from the current position into the specified byte array, starting at the specified offset, and increases the position by the number of bytes read.

    Declaration
    public virtual ByteBuffer Get(byte[] dest, int off, int len)
    Parameters
    Type Name Description
    System.Byte[] dest

    the target byte array.

    System.Int32 off

    the offset of the byte array, must not be negative and not greater than dest.Length.

    System.Int32 len

    the number of bytes to read, must not be negative and not greater than dest.Length - off

    Returns
    Type Description
    ByteBuffer

    this buffer.

    Exceptions
    Type Condition
    System.IndexOutOfRangeException

    if either off or len is invalid.

    BufferUnderflowException

    if len is greater than Remaining.

    | Improve this Doc View Source

    Get(Int32)

    Returns the byte at the specified index and does not change the position.

    Declaration
    public abstract byte Get(int index)
    Parameters
    Type Name Description
    System.Int32 index

    the index, must not be negative and less than limit.

    Returns
    Type Description
    System.Byte

    the byte at the specified index.

    Exceptions
    Type Condition
    System.IndexOutOfRangeException

    if index is invalid.

    | Improve this Doc View Source

    GetChar()

    Returns the char at the current position and increases the position by 2.

    The 2 bytes starting at the current position are composed into a char according to the current byte order and returned.

    Declaration
    public abstract char GetChar()
    Returns
    Type Description
    System.Char

    the char at the current position.

    Exceptions
    Type Condition
    BufferUnderflowException

    if the position is greater than limit - 2.

    | Improve this Doc View Source

    GetChar(Int32)

    Returns the char at the specified index.

    The 2 bytes starting from the specified index are composed into a char according to the current byte order and returned. The position is not changed.

    Declaration
    public abstract char GetChar(int index)
    Parameters
    Type Name Description
    System.Int32 index

    the index, must not be negative and equal or less than limit - 2.

    Returns
    Type Description
    System.Char

    the char at the specified index.

    Exceptions
    Type Condition
    System.IndexOutOfRangeException

    if index is invalid.

    | Improve this Doc View Source

    GetDouble()

    Returns the double at the current position and increases the position by 8.

    The 8 bytes starting from the current position are composed into a double according to the current byte order and returned.

    Declaration
    public abstract double GetDouble()
    Returns
    Type Description
    System.Double

    the double at the current position.

    Exceptions
    Type Condition
    BufferUnderflowException

    if the position is greater than limit - 8.

    | Improve this Doc View Source

    GetDouble(Int32)

    Returns the System.Double at the specified index.

    The 8 bytes starting at the specified index are composed into a System.Double according to the current byte order and returned. The position is not changed.

    Declaration
    public abstract double GetDouble(int index)
    Parameters
    Type Name Description
    System.Int32 index

    the index, must not be negative and equal or less than limit - 8.

    Returns
    Type Description
    System.Double

    the System.Double at the specified index.

    Exceptions
    Type Condition
    System.IndexOutOfRangeException

    if index is invalid.

    | Improve this Doc View Source

    GetHashCode()

    Calculates this buffer's hash code from the remaining chars. The position, limit, capacity and mark don't affect the hash code.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    System.Int32

    the hash code calculated from the remaining bytes.

    Overrides
    System.Object.GetHashCode()
    | Improve this Doc View Source

    GetInt16()

    Returns the System.Int16 at the current position and increases the position by 2.

    The 2 bytes starting at the current position are composed into a System.Int16 according to the current byte order and returned.

    NOTE: This was getShort() in the JDK

    Declaration
    public abstract short GetInt16()
    Returns
    Type Description
    System.Int16

    the System.Int16 at the current position.

    Exceptions
    Type Condition
    BufferUnderflowException

    if the position is greater than limit - 2.

    | Improve this Doc View Source

    GetInt16(Int32)

    Returns the System.Int16 at the specified index.

    The 2 bytes starting at the specified index are composed into a System.Int16 according to the current byte order and returned. The position is not changed.

    NOTE: This was getShort() in the JDK

    Declaration
    public abstract short GetInt16(int index)
    Parameters
    Type Name Description
    System.Int32 index

    the index, must not be negative and equal or less than limit - 2.

    Returns
    Type Description
    System.Int16

    the System.Int16 at the specified index.

    Exceptions
    Type Condition
    System.IndexOutOfRangeException

    if index is invalid.

    | Improve this Doc View Source

    GetInt32()

    Returns the System.Int32 at the current position and increases the position by 4.

    The 4 bytes starting at the current position are composed into a System.Int32 according to the current byte order and returned.

    NOTE: This was getInt() in the JDK

    Declaration
    public abstract int GetInt32()
    Returns
    Type Description
    System.Int32

    the System.Int32 at the current position.

    Exceptions
    Type Condition
    BufferUnderflowException

    if the position is greater than limit - 4.

    | Improve this Doc View Source

    GetInt32(Int32)

    Returns the System.Int32 at the specified index.

    The 4 bytes starting at the specified index are composed into a System.Int32 according to the current byte order and returned. The position is not changed.

    NOTE: This was getInt() in the JDK

    Declaration
    public abstract int GetInt32(int index)
    Parameters
    Type Name Description
    System.Int32 index

    the index, must not be negative and equal or less than limit - 4.

    Returns
    Type Description
    System.Int32

    the System.Int32 at the specified index.

    Exceptions
    Type Condition
    System.IndexOutOfRangeException

    if index is invalid.

    | Improve this Doc View Source

    GetInt64()

    Returns the System.Int64 at the current position and increases the position by 8.

    The 8 bytes starting at the current position are composed into a System.Int64 according to the current byte order and returned.

    NOTE: This was getLong() in the JDK

    Declaration
    public abstract long GetInt64()
    Returns
    Type Description
    System.Int64

    the System.Int64 at the current position.

    Exceptions
    Type Condition
    BufferUnderflowException

    if the position is greater than limit - 8.

    | Improve this Doc View Source

    GetInt64(Int32)

    Returns the System.Int64 at the specified index.

    The 8 bytes starting at the specified index are composed into a System.Int64 according to the current byte order and returned. The position is not changed.

    NOTE: This was getLong() in the JDK

    Declaration
    public abstract long GetInt64(int index)
    Parameters
    Type Name Description
    System.Int32 index

    the index, must not be negative and equal or less than limit - 8.

    Returns
    Type Description
    System.Int64

    the System.Int64 at the specified index.

    Exceptions
    Type Condition
    System.IndexOutOfRangeException

    if index is invalid.

    | Improve this Doc View Source

    GetSingle()

    Returns the System.Single at the current position and increases the position by 4.

    The 4 bytes starting at the current position are composed into a System.Single according to the current byte order and returned.

    NOTE: This was getFloat() in the JDK

    Declaration
    public abstract float GetSingle()
    Returns
    Type Description
    System.Single

    the System.Single at the current position.

    Exceptions
    Type Condition
    BufferUnderflowException

    if the position is greater than limit - 4.

    | Improve this Doc View Source

    GetSingle(Int32)

    Returns the System.Single at the specified index.

    The 4 bytes starting at the specified index are composed into a System.Single according to the current byte order and returned. The position is not changed.

    NOTE: This was getFloat() in the JDK

    Declaration
    public abstract float GetSingle(int index)
    Parameters
    Type Name Description
    System.Int32 index

    the index, must not be negative and equal or less than limit - 4.

    Returns
    Type Description
    System.Single

    the System.Single at the specified index.

    Exceptions
    Type Condition
    System.IndexOutOfRangeException

    if index is invalid.

    | Improve this Doc View Source

    Put(ByteBuffer)

    Writes all the remaining bytes of the src byte buffer to this buffer's current position, and increases both buffers' position by the number of bytes copied.

    Declaration
    public virtual ByteBuffer Put(ByteBuffer src)
    Parameters
    Type Name Description
    ByteBuffer src

    the source byte buffer.

    Returns
    Type Description
    ByteBuffer

    this buffer.

    Exceptions
    Type Condition
    BufferOverflowException

    if src.Remaining is greater than this buffer's Remaining.

    System.ArgumentException

    if src is this buffer.

    ReadOnlyBufferException

    if no changes may be made to the contents of this buffer.

    | Improve this Doc View Source

    Put(Byte)

    Writes the given byte to the current position and increases the position by 1.

    Declaration
    public abstract ByteBuffer Put(byte b)
    Parameters
    Type Name Description
    System.Byte b

    the byte to write.

    Returns
    Type Description
    ByteBuffer

    this buffer.

    Exceptions
    Type Condition
    BufferOverflowException

    if position is equal or greater than limit.

    ReadOnlyBufferException

    if no changes may be made to the contents of this buffer.

    | Improve this Doc View Source

    Put(Byte[])

    Writes bytes in the given byte array to the current position and increases the position by the number of bytes written.

    Calling this method has the same effect as Put(src, 0, src.Length).

    Declaration
    public ByteBuffer Put(byte[] src)
    Parameters
    Type Name Description
    System.Byte[] src

    the source byte array.

    Returns
    Type Description
    ByteBuffer

    this buffer.

    Exceptions
    Type Condition
    BufferOverflowException

    if Remaining is less than src.Length.

    ReadOnlyBufferException

    if no changes may be made to the contents of this buffer.

    | Improve this Doc View Source

    Put(Byte[], Int32, Int32)

    Writes bytes in the given byte array, starting from the specified offset, to the current position and increases the position by the number of bytes written.

    Declaration
    public virtual ByteBuffer Put(byte[] src, int off, int len)
    Parameters
    Type Name Description
    System.Byte[] src

    the source byte array.

    System.Int32 off

    the offset of byte array, must not be negative and not greater than src.Length.

    System.Int32 len

    the number of bytes to write, must not be negative and not greater than src.Length - off.

    Returns
    Type Description
    ByteBuffer

    this buffer.

    Exceptions
    Type Condition
    BufferOverflowException

    if Remaining is less than len.

    System.IndexOutOfRangeException

    if either off or len is invalid.

    ReadOnlyBufferException

    if no changes may be made to the contents of this buffer.

    | Improve this Doc View Source

    Put(Int32, Byte)

    Write a System.Byte to the specified index of this buffer without changing the position.

    Declaration
    public abstract ByteBuffer Put(int index, byte b)
    Parameters
    Type Name Description
    System.Int32 index

    the index, must not be negative and less than the limit.

    System.Byte b

    the System.Byte to write.

    Returns
    Type Description
    ByteBuffer

    this buffer.

    Exceptions
    Type Condition
    System.IndexOutOfRangeException

    if index is invalid.

    ReadOnlyBufferException

    if no changes may be made to the contents of this buffer.

    | Improve this Doc View Source

    PutChar(Char)

    Writes the given System.Char to the current position and increases the position by 2.

    The System.Char is converted to bytes using the current byte order.

    Declaration
    public abstract ByteBuffer PutChar(char value)
    Parameters
    Type Name Description
    System.Char value

    the System.Char to write.

    Returns
    Type Description
    ByteBuffer

    this buffer.

    Exceptions
    Type Condition
    BufferOverflowException

    if position is greater than limit - 2.

    ReadOnlyBufferException

    if no changes may be made to the contents of this buffer.

    | Improve this Doc View Source

    PutChar(Int32, Char)

    Writes the given System.Char to the specified index of this buffer.

    The System.Char is converted to bytes using the current byte order. The position is not changed.

    Declaration
    public abstract ByteBuffer PutChar(int index, char value)
    Parameters
    Type Name Description
    System.Int32 index

    the index, must not be negative and equal or less than limit - 2.

    System.Char value

    the System.Char to write.

    Returns
    Type Description
    ByteBuffer

    this buffer.

    Exceptions
    Type Condition
    System.IndexOutOfRangeException

    if index is invalid.

    ReadOnlyBufferException

    if no changes may be made to the contents of this buffer.

    | Improve this Doc View Source

    PutDouble(Double)

    Writes the given System.Double to the current position and increases the position by 8.

    The System.Double is converted to bytes using the current byte order.

    Declaration
    public abstract ByteBuffer PutDouble(double value)
    Parameters
    Type Name Description
    System.Double value

    the System.Double to write.

    Returns
    Type Description
    ByteBuffer

    this buffer.

    Exceptions
    Type Condition
    BufferOverflowException

    if position is greater than limit - 8.

    ReadOnlyBufferException

    if no changes may be made to the contents of this buffer.

    | Improve this Doc View Source

    PutDouble(Int32, Double)

    Writes the given System.Double to the specified index of this buffer.

    The System.Double is converted to bytes using the current byte order. The position is not changed.

    Declaration
    public abstract ByteBuffer PutDouble(int index, double value)
    Parameters
    Type Name Description
    System.Int32 index

    the index, must not be negative and equal or less than limit - 8.

    System.Double value

    the System.Double to write.

    Returns
    Type Description
    ByteBuffer
    Exceptions
    Type Condition
    System.IndexOutOfRangeException

    if index is invalid.

    ReadOnlyBufferException

    if no changes may be made to the contents of this buffer.

    | Improve this Doc View Source

    PutInt16(Int16)

    Writes the given System.Int16 to the current position and increases the position by 2.

    The System.Int16 is converted to bytes using the current byte order.

    NOTE: This was putShort() in the JDK

    Declaration
    public abstract ByteBuffer PutInt16(short value)
    Parameters
    Type Name Description
    System.Int16 value

    the System.Int16 to write.

    Returns
    Type Description
    ByteBuffer

    this buffer.

    Exceptions
    Type Condition
    BufferOverflowException

    if position is greater than limit - 2.

    ReadOnlyBufferException

    if no changes may be made to the contents of this buffer.

    | Improve this Doc View Source

    PutInt16(Int32, Int16)

    Writes the given System.Int16 to the specified index of this buffer.

    The System.Int16 is converted to bytes using the current byte order. The position is not changed.

    NOTE: This was putShort() in the JDK

    Declaration
    public abstract ByteBuffer PutInt16(int index, short value)
    Parameters
    Type Name Description
    System.Int32 index

    the index, must not be negative and equal or less than limit - 2.

    System.Int16 value

    the System.Int16 to write.

    Returns
    Type Description
    ByteBuffer

    this buffer.

    Exceptions
    Type Condition
    System.IndexOutOfRangeException

    if index is invalid.

    ReadOnlyBufferException

    if no changes may be made to the contents of this buffer.

    | Improve this Doc View Source

    PutInt32(Int32)

    Writes the given System.Int32 to the current position and increases the position by 4.

    The System.Int32 is converted to bytes using the current byte order.

    NOTE: This was putInt() in the JDK

    Declaration
    public abstract ByteBuffer PutInt32(int value)
    Parameters
    Type Name Description
    System.Int32 value

    the System.Int32 to write.

    Returns
    Type Description
    ByteBuffer

    this buffer.

    Exceptions
    Type Condition
    BufferOverflowException

    if position is greater than limit - 4.

    ReadOnlyBufferException

    if no changes may be made to the contents of this buffer.

    | Improve this Doc View Source

    PutInt32(Int32, Int32)

    Writes the given System.Int32 to the specified index of this buffer.

    The System.Int32 is converted to bytes using the current byte order. The position is not changed.

    NOTE: This was putInt() in the JDK

    Declaration
    public abstract ByteBuffer PutInt32(int index, int value)
    Parameters
    Type Name Description
    System.Int32 index

    the index, must not be negative and equal or less than limit - 4.

    System.Int32 value

    the System.Int32 to write.

    Returns
    Type Description
    ByteBuffer

    this buffer.

    Exceptions
    Type Condition
    System.IndexOutOfRangeException

    if index is invalid.

    ReadOnlyBufferException

    if no changes may be made to the contents of this buffer.

    | Improve this Doc View Source

    PutInt64(Int32, Int64)

    Writes the given System.Int64 to the specified index of this buffer.

    The System.Int64 is converted to bytes using the current byte order. The position is not changed.

    NOTE: This was putLong() in the JDK

    Declaration
    public abstract ByteBuffer PutInt64(int index, long value)
    Parameters
    Type Name Description
    System.Int32 index

    the index, must not be negative and equal or less than limit - 8.

    System.Int64 value

    the System.Int64 to write.

    Returns
    Type Description
    ByteBuffer

    this buffer.

    Exceptions
    Type Condition
    System.IndexOutOfRangeException

    if index is invalid.

    ReadOnlyBufferException

    if no changes may be made to the contents of this buffer.

    | Improve this Doc View Source

    PutInt64(Int64)

    Writes the given System.Int64 to the current position and increases the position by 8.

    The System.Int64 is converted to bytes using the current byte order.

    NOTE: This was putLong() in the JDK

    Declaration
    public abstract ByteBuffer PutInt64(long value)
    Parameters
    Type Name Description
    System.Int64 value

    the System.Int64 to write.

    Returns
    Type Description
    ByteBuffer

    this buffer.

    Exceptions
    Type Condition
    BufferOverflowException

    if position is greater than limit - 8.

    ReadOnlyBufferException

    if no changes may be made to the contents of this buffer.

    | Improve this Doc View Source

    PutSingle(Int32, Single)

    Writes the given System.Single to the specified index of this buffer.

    The System.Single is converted to bytes using the current byte order. The position is not changed.

    NOTE: This was putSingle() in the JDK

    Declaration
    public abstract ByteBuffer PutSingle(int index, float value)
    Parameters
    Type Name Description
    System.Int32 index

    the index, must not be negative and equal or less than limit - 4.

    System.Single value

    the System.Single to write.

    Returns
    Type Description
    ByteBuffer
    Exceptions
    Type Condition
    System.IndexOutOfRangeException

    if index is invalid.

    ReadOnlyBufferException

    if no changes may be made to the contents of this buffer.

    | Improve this Doc View Source

    PutSingle(Single)

    Writes the given System.Single to the current position and increases the position by 4.

    The System.Single is converted to bytes using the current byte order.

    NOTE: This was putSingle() in the JDK

    Declaration
    public abstract ByteBuffer PutSingle(float value)
    Parameters
    Type Name Description
    System.Single value

    the System.Single to write.

    Returns
    Type Description
    ByteBuffer

    this buffer.

    Exceptions
    Type Condition
    BufferOverflowException

    if position is greater than limit - 4.

    ReadOnlyBufferException

    if no changes may be made to the contents of this buffer.

    | Improve this Doc View Source

    SetOrder(ByteOrder)

    Sets the byte order of this buffer.

    Declaration
    public ByteBuffer SetOrder(ByteOrder byteOrder)
    Parameters
    Type Name Description
    ByteOrder byteOrder

    the byte order to set.

    Returns
    Type Description
    ByteBuffer

    this buffer.

    | Improve this Doc View Source

    Slice()

    Returns a sliced buffer that shares its content with this buffer.

    The sliced buffer's capacity will be this buffer's Remaining, and it's zero position will correspond to this buffer's current position. The new buffer's position will be 0, limit will be its capacity, and its mark is cleared. The new buffer's read-only property and byte order are the same as this buffer's.

    The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the other. The two buffer's position, limit and mark are independent.

    Declaration
    public abstract ByteBuffer Slice()
    Returns
    Type Description
    ByteBuffer

    A sliced buffer that shares its content with this buffer.

    | Improve this Doc View Source

    ToString()

    Returns a string representing the state of this byte buffer.

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String

    A string representing the state of this byte buffer.

    Overrides
    System.Object.ToString()
    | Improve this Doc View Source

    Wrap(Byte[])

    Creates a new byte buffer by wrapping the given byte array.

    Calling this method has the same effect as Wrap(array, 0, array.Length).

    Declaration
    public static ByteBuffer Wrap(byte[] array)
    Parameters
    Type Name Description
    System.Byte[] array

    The byte array which the new buffer will be based on

    Returns
    Type Description
    ByteBuffer

    The new byte buffer

    | Improve this Doc View Source

    Wrap(Byte[], Int32, Int32)

    Creates a new byte buffer by wrapping the given byte array.

    The new buffer's position will be start, limit will be start + len, capacity will be the length of the array.

    Declaration
    public static ByteBuffer Wrap(byte[] array, int start, int length)
    Parameters
    Type Name Description
    System.Byte[] array

    The byte array which the new buffer will be based on.

    System.Int32 start

    The start index, must not be negative and not greater than array.Length.

    System.Int32 length

    The length, must not be negative and not greater than array.Length - start.

    Returns
    Type Description
    ByteBuffer

    The new byte buffer

    Exceptions
    Type Condition
    System.IndexOutOfRangeException

    if either start or length are invalid.

    Implements

    System.IComparable<T>

    Extension Methods

    Number.IsNumber(Object)
    • Improve this Doc
    • View Source
    Back to top Copyright © 2019 Licensed to the Apache Software Foundation (ASF)