|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractCollection<E> java.util.AbstractSet<E> java.util.HashSet<Publication> com.jalios.jcms.QueryResultSet
public class QueryResultSet
This class holds results of a query.
It keeps tracks of all results (Publication
) from a query and their scores.
Nested Class Summary | |
---|---|
static class |
QueryResultSet.ScoreComparator
This Comparator compares two Object s using a score
retrieved from a map of Object to float . |
Field Summary | |
---|---|
static String |
REVISION
|
Constructor Summary | |
---|---|
QueryResultSet()
|
Method Summary | |
---|---|
boolean |
add(Publication pub,
float score)
Adds the given Publication and its score to this
QueryResultSet . |
boolean |
addAll(Collection<? extends Publication> coll)
Overrides AbstractCollection.addAll(Collection) to call
when addAll(QueryResultSet) if the specified collection is
a QueryResultSet . |
boolean |
addAll(Collection<? extends Publication> coll,
float score)
Adds all the Publication in the specified collection to this
QueryResultSet . |
boolean |
addAll(PageResult<Publication> pr)
|
boolean |
addAll(QueryResultSet resultSet)
Adds all the Publication in the specified result Set to this
QueryResultSet . |
void |
clear()
Clear all Object from this result set (also remove associated score). |
SortedSet<Publication> |
getAsSortedSet()
Gets all the results contained in this QueryResultSet as
a SortedSet (a TreeSet ) using the
ScoreComparator . |
SortedSet<Publication> |
getAsSortedSet(Comparator comparator)
Gets all the results contained in this QueryResultSet as
a SortedSet (a TreeSet ) using the given
Comparator or none if null. |
Object |
getAttribute(String name)
Returns the value of the named attribute as an Object ,
or null if no attribute of the given name exists. |
Map<String,Object> |
getAttributeMap()
Returns a java.util.Map of the attributes of this results. |
float |
getMaxScore()
Retrieve the maximum score value available in this QueryResultSet . |
int |
getResultSize()
|
float |
getScore(Object obj)
Deprecated. use getScore(Publication) |
float |
getScore(Publication pub)
Retrieve score of the specified Publication . |
static Comparator |
getScoreComparator(QueryResultSet resultSet,
Comparator parentComparator)
Gets a new instance of a ScoreComparator for relevance
sorting of the given QueryResultSet . |
int |
getTotalSize()
|
boolean |
remove(Object o)
Remove the given Object from this result set (also remove associated score). |
Object |
removeAttribute(String name)
Removes an attribute from this result. |
boolean |
retainAll(Collection<?> coll)
Overrides AbstractCollection.retainAll(Collection) to call
when retainAll(QueryResultSet) if the specified collection is
a QueryResultSet . |
boolean |
retainAll(QueryResultSet resultSet)
Retains only the elements in this QueryResultSet that are contained in the
specified QueryResultSet . |
Object |
setAttribute(String name,
Object obj)
Stores an attribute in this result. |
void |
setTotalSize(int totalSize)
|
Methods inherited from class java.util.HashSet |
---|
add, clone, contains, isEmpty, iterator, size |
Methods inherited from class java.util.AbstractSet |
---|
equals, hashCode, removeAll |
Methods inherited from class java.util.AbstractCollection |
---|
containsAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Set |
---|
containsAll, equals, hashCode, removeAll, toArray, toArray |
Field Detail |
---|
public static final String REVISION
Constructor Detail |
---|
public QueryResultSet()
Method Detail |
---|
public Object setAttribute(String name, Object obj)
removeAttribute(java.lang.String)
.
name
- a String
specifying the name of the attributeobj
- the Object
to be stored
public Object removeAttribute(String name)
name
- a String
specifying
public Object getAttribute(String name)
Object
,
or null
if no attribute of the given name exists.
name
- a String
specifying the name of the attribute
Object
containing the value of the attribute,
or null
if the attribute does not existpublic Map<String,Object> getAttributeMap()
public boolean add(Publication pub, float score)
Publication
and its score to this
QueryResultSet
. Object
was already in this
QueryResultSet
for a given element, its score is replaced.
pub
- the Publication
to add.score
- the new score of the Publication
public boolean addAll(Collection<? extends Publication> coll, float score)
Publication
in the specified collection to this
QueryResultSet
. Collection
for a given element,
its score is replaced.
coll
- collection whose elements are to be added to this collection.score
- the score of the Publication
in the
Collection
(should be between 0.0f and 1.0f)
public boolean addAll(QueryResultSet resultSet)
Publication
in the specified result Set to this
QueryResultSet
. Also puts all attribute of the specified
QueryResultSet into this QueryResultSet.Publication
was already in this QueryResultSet
,
it is replaced with its score in the given QueryResultSet
.
resultSet
- QueryResultSet
whose elements are to be added to this QueryResultSet.
public boolean retainAll(QueryResultSet resultSet)
QueryResultSet
that are contained in the
specified QueryResultSet
. In other words, removes
from this QueryResultSet
all of its elements that are not contained in the
specified QueryResultSet
.
Also updates scores of elements kept in this QueryResultSet
if their
existing score are below the score of the specified QueryResultSet
.
resultSet
- elements to be retained in this collection.
QueryResultSet
changed as a result of the call.public boolean addAll(Collection<? extends Publication> coll)
AbstractCollection.addAll(Collection)
to call
when addAll(QueryResultSet)
if the specified collection is
a QueryResultSet
.
addAll
in interface Collection<Publication>
addAll
in interface Set<Publication>
addAll
in class AbstractCollection<Publication>
addAll(QueryResultSet)
,
AbstractCollection.addAll(Collection)
public boolean retainAll(Collection<?> coll)
AbstractCollection.retainAll(Collection)
to call
when retainAll(QueryResultSet)
if the specified collection is
a QueryResultSet
.
retainAll
in interface Collection<Publication>
retainAll
in interface Set<Publication>
retainAll
in class AbstractCollection<Publication>
retainAll(QueryResultSet)
,
AbstractCollection.retainAll(Collection)
public boolean addAll(PageResult<Publication> pr)
public boolean remove(Object o)
remove
in interface Collection<Publication>
remove
in interface Set<Publication>
remove
in class HashSet<Publication>
HashSet.remove(java.lang.Object)
public void clear()
clear
in interface Collection<Publication>
clear
in interface Set<Publication>
clear
in class HashSet<Publication>
HashSet.clear()
public float getScore(Object obj)
getScore(Publication)
Object
(a Publication
).
obj
- the Object
(a Publication
)
from which to retrieve the score.
obj
or 0.0f
if no score is available for this Object
.public float getScore(Publication pub)
Publication
.
pub
- the Publication
from which to retrieve the score.
obj
or 0.0f
if no score is available for this Publication
.public float getMaxScore()
QueryResultSet
.
public SortedSet<Publication> getAsSortedSet()
QueryResultSet
as
a SortedSet
(a TreeSet
) using the
ScoreComparator
.
Because this method sort all the result in a new TreeSet
,
this method is expensive, be careful when using it.
SortedSet
(a TreeSet
)
using ScoreComparator
.QueryResultSet.ScoreComparator
public SortedSet<Publication> getAsSortedSet(Comparator comparator)
QueryResultSet
as
a SortedSet
(a TreeSet
) using the given
Comparator
or none if null.
Because this method sort all the result in a new TreeSet
,
this method is expensive, be careful when using it.
comparator
- the Comparator
to use in the
SortedSet
, can be null to sort using natural order.
SortedSet
(a TreeSet
)
using ScoreComparator
.QueryResultSet.ScoreComparator
public static Comparator getScoreComparator(QueryResultSet resultSet, Comparator parentComparator)
ScoreComparator
for relevance
sorting of the given QueryResultSet
.
resultSet
- the QueryResultSet
from which to retrieve
score of each Publication
.parentComparator
- the Comparator
to use when score of
compared Object
are identical.
ScoreComparator
using the given parent Comparator.QueryResultSet.ScoreComparator
public int getTotalSize()
public void setTotalSize(int totalSize)
public int getResultSize()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |