org.hd.d.pg2k.webSvr.catalogue
Class TrailData

java.lang.Object
  extended by org.hd.d.pg2k.webSvr.catalogue.TrailData

public final class TrailData
extends java.lang.Object

Immutable representation of data for one trail/sequence of exhibits and commentary. These instances are not intended to be persisted, so the class does not implement java.io.Serializable.


Field Summary
 java.util.List<Tuple.Pair<Name,Compact7BitString>> body
          Body of trail (immutable); never null nor empty.
static int MAX_TITLE_LEN
          Maximum title length in raw bytes/characters; strictly positive.
 Compact7BitString title
          Title for trail (immutable); never null nor empty.
 
Constructor Summary
private TrailData(Compact7BitString title, java.util.List<Tuple.Pair<Name,Compact7BitString>> body)
          Create instance from pre-parsed data.
 
Method Summary
static TrailData parseFromByteStream(java.io.InputStream in)
          Parse an instance from a 7-bit XHTML-safe ASCII text byte stream.
static TrailData readTrailFromExhibit(SimpleExhibitPipelineIF dataSource, Name.ExhibitFull trailExhibitName, SimpleLoggerIF log)
          Read trail data from specified trail exhibit (full) name, or null if not available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_TITLE_LEN

public static final int MAX_TITLE_LEN
Maximum title length in raw bytes/characters; strictly positive. On the generous side to allow for bulky character entities in non-English titles.

See Also:
Constant Field Values

title

public final Compact7BitString title
Title for trail (immutable); never null nor empty. Immutable 7-bit XHTML/HTML-safe title with no mark-up except UNICODE character entities.


body

public final java.util.List<Tuple.Pair<Name,Compact7BitString>> body
Body of trail (immutable); never null nor empty. Either but not both of each pair may be null, and neither of any pair can be empty.

Constructor Detail

TrailData

private TrailData(Compact7BitString title,
                  java.util.List<Tuple.Pair<Name,Compact7BitString>> body)
Create instance from pre-parsed data. Marked 'private' since only intended to be called from factory methods.

Parameters:
title - 7-bit XHTML-safe markup-free (except for UNICODE character entities); non-null, non-empty, no longer than MAX_TITLE_LEN characters/bytes
body - sequence of exhibit short names (and Name) with associated (7-bit XHTML-safe) texts (either but not both of each pair may be null, and neither of any pair can be empty); non-null, non-empty
Method Detail

parseFromByteStream

public static TrailData parseFromByteStream(java.io.InputStream in)
                                     throws java.io.IOException
Parse an instance from a 7-bit XHTML-safe ASCII text byte stream. This attempts to be generous, and work around as many problems as possible, but may give up without grace on, for example, finding no title or body, or on encountering non-7-bit characters.

This does not close its input stream.

Should be able to parse input with UNIX (\r aka LF) or Windows (\r\n aka CRLF) line termination, or even a mixture.

The first line must start "@ " followed by the HTML-safe title.

Each image/exhibit to be inserted should be on a line starting "* " followed by the exhibit short name and then an optional space and HTML-safe comment. The exhibit short names are held as Name values and are only checked for syntax.

Each blank (whitespace-only) line is treated as a paragraph boundary.

Parameters:
in - 7-bit ASCII line-oriented input stream; non-null
Throws:
java.io.IOException - in case of input error
java.lang.IllegalArgumentException - in case of corrupt input too garbled to handle

readTrailFromExhibit

public static final TrailData readTrailFromExhibit(SimpleExhibitPipelineIF dataSource,
                                                   Name.ExhibitFull trailExhibitName,
                                                   SimpleLoggerIF log)
Read trail data from specified trail exhibit (full) name, or null if not available. Guaranteed not to throw any Exception except for null arguments; useful for JSPs.


DHD Multimedia Gallery V1.57.21

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