com.facetmap.sql
Class SqlSelection

java.lang.Object
  extended by com.facetmap.sql.SqlSelection
All Implemented Interfaces:
Selection

public class SqlSelection
extends java.lang.Object
implements Selection


Nested Class Summary
protected static class SqlSelection.IdIterator
           
static class SqlSelection.SubselectionResourceCount
           
 
Field Summary
protected  java.util.List[] backwardSelections
           
protected  java.util.List compoundHeadingsUsed
           
protected  int facetCount
           
protected  SqlFacetmap facetmap
           
protected  java.util.List[] forwardSelections
           
protected  java.util.Map headingMap
           
protected  java.util.Set[] headingSets
           
protected  java.util.Properties props
           
protected  RefCodec refCodec
           
protected  int resultCount
           
protected  java.util.List results
           
protected  boolean tagSelection
           
 
Constructor Summary
SqlSelection(SelectionData selectionData)
           
SqlSelection(SqlFacetmap facetmap)
           
SqlSelection(SqlFacetmap facetmap, java.util.Properties props, Heading[] headings)
           
 
Method Summary
protected  java.util.List findResults()
           
 java.util.Iterator getBackwardSelections(Facet facet)
          An Enumeration of the Selections that represent "backtracking" in navigation along the given dimension of facetspace.
 java.util.Iterator getBackwardSelections(int index)
          An array-oriented version of Selection.getHeadings(Facet) .
 int getFacetCount()
           
 Facetmap getFacetmap()
           
 java.util.Iterator getForwardSelections(Facet facet)
          An Enumeration of the Selections that are the possible "next steps" in navigation along the given dimension of facetspace.
 java.util.Iterator getForwardSelections(int index)
          An array-oriented version of Selection.getHeadings(Facet) .
 Heading[] getHeadings()
           
 Heading[] getHeadings(Facet facet)
          Returns the Heading(s) of this selection in a specified facet.
 Heading[] getHeadings(int index)
          An array-oriented version of Selection.getHeadings(Facet) .
 java.util.Properties getProperties()
          The properties that were used in the creation of this Selection.
 java.lang.String getRef()
          Returns a String ID (known as a reference or "ref") that uniquely identifies the Headings used to construct this Selection.
 int getResourceCount()
          The number of Resources specified by the Headings in this Selection (regardless of any maximum specified by property com.facetmap.Selection.resultLimit).
 SelectedResourceIterator getResources()
          Presumes that there's enough memory to hold one Integer per record in the result set (capped by com.facetmap.Selection.resultLimit).
 java.util.List getSubsetResourceCount(int facetid)
          Returns a list of SubselectionResourceCount.
 boolean hasTagSelection()
           
 boolean isMasterRoot()
          Returns true if each of this Selection's Headings is the root Heading of its Facet.
protected  void setHeadings(Heading[] headings)
           
protected  void setOtherSelections()
           
protected  java.lang.String sqlFilterClause()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

facetmap

protected SqlFacetmap facetmap

props

protected java.util.Properties props

facetCount

protected int facetCount

headingSets

protected java.util.Set[] headingSets

headingMap

protected java.util.Map headingMap

refCodec

protected RefCodec refCodec

tagSelection

protected boolean tagSelection

compoundHeadingsUsed

protected java.util.List compoundHeadingsUsed

forwardSelections

protected java.util.List[] forwardSelections

backwardSelections

protected java.util.List[] backwardSelections

resultCount

protected int resultCount

results

protected java.util.List results
Constructor Detail

SqlSelection

public SqlSelection(SqlFacetmap facetmap)
             throws UnknownReferenceException
Throws:
UnknownReferenceException

SqlSelection

public SqlSelection(SqlFacetmap facetmap,
                    java.util.Properties props,
                    Heading[] headings)

SqlSelection

public SqlSelection(SelectionData selectionData)
Method Detail

setHeadings

protected void setHeadings(Heading[] headings)

setOtherSelections

protected void setOtherSelections()
                           throws InternalException
Throws:
InternalException

findResults

protected java.util.List findResults()
                              throws InternalException
Throws:
InternalException

hasTagSelection

public boolean hasTagSelection()

getResourceCount

public int getResourceCount()
                     throws InternalException
Description copied from interface: Selection
The number of Resources specified by the Headings in this Selection (regardless of any maximum specified by property com.facetmap.Selection.resultLimit).

This could be regarded as just a special case of getResourceWeight() , but of course it's by far the most common and we want a method that returns an int.

Specified by:
getResourceCount in interface Selection
Throws:
InternalException

getSubsetResourceCount

public java.util.List getSubsetResourceCount(int facetid)
Returns a list of SubselectionResourceCount. This should probably go into SqlFacet.


sqlFilterClause

protected java.lang.String sqlFilterClause()

getBackwardSelections

