org.hd.d.pg2k.svrCore
Class Compact7BitString.WithDict

java.lang.Object
  extended by org.hd.d.pg2k.svrCore.Compact7BitString
      extended by org.hd.d.pg2k.svrCore.Compact7BitString.WithDict
All Implemented Interfaces:
java.io.ObjectInputValidation, java.io.Serializable, MemoryTools.Internable
Enclosing class:
Compact7BitString

private static final class Compact7BitString.WithDict
extends Compact7BitString

Specialised immutable sub-class to allow use with a StaticDictionary. Not directly visible outside this class, but is constructed by convertToCompact7BitString() as necessary.

Note that this can never be directly (de)serialised since this forces itself to String form when serialisation is attempted. This is because we cannot efficiently serialise the dictionary and thus would nto have enough information to ensure correct decoding.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.hd.d.pg2k.svrCore.Compact7BitString
Compact7BitString.StaticDictionary
 
Field Summary
private  int _hash
          Cache of the hash code for speed.
private  Compact7BitString.StaticDictionary dict
          Static dictionary (if any) used to aid compression; never null.
private static long serialVersionUID
          Serialisation UID; never really used.
 
Fields inherited from class org.hd.d.pg2k.svrCore.Compact7BitString
EMPTY
 
Constructor Summary
private Compact7BitString.WithDict(byte[] text, Compact7BitString.StaticDictionary dict)
           
 
Method Summary
protected  Compact7BitString.StaticDictionary getDict()
          Get the static dictionary, null if none.
 int hashCode()
          Derive (and cache) a hash based on the text and the dictionary.
protected  java.lang.Object writeReplace()
          Always write as (ie return) a String; never null.
 
Methods inherited from class org.hd.d.pg2k.svrCore.Compact7BitString
convertToCompact7BitString, equals, getInternalBytes, isEmpty, makeFromInternalBytes, toString, validateObject
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

dict

private final Compact7BitString.StaticDictionary dict
Static dictionary (if any) used to aid compression; never null. It is forbidden to serialise an instance as-is so as to prevent decompression errors/ambiguitites, so these sub-classes as always serialised as String instances.


_hash

private int _hash
Cache of the hash code for speed. Since we've blown some extra space on the (reference) to the dictionary, we'll blow a little more on a cache since hash computation can be expensive.

We assume that it has not been computed and cached if zero.


serialVersionUID

private static final long serialVersionUID
Serialisation UID; never really used.

See Also:
Constant Field Values
Constructor Detail

Compact7BitString.WithDict

private Compact7BitString.WithDict(byte[] text,
                                   Compact7BitString.StaticDictionary dict)
Method Detail

writeReplace

protected java.lang.Object writeReplace()
                                 throws java.io.ObjectStreamException
Always write as (ie return) a String; never null.

Overrides:
writeReplace in class Compact7BitString
Throws:
java.io.ObjectStreamException

getDict

protected Compact7BitString.StaticDictionary getDict()
Get the static dictionary, null if none.

Overrides:
getDict in class Compact7BitString

hashCode

public int hashCode()
Derive (and cache) a hash based on the text and the dictionary. This adds in some distinguishing sauce from the dictionary to better spread out hash codes from C7BS texts.

Overrides:
hashCode in class Compact7BitString

DHD Multimedia Gallery V1.50.55

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