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

java.lang.Object
  extended by org.hd.d.pg2k.webSvr.catalogue.PaginationBeanBase
      extended by org.hd.d.pg2k.webSvr.catalogue.PaginationBeanTree
All Implemented Interfaces:
java.io.Serializable

public final class PaginationBeanTree
extends PaginationBeanBase

Provides pagination to be used in conjunction with (tree-structured) browsable exhibit collections. A specialisation of PaginationBeanBase that provides pagination for nodes created with the TreeFilterBean that creates alphanumeric labels based on distinguishing prefixes of the leaves of the node, intended to be as short as possible but give the user a large hint as to the full set of available choices even when only a tiny fraction of the choices (page buttons) can be shown.

See Also:
TreeFilterBean, PaginationBeanNumeric, Serialized Form

Field Summary
static boolean LABEL_ALL_LC
          If true, convert all page labels to lower-case rather than allowing mixed case.
static int LABEL_MIN_LEN
          Minimum letters in label, but only up to first word boundary.
private  Name nodePrefix
          Store of prefix for the current node.
private  java.util.List<java.lang.CharSequence> prefixList
          Store of prefix list.
static java.lang.String SAFE_LABEL
          Safe page value that will be interpreted as page 1.
private static long serialVersionUID
          Unique Serialisation class ID generated by http://random.hd.org/.
 
Constructor Summary
PaginationBeanTree()
           
 
Method Summary
 java.lang.String getPageLabel(int pageNum)
          Return the page label as a String for the given page (1 upwards), never null; the page must be in range else the result is undefined.
 int getPageNumber(java.lang.String s)
          Get the page number as a from the String label; in case of bad input return 1.
 void setNumberOfItems()
          Don't call this directly; use setTreeNodeDetails() instead.
 void setTreeNodeDetails(java.lang.CharSequence prefix, java.util.List<java.lang.CharSequence> prefixesAndShortExhibitName)
          Given a List of CharSequence prefixes and Name.ExhibitShort short exhibit names as produced by TreeFilterBean, enables computation of the page labels.
 
Methods inherited from class org.hd.d.pg2k.webSvr.catalogue.PaginationBeanBase
getEndIndex, getNumberOfItems, getNumberOfPages, getPageLabels, getPageNumbers, getPg, getStartIndex, setNumberOfItems, setPg, setPg
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LABEL_ALL_LC

public static final boolean LABEL_ALL_LC
If true, convert all page labels to lower-case rather than allowing mixed case.

See Also:
Constant Field Values

LABEL_MIN_LEN

public static final int LABEL_MIN_LEN
Minimum letters in label, but only up to first word boundary.

See Also:
Constant Field Values

nodePrefix

private Name nodePrefix
Store of prefix for the current node. Default value is safe (Name.EMPTY, ie "").


prefixList

private java.util.List<java.lang.CharSequence> prefixList
Store of prefix list. Default value is safe (the empty list).


SAFE_LABEL

public static final java.lang.String SAFE_LABEL
Safe page value that will be interpreted as page 1. Should only be called on in case of difficulty.

Is not a valid prefix to avoid ambiguity.

See Also:
Constant Field Values

serialVersionUID

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

See Also:
Constant Field Values
Constructor Detail

PaginationBeanTree

public PaginationBeanTree()
Method Detail

setTreeNodeDetails

public void setTreeNodeDetails(java.lang.CharSequence prefix,
                               java.util.List<java.lang.CharSequence> prefixesAndShortExhibitName)
Given a List of CharSequence prefixes and Name.ExhibitShort short exhibit names as produced by TreeFilterBean, enables computation of the page labels. This replaces direct use of the setNumberOfItems() call.

This expects an (immutable) List of word-prefixes (as CharSequence) and short exhibit names (as Name.ExhibitShort), sorted in case-insensitive order, as produced by TreeFilterBean. Results are undefined if this is not the case.

All word-prefixes in the list must start with (case-insensitively) the supplied prefix for the node, the short-name part of each exhibit name must do too.

This caches the List that it is passed.

See Also:
TreeFilterBean

setNumberOfItems

public final void setNumberOfItems()
Don't call this directly; use setTreeNodeDetails() instead.


getPageLabel

public java.lang.String getPageLabel(int pageNum)
Return the page label as a String for the given page (1 upwards), never null; the page must be in range else the result is undefined. This will usually be the shortest prefix that will distinguish the first entry in the desired page from the first entry in the pages before and after.

(This may either be the shortest word prefix or the shortest character prefix.)

Specified by:
getPageLabel in class PaginationBeanBase

getPageNumber

public int getPageNumber(java.lang.String s)
Get the page number as a from the String label; in case of bad input return 1. We reconstruct the label set we generated and look up in that.

Specified by:
getPageNumber in class PaginationBeanBase

DHD Multimedia Gallery V1.57.21

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