Package morfologik.stemming
Class BufferUtils
java.lang.Object
morfologik.stemming.BufferUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CharBuffer
bytesToChars
(CharsetDecoder decoder, ByteBuffer bytes, CharBuffer chars) Convert byte buffer's content into characters.static ByteBuffer
charsToBytes
(CharsetEncoder encoder, CharBuffer chars, ByteBuffer bytes) Convert chars into bytes.static ByteBuffer
clearAndEnsureCapacity
(ByteBuffer buffer, int elements) Ensure the buffer's capacity is large enough to hold a given number of elements.static CharBuffer
clearAndEnsureCapacity
(CharBuffer buffer, int elements) Ensure the buffer's capacity is large enough to hold a given number of elements.(package private) static int
sharedPrefixLength
(ByteBuffer a, int aStart, ByteBuffer b, int bStart) Compute the length of the shared prefix between two byte sequences.(package private) static int
Compute the length of the shared prefix between two byte sequences.static byte[]
toArray
(ByteBuffer buffer) static String
toString
(ByteBuffer buffer, Charset charset) static String
toString
(CharBuffer buffer)
-
Constructor Details
-
BufferUtils
private BufferUtils()No instances.
-
-
Method Details
-
clearAndEnsureCapacity
Ensure the buffer's capacity is large enough to hold a given number of elements. If the input buffer is not large enough, a new buffer is allocated and returned.- Parameters:
buffer
- The buffer to check ornull
if a new buffer should be allocated.elements
- The required number of elements to be appended to the buffer.- Returns:
- Returns the same buffer or a new buffer with the given capacity.
-
clearAndEnsureCapacity
Ensure the buffer's capacity is large enough to hold a given number of elements. If the input buffer is not large enough, a new buffer is allocated and returned.- Parameters:
buffer
- The buffer to check ornull
if a new buffer should be allocated.elements
- The required number of elements to be appended to the buffer.- Returns:
- Returns the same buffer or a new buffer with the given capacity.
-
toString
- Parameters:
buffer
- The buffer to convert to a string.charset
- The charset to use when converting bytes to characters.- Returns:
- A string representation of buffer's content.
-
toString
-
toArray
- Parameters:
buffer
- The buffer to read from.- Returns:
- Returns the remaining bytes from the buffer copied to an array.
-
bytesToChars
Convert byte buffer's content into characters. The input buffer's bytes are not consumed (mark is set and reset). -
charsToBytes
public static ByteBuffer charsToBytes(CharsetEncoder encoder, CharBuffer chars, ByteBuffer bytes) throws UnmappableInputException Convert chars into bytes.- Throws:
UnmappableInputException
-