Package com.yahoo.text
Class Utf8Array
- java.lang.Object
-
- com.yahoo.text.AbstractUtf8Array
-
- com.yahoo.text.Utf8Array
-
- All Implemented Interfaces:
java.lang.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- Since:
- 5.2
- 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(java.nio.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()
protected int
getByteOffset()
byte[]
getBytes()
-
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(java.nio.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()
- Specified by:
getBytes
in classAbstractUtf8Array
- Returns:
- The backing byte array.
-
getByteLength
public int getByteLength()
- Specified by:
getByteLength
in classAbstractUtf8Array
- Returns:
- Length in bytes of the utf8 sequence.
-
getByteOffset
protected int getByteOffset()
- Specified by:
getByteOffset
in classAbstractUtf8Array
- Returns:
- The offset in the backing array where the utf8 sequence starts.
-
-