org.hd.d.pg2k.svrCore.uploader
Class ExhibitHandlerBeanBase

java.lang.Object
  extended by org.hd.d.pg2k.svrCore.uploader.ExhibitHandlerBeanBase
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
SearchPageJavaBean, UploadInfoBean

public class ExhibitHandlerBeanBase
extends java.lang.Object
implements java.io.Serializable

Base for a JavaBean to handle exhibit data for search or upload. Unset items are empty strings rather than null for simplest handling in JSPs.

This is thread-safe and Serializable so as to be able to be stored in a servlet session; nothing especially long-lived or sensitive.

See Also:
Serialized Form

Field Summary
private  AllExhibitProperties aep
          The AllExhibitProperties data; never null.
private  java.util.List<java.lang.String> attributes
          List of attribute words (String), or empty if none; immutable.
private  java.lang.String author
          Author (initials) selected, or "" if none.
private  java.lang.String category
          Category selected, or "" if none.
protected  boolean onlyAllowExtant
          If true, limit selections to existing values in the database.
private static long serialVersionUID
          Unique Serialisation class ID generated by http://random.hd.org/.
static java.lang.String SETTER_ALL
          Used in a selector value or setter to mean all values or no item.
private  java.lang.String suffix
          Suffix selected (starting with ``.''), or "" if none (ie all types OK).
 
Constructor Summary
protected ExhibitHandlerBeanBase()
          Only allow selections from extant values.
protected ExhibitHandlerBeanBase(boolean _onlyAllowExtant)
          Choose whether new values of some fields are allowed.
 
Method Summary
 void dedupAttrs()
          Eliminates duplicate attribute words and sorts into lexical order.
 AllExhibitProperties getAep()
          Get the AllExhibitProperties; never null.
 java.lang.String[] getAllAuthors()
          Get all authors user is allowed to accept, sorted.
 java.lang.String[] getAllCategories()
          Get all categories user is allowed to accept, sorted.
 java.lang.String[] getAllSuffixes()
          Get all file suffixes user is allowed to select, sorted.
 java.lang.String getAttributeWords()
          Get attribute words as a valid string of hyphen-separated words; can be "" but never null.
 java.util.List<java.lang.String> getAttributeWordsAsList()
          Get attribute words as immutable List; can be zero-length but never null.
 java.lang.String getAuthor()
          Returns author (initials) selected, or "" if none.
 java.lang.String getCategory()
          Returns category selected, or "" if none.
 java.lang.String getInUseAttrWordListAsString(boolean inUse)
          Get all acceptable attribute words that are in use as a single String for display to the user.
 java.lang.String getLegalAttrWordListAsString()
          Get list of all acceptable attribute words as single String for display to user.
 java.lang.String getSuffix()
          Get suffix selected (starting with ``.''), or "" if none (ie all types OK).
 java.lang.String makeAttributeSelectBody(boolean inUse, java.lang.String selectedAttr)
          Generates body of attribute HTML select statement (dependent on old value, if any).
 java.lang.String makeAttributeSelectBody(boolean inUse, java.lang.String selectedAttr, LocaleBeanBase localeBean)
          Generates body of attribute HTML select statement (dependent on old value, if any).
 java.lang.String makeAuthorSelectBody()
          Generates body of author HTML select statement (dependent on old value, if any).
 java.lang.String makeCategorySelectBody()
          Generates body of category HTML select statement (dependent on old value, if any).
 java.lang.String makeCategorySelectBody(LocaleBeanBase localeBean)
          Generates body of category HTML select statement (dependent on old value, if any).
 java.lang.String makeSuffixSelectBody()
          Generates body of suffix HTML select statement (dependent on old value, if any).
 void setAep(AllExhibitProperties _aep)
          Set the AllExhibitProperties; ignored if null and must happen before other properties are set.
 void setAttributeWords(java.util.List<java.lang.String> words)
          Set attribute words; any invalid items will be silently discarded.
 void setAttributeWords(java.lang.String attributeWords)
          Set attribute words; valid string of hyphen-separated words; can be "" or null.
 void setAttributeWords(java.lang.String[] words)
          Set attribute words; any invalid items will be silently discarded.
 void setAuthor(java.lang.String auth)
          Set author (initials) selected, or "" or SETTER_ALL if none (ie all types OK).
 void setCategory(java.lang.String cat)
          Set category selected, or "" or SETTER_ALL if none (ie all types OK).
 void setCommonValuesForUnsetFields()
          For some unset values, set the most common value.
 void setSuffix(java.lang.String suf)
          Set suffix selected (starting with ``.''), or "" or SETTER_ALL if none (ie all types OK).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

