com.facetmap.simple
Class MapAdapter

java.lang.Object
  extended bycom.facetmap.simple.MapAdapter
All Implemented Interfaces:
Map
Direct Known Subclasses:
SimpleFacetmap

public abstract class MapAdapter
extends java.lang.Object
implements Map

Convenience superclass; provides default implementations of many Map methods. Many of the method implementations here can be made more efficient in a subclass, depending on its underlying persistence layer. Also, this class allows use of a foreign ResourceSpace module, by way of setResourceSpace().


Nested Class Summary
 class MapAdapter.Fbond
           
 
Field Summary
protected  boolean autoSelectOnlyChild
           
protected  ResourceSpace resourceSpace
           
protected  boolean showEmptySelections
           
protected  java.lang.String title
           
 
Constructor Summary
MapAdapter()
           
 
Method Summary
 int countAllResources(Selection sel)
          Default simply calls Selection.getContainedResourceCount() .
 void doEndMap()
          Empty implementation.
 void doStartMap()
          Empty implementation.
abstract  Resource[] getAllResources(Selection sel)
          this is not useful.
 boolean getAutoSelectOnlyChild()
          Return current value of autoSelectOnlyChild.
abstract  Resource[] getDirectResources(Selection sel)
          Returns the Resources directly contained by this selection.
abstract  FacetSpace getFacetSpace()
           
 ResourceSpace getResourceSpace()
           
abstract  Selection getRootSelection()
          Produce a root Selection for the FacetSpace contained in the given facetmap.
abstract  Selection getSelection(java.lang.String ref)
           
 boolean getShowEmptySelections()
          Return current value of showEmptySelections.
 java.lang.String getTitle()
          A descriptive title for this FacetMap instance.
 void map(Resource resource)
          Maps a resource to all its headings at once.
 void map(Resource[] resources)
          Maps headings for multiple resources.
abstract  void map(Resource resource, Heading heading)
          Establishes a bond between a resource and a heading.
 void preprocess()
          Does any calculation that needs to be done before the map can be browsed.
 void setAutoSelectOnlyChild(boolean set)
          If this parameter is set true, FacetMap will avoid the situation where there's only one possible next step in any dimension, by automatically selecting that next step and presenting the options from there.
 void setResourceSpace(ResourceSpace resourceSpace)
           
 void setShowEmptySelections(boolean set)
          If this parameter is set true, FacetMap may provide Selections with which no Resources can be reached.
 void setTitle(java.lang.String title)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.facetmap.Map
getInfo, getSelection
 

Field Detail

title

protected java.lang.String title

resourceSpace

protected ResourceSpace resourceSpace

autoSelectOnlyChild

protected boolean autoSelectOnlyChild

showEmptySelections

protected boolean showEmptySelections
Constructor Detail

MapAdapter

public MapAdapter()
Method Detail

getFacetSpace

public abstract FacetSpace getFacetSpace()
Specified by:
getFacetSpace in interface Map

preprocess

public void preprocess()
                throws InternalException,
                       DataException
Description copied from interface: Map
Does any calculation that needs to be done before the map can be browsed. This is the place to load interim data into database, or any other task that makes it easier to serve a Selection at runtime. This method generally invokes doStartMap(), map(), and doEndMap() internally; most applications will only need to call preprocess() .

Specified by:
preprocess in interface Map
Throws:
InternalException
DataException

doStartMap

public void doStartMap()
                throws InternalException
Empty implementation.

Specified by:
doStartMap in interface Map
Throws:
InternalException

doEndMap

public void doEndMap()
              throws InternalException
Empty implementation.

Specified by:
doEndMap in interface Map
Throws:
InternalException

map

public abstract void map(Resource resource,
                         Heading heading)
                  throws InternalException
Description copied from interface: Map
Establishes a bond between a resource and a heading.

Specified by:
map in interface Map
Throws:
InternalException

getDirectResources

public abstract Resource[] getDirectResources(Selection sel)
                                       throws InternalException
Returns the Resources directly contained by this selection. The Selection's Headings must have correct ranges.

Specified by:
getDirectResources in interface Map
Throws:
InternalException

getAllResources

public abstract Resource[] getAllResources(Selection sel)
                                    throws InternalException
Description copied from interface: Map
this is not useful.

Specified by:
getAllResources in interface Map
Throws:
InternalException

getRootSelection

public abstract Selection getRootSelection()
                                    throws InternalException
Description copied from interface: Map
Produce a root Selection for the FacetSpace contained in the given facetmap. In other words, the Selection returned will serve as a starting point for navigation. It should have no backward selections of its own.

Specified by:
getRootSelection in interface Map
Throws:
InternalException

getSelection

public abstract Selection getSelection(java.lang.String ref)
                                throws InternalException,
                                       UnknownReferenceException
Specified by:
getSelection in interface Map
Throws:
InternalException
UnknownReferenceException

map

public void map(Resource resource)
         throws InternalException,
                DataException
Maps a resource to all its headings at once. The headings must already be properly specified in the Resource.

The default implementation just calls map() separately for each heading in the array. Subclasses may want to do this in a more efficient manner.

Specified by:
map in interface Map
Throws:
InternalException
DataException

map

public void map(Resource[] resources)
         throws InternalException,
                DataException
Maps headings for multiple resources. The default implementation just loops through the array and calls map(Resource), but again, optimizations by subclasses are possible here. For example, SQL-based maps may reuse the same PreparedStatement for all Resources.

Specified by:
map in interface Map
Throws:
InternalException
DataException

countAllResources

public int countAllResources(Selection sel)
                      throws InternalException
Default simply calls Selection.getContainedResourceCount() .

Specified by:
countAllResources in interface Map
Throws:
InternalException

getTitle

public java.lang.String getTitle()
Description copied from interface: Map
A descriptive title for this FacetMap instance.

Specified by:
getTitle in interface Map

setTitle

public void setTitle(java.lang.String title)

getResourceSpace

public ResourceSpace getResourceSpace()
Specified by:
getResourceSpace in interface Map

setResourceSpace

public void setResourceSpace(ResourceSpace resourceSpace)

getAutoSelectOnlyChild

public boolean getAutoSelectOnlyChild()
Description copied from interface: Map
Return current value of autoSelectOnlyChild.

Specified by:
getAutoSelectOnlyChild in interface Map

getShowEmptySelections

public boolean getShowEmptySelections()
Description copied from interface: Map
Return current value of showEmptySelections.

Specified by:
getShowEmptySelections in interface Map

setAutoSelectOnlyChild

public void setAutoSelectOnlyChild(boolean set)
Description copied from interface: Map
If this parameter is set true, FacetMap will avoid the situation where there's only one possible next step in any dimension, by automatically selecting that next step and presenting the options from there. See getForwardSelections for the specific mechanism.

This value is false by default.

Specified by:
setAutoSelectOnlyChild in interface Map
See Also:
Selection.getForwardSelections(int)

setShowEmptySelections

public void setShowEmptySelections(boolean set)
Description copied from interface: Map
If this parameter is set true, FacetMap may provide Selections with which no Resources can be reached. (Of course, such an empty Selection may have backward Selections which contain Resources, but its forward Selections will not). If the parameter is false, the user is guaranteed to have results in every Selection.

This value is false by default.

Specified by:
setShowEmptySelections in interface Map
See Also:
Selection.getForwardSelections(int)