Package com.yahoo.text
Class Utf8Array
java.lang.Object
com.yahoo.text.AbstractUtf8Array
com.yahoo.text.Utf8Array
- All Implemented Interfaces:
Comparable<AbstractUtf8Array>
- Direct Known Subclasses:
Identifier
,Utf8PartialArray
,Utf8String
This is a primitive class that owns an array of utf8 encoded string.
This is a class that has speed as its primary purpose.
If you have a string, consider Utf8String
If you have a large backing array consider Utf8PartialArray.
- Author:
- baldersheim
-
Field Summary
-
Constructor Summary
ConstructorDescriptionUtf8Array
(byte[] utf8data) This will simply wrap the given array assuming it is valid utf8.Utf8Array
(byte[] utf8data, int offset, int length) This will create a new array from the window given.Utf8Array
(ByteBuffer buf, int length) This will fetch length bytes from the given buffer. -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the length in bytes of the utf8 sequence.protected int
Returns the offset in the backing array where the utf8 sequence starts.byte[]
getBytes()
Returns the backing byte array.Methods inherited from class com.yahoo.text.AbstractUtf8Array
ascii7BitLowerCase, compareTo, equals, getByte, hashCode, isEmpty, toString, wrap, writeTo
-
Field Details
-
utf8
protected final byte[] utf8
-
-
Constructor Details
-
Utf8Array
public Utf8Array(byte[] utf8data) This will simply wrap the given array assuming it is valid utf8. Note that the immutability of this primitive class depends on that the buffer is not modified after ownership has been transferred.- Parameters:
utf8data
- The utf8 byte sequence.
-
Utf8Array
public Utf8Array(byte[] utf8data, int offset, int length) This will create a new array from the window given. No validation done. Note that this will copy data. You might also want to consider Utf8PartialArray- Parameters:
utf8data
- The base array.offset
- The offset from where to copy fromlength
- The number of bytes that should be copied.
-
Utf8Array
This will fetch length bytes from the given buffer.- Parameters:
buf
- The ByteBuffer to read fromlength
- number of bytes to read
-
-
Method Details
-
getBytes
public byte[] getBytes()Description copied from class:AbstractUtf8Array
Returns the backing byte array.- Specified by:
getBytes
in classAbstractUtf8Array
-
getByteLength
public int getByteLength()Description copied from class:AbstractUtf8Array
Returns the length in bytes of the utf8 sequence.- Specified by:
getByteLength
in classAbstractUtf8Array
-
getByteOffset
protected int getByteOffset()Description copied from class:AbstractUtf8Array
Returns the offset in the backing array where the utf8 sequence starts.- Specified by:
getByteOffset
in classAbstractUtf8Array
-