onlyAllowExtant

protected final boolean onlyAllowExtant
If true, limit selections to existing values in the database. If false, a wider range of legal values is allowed.

If true, file types and authors can only be selected from ones already represented in the production database.


SETTER_ALL

public static final java.lang.String SETTER_ALL
Used in a selector value or setter to mean all values or no item.

See Also:
Constant Field Values

aep

private AllExhibitProperties aep
The AllExhibitProperties data; never null. Must be set before other property values are set.


suffix

private java.lang.String suffix
Suffix selected (starting with ``.''), or "" if none (ie all types OK).


author

private java.lang.String author
Author (initials) selected, or "" if none.


category

private java.lang.String category
Category selected, or "" if none.


attributes

private java.util.List<java.lang.String> attributes
List of attribute words (String), or empty if none; immutable. We preserve order and repetition unless the dedupAttrs() call is made.

This item may be replaced but is not mutated in situ and is immutable and so can be safely handed out to callers.


serialVersionUID

private static final long serialVersionUID
Unique Serialisation class ID generated by http://random.hd.org/.

See Also:
Constant Field Values
Constructor Detail

ExhibitHandlerBeanBase

protected ExhibitHandlerBeanBase(boolean _onlyAllowExtant)
Choose whether new values of some fields are allowed.


ExhibitHandlerBeanBase

protected ExhibitHandlerBeanBase()
Only allow selections from extant values.

Method Detail

setCommonValuesForUnsetFields

public void setCommonValuesForUnsetFields()
For some unset values, set the most common value. Can be overridden for values unique to derived classes. Any overriding method should hold the instance lock to avoid races.

Should only be called in selected environments where an empty value is not useful anyway (eg not valid as a wildcard).


setAep

public void setAep(AllExhibitProperties _aep)
Set the AllExhibitProperties; ignored if null and must happen before other properties are set.


getAep

public AllExhibitProperties getAep()
Get the AllExhibitProperties; never null.


getAllSuffixes

public java.lang.String[] getAllSuffixes()
Get all file suffixes user is allowed to select, sorted. If onlyAllowExtant is true, only file types in the database can be selected, else all acceptable types can be selected.


getSuffix

public java.lang.String getSuffix()
Get suffix selected (starting with ``.''), or "" if none (ie all types OK).


setSuffix

public void setSuffix(java.lang.String suf)
Set suffix selected (starting with ``.''), or "" or SETTER_ALL if none (ie all types OK). If the suffix is invalid it is ignored.


makeSuffixSelectBody

public java.lang.String makeSuffixSelectBody()
Generates body of suffix HTML select statement (dependent on old value, if any). Assumed not to require localisation or internationalisation.


getAllAuthors

public java.lang.String[] getAllAuthors()
Get all authors user is allowed to accept, sorted.


getAuthor

public java.lang.String getAuthor()
Returns author (initials) selected, or "" if none.


setAuthor

public void setAuthor(java.lang.String auth)
Set author (initials) selected, or "" or SETTER_ALL if none (ie all types OK). If the author is invalid it is ignored.


makeAuthorSelectBody

public java.lang.String makeAuthorSelectBody()
Generates body of author HTML select statement (dependent on old value, if any). Assumed not to require localisation or internationalisation.


getAllCategories

public java.lang.String[] getAllCategories()
Get all categories user is allowed to accept, sorted.


getCategory

public java.lang.String getCategory()
Returns category selected, or "" if none.


setCategory

public void setCategory(java.lang.String cat)
Set category selected, or "" or SETTER_ALL if none (ie all types OK). If the category is invalid it is ignored.


makeCategorySelectBody

public java.lang.String makeCategorySelectBody()
Generates body of category HTML select statement (dependent on old value, if any). This version does not use a LocaleBean.

