com.facetmap.simple
Class SelectionData

java.lang.Object
  extended bycom.facetmap.simple.SelectionData
All Implemented Interfaces:
Selection

public class SelectionData
extends java.lang.Object
implements Selection

A class intended for storage of Selection state. There's very little logic in here; it just accepts data and spits it out on request. It will do a bit of dynamic allocation when you set its facetmap, and it does have a rudimentary system to encode and decode its own ref.

Consider adding an equals() implementation and other basics.


Field Summary
 int facetCount
           
 Map facetmap
           
 Heading[] headings
           
static java.lang.String REF_DELIM
           
 int resultCount
           
 int resultLimit
           
 java.util.ArrayList results
           
 java.util.List subsets
          List of Vectors of Selections, one Collection per facet
 java.util.List supersets
          List of Vectors of Selections, one Collection per facet
 
Constructor Summary
SelectionData()
          Construct a SelectionData with no state defined at all.
SelectionData(Map facetmap)
          Create a SelectionData with default or null values.
 
Method Summary
 boolean containsAnyResources()
           
 void decodeRef(java.lang.String refCode)
          Sets the Headings of this Selection according to the given ref.
 java.util.Enumeration getBackwardSelections(int index)
          An Enumeration of the Selections that represent "backtracking" in navigation along the given dimension of facetspace.
 int getContainedResourceCount()
           
 Resource[] getContainedResources()
          This selection's result set should never exceed the limit specified by resultLimit.
 int getDimensionCount()
           
 java.util.Enumeration getForwardSelections(int index)
          An Enumeration of the Selections that are the possible "next steps" in navigation along the given dimension of facetspace.
 Heading getHeading(int index)
          Returns the Heading along the given dimension of facetspace.
 Map getMap()
           
 int getMatchedResourceCount()
           
 Resource[] getMatchedResources()
          If each of a Resource's Headings match this Selection's Headings, then that Resource is included in the returned array.
 java.lang.String getRef()
          Returns a String ID (known as a reference or "ref") that uniquely identifies this Selection.
 java.util.Collection getSubset(int facetIndex)
           
 java.util.Collection getSuperset(int facetIndex)
           
 boolean isMasterRoot()
          Returns true if each of this Selection's Headings is the Root of its Facet.
 boolean matchesAnyResources()
           
 void setHeading(Heading heading)
          Sets the given Heading as a Heading of this Selection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REF_DELIM

public static final java.lang.String REF_DELIM
See Also:
Constant Field Values

facetCount

public int facetCount

headings

public Heading[] headings

supersets

public java.util.List supersets
List of Vectors of Selections, one Collection per facet


subsets

public java.util.List subsets
List of Vectors of Selections, one Collection per facet


resultCount

public int resultCount

resultLimit

public int resultLimit

results

public java.util.ArrayList results

facetmap

public Map facetmap
Constructor Detail

SelectionData

public SelectionData()
Construct a SelectionData with no state defined at all. May be unstable. For low-level operations only. Not too useful unless a Selection is being built at the same time as its facetmap.


SelectionData

public SelectionData(Map facetmap)
Create a SelectionData with default or null values.

Method Detail

getSuperset

public java.util.Collection getSuperset(int facetIndex)

getSubset

public java.util.Collection getSubset(int facetIndex)

getHeading

public Heading getHeading(int index)
                   throws java.lang.ArrayIndexOutOfBoundsException
Returns the Heading along the given dimension of facetspace.

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

getMap

public Map getMap()
Specified by:
getMap in interface Selection

getDimensionCount

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

setHeading

public void setHeading(Heading heading)
                throws java.lang.IllegalArgumentException
Sets the given Heading as a Heading of this Selection. The given Heading replaces any Heading that is from the same Facet.

Specified by:
setHeading in interface Selection
Throws:
java.lang.IllegalArgumentException

isMasterRoot

public boolean isMasterRoot()
Returns true if each of this Selection's Headings is the Root of its Facet.

Specified by:
isMasterRoot in interface Selection
See Also:
Facet#getRootHeading

getRef

public java.lang.String getRef()
Returns a String ID (known as a reference or "ref") that uniquely identifies this Selection.

Specified by:
getRef in interface Selection

decodeRef

public void decodeRef(java.lang.String refCode)
               throws UnknownReferenceException
Sets the Headings of this Selection according to the given ref.

Specified by:
decodeRef in interface Selection
Throws:
UnknownReferenceException

getMatchedResourceCount

public int getMatchedResourceCount()
                            throws InternalException
Specified by:
getMatchedResourceCount in interface Selection
Throws:
InternalException

getContainedResourceCount

public int getContainedResourceCount()
                              throws InternalException
Specified by:
getContainedResourceCount in interface Selection
Throws:
InternalException

containsAnyResources

public boolean containsAnyResources()
                             throws InternalException
Specified by:
containsAnyResources in interface Selection
Throws:
InternalException

matchesAnyResources

public boolean matchesAnyResources()
                            throws InternalException
Specified by:
matchesAnyResources in interface Selection
Throws:
InternalException

getForwardSelections

public java.util.Enumeration getForwardSelections(int index)
                                           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 autoSelectOnlyChild is set true on this Selection's Map, 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 showEmptySelections is set true on this Selection's Map, this method will return all possible forward Selections, 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
See Also:
Map.setAutoSelectOnlyChild(boolean), Map.setShowEmptySelections(boolean)

getBackwardSelections

public java.util.Enumeration getBackwardSelections(int index)
                                            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

getMatchedResources

public Resource[] getMatchedResources()
                               throws InternalException
Description copied from interface: Selection
If each of a Resource's Headings match this Selection's Headings, then that Resource is included in the returned array.

Specified by:
getMatchedResources in interface Selection
Throws:
InternalException

getContainedResources

public Resource[] getContainedResources()
                                 throws InternalException
This selection's result set should never exceed the limit specified by resultLimit. If for some reason it does, there are safeguards to make sure the code doesn't break; however, the returned array will be the size of resultCount, not resultCount. We can fix this pretty easily within this method, if it becomes a priority.

Specified by:
getContainedResources in interface Selection
Throws:
InternalException