public java.util.Iterator getBackwardSelections(Facet facet)
                                         throws InternalException,
                                                java.lang.ArrayIndexOutOfBoundsException
Description copied from interface: Selection
An Enumeration of the Selections that represent "backtracking" in navigation along the given dimension of facetspace. Exactly what "backtracking" entails is a little dependent on the type of Facet used in this dimension. It is never required that a returned Selection be a Selection already visited by the user; see the notes on directionality in Facet.

Specified by:
getBackwardSelections in interface Selection
Throws:
InternalException
java.lang.ArrayIndexOutOfBoundsException
See Also:
Facet

getBackwardSelections

public java.util.Iterator getBackwardSelections(int index)
                                         throws InternalException,
                                                java.lang.ArrayIndexOutOfBoundsException
Description copied from interface: Selection
An array-oriented version of Selection.getHeadings(Facet) . Provide the ordinal index number of the Facet within the FacetSpace, instead of the Facet itself.

Specified by:
getBackwardSelections in interface Selection
Throws:
InternalException
java.lang.ArrayIndexOutOfBoundsException

getForwardSelections

public java.util.Iterator getForwardSelections(Facet facet)
                                        throws InternalException,
                                               java.lang.ArrayIndexOutOfBoundsException
Description copied from interface: Selection
An Enumeration of the Selections that are the possible "next steps" in navigation along the given dimension of facetspace.

If property com.facetmap.Selection.autoSelectOnlyChild is set true, then this method may not return exactly one Selection (an "only child"). If it would ordinarily return an only child, it must return the forward selections of that child (and act recursively until the size of the result set is not one).

If property com.facetmap.Selection.showEmptySelections is set true, this method will return all possible forward Selections in the Facet, even those that contain no resources (as defined by getContainedResources). Otherwise, Selections with no contained resources must not appear in the result.

Specified by:
getForwardSelections in interface Selection
Throws:
InternalException
java.lang.ArrayIndexOutOfBoundsException

getForwardSelections

public java.util.Iterator getForwardSelections(int index)
                                        throws InternalException,
                                               java.lang.ArrayIndexOutOfBoundsException
Description copied from interface: Selection
An array-oriented version of Selection.getHeadings(Facet) . Provide the ordinal index number of the Facet within the FacetSpace, instead of the Facet itself.

Specified by:
getForwardSelections in interface Selection
Throws:
InternalException
java.lang.ArrayIndexOutOfBoundsException

getResources

public SelectedResourceIterator getResources()
                                      throws InternalException
Presumes that there's enough memory to hold one Integer per record in the result set (capped by com.facetmap.Selection.resultLimit).

Specified by:
getResources in interface Selection
Throws:
InternalException

getHeadings

public Heading[] getHeadings(int index)
                      throws java.lang.ArrayIndexOutOfBoundsException
Description copied from interface: Selection
An array-oriented version of Selection.getHeadings(Facet) . Provide the ordinal index number of the Facet within the FacetSpace, instead of the Facet itself.

Specified by:
getHeadings in interface Selection
Throws:
java.lang.ArrayIndexOutOfBoundsException

getHeadings

public Heading[] getHeadings(Facet facet)
                      throws java.lang.ArrayIndexOutOfBoundsException
Description copied from interface: Selection
Returns the Heading(s) of this selection in a specified facet. The returned array always contains at least one Heading -- if no Heading from the specified facet was used to create this Selection, then the root Heading is returned. In other words, it's always safe to reference getHeading(facet)[0] as a non-null Heading.

Note that the return value, because it is an array, can be modified. However, modifying it does not change the state of this underlying Selection. Implementors of Selection should take care that this rule is enforced.

Specified by:
getHeadings in interface Selection
Throws:
java.lang.ArrayIndexOutOfBoundsException

getHeadings

public Heading[] getHeadings()

getFacetCount

public int getFacetCount()
Specified by:
getFacetCount in interface Selection

getFacetmap

public Facetmap getFacetmap()
Specified by:
getFacetmap in interface Selection

getProperties

public java.util.Properties getProperties()
Description copied from interface: Selection
The properties that were used in the creation of this Selection. This set of properties can be different from the set that was specified in Facetmap.getSelection() because the facetmap may not recognize or honor all properties; see that method for details.

Specified by:
getProperties in interface Selection
See Also:
Facetmap.getSelection(Heading[], Properties)

getRef

public java.lang.String getRef()
Description copied from interface: Selection
Returns a String ID (known as a reference or "ref") that uniquely identifies the Headings used to construct this Selection. Consumers may use this ref string to implement their own serialization.

The reference does not contain information about the Properties used in this selection. If desired, those must be serialized separately.

Specified by:
getRef in interface Selection

isMasterRoot

public boolean isMasterRoot()
Description copied from interface: Selection
Returns true if each of this Selection's Headings is the root Heading of its Facet.

Specified by:
isMasterRoot in interface Selection
See Also:
Facet.getRootHeading()