org.hd.d.pg2k.svrCore
Class ExhibitAttrUtils.ExhibitAttrWords

java.lang.Object
  extended by org.hd.d.pg2k.svrCore.ExhibitAttrUtils.ExhibitAttrWords
All Implemented Interfaces:
java.io.Serializable
Enclosing class:
ExhibitAttrUtils

public static final class ExhibitAttrUtils.ExhibitAttrWords
extends java.lang.Object
implements java.io.Serializable

This class contains exhibit attribute words. This data is derived from global config data.

See Also:
Serialized Form

Nested Class Summary
private static class ExhibitAttrUtils.ExhibitAttrWords.IndirectComparatorStub
          Device to allow serialisation of trivial stubs and do proper quality test.
private static class ExhibitAttrUtils.ExhibitAttrWords.SmartOrderComp
          Class to implement our "smart" order Comparator.
private static class ExhibitAttrUtils.ExhibitAttrWords.SubjOrderComp
          Class to implement our "subject" order Comparator.
 
Field Summary
private  java.util.Comparator<java.lang.String> _SMART_ORDER
          Internal copy of SMART_ORDER; not serialised.
private  java.util.Comparator<java.lang.String> _SUBJECT_ORDER
          Internal copy of SUBJECT_ORDER; not serialised.
private  java.lang.String[] attrWords
          The sorted and duplicate-free list of attribute words.
private  java.util.SortedSet<java.lang.String> attrWordsSortedSet
          The immutable sorted set of attribute words.
 long longHash
          The hash of all the data held; guaranteed non-negative.
private static long serialVersionUID
          Our serial version...
 java.util.Comparator<java.lang.String> SMART_ORDER
          A Comparator that sorts exhibits by name taking account of attribute words.
 java.util.Comparator<java.lang.String> SUBJECT_ORDER
          A Comparator that sorts exhibits by name comparing as equal those that differ only in attribute words.
 
Constructor Summary
private ExhibitAttrUtils.ExhibitAttrWords(java.lang.String[] attributeWords)
          Construct a set of global (immutable) properties.
 
Method Summary
private  void _setComparators(java.util.Set<java.lang.String> attrWordsSortedSet)
          Routine to set _SUBJECT_ORDER and _SMART_ORDER.
private  long computeHash()
          Compute a hash over all the data in the object; guaranteed non-negative.
 boolean equals(java.lang.Object obj)
          Indicates whether some other object is "equal to" this one; the underlying data is the same if true.
 java.lang.String[] getAttrWords()
          The sorted and duplicate-free non-null list of attribute words.
 java.util.SortedSet<java.lang.String> getAttrWordsSortedSet()
          The set of attribute words as a view in an immutable SortedSet.
 int hashCode()
          Returns a hash code value for the object; derived from the longHash.
private  void readObject(java.io.ObjectInputStream in)
          Deserialise.
 void validateObject()
          Validate fields/state.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

longHash

public final long longHash
The hash of all the data held; guaranteed non-negative. Depends all the information held in this object.


attrWords

private java.lang.String[] attrWords
The sorted and duplicate-free list of attribute words. All of these should meet the rules for ExhibitNames.validAttributeWord().

We are careful never to share a reference to this outside the class, eg upon deserialisation.

This is the primary store of attribute words information.


attrWordsSortedSet

private transient java.util.SortedSet<java.lang.String> attrWordsSortedSet
The immutable sorted set of attribute words. A duplicate of the info in attrWords[].


_SUBJECT_ORDER

private transient java.util.Comparator<java.lang.String> _SUBJECT_ORDER
Internal copy of SUBJECT_ORDER; not serialised.


_SMART_ORDER

private transient java.util.Comparator<java.lang.String> _SMART_ORDER
Internal copy of SMART_ORDER; not serialised.


SUBJECT_ORDER

public final java.util.Comparator<java.lang.String> SUBJECT_ORDER
A Comparator that sorts exhibits by name comparing as equal those that differ only in attribute words. This sorts, in order by:
  1. main stem of the name case-insensitively
  2. author
  3. number-in-series


SMART_ORDER

public final java.util.Comparator<java.lang.String> SMART_ORDER
A Comparator that sorts exhibits by name taking account of attribute words. This sorts, in order by:
  1. SUBJECT_ORDER to sort into order by exhibit subject
  2. attribute words to sort within an exhibit subject
  3. ExhibitName.SIMPLE_SMART_ORDER to break ties

equals() is true iff referring underlying comparator's backing AEP has an unchanged longHash.


serialVersionUID

private static final long serialVersionUID
Our serial version...

See Also:
Constant Field Values
Constructor Detail

ExhibitAttrUtils.ExhibitAttrWords

private ExhibitAttrUtils.ExhibitAttrWords(java.lang.String[] attributeWords)
Construct a set of global (immutable) properties.

Parameters:
attributeWords - set of attribute words for exhibit names; need not be sorted, may be null or zero length, but should not contain any zero-length words nor words consisting purely of digits nor that contain anything other than digits or lower-case letters
Method Detail

getAttrWords

public java.lang.String[] getAttrWords()
The sorted and duplicate-free non-null list of attribute words. This array contains no nulls nor duplicates and all entries meet the rules for ExhibitNames.validAttributeWord().

Creating the return value may be expensive, requiring extensive copying.

Returns:
private copy of attribute-words list

getAttrWordsSortedSet

public java.util.SortedSet<java.lang.String> getAttrWordsSortedSet()
The set of attribute words as a view in an immutable SortedSet. This set contains no nulls and all entries meet the rules for ExhibitNames.validAttributeWord().

Preparing this return value should take a constant, small, time.

Returns:
immutable view of attribute-words sorted set

_setComparators

private void _setComparators(java.util.Set<java.lang.String> attrWordsSortedSet)
Routine to set _SUBJECT_ORDER and _SMART_ORDER. Called from constructor and readObject().


computeHash

private long computeHash()
Compute a hash over all the data in the object; guaranteed non-negative. Aims to be quick and comprehensive and portable between VMs, and should not miss even quite subtle changes in the stored data.


hashCode

public int hashCode()
Returns a hash code value for the object; derived from the longHash. Guaranteed zero if there are no exhibits, non-zero otherwise.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object.
See Also:
Object.equals(Object), Hashtable

equals

public boolean equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one; the underlying data is the same if true. The hashNotChangedSince value is excluded from the comnparison.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.
See Also:
Boolean.hashCode(), Hashtable

validateObject

public void validateObject()
                    throws java.io.InvalidObjectException
Validate fields/state. Called in the constructor and possibly after de-serialising.

Barf if something bad is found. (Maybe allow some extra info in debug version.)

Throws:
java.io.InvalidObjectException

readObject

private void readObject(java.io.ObjectInputStream in)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Deserialise.

Throws:
java.io.IOException
java.lang.ClassNotFoundException

DHD Multimedia Gallery V1.50.55

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