|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.facetmap.simple.SimpleFacetmap
public class SimpleFacetmap
SimpleFacetmap stores all facetmap data as internal object state, and provides Facetmap reference implementations which basically query internal state a lot. This makes the class well-suited to representing (and passing around) the data in a Facetmap, and also to doing queries on small facetmaps or prototypes.
It isn't so good for production environments, but it makes a good base class upon which to write higher-performance Facetmap code.
| Field Summary | |
|---|---|
protected FacetSpace |
facetSpace
|
static java.lang.String |
INFO
|
protected RefCodec |
refCodec
|
protected ResourceSpace |
resourceSpace
|
protected java.util.Properties |
selectionProps
|
protected java.lang.String |
title
|
| Constructor Summary | |
|---|---|
protected |
SimpleFacetmap()
|
|
SimpleFacetmap(java.lang.String title,
ResourceSpace resourceSpace)
Quick construction of SimpleFacetmap. |
|
SimpleFacetmap(java.lang.String title,
ResourceSpace resourceSpace,
java.util.Properties defaultSelectionProperties)
Quick construction of SimpleFacetmap. |
| Method Summary | |
|---|---|
void |
applyHeadingsToSelection(SelectionData selection,
Heading[] headings)
|
void |
applyHeadingsToSelection(SelectionData selection,
java.util.Set[] headingSets)
|
void |
applyPropertiesToSelection(SelectionData selection,
java.util.Properties props)
|
static boolean |
booleanProperty(java.util.Properties props,
java.lang.String propKey)
The boolean returned represents the value true if the property value is not null and is equal, ignoring case, to the string "true". |
void |
defineBackwardSelections(SelectionData selectionData,
int facetIndex)
Creates all backward selections in a single facet, and sets their headings, but no other information (e.g. |
void |
defineForwardSelections(SelectionData selectionData,
int facetIndex)
Creates all forward selections in a single facet, and sets their headings, but no other information (e.g. |
Heading |
getCommonAncestor(java.util.Collection headings)
Returns the heading that is the closest (most specific) ancestor of all the input headings. |
FacetSpace |
getFacetSpace()
|
java.lang.String |
getInfo()
Implementation-specific string for this FacetMap class. |
ResourceSpace |
getResourceSpace()
|
Selection |
getRootSelection()
Produce a root Selection, a starting point for browsing this Facetmap. |
Selection |
getRootSelection(java.util.Properties props)
Caches root selection for the life of the SimpleFacetmap object, which underscores the intended immutability of SimpleFacetmap. |
Selection |
getSelection(Heading[] headingList)
Generate a Selection that contains Resources which match the specified Headings, according to the following logic. |
Selection |
getSelection(Heading[] headingList,
java.util.Properties props)
This is the basic getSelection call. |
Selection |
getSelection(java.lang.String ref)
Get a Selection defined by string ref. |
Selection |
getSelection(java.lang.String ref,
java.util.Properties properties)
Get a Selection defined by string ref and subject
to special restrictions in properties. |
java.util.Properties |
getSelectionProps()
|
java.lang.String |
getTitle()
A descriptive title for this Facetmap instance. |
boolean |
headingIsAncestorOfHeading(Heading ancestor,
Heading child)
|
static int |
intProperty(java.util.Properties props,
java.lang.String propKey,
int defaultValue)
|
boolean |
isSelectedInFacet(Heading heading,
SelectionData selection,
java.util.Set subselections)
Determines whether the Heading is selected (either matched or contained) in the specified Selection. |
void |
removeEmptySelections(SelectionData selection)
|
void |
setResourceSpace(ResourceSpace resourceSpace)
|
void |
setSelectionProps(java.util.Properties selectionProps)
|
void |
setTitle(java.lang.String title)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static java.lang.String INFO
protected java.lang.String title
protected FacetSpace facetSpace
protected ResourceSpace resourceSpace
protected java.util.Properties selectionProps
protected RefCodec refCodec
| Constructor Detail |
|---|
protected SimpleFacetmap()
public SimpleFacetmap(java.lang.String title,
ResourceSpace resourceSpace,
java.util.Properties defaultSelectionProperties)
public SimpleFacetmap(java.lang.String title,
ResourceSpace resourceSpace)
| Method Detail |
|---|
public void applyHeadingsToSelection(SelectionData selection,
Heading[] headings)
public void applyHeadingsToSelection(SelectionData selection,
java.util.Set[] headingSets)
public void applyPropertiesToSelection(SelectionData selection,
java.util.Properties props)
public void defineBackwardSelections(SelectionData selectionData,
int facetIndex)
SimpleFacetmap's implementation produces the first backward selection based on the common ancestor of all headings in the facet for this selection. Other backward selections are based on the ancestors of the first.
public Heading getCommonAncestor(java.util.Collection headings)
throws DataException
DataException - if headings are from different facets.
public boolean headingIsAncestorOfHeading(Heading ancestor,
Heading child)
public void defineForwardSelections(SelectionData selectionData,
int facetIndex)
If there are multiple headings selected in this facet, we create forward selections from each of those headings (and throw out the other headings). For example, in wine, the forward selections of red|white@foo would be merlot@foo, cabernet@foo, chardonnay@foo, etc. They would _not_ be merlot|white@foo, red|chardonnay@foo, etc.
public boolean isSelectedInFacet(Heading heading,
SelectionData selection,
java.util.Set subselections)
throws InternalException
subselections will include that
subselection; otherwise it won't. It will not be used at all
if it's null, or if this function returns false.
InternalException
public void removeEmptySelections(SelectionData selection)
throws InternalException
InternalExceptionpublic FacetSpace getFacetSpace()
getFacetSpace in interface Facetmappublic ResourceSpace getResourceSpace()
getResourceSpace in interface Facetmappublic void setResourceSpace(ResourceSpace resourceSpace)
public java.lang.String getTitle()
Facetmap
getTitle in interface Facetmappublic void setTitle(java.lang.String title)
public java.util.Properties getSelectionProps()
public void setSelectionProps(java.util.Properties selectionProps)
public Selection getSelection(java.lang.String ref)
throws InternalException,
UnknownReferenceException
Facetmapref. The ref string
is assumed to have been generated by a Selection from this Facetmap;
otherwise unpredictable results can occur.
We expose this method separately in the Facetmap interface because a ref string could potentially contain more than simply a set of Headings (e.g. a facetmap hash code for integrity checking). It is therefore preferred over getSelection(Heading[]) in cases where the desired Selection is based on the previous Selection (but the previous Selection object itself is unavailable). In those cases, you'd be serializing a Selection reference anyway, so the String ref is the natural choice.
getSelection in interface FacetmapInternalException
UnknownReferenceException
public Selection getSelection(Heading[] headingList,
java.util.Properties props)
throws DataException,
InternalException
getSelection in interface FacetmapDataException
InternalExceptionFacetmap.getSelection(Heading[])
public Selection getRootSelection()
throws InternalException
Facetmap
getRootSelection in interface FacetmapInternalException
public Selection getSelection(Heading[] headingList)
throws DataException,
InternalException
Facetmap1. If each Heading is from a different Facet (the usual case, and also the case handled by earlier versions of Facetmap), then each contained Resource is mapped to each Heading (or a forward Heading in the Heading's Facet).
2. If there are multiple Headings from the same Facet, then each contained Resource only needs to be mapped to at least one of the specified Headings (or their forward Headings) from the same Facet.
In essence, Headings from the same Facet are combined with OR, and then Headings from different Facets are combined with AND. This corresponds to the needs of a typical browsing user. e.g.
Heading a1 = facetmap.getTaxonomy("A").getHeading("a1");
Heading a2 = facetmap.getTaxonomy("A").getHeading("a2");
Heading a3 = facetmap.getTaxonomy("A").getHeading("a3");
Heading b1 = facetmap.getSpectrum("B").getHeading(0,100);
Heading c1 = facetmap.getKeywordFacet("C").getHeading("foo");
Selection selection = facetmap.getSelection( new Heading[5] {
a1,a2,a3,b1,c1
} );
.... will produce ....
a selection that contains all Resources r for which: (
( r is classified in facet A under a1 OR a2 OR a3 OR a child of those )
AND
( r is classified in facet B between 0 and 100 )
AND
( r contains keyword "foo" )
)
getSelection in interface FacetmapDataException
InternalException
public Selection getSelection(java.lang.String ref,
java.util.Properties properties)
throws InternalException,
UnknownReferenceException
Facetmapref and subject
to special restrictions in properties. Note that
selection properties are not conveyed by the ref string.
getSelection in interface FacetmapInternalException
UnknownReferenceException
public Selection getRootSelection(java.util.Properties props)
throws InternalException
getRootSelection in interface FacetmapInternalExceptionFacetmap.getSelection(Heading[], Properties)public java.lang.String getInfo()
getInfo in interface Facetmap
public static boolean booleanProperty(java.util.Properties props,
java.lang.String propKey)
public static int intProperty(java.util.Properties props,
java.lang.String propKey,
int defaultValue)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||