Table of Contents

Class CharBuffer

Namespace
Java.Nio
Assembly
MASES.JNet.dll
public class CharBuffer : Buffer, IDynamicMetaObjectProvider, IJVMBridgeCore, IEquatable<IJVMBridgeBaseInstance>, IDisposable, IJVMBridgeBaseStatic, IJVMBridgeBase, IJVMBridgeBaseInstance, IJVMBridgeDefinition
Inheritance
CharBuffer
Implements
Inherited Members
Extension Methods

Constructors

CharBuffer(IJVMBridgeBaseInitializer)

Initializer used internally by JCOBridge. Do not use directly.

[Obsolete("This public initializer is needed for JCOBridge internal use, other uses can produce unidentible behaviors.")]
public CharBuffer(IJVMBridgeBaseInitializer initializer)

Parameters

initializer IJVMBridgeBaseInitializer

Properties

BridgeClassName

Java class name to be instantiated

public override string BridgeClassName { get; }

Property Value

string

IsBridgeAbstract

true if the BridgeClassName is an abstract class, i.e. cannot be created an instance

public override bool IsBridgeAbstract { get; }

Property Value

bool

IsBridgeCloseable

true if the BridgeClassName implements java.lang.AutoCloseable

public override bool IsBridgeCloseable { get; }

Property Value

bool

IsBridgeInterface

true if the BridgeClassName is an interface, i.e. does not have any public constructor

public override bool IsBridgeInterface { get; }

Property Value

bool

IsBridgeStatic

true if the BridgeClassName is a static class, i.e. does not have any public constructor

public override bool IsBridgeStatic { get; }

Property Value

bool

Methods

Allocate(int)

public static CharBuffer Allocate(int arg0)

Parameters

arg0 int

int

Returns

CharBuffer

CharBuffer

Append(CharSequence)

public Appendable Append(CharSequence arg0)

Parameters

arg0 CharSequence

CharSequence

Returns

Appendable

Appendable

Exceptions

IOException

Append(CharSequence, int, int)

public Appendable Append(CharSequence arg0, int arg1, int arg2)

Parameters

arg0 CharSequence

CharSequence

arg1 int

int

arg2 int

int

Returns

Appendable

Appendable

Exceptions

IOException

Append(char)

public Appendable Append(char arg0)

Parameters

arg0 char

char

Returns

Appendable

Appendable

Exceptions

IOException

AsReadOnlyBuffer()

public CharBuffer AsReadOnlyBuffer()

Returns

CharBuffer

CharBuffer

CharAt(int)

public char CharAt(int arg0)

Parameters

arg0 int

int

Returns

char

char

Chars()

public IntStream Chars()

Returns

IntStream

IntStream

Compact()

public CharBuffer Compact()

Returns

CharBuffer

CharBuffer

CompareTo(CharBuffer)

public int CompareTo(CharBuffer arg0)

Parameters

arg0 CharBuffer

CharBuffer

Returns

int

int

CompareTo(object)

public int CompareTo(object arg0)

Parameters

arg0 object

object

Returns

int

int

Dispose(bool)

protected override void Dispose(bool disposing)

Parameters

disposing bool

The disposing parameter is a bool that indicates whether the method call comes from a Dispose() method (its value is true) or from a finalizer (its value is false)

Duplicate()

public CharBuffer Duplicate()

Returns

CharBuffer

CharBuffer

From(JCOBridgeSharedBufferStream<char>)

Creates a new CharBuffer in the JVM which shares the memory of stream. This is the preferred overload for high-rate scenarios as it avoids repeated array copies from CLR to JVM and benefits from pooled buffer management.

public static CharBuffer From(JCOBridgeSharedBufferStream<char> stream)

Parameters

stream JCOBridgeSharedBufferStream<char>

A JCOBridgeSharedBufferStream<T> obtained from Rent(long) and populated via Stream-based APIs, to be used directly within the JVM from a CharBuffer.

Returns

CharBuffer

A new instance of CharBuffer holding the memory of stream shared with the CharBuffer.

Remarks

The memory associated to stream will be retained until the JVM reference of the newly created CharBuffer is garbage collected. Under heavy pressure the memory footprint can raise up and generate an OutOfMemoryException; use the functionality with caution.

Lifecycle management: the subsystem automatically returns stream to the internal pool once the JVM Garbage Collector retires the associated CharBuffer, i.e. when the CharBuffer has been fully consumed by the JVM. A direct call to Dispose() on the returned CharBuffer is therefore a no-op; do not attempt to manually dispose stream after passing it to this method.

