@MinDoc(copyright="Copyright 2006, 2009, 2013 A. Weinert", author="Albrecht Weinert", version="V.32", lastModified="22.03.2021", usage="use for repeated byte stream input + raw character interpretation", purpose="avoid throwaway objects in single threaded repeated use") public class ByteCharSeq extends Object implements CharSequence
InputStream
(as whole) andCharSequence
. toString()
and
subSequence(int, int)
.TextHelper
,
TextHelper.trimUq(CharSequence, String)
Modifier and Type | Field and Description |
---|---|
int |
maxCapacity
The maximum length (of input and) the CharSequence.
|
Constructor and Description |
---|
ByteCharSeq(byte[] buff)
Make a ByteCharSeq providing the internal buffer.
|
Modifier and Type | Method and Description |
---|---|
char |
charAt(int index) |
int |
length()
The CharSequence's length.
|
int |
readFrom(InputStream in)
Read from an InputStream.
|
void |
setBounds(int offset,
int length)
Arbitrarily choose a part of the whole (input) as CharSequence.
|
CharSequence |
subSequence(int start,
int end)
Getting a subsequence.
|
String |
toString()
Get the content as String.
|
int |
trimUq()
Trim (and "un-quote") the character sequence.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
chars, codePoints
public final int maxCapacity
public ByteCharSeq(byte[] buff)
buff
should not be used further
elsewhere, except one knows the consequences. The safe way is new ByteCharSeq(new byte[maxCapacity])
.NullPointerException
- if buff is nullIllegalArgumentException
- if buff.length < 1public final int length()
length
in interface CharSequence
public void setBounds(int offset, int length)
IndexOutOfBoundsException
- if length
or offset
negative or if chosen range violates maxCapacity
.public int readFrom(InputStream in) throws IOException
setBounds(0, numberOfBytesRead)
, even if 0
bytes are input. Returned value is numberOfBytesRead.in
is null or EOF already reached, nothing is changed and -1
is returned.IOException
- on problems while reading from in
public int trimUq()
setBounds(newOffset, newLength)
may, of
cause result in an empty (newLength == 0) sequence.TextHelper.trimUq(CharSequence, String)
to this object. (Its
"cheaper").TextHelper.trimUq(CharSequence, String)
public char charAt(int index)
charAt
in interface CharSequence
public CharSequence subSequence(int start, int end)
String
featuring the requested subsequence of
this sequence.subSequence
in interface CharSequence
IndexOutOfBoundsException
- if the chosen subsequence falls out of
given (buffer) bounds.toString()
,
setBounds(int, int)
public String toString()
toString
in interface CharSequence
toString
in class Object
subSequence(int, int)