org.hd.d.pg2k.svrCore
Class ExhibitPropsGlobalImmutable

java.lang.Object
  extended by org.hd.d.pg2k.svrCore.ExhibitPropsGlobalImmutable
All Implemented Interfaces:
java.io.Serializable

public final class ExhibitPropsGlobalImmutable
extends java.lang.Object
implements java.io.Serializable

This contains global immutable exhibit data over all exhibits that must live with the exhibits. This is data that does not apply to any one exhibit but is small and critical to handling of all exhibits.

Currently this contains:

This can include:

This has a hash computed over its contents to make it easy for users of this object to tell if it has changed since previous incarnations.

This object is immutable and Serializable, and tries to validate its contents upon deserialisation.

See Also:
Serialized Form

Nested Class Summary
static class ExhibitPropsGlobalImmutable.EPGIDiff
          Immutable record of the difference between two EPGI instances.
private static class ExhibitPropsGlobalImmutable.PropertiesDiffResourceBundle
          Thin wrapper/holder for a local treedesc resource bundle based on PropertiesDiff.
private static class ExhibitPropsGlobalImmutable.RBControl
           
 
Field Summary
private  PropertiesDiff locationDB
          The (immutable) location DB in properties format; null if absent.
 long locationDBTimestamp
          The location DB timestamp; strictly positive, or zero if no/empty locationDB.
private  LocationMap locMap
          The (immutable) LocationMap derived from the locationDB; never null.
 long longHash
          The hash of all the data held; guaranteed non-negative.
private static long serialVersionUID
          Our serial version...
private  PropertiesBundleDiff treedesc
          The (immutable) treedesc bundle; null if absent.
 long treedescTimestamp
          The treedesc bundle timestamp; non-negative, or may be zero if locationDBis empty/absent.
 
Constructor Summary
ExhibitPropsGlobalImmutable()
          Create an empty instance.
ExhibitPropsGlobalImmutable(PropertiesDiff locationDB, long locationDBTimestamp, PropertiesBundleDiff treedesc, long treedescTimestamp)
          Create an instance.
ExhibitPropsGlobalImmutable(java.util.Properties locationDB, long locationDBTimestamp, java.util.Map<java.lang.String,java.util.Properties> treedesc, long treedescTimestamp)
          Create an instance.
 
Method Summary
 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.CharSequence getLocalisedTreeDescMessage(java.lang.String msgName, java.util.Locale locale)
          Gets the appropriate localised tree-description message; never null unless the key is null.
 LocationMap getLocationMap()
          Get the LocationMap; never null.
 int getTreedescHash()
          Get the hash of the treedesc; non-negative, or may be zero if treedesc is empty/absent.
 int hashCode()
          Returns a hash code value for the object; derived from the longHash.
static ExhibitPropsGlobalImmutable loadFromDataDir(java.io.File exhibitDataDir)
          Load global data from filesystem.
protected  java.lang.Object readResolve()
          Deserialise: use constructor for validation, defensive copying, conversion from old formats, etc.
 java.lang.String toString()
          Human-readable summary of state.
 void validateObject()
          Validate fields/state.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

locationDBTimestamp

public final long locationDBTimestamp
The location DB timestamp; strictly positive, or zero if no/empty locationDB.


locationDB

private final PropertiesDiff locationDB
The (immutable) location DB in properties format; null if absent. We store this in PropertiesDiff format for efficiency on the wire, but convert it to LocationMap before use.

May be absent if there was no location data available at AEP creation or when deserialising an older AEP that has no location data, or as a more efficient way to represent an empty value (we always store an empty value as null for efficiency).


treedescTimestamp

public final long treedescTimestamp
The treedesc bundle timestamp; non-negative, or may be zero if locationDBis empty/absent.


treedesc

private final PropertiesBundleDiff treedesc
The (immutable) treedesc bundle; null if absent. We store this in PropertiesBundleDiff format for efficiency on the wire.

May be absent if there was no location data available at AEP creation or when deserialising an older AEP that has no location data, or as a more efficient way to represent an empty value (we always store an empty value as null for efficiency).


locMap

private transient volatile LocationMap locMap
The (immutable) LocationMap derived from the locationDB; never null. Created on or before first use.

Derived from the locationDB info, empty if no locationDB.

Not part of the serialised state.

Marked volatile for lock-free thread-safe access.


longHash

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

Will be zero if this contains no data.


serialVersionUID

private static final long serialVersionUID
Our serial version...

See Also:
Constant Field Values
Constructor Detail

ExhibitPropsGlobalImmutable

public ExhibitPropsGlobalImmutable()
Create an empty instance.


ExhibitPropsGlobalImmutable

public ExhibitPropsGlobalImmutable(java.util.Properties locationDB,
                                   long locationDBTimestamp,
                                   java.util.Map<java.lang.String,java.util.Properties> treedesc,
                                   long treedescTimestamp)
Create an instance.


ExhibitPropsGlobalImmutable

public ExhibitPropsGlobalImmutable(PropertiesDiff locationDB,
                                   long locationDBTimestamp,
                                   PropertiesBundleDiff treedesc,
                                   long treedescTimestamp)
Create an instance.

Method Detail

loadFromDataDir

public static ExhibitPropsGlobalImmutable loadFromDataDir(java.io.File exhibitDataDir)
                                                   throws java.io.IOException
Load global data from filesystem.

Throws:
java.io.IOException

getTreedescHash

public final int getTreedescHash()
Get the hash of the treedesc; non-negative, or may be zero if treedesc is empty/absent.


getLocationMap

public LocationMap getLocationMap()
Get the LocationMap; never null.


getLocalisedTreeDescMessage

public java.lang.CharSequence getLocalisedTreeDescMessage(java.lang.String msgName,
                                                          java.util.Locale locale)
Gets the appropriate localised tree-description message; never null unless the key is null. In case of a missing message, or unavailable treedesc data, this returns the key itself.

The key is converted to lower-case (if necessary) before lookup.

If the name is null, the result is null.

Parameters:
locale - desired locale, or null

hashCode

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

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object.

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.

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.

toString

public java.lang.String toString()
Human-readable summary of state.

Overrides:
toString in class java.lang.Object

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

readResolve

protected java.lang.Object readResolve()
                                throws java.io.ObjectStreamException
Deserialise: use constructor for validation, defensive copying, conversion from old formats, etc. Also allows us to (re)normalise the data in this instance, eg to recompute the longHash in case our hash algorithm changes.

Throws:
java.io.ObjectStreamException

DHD Multimedia Gallery V1.57.21

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