Package morfologik.stemming
Class BufferUtils
java.lang.Object
morfologik.stemming.BufferUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CharBufferbytesToChars(CharsetDecoder decoder, ByteBuffer bytes, CharBuffer chars) Convert byte buffer's content into characters.static ByteBuffercharsToBytes(CharsetEncoder encoder, CharBuffer chars, ByteBuffer bytes) Convert chars into bytes.static ByteBufferclearAndEnsureCapacity(ByteBuffer buffer, int elements) Ensure the buffer's capacity is large enough to hold a given number of elements.static CharBufferclearAndEnsureCapacity(CharBuffer buffer, int elements) Ensure the buffer's capacity is large enough to hold a given number of elements.(package private) static intsharedPrefixLength(ByteBuffer a, int aStart, ByteBuffer b, int bStart) Compute the length of the shared prefix between two byte sequences.(package private) static intCompute the length of the shared prefix between two byte sequences.static byte[]toArray(ByteBuffer buffer) static StringtoString(ByteBuffer buffer, Charset charset) static StringtoString(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 ornullif 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 ornullif 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
-