org.hd.d.pg2k.svrCore
Class ExhibitStaticAttr

java.lang.Object
  extended by org.hd.d.pg2k.svrCore.ExhibitStaticAttr
All Implemented Interfaces:
java.io.ObjectInputValidation, java.io.Serializable, java.lang.Comparable<ExhibitStaticAttr>

public final class ExhibitStaticAttr
extends java.lang.Object
implements java.lang.Comparable<ExhibitStaticAttr>, java.io.Serializable, java.io.ObjectInputValidation

Immutable, Serializable collection of the basic static attributes of an exhibit. This is designed to be fast to do comparisons against, and to be transportable across a network, persistable to disc, and easy to run filtering queries against.

This verifies that its contents make sense at construction and after deserialisation.

This is keyed on the exhibit underlying name, but should be easy to use with other comparators.

The timestamp can be used to compare that the version of the object held is up-to-date.

Some core values are made available as public final fields for speed of access.

See Also:
Serialized Form

Field Summary
private static boolean ALWAYS_USE_EFP
          True if always EFP is always used as the normal internal form.
private  java.lang.CharSequence filePath
          The full (relative) path/name of the exhibit; never null.
 long length
          The length of the exhibit in bytes; strictly positive.
private static long serialVersionUID
          My initial version number.
 long timestamp
          The Java-style timestamp (last-modified-time) of the exhibit (ms); strictly positive.
 
Constructor Summary
private ExhibitStaticAttr(java.lang.CharSequence _filePath)
          Used by makeNameOnlyKey() to make a name-only key efficiently.
  ExhibitStaticAttr(java.lang.CharSequence _filePath, long _length, long _timestamp)
          Construct new immutable instance.
 
Method Summary
 int compareTo(ExhibitStaticAttr o)
          All comparison is done on the exhibit name alone.
 boolean equals(java.lang.Object o)
          All comparison is done on the name only, NOT on all fields.
 java.lang.CharSequence getCharSequence()
          Get the file path (full exhibit name) as an immutable CharSequence; never null.
 Name.ExhibitFull getExhibitFullName()
          Get the full exhibit name; never null.
 java.lang.String getFilePath()
          Deprecated. getExhibitFullName() or getCharSequence() preferred
 java.lang.Comparable<?> getKey()
          Extract compound key that does depend on all the fields; never null.
 int hashCode()
          All comparison is done on the name.
private  boolean isEFP()
          Returns true iff the run-time type of filePath is an ExhibitFullName.
 boolean isIdentical(ExhibitStaticAttr other)
          Tests that instances are identical in all parameters.
static ExhibitStaticAttr makeNameOnlyKey(java.lang.CharSequence filePath)
          Generate a lookup key with just the name significant; never null.
protected  java.lang.Object readResolve()
          Deserialise: use constructor for validation, defensive copying, etc.
 java.lang.String toString()
          Human-readable summary contains at least the name.
 void validateObject()
          Validate fields/state.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

filePath

private final java.lang.CharSequence filePath
The full (relative) path/name of the exhibit; never null. Must be unique and acceptable to ExhibitName.

The field type is CharSequence to allow reading in of old String-valued instances but allows holding of ExhibitFileName instances at run-time.

All run-time instances will have the same type, except possibly fleetingly during (de)serialisation.


length

public final long length
The length of the exhibit in bytes; strictly positive.


timestamp

public final long timestamp
The Java-style timestamp (last-modified-time) of the exhibit (ms); strictly positive. This must be valid Gallery timestamp which means not before the Gallery was created and not too far into the future allowing for clock skew...


ALWAYS_USE_EFP

private static final boolean ALWAYS_USE_EFP
True if always EFP is always used as the normal internal form. Other types may be used temporarily during (de)serialisation.

See Also:
Constant Field Values

serialVersionUID

private static final long serialVersionUID
My initial version number.

See Also:
Constant Field Values
Constructor Detail

ExhibitStaticAttr

public ExhibitStaticAttr(java.lang.CharSequence _filePath,
                         long _length,
                         long _timestamp)
                  throws java.lang.IllegalArgumentException
Construct new immutable instance. Try to force sharing of the potentially large and numerous paths/names to avoid memory bloat, even though this costs some time.

Throws:
java.lang.IllegalArgumentException - in the case of a null or invalid filePath

ExhibitStaticAttr

private ExhibitStaticAttr(java.lang.CharSequence _filePath)
Used by makeNameOnlyKey() to make a name-only key efficiently. Skips some checking but will still ensure that only a valid instance is created.

Throws:
java.lang.IllegalArgumentException - in the case of a null or invalid filePath
Method Detail

hashCode

public final int hashCode()
All comparison is done on the name. Relies on hash of underlying data type, assuming all run-time filePath instances will have same type.

Overrides:
hashCode in class java.lang.Object

equals

public final boolean equals(java.lang.Object o)
All comparison is done on the name only, NOT on all fields. Relies on all run-time filePath instances will have same type.

Overrides:
equals in class java.lang.Object

isEFP

private boolean isEFP()
Returns true iff the run-time type of filePath is an ExhibitFullName.


getFilePath

@Deprecated
public java.lang.String getFilePath()
Deprecated. getExhibitFullName() or getCharSequence() preferred

Get the file path (full exhibit name) as a String; never null. This operation may be expensive and slow.


getExhibitFullName

public Name.ExhibitFull getExhibitFullName()
Get the full exhibit name; never null. This operation may be expensive and slow initially, but will become the preferred option.


getCharSequence

public java.lang.CharSequence getCharSequence()
Get the file path (full exhibit name) as an immutable CharSequence; never null. This avoids any possible expensive value conversion for callers that don't care about the exact representation.


toString

public java.lang.String toString()
Human-readable summary contains at least the name.

Overrides:
toString in class java.lang.Object

compareTo

public final int compareTo(ExhibitStaticAttr o)
All comparison is done on the exhibit name alone.

Specified by:
compareTo in interface java.lang.Comparable<ExhibitStaticAttr>

isIdentical

public final boolean isIdentical(ExhibitStaticAttr other)
Tests that instances are identical in all parameters.


getKey

public java.lang.Comparable<?> getKey()
Extract compound key that does depend on all the fields; never null. Suitable for hashed and sorted collections.


makeNameOnlyKey

public static ExhibitStaticAttr makeNameOnlyKey(java.lang.CharSequence filePath)
Generate a lookup key with just the name significant; never null.

Throws:
java.lang.IllegalArgumentException - in the case of a null or invalid filePath

readResolve

protected java.lang.Object readResolve()
Deserialise: use constructor for validation, defensive copying, etc.


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.)

Specified by:
validateObject in interface java.io.ObjectInputValidation
Throws:
java.io.InvalidObjectException

DHD Multimedia Gallery V1.57.21

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