com.facetmap.simple
Class SimpleFacetmap

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

public class SimpleFacetmap
extends MapAdapter


Nested Class Summary
static class SimpleFacetmap.SimpleXmlConverter
           
 
Nested classes inherited from class com.facetmap.simple.MapAdapter
MapAdapter.Fbond
 
Field Summary
protected  FacetSpace facetSpace
           
static java.lang.String INFO
           
protected static InternalException NO_PREPROCESS
           
 
Fields inherited from class com.facetmap.simple.MapAdapter
autoSelectOnlyChild, resourceSpace, showEmptySelections, title
 
Constructor Summary
SimpleFacetmap()
           
 
Method Summary
static Map createFromXml(java.io.InputStream inputStream, java.net.URL docsUrl, java.io.File workDir)
           
static Map createFromXml(java.lang.String xmlFile, java.net.URL docsUrl, java.io.File workDir)
           
 void fillSubset(SelectionData selectionData, int facetIndex)
          Populates a subset (containing all subselections) for a single facet.
 void fillSuperset(SelectionData selectionData, int facetIndex)
          Populates a subset (containing all subselections) for a single facet.
 Resource[] getAllResources(Selection sel)
          this is not useful.
 Resource[] getDirectResources(Selection sel)
          Returns the Resources directly contained by this selection.
 FacetSpace getFacetSpace()
           
 java.lang.String getInfo()
          Implementation-specific string for this FacetMap class.
 int getResultLimit()
           
 Selection getRootSelection()
          Generates the Selection with ref "" (the empty string).
 Selection getSelection(Heading[] headingList)
           
 Selection getSelection(java.lang.String ref)
           
 SelectionData getSubselectionContainingHeading(SelectionData parentSelection, Heading heading, int facetIndex)
          Find the forward Selection of parentSelection that contains heading.
 boolean isSelected(TaxonomicHeading heading, SelectionData selection, SelectionData[] subselection)
          Determines whether the Heading is selected (either matched or contained) in the specified Selection.
 void map(Resource[] resources)
          Maps headings for multiple resources.
 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.
 
Methods inherited from class com.facetmap.simple.MapAdapter
countAllResources, doEndMap, doStartMap, getAutoSelectOnlyChild, getResourceSpace, getShowEmptySelections, getTitle, map, setAutoSelectOnlyChild, setResourceSpace, setShowEmptySelections, setTitle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INFO

public static java.lang.String INFO

NO_PREPROCESS

protected static InternalException NO_PREPROCESS

facetSpace

protected FacetSpace facetSpace
Constructor Detail

SimpleFacetmap

public SimpleFacetmap()
Method Detail

createFromXml

public static Map createFromXml(java.lang.String xmlFile,
                                java.net.URL docsUrl,
                                java.io.File workDir)
                         throws java.io.IOException,
                                DataException,
                                InternalException
Throws:
java.io.IOException
DataException
InternalException

createFromXml

public static Map createFromXml(java.io.InputStream inputStream,
                                java.net.URL docsUrl,
                                java.io.File workDir)
                         throws java.io.IOException,
                                DataException,
                                InternalException
Throws:
java.io.IOException
DataException
InternalException

fillSuperset

public void fillSuperset(SelectionData selectionData,
                         int facetIndex)
Populates a subset (containing all subselections) for a single facet. Call this once per facet.


fillSubset

public void fillSubset(SelectionData selectionData,
                       int facetIndex)
Populates a subset (containing all subselections) for a single facet. Call this once per facet.


isSelected

public boolean isSelected(TaxonomicHeading heading,
                          SelectionData selection,
                          SelectionData[] subselection)
                   throws InternalException
Determines whether the Heading is selected (either matched or contained) in the specified Selection. If it is contained in a subselection, subselection[0] will be set to that subselection; otherwise it will be set to null. It will not be set at all if this function returns false. (Be sure to allocate subselection.

The restriction to TaxonomicHeading is done for performance reasons. It makes sense to accept any Heading and then refer to heading.getBackwardHeadings().nextElement() instead of to heading.getParentHeading() , but that causes too much construction within SimpleTaxHeading. FIXME so that SimpleTaxHeading provides it backward headings more efficiently, and then reclass the heading argument.

Recursion would be cute but heavier. REVISIT anyway.

Throws:
InternalException

getSubselectionContainingHeading

public SelectionData getSubselectionContainingHeading(SelectionData parentSelection,
                                                      Heading heading,
                                                      int facetIndex)
                                               throws InternalException
Find the forward Selection of parentSelection that contains heading.

facetIndex param could be determined from heading, but is passed in for performance reasons. Unknown behavior if facetIndex != this.facetSpace.indexOf(heading.getFacet());

Would be nice to relocate this to SelectionData, but too much information is in this class, e.g. facetIndex of the specified Heading.

Throws:
InternalException

getFacetSpace

public FacetSpace getFacetSpace()
Specified by:
getFacetSpace in interface Map
Specified by:
getFacetSpace in class MapAdapter

getResultLimit

public int getResultLimit()

getRootSelection

public Selection getRootSelection()
                           throws InternalException
Generates the Selection with ref "" (the empty string). TODO cache this and determine when it's safe to retrieve from cache.

Specified by:
getRootSelection in interface Map
Specified by:
getRootSelection in class MapAdapter
Throws:
InternalException

getSelection

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

getSelection

public Selection getSelection(Heading[] headingList)
                       throws DataException
Throws:
DataException

getDirectResources

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

Specified by:
getDirectResources in interface Map
Specified by:
getDirectResources in class MapAdapter
Throws:
InternalException

getAllResources

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

Specified by:
getAllResources in interface Map
Specified by:
getAllResources in class MapAdapter
Throws:
InternalException

map

public 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
Specified by:
map in class MapAdapter
Throws:
InternalException

map

public void map(Resource[] resources)
         throws InternalException,
                DataException
Description copied from class: MapAdapter
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
Overrides:
map in class MapAdapter
Throws:
InternalException
DataException

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
Overrides:
preprocess in class MapAdapter
Throws:
InternalException
DataException

getInfo

public java.lang.String getInfo()
Implementation-specific string for this FacetMap class.