Assumed not to require localisation or internationalisation.

We munge the categories for display by stripping any non-alphanumerics (actually just ``-'' and ``_'') and converting everything to lower-case.


makeCategorySelectBody

public java.lang.String makeCategorySelectBody(LocaleBeanBase localeBean)
Generates body of category HTML select statement (dependent on old value, if any). Assumed not to require localisation or internationalisation.

We munge the categories for display by stripping any non-alphanumerics (actually just ``-'' and ``_'') and converting everything to lower-case.

Parameters:
localeBean - if non-null, used to lookup and localise attribute descriptions

makeAttributeSelectBody

public java.lang.String makeAttributeSelectBody(boolean inUse,
                                                java.lang.String selectedAttr)
Generates body of attribute HTML select statement (dependent on old value, if any). This version does not take a localeBean.

Assumed not to require localisation or internationalisation.

We assume that all attribute words are safe for use as values.

We explicitly pass in the attribute word we want selected, or SETTER_ALL (or null) to select the default.

Parameters:
inUse - if true, only attributes currently in use in the Gallery will be includes, else all legal attributes will be included
selectedAttr - if non-null and not SETTER_ALL and and attribute in the final select list, causes that item to be selected by default

makeAttributeSelectBody

public java.lang.String makeAttributeSelectBody(boolean inUse,
                                                java.lang.String selectedAttr,
                                                LocaleBeanBase localeBean)
Generates body of attribute HTML select statement (dependent on old value, if any). Assumed not to require localisation or internationalisation.

We assume that all attribute words are safe for use as values.

We explicitly pass in the attribute word we want selected, or SETTER_ALL (or null) to select the default.

Parameters:
inUse - if true, only attributes currently in use in the Gallery will be includes, else all legal attributes will be included
selectedAttr - if non-null and not SETTER_ALL and and attribute in the final select list, causes that item to be selected by default
localeBean - if non-null, used to lookup and localise attribute descriptions

getInUseAttrWordListAsString

public java.lang.String getInUseAttrWordListAsString(boolean inUse)
Get all acceptable attribute words that are in use as a single String for display to the user. This returns the list of attribute words in use in the Gallery exhibits if inUse is true, else it returns the list of attribute words not currently in use though legal.

The result is a space-separated sorted list.

This returns the empty string if no list is available.


getLegalAttrWordListAsString

public java.lang.String getLegalAttrWordListAsString()
Get list of all acceptable attribute words as single String for display to user. This displays the legal attribute word set in sorted order, space-separated, for display to a user (eg in an HTML page).

This returns the empty string if no list is available.


dedupAttrs

public void dedupAttrs()
Eliminates duplicate attribute words and sorts into lexical order. Must only be called once the attributes have been set.

Assumes all entries are valid ie are non-null, legal attribute words.

Idempotent.


getAttributeWordsAsList

public java.util.List<java.lang.String> getAttributeWordsAsList()
Get attribute words as immutable List; can be zero-length but never null. All words are valid attribute words (at least when they were set) and the trailing one will not be a number.


getAttributeWords

public java.lang.String getAttributeWords()
Get attribute words as a valid string of hyphen-separated words; can be "" but never null. All words are valid attribute words (at least when they were set) and the trailing one will not be a number.


setAttributeWords

public void setAttributeWords(java.lang.String[] words)
Set attribute words; any invalid items will be silently discarded. Any existing attribute words held by this bean are removed first.

The argument may not be null nor contain nulls.


setAttributeWords

public void setAttributeWords(java.util.List<java.lang.String> words)
Set attribute words; any invalid items will be silently discarded. Any existing attribute words held by this bean are removed first.

The argument may not be null nor contain nulls.


setAttributeWords

public void setAttributeWords(java.lang.String attributeWords)
Set attribute words; valid string of hyphen-separated words; can be "" or null. Use null or "" or SETTER_ALL to clear this field.

All words must be attribute words and the trailing one may not be a number.

Any items that are not valid attribute words will just be silently deleted.

Any non-valid word characters (eg including spaces) will be converted to hyphens.

This tries very hard to keep as much of its input as possible.


DHD Multimedia Gallery V1.57.21

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