Pool strategy: the HPA (High Performance Application) runtime variant draws stream instances from a highly optimized pool tuned for high-throughput workloads, while the standard runtime variant uses a lighter pool. In both cases the pooling is fully transparent to the caller.

Exceptions

ArgumentException

Thrown when stream was not obtained through Rent(long).

NotSupportedException

Thrown when the JVM is unable to generate a CharBuffer instance.

From(char[], bool, int)

Creates a new CharBuffer in the JVM which belongs to data

public static CharBuffer From(char[] data, bool arrangeCapacity = true, int timeToLive = -1)

Parameters

data char[]

The data to be shared

arrangeCapacity bool

If true the char array in data will be resized to the next power of 2, so capacity will be memory aligned and the limit of java.nio.CharBuffer will be current size of data

timeToLive int

The time to live, expressed in milliseconds, the underlying memory shall remain available; if the time to live expires the pinned memory is retired leaving potentially the JVM under the possibility of an access violation.

Returns

CharBuffer

A new instance of CharBuffer

Get()

public char Get()

Returns

char

char

Get(char[])

public CharBuffer Get(char[] arg0)

Parameters

arg0 char[]

char

Returns

CharBuffer

CharBuffer

Get(char[], int, int)

public CharBuffer Get(char[] arg0, int arg1, int arg2)

Parameters

arg0 char[]

char

arg1 int

int

arg2 int

int

Returns

CharBuffer

CharBuffer

Get(int)

public char Get(int arg0)

Parameters

arg0 int

int

Returns

char

char

Length()

public int Length()

Returns

int

int

Order()

public ByteOrder Order()

Returns

ByteOrder

ByteOrder

Put(String)

public CharBuffer Put(String arg0)

Parameters

arg0 String

String

Returns

CharBuffer

CharBuffer

Put(String, int, int)

public CharBuffer Put(String arg0, int arg1, int arg2)

Parameters

arg0 String

String

arg1 int

int

arg2 int

int

Returns

CharBuffer

CharBuffer

Put(CharBuffer)

public CharBuffer Put(CharBuffer arg0)

Parameters

arg0 CharBuffer

CharBuffer

Returns

CharBuffer

CharBuffer

Put(char)

public CharBuffer Put(char arg0)

Parameters

arg0 char

char

Returns

CharBuffer

CharBuffer

Put(char[])

public CharBuffer Put(char[] arg0)

Parameters

arg0 char[]

char

Returns

CharBuffer

CharBuffer

Put(char[], int, int)

public CharBuffer Put(char[] arg0, int arg1, int arg2)

Parameters

arg0 char[]

char

arg1 int

int

arg2 int

int

Returns

CharBuffer

CharBuffer

Put(int, char)

public CharBuffer Put(int arg0, char arg1)

Parameters

arg0 int

int

arg1 char

char

Returns

CharBuffer

CharBuffer

Read(CharBuffer)

public int Read(CharBuffer arg0)

Parameters

arg0 CharBuffer

CharBuffer

Returns

int

int

Exceptions

IOException

Rent(long)

Returns a JCOBridgeSharedBufferStream<T> with an initial capacity derived from capacity, to be populated via Stream-based APIs and then passed to From(JCOBridgeSharedBufferStream<char>).

public static JCOBridgeSharedBufferStream<char> Rent(long capacity = -1)

Parameters

capacity long

The plausible number of elements of char type to be written into the stream; the byte size is computed as capacity * sizeof(char). The default value of -1 instructs the subsystem to allocate the minimum meaningful unit, which corresponds to one system memory page (see SystemPageSize). Regardless of the value provided, the effective allocation is always rounded up to the nearest multiple of the system page size, since the underlying native allocator operates at page granularity. Passing a value smaller than one page therefore has no practical advantage over using the default. This value is a hint, not a hard limit: if the actual data written exceeds the initial allocation, the underlying buffer will grow automatically via reallocation. However, providing a value greater than or equal to the actual data size is strongly recommended to avoid reallocation overhead, especially in high-rate scenarios. Callers that process data of a known or predictable size are encouraged to implement their own estimation strategy — for example, tracking the stable size observed in previous invocations — so that the initial capacity converges toward the real value over time and reallocations become increasingly rare or disappear entirely.

Returns

JCOBridgeSharedBufferStream<char>

A pooled instance of JCOBridgeSharedBufferStream<T> ready to be written via Stream-based APIs and then passed to From(JCOBridgeSharedBufferStream<char>).

Remarks

