Package it.unimi.dsi.law.warc.util
Class ByteArrayCharSequence
java.lang.Object
it.unimi.dsi.law.warc.util.ByteArrayCharSequence
- All Implemented Interfaces:
CharSequence
public class ByteArrayCharSequence extends Object implements CharSequence
An adapter exposing a byte array as an ISO-8859-1-encoded
character sequence.
An instance of this adapter can be reused by wrapping a new byte array.
Note that for convenience this class exposes a hashCode() method that
return the same result as String, but equality is not by content.
-
Constructor Summary
Constructors Constructor Description ByteArrayCharSequence()Creates a new empty byte-array character sequence.ByteArrayCharSequence(byte[] b)Creates a new byte-array character sequence using the provided byte array.ByteArrayCharSequence(byte[] b, int offset, int length)Creates a new byte-array character sequence using the provided byte-array fragment. -
Method Summary
Modifier and Type Method Description charcharAt(int index)inthashCode()intlength()CharSequencesubSequence(int start, int end)StringtoString()voidwrap(byte[] b)Wraps a byte array into this byte-array character sequence.ByteArrayCharSequencewrap(byte[] b, int offset, int length)Wraps a byte-array fragment into this byte-array character sequence.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Constructor Details
-
ByteArrayCharSequence
public ByteArrayCharSequence(byte[] b, int offset, int length)Creates a new byte-array character sequence using the provided byte-array fragment.- Parameters:
b- a byte array.offset- the first valid byte inb.length- the number of valid bytes inb, starting atoffset.
-
ByteArrayCharSequence
public ByteArrayCharSequence(byte[] b)Creates a new byte-array character sequence using the provided byte array.- Parameters:
b- a byte array.
-
ByteArrayCharSequence
public ByteArrayCharSequence()Creates a new empty byte-array character sequence.
-
-
Method Details
-
wrap
Wraps a byte-array fragment into this byte-array character sequence.- Parameters:
b- a byte array.offset- the first valid byte inb.length- the number of valid bytes inb, starting atoffset.- Returns:
- this byte-array character sequence.
-
wrap
public void wrap(byte[] b)Wraps a byte array into this byte-array character sequence.- Parameters:
b- a byte array.
-
length
public int length()- Specified by:
lengthin interfaceCharSequence
-
charAt
public char charAt(int index)- Specified by:
charAtin interfaceCharSequence
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-
toString
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-
hashCode
public int hashCode()
-