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
public class Utf8Array extends AbstractUtf8Array
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
Fields Modifier and Type Field Description protected byte[]
utf8
-
Constructor Summary
Constructors Constructor Description Utf8Array(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getByteLength()
Returns the length in bytes of the utf8 sequence.protected int
getByteOffset()
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
-
-
-
-
Constructor Detail
-
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
public Utf8Array(ByteBuffer buf, int length)
This will fetch length bytes from the given buffer.- Parameters:
buf
- The ByteBuffer to read fromlength
- number of bytes to read
-
-
Method Detail
-
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
-
-