Class ByteBackedCharSequence
- java.lang.Object
-
- com.biomatters.geneious.publicapi.documents.sequence.ByteBackedCharSequence
-
- All Implemented Interfaces:
java.lang.CharSequence
public class ByteBackedCharSequence extends java.lang.Object implements java.lang.CharSequence
A CharSequence whose data is stored as bytes (instead of a String) to reduce memory usage. The API of the class is intended to make this class immutable, although in practice clients of this class can easily violate the immutability of the class.
-
-
Constructor Summary
Constructors Constructor Description ByteBackedCharSequence(byte[] bytes)
Creates a new ByteBackedCharSequence based on the given char sequence which stores the given byte array as its internal byte array.ByteBackedCharSequence(char[] characters)
Constructs a new ByteBackedCharSequence based on the given char sequenceByteBackedCharSequence(java.lang.CharSequence sequence)
Constructs a new ByteBackedCharSequence based on the given char sequence
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description char
charAt(int index)
byte[]
getBytes()
int
length()
java.lang.CharSequence
subSequence(int start, int end)
java.lang.String
toString()
-
-
-
Constructor Detail
-
ByteBackedCharSequence
public ByteBackedCharSequence(byte[] bytes)
Creates a new ByteBackedCharSequence based on the given char sequence which stores the given byte array as its internal byte array.- Parameters:
bytes
- the contents of this array must not be modified after this constructor is invoked.
-
ByteBackedCharSequence
public ByteBackedCharSequence(java.lang.CharSequence sequence)
Constructs a new ByteBackedCharSequence based on the given char sequence- Parameters:
sequence
- the sequence to store as an array of bytes.- Throws:
java.lang.IllegalArgumentException
- if any of the characters in sequence are not in the range 0 to 127 inclusive
-
ByteBackedCharSequence
public ByteBackedCharSequence(char[] characters)
Constructs a new ByteBackedCharSequence based on the given char sequence- Parameters:
characters
- the characters to store as an array of bytes.- Throws:
java.lang.IllegalArgumentException
- if any of the characters in sequence are not in the range 0 to 127 inclusive
-
-
Method Detail
-
length
public int length()
- Specified by:
length
in interfacejava.lang.CharSequence
-
charAt
public char charAt(int index)
- Specified by:
charAt
in interfacejava.lang.CharSequence
-
subSequence
public java.lang.CharSequence subSequence(int start, int end)
- Specified by:
subSequence
in interfacejava.lang.CharSequence
-
getBytes
public byte[] getBytes()
- Returns:
- the underlying bytes stored in this sequence. The caller of this method must not modify the bytes in the returned array.
-
toString
public java.lang.String toString()
- Specified by:
toString
in interfacejava.lang.CharSequence
- Overrides:
toString
in classjava.lang.Object
-
-