org.hd.d.pg2k.svrCore
Class CS8Bit

java.lang.Object
  extended by org.hd.d.pg2k.svrCore.CS8Bit
All Implemented Interfaces:
java.lang.CharSequence, MemoryTools.Internable, TextUtils.CharSequence8Bit

public final class CS8Bit
extends java.lang.Object
implements TextUtils.CharSequence8Bit, MemoryTools.Internable

Immutable lightweight CharSequence holding 8-bit text only. Internally the text is stored as a byte[] for compactness.

Implements hashCode() and equals() so suitable as a hash key.


Field Summary
private  byte[] data
          The 8-bit text of this sequence; ever null but may be empty.
private  int hash
          Cache of the computed hash code.
 
Constructor Summary
CS8Bit(byte[] d)
          Copy from byte array.
CS8Bit(java.lang.CharSequence other)
          Copy from another CharSequence, vetoing if any non-8-bit data.
CS8Bit(TextUtils.CharSequence8Bit other)
          Copy from another CharSequence8Bit (defensively).
CS8Bit(TextUtils.CharSequence8Bit other, int start, int end)
          Copy a sub-sequence of another CharSequence8Bit.
 
Method Summary
 char charAt(int index)
           
 boolean equals(java.lang.Object o)
          Equality depends on the entire content being the same.
 int hashCode()
          The hash is computed over the entire text as for String.
 int length()
           
 TextUtils.CharSequence8Bit subSequence(int startSS, int endSS)
          Extract subsequence; never null.
 byte[] toByteArray()
          Create private byte[] copy for caller; never null.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

data

private final byte[] data
The 8-bit text of this sequence; ever null but may be empty.


hash

private transient int hash
Cache of the computed hash code. Not part of the permanent/serialised state of the object since easy to recompute.

Constructor Detail

CS8Bit

public CS8Bit(byte[] d)
Copy from byte array.


CS8Bit

public CS8Bit(TextUtils.CharSequence8Bit other)
Copy from another CharSequence8Bit (defensively).


CS8Bit

public CS8Bit(TextUtils.CharSequence8Bit other,
              int start,
              int end)
Copy a sub-sequence of another CharSequence8Bit.

Parameters:
other - other sequence; never null
start - inclusive start index
end - exclusive end index

CS8Bit

public CS8Bit(java.lang.CharSequence other)
       throws java.lang.IllegalArgumentException
Copy from another CharSequence, vetoing if any non-8-bit data.

Throws:
java.lang.IllegalArgumentException
Method Detail

length

public int length()
Specified by:
length in interface java.lang.CharSequence

charAt

public char charAt(int index)
Specified by:
charAt in interface java.lang.CharSequence

subSequence

public TextUtils.CharSequence8Bit subSequence(int startSS,
                                              int endSS)
Extract subsequence; never null. Usually a very lightweight wrapper around this instance, but may be an outright copy for very short subsequences for efficiency.

Specified by:
subSequence in interface java.lang.CharSequence

toString

public final java.lang.String toString()
Specified by:
toString in interface java.lang.CharSequence
Overrides:
toString in class java.lang.Object

toByteArray

public final byte[] toByteArray()
Create private byte[] copy for caller; never null.

Specified by:
toByteArray in interface TextUtils.CharSequence8Bit

hashCode

public int hashCode()
The hash is computed over the entire text as for String.

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Equality depends on the entire content being the same.

Overrides:
equals in class java.lang.Object

DHD Multimedia Gallery V1.53.0

Copyright (c) 1996-2009, Damon Hart-Davis. All rights reserved.