The returned JCOBridgeSharedBufferStream<T> is drawn from an internal pool. The HPA (High Performance Application) runtime variant uses a highly optimized pool tuned for high-throughput scenarios, while the standard runtime variant uses a lighter pool suitable for moderate workloads. The instance must not be manually disposed; its lifecycle is fully managed by the subsystem and it is automatically returned to the pool once the JVM Garbage Collector retires the associated CharBuffer created by From(JCOBridgeSharedBufferStream<char>).

Exceptions

ArgumentOutOfRangeException

Thrown when capacity is zero or any positive value that, once multiplied by sizeof(char), overflows a long.

Slice()

public CharBuffer Slice()

Returns

CharBuffer

CharBuffer

SubSequence(int, int)

public CharSequence SubSequence(int arg0, int arg1)

Parameters

arg0 int

int

arg1 int

int

Returns

CharSequence

CharSequence

ToArray(bool)

Returns the char array managed from this CharBuffer

public char[] ToArray(bool bypassDirectConvert = false)

Parameters

bypassDirectConvert bool

true to bypass the conversion using direct buffer

Returns

char[]

The char array managed from this CharBuffer

ToDirectBuffer(bool)

Returns an instance of JCOBridgeDirectBuffer<T> can be used to directly access and manages JVM memory without any memory move

[Obsolete("DO NOT CALL Dispose() on the returned JCOBridgeDirectBuffer: it is an internal instance whose lifetime is managed by the owning object.", false)]
public JCOBridgeDirectBuffer<char> ToDirectBuffer(bool rewind)

Parameters

rewind bool

Rewind() the instance before return JCOBridgeDirectBuffer<T>

Returns

JCOBridgeDirectBuffer<char>

The JCOBridgeDirectBuffer<T> associated to this CharBuffer instance

Remarks

Do not call Dispose() on the returned instance. Its lifetime is managed by the owning object.

Wrap(CharSequence)

public static CharBuffer Wrap(CharSequence arg0)

Parameters

arg0 CharSequence

CharSequence

Returns

CharBuffer

CharBuffer

Wrap(CharSequence, int, int)

public static CharBuffer Wrap(CharSequence arg0, int arg1, int arg2)

Parameters

arg0 CharSequence

CharSequence

arg1 int

int

arg2 int

int

Returns

CharBuffer

CharBuffer

Wrap(char[])

public static CharBuffer Wrap(char[] arg0)

Parameters

arg0 char[]

char

Returns

CharBuffer

CharBuffer

Wrap(char[], int, int)

public static CharBuffer Wrap(char[] arg0, int arg1, int arg2)

Parameters

arg0 char[]

char

arg1 int

int

arg2 int

int

Returns

CharBuffer

CharBuffer

Operators

implicit operator Appendable(CharBuffer)

Converter from CharBuffer to Appendable

public static implicit operator Appendable(CharBuffer t)

Parameters

t CharBuffer

Returns

Appendable

implicit operator CharSequence(CharBuffer)

Converter from CharBuffer to CharSequence

public static implicit operator CharSequence(CharBuffer t)

Parameters

t CharBuffer

Returns

CharSequence

implicit operator Comparable(CharBuffer)

Converter from CharBuffer to Comparable

public static implicit operator Comparable(CharBuffer t)

Parameters

t CharBuffer

Returns

Comparable

implicit operator Comparable<CharBuffer>(CharBuffer)

Converter from CharBuffer to Comparable<T>

public static implicit operator Comparable<CharBuffer>(CharBuffer buffer)

Parameters

buffer CharBuffer

Returns

Comparable<CharBuffer>

implicit operator Readable(CharBuffer)

Converter from CharBuffer to Readable

public static implicit operator Readable(CharBuffer t)

Parameters

t CharBuffer

Returns

Readable

implicit operator JCOBridgeDirectBuffer<char>(CharBuffer)

Converts an instance of CharBuffer into JCOBridgeDirectBuffer<T>

public static implicit operator JCOBridgeDirectBuffer<char>(CharBuffer t)

Parameters

t CharBuffer

Returns

JCOBridgeDirectBuffer<char>

implicit operator char[](CharBuffer)

Converts an instance of CharBuffer into char array

public static implicit operator char[](CharBuffer t)

Parameters

t CharBuffer

Returns

char[]

Remarks

If the CharBuffer supports direct access the function tries to move data from JVM memory without JNI, otherwise fallback to the standard memory copy.

implicit operator CharBuffer(char[])

Converts an instance of char array into CharBuffer using the default parameters of From(char[], bool, int)

public static implicit operator CharBuffer(char[] t)

Parameters

t char[]

Returns

CharBuffer

Remarks

If the JVM supports direct access the function will share with the JVM the memory without JNI, otherwise fallback to the standard memory copy.