|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.svrCore.ExhibitPropsLoadable
public final class ExhibitPropsLoadable
Immutable (and serialisable) store of all loadable auxiliary properties of a single exhibit. These are properties (such as descriptive comment) that must be fetched from the exhibit database and that cannot be computed.
This is designed to be efficient on the wire and in memory, since these details will be held for each and every exhibit.
Note that a factory method is used to generate instances of this class and where there is no loadable data for an exhibit (which will be rare) null is returned.
Equals is implemented so that duplicates (particularly of EMPTY) can easily be discarded. hashCode() is implemented to support the semantics of equals() and as a hash over all the contents of the object.
By default this looks for data in a new-style properties file first (fileBase + '/' + exhibitName + ".props"), and then, iff READ_OLD_FILES == true, in the old-style individual files.
| Field Summary | |
|---|---|
private int |
_hash
Private to hashCode() lock-free cache of computed hash value; initially 0 indicating not computed. |
private AccessionData |
accession
Accession data; null if none. |
private static boolean |
DEFER_COMPACTION
If true then defer compaction of metadata. |
private java.lang.Object |
description
The description. |
static ExhibitPropsLoadable |
EMPTY
Shared EMPTY instance (no auxiliary data on exhibit). |
static java.lang.String |
EXHIBIT_PROPS_FILENAME_SUFFIX
Suffix for new-format exhibit-properties file, if extant. |
private Location.Base |
location
Location information; null if none. |
static java.lang.String |
PNAME_DESCRIPTION
Name of property for (default English text/HTML) description in new properties file. |
static java.lang.String |
PNAME_LOCATION_PREFIX
Prefix of property names for location information in new properties file. |
static boolean |
READ_OLD_FILES
Allow backwards compatibility if true, ie look for old-style files for info not found in new props file. |
static Compact7BitString.StaticDictionary |
sDict
Shared static dictionary for use with in-memory Compact7BitString metadata. |
private static long |
serialVersionUID
My serial ID. |
| Constructor Summary | |
|---|---|
private |
ExhibitPropsLoadable(java.lang.Object _description,
Location.Base _location,
AccessionData _accession,
boolean doNotCompact)
Private constructor so creation is by factory method. |
| Method Summary | |
|---|---|
private static java.lang.String |
_decompressASCII7Text(byte[] compressed)
Attempt to decompress some deflated bytes to an ASCII 7-bit String. |
void |
compact()
Compact the internal representation of this instance (and its sub-objects) if possible. |
boolean |
equals(java.lang.Object o)
Based on entire content of object; if equivalent content then they are equal. |
AccessionData |
getAccessionMetadata()
Get exhibit accession metadata; null if none available. |
java.lang.String |
getCompactableInstanceName()
Get name of this Compactable instance for tracking purposes, or null if none. |
java.lang.String |
getDescription()
Get the description; returns null if none, else non-empty String. |
static ExhibitPropsLoadable |
getLoadableProperties(Name.ExhibitFull exhibitName,
java.io.File exhibitBaseDir)
Make a new instance with data loaded from the filesystem, given the exhibit name and some filesystem base directories. |
Location.Base |
getLocation()
Return location information; null if none. |
boolean |
hasDescription()
Reports if there is a description; returns true if so. |
int |
hashCode()
Based on entire content of object; if equivalent content then they have same hash. |
static java.util.Set<java.lang.String> |
listPropsFiles(Name.ExhibitFull exhibitName,
java.io.File exhibitBaseDir)
Method that lists exhibit-specific files containing loadable properties of the given exhibit. |
protected java.lang.Object |
readResolve()
Deserialise: use constructor for validation, defensive copying, etc. |
static java.lang.String |
relPathToNewAccession(Name.ExhibitFull exhibitName)
Make relative path to new accession-date file; never null. |
private static java.lang.String |
relPathToNewProperties(Name.ExhibitFull exhibitName)
Make relative path to new-style properties file. |
static java.lang.String |
relPathToOldAccession(Name.ExhibitFull exhibitName)
Make relative path to old accession-date file; never null. |
private static java.lang.String |
relPathToOldDescription(Name.ExhibitFull exhibitName)
Make relative path to old-style en-GB HTML generic description file. |
private static java.lang.String |
relPathToOldLocation(Name.ExhibitFull exhibitName)
Make relative path to old-style accession-date YYYY[/MM[/DD]] file. |
java.lang.String |
toString()
Human-readable summary. |
void |
validateObject()
Validate fields/state. |
protected java.lang.Object |
writeReplace()
Serialise: write in the best format for the wire. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final ExhibitPropsLoadable EMPTY
private transient int _hash
private static final long serialVersionUID
public static final java.lang.String EXHIBIT_PROPS_FILENAME_SUFFIX
public static final boolean READ_OLD_FILES
public static final java.lang.String PNAME_DESCRIPTION
public static final java.lang.String PNAME_LOCATION_PREFIX
public static final Compact7BitString.StaticDictionary sDict
private volatile java.lang.Object description
Support for the byte[] and ROByteArray formats exists mainly for backwards compatibility, ie deserialising old values. All bytes in the source string are of value 0--127 (ie ASCII 7-bit).
Marked volatile to allow safe lockless update by compact().
private final Location.Base location
private final AccessionData accession
private static final boolean DEFER_COMPACTION
Conversely, this could save a lot of time constructing/deserialising data before the first operations can be performed on it and where memory space is not the primary constraint.
| Constructor Detail |
|---|
private ExhibitPropsLoadable(java.lang.Object _description,
Location.Base _location,
AccessionData _accession,
boolean doNotCompact)
We may intern() components that are likely to be duplicated and that may consume significant memory.
_description - no more than MAX_DESCRIPTION_CHARS or null or "" if nonedoNotCompact - if true then do not attempt to compact the description; store as passed in| Method Detail |
|---|
private static java.lang.String relPathToNewProperties(Name.ExhibitFull exhibitName)
private static java.lang.String relPathToOldDescription(Name.ExhibitFull exhibitName)
public static java.lang.String relPathToNewAccession(Name.ExhibitFull exhibitName)
Public so that other routines can find and read this file directly.
exhibitName - non-null relative path to exhibitpublic static java.lang.String relPathToOldAccession(Name.ExhibitFull exhibitName)
YYYY[/MM[/DD]]
where YYYY is the year and MM is the month 01--12 and DD is the 01-31,
all relative to UTC/GMT, and represent the approximate date that the
exhibits where incorporated in the library.
Public so that other routines can find and read this file directly.
exhibitName - non-null relative path to exhibitprivate static java.lang.String relPathToOldLocation(Name.ExhibitFull exhibitName)
public static ExhibitPropsLoadable getLoadableProperties(Name.ExhibitFull exhibitName,
java.io.File exhibitBaseDir)
throws java.io.IOException
java.io.IOException - in case of severe, unrecoverable difficulty with this exhibitpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic int hashCode()
The cache relies on atomic assignment of int and is lock-free.
This may be slow to compute.
The hash value is never zero.
hashCode in class java.lang.Objectprotected java.lang.Object readResolve()
protected java.lang.Object writeReplace()
This allows a stream compressor to effectively remove the redundancy between instances of this class on the wire as well as internal redundancies.
We assume that there will almost never be entirely identical instances on one stream so we don't mind writing new copies each time where it does happen.
public void validateObject()
throws java.io.InvalidObjectException
Barf if something bad is found. (Maybe allow some extra info in debug version.)
validateObject in interface java.io.ObjectInputValidationjava.io.InvalidObjectExceptionpublic java.lang.String getDescription()
public boolean hasDescription()
private static java.lang.String _decompressASCII7Text(byte[] compressed)
throws java.io.IOException
java.io.IOExceptionpublic Location.Base getLocation()
public AccessionData getAccessionMetadata()
public void compact()
This may be able to convert some state to a more memory-efficient representation after construction or deserialisation, and is suitable to call in a background thread.
We don't prevent multiple concurrent calls to this routine, since they are at worst wasteful of CPU but not unsafe.
compact in interface MemoryTools.Compactablepublic java.lang.String getCompactableInstanceName()
getCompactableInstanceName in interface MemoryTools.Compactable
public static java.util.Set<java.lang.String> listPropsFiles(Name.ExhibitFull exhibitName,
java.io.File exhibitBaseDir)
This may name more files than are currently used by the system, eg including legacy files.
This never returns null, though may return an empty set.
When backing up exhibit data these files should be backed up with the relevant exhibit.
|
DHD Multimedia Gallery V1.57.21 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||