public abstract class ByteString
extends java.lang.Object
implements java.lang.Comparable, java.io.Serializable
The motivation for this class is to contain meteorlogical bulletins or observations. The "text" in these is encoded in "International Alphabet Number 5", aka CCITT Recommendation T.50, essentially ISO 646, which we know as 7 bit ASCII. Any data (non-text) portion is an octet (byte) sequence. We intend to store _many_ of these, so doubling the size to String may not be acceptable. Further, since the data has archival value, we wish to minimize alteration and transformation of the data.
String
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
ByteString.Concrete
Class Concrete
|
static class |
ByteString.Empty
Class Empty
|
static class |
ByteString.SubString
A ByteString implementation whose
origin is offset in the underlying byte array and
whose length is possibly less than the underlying
byte array.
|
static class |
ByteString.TrSubString
A ByteString implementation which
which is zero based in the underlying byte array
but whose length is possibly less than the underlying
byte array.
|
Modifier and Type | Field and Description |
---|---|
static byte[] |
nada
Zero length byte array to use as the contents of Empty ByteString
|
Modifier | Constructor and Description |
---|---|
protected |
ByteString()
_more_
|
Modifier and Type | Method and Description |
---|---|
abstract byte |
byteAt(int ii)
Returns the byte at the specified index.
|
static char |
ByteToChar8859_1(byte bb)
Widen an 8859_1 encoded byte to Unicode char.
|
char |
charAt(int ii)
Returns the byte at the specified index, widened
to Unicode char.
|
static byte |
CharToByte8859_1(char cc)
Narrow Unicode char to an 8859_1 encoded byte.
|
static int |
compare(ByteString bs1,
ByteString bs2)
Compare two byte strings lexographically.
|
static int |
compare(ByteString bs1,
java.lang.String s2)
Compare two byte strings lexographically.
|
int |
compareTo(ByteString bs)
Compare this and another byte string lexographically.
|
int |
compareTo(java.lang.Object oo)
Compares this to another Object.
|
int |
compareTo(java.lang.String ss)
Compare this and a String string lexographically.
|
static byte[] |
concat(byte[] b1,
byte[] b2,
byte sep)
_more_
|
static ByteString |
concat(ByteString bs1,
ByteString bs2,
char sep)
_more_
|
byte[] |
copyBytes(int srcpos,
byte[] dst,
int dstpos,
int nbytes)
Copies bytes from this ByteString into the destination byte
array.
|
boolean |
equals(java.lang.Object oo)
_more_
|
boolean |
equalS(java.lang.String ss)
Returns true iff this and the String argument
represent the same sequence of characters.
|
java.lang.StringBuffer |
format(java.lang.StringBuffer buf)
Widen this to Unicode in a StringBuffer.
|
abstract int |
getLength()
Returns the length of this string.
|
int |
hashCode()
_more_
|
int |
length()
String compatible entry point for getLength();
|
static void |
main(java.lang.String[] args)
_more_
|
ByteString |
subByteString(int beginIndex,
int length)
Returns a new string that is a substring of this string.
|
ByteString |
substring(int beginIndex) |
ByteString |
substring(int beginIndex,
int endindex) |
byte[] |
toArray()
Converts this string to a new byte array.
|
java.lang.String |
toString()
Widen this to a Unicode as in a String
|
public static final byte[] nada
public static final char ByteToChar8859_1(byte bb)
bb
- public static final byte CharToByte8859_1(char cc)
cc
- public static int compare(ByteString bs1, ByteString bs2)
bs1
- bs2
- String.compareTo(java.lang.String)
public static int compare(ByteString bs1, java.lang.String s2)
bs1
- s2
- String.compareTo(java.lang.String)
public static byte[] concat(byte[] b1, byte[] b2, byte sep)
b1
- b2
- sep
- public static ByteString concat(ByteString bs1, ByteString bs2, char sep)
bs1
- bs2
- sep
- public abstract int getLength()
public abstract byte byteAt(int ii)
0
to getLength() - 1
.
The first byte of the sequence is at index 0
,
the next at index 1
, and so on, as for array indexing.ii
- the index of the character.public char charAt(int ii)
ii
- byteAt(int)
,
String.charAt(int)
public byte[] copyBytes(int srcpos, byte[] dst, int dstpos, int nbytes)
The first byte to be copied is at index srcpos
;
The total number of bytes to be copied is
nbytes
. The bytes are copied into the subarray of
dst
starting at index dstpos
.
srcpos
- int index of the first byte to copy.dst
- the destination array.dstpos
- int start index in the destination array.nbytes
- int number of bytes to copypublic byte[] toArray()
public ByteString subByteString(int beginIndex, int length)
beginIndex
and
is length
long.
The resulting substring will share the same byte storage as this.
Note: the parameters and name of this method are somewhat
different than java.lang.String.substring(int,int)
There is a String
compatible version below.
beginIndex
- the beginning index, inclusive.length
- int length of the substring.public ByteString substring(int beginIndex, int endindex)
beginIndex
- endindex
- String.substring(int,int)
public ByteString substring(int beginIndex)
beginIndex
- String.substring(int)
public final int length()
getLength()
,
String.length()
public int compareTo(ByteString bs)
bs
- compare(ucar.unidata.util.ByteString, ucar.unidata.util.ByteString)
public int compareTo(java.lang.String ss)
ss
- compare(ucar.unidata.util.ByteString, ucar.unidata.util.ByteString)
public int compareTo(java.lang.Object oo)
compareTo(ByteString)
.
Otherwise, it throws a ClassCastException
.compareTo
in interface java.lang.Comparable
oo
- public java.lang.StringBuffer format(java.lang.StringBuffer buf)
buf
- public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object oo)
equals
in class java.lang.Object
oo
- public boolean equalS(java.lang.String ss)
ss
- public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args)
args
-