public class QueryResultSet extends java.util.HashSet<Publication>
Publication
) from a query and their scores.Modifier and Type | Class and Description |
---|---|
static class |
QueryResultSet.ScoreComparator<T extends Publication>
This
Comparator compares two Object s using a score
retrieved from a map of Object to float . |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
REVISION |
Constructor and Description |
---|
QueryResultSet() |
Modifier and Type | Method and Description |
---|---|
boolean |
add(Publication pub,
float score)
Adds the given
Publication and its score to this
QueryResultSet . |
boolean |
addAll(java.util.Collection<? extends Publication> coll)
Overrides
AbstractCollection.addAll(Collection) to call
when addAll(QueryResultSet) if the specified collection is
a QueryResultSet . |
boolean |
addAll(java.util.Collection<? extends Publication> coll,
float score)
Adds all the
Publication in the specified collection to this
QueryResultSet . |
boolean |
addAll(PageResult<Publication> pr)
Adds the given
PageResult to this QueryResultSet . |
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).
|
java.util.SortedSet<Publication> |
getAsSortedSet()
Gets all the results contained in this
QueryResultSet as
a SortedSet (a TreeSet ) using the
ScoreComparator . |
java.util.SortedSet<Publication> |
getAsSortedSet(java.lang.Class<? extends Publication> typeClazz,
java.lang.String comparatorName,
boolean reverse)
Gets all the results contained in this
QueryResultSet as
a SortedSet (a TreeSet ) retrieving the appropriate
Comparator through ComparatorManager . |
java.util.SortedSet<Publication> |
getAsSortedSet(java.util.Comparator comparator)
Gets all the results contained in this
QueryResultSet as
a SortedSet (a TreeSet ) using the given
Comparator or none if null. |
java.util.SortedSet<Publication> |
getAsSortedSet(java.lang.String comparatorName,
boolean reverse)
Gets all the results contained in this
QueryResultSet as
a SortedSet (a TreeSet ) retrieving the appropriate
Comparator through ComparatorManager . |
java.lang.Object |
getAttribute(java.lang.String name)
Returns the value of the named attribute as an
Object ,
or null if no attribute of the given name exists. |
java.util.Map<java.lang.String,java.lang.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(java.lang.Object obj)
Deprecated.
|
float |
getScore(Publication pub)
Retrieve score of the specified
Publication . |
static java.util.Comparator |
getScoreComparator(QueryResultSet resultSet,
java.util.Comparator parentComparator)
Gets a new instance of a
ScoreComparator for relevance
sorting of the given QueryResultSet . |
PageResult.Status |
getStatus() |
int |
getTotalSize()
Returns the total size of this
QueryResultSet (it may be much larger than getResultSize().size() with DB query). |
boolean |
isHybrid() |
boolean |
isTotalAccurate() |
java.util.Iterator<Publication> |
iterator()
Overrides
HashSet.iterator() to wrap the
native Iterator instance returned by the Java API with
a custom one making sure the max score is updated on removal. |
boolean |
remove(java.lang.Object o)
Remove the given Object from this result set (also remove associated score).
|
java.lang.Object |
removeAttribute(java.lang.String name)
Removes an attribute from this result.
|
boolean |
retainAll(java.util.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 . |
java.lang.Object |
setAttribute(java.lang.String name,
java.lang.Object obj)
Stores an attribute in this result.
|
void |
setHybrid(boolean isHybrid) |
void |
setStatus(PageResult.Status status) |
void |
setTotalAccurate(boolean isTotalAccurate)
Indicates if the total size accurate
|
void |
setTotalSize(int totalSize)
Assigns the totla size of this
QueryResultSet . |
finalize, getClass, notify, notifyAll, wait, wait, wait
public static final java.lang.String REVISION
public java.lang.Object setAttribute(java.lang.String name, java.lang.Object obj)
removeAttribute(java.lang.String)
.name
- a String
specifying the name of the attributeobj
- the Object
to be storedpublic java.lang.Object removeAttribute(java.lang.String name)
name
- a String
specifyingpublic java.lang.Object getAttribute(java.lang.String name)
Object
,
or null
if no attribute of the given name exists.name
- a String
specifying the name of the attributeObject
containing the value of the attribute,
or null
if the attribute does not existpublic java.util.Map<java.lang.String,java.lang.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(java.util.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 java.util.Iterator<Publication> iterator()
HashSet.iterator()
to wrap the
native Iterator
instance returned by the Java API with
a custom one making sure the max score is updated on removal.
Needed for bug fix JCMS-3368.
iterator
in interface java.lang.Iterable<Publication>
iterator
in interface java.util.Collection<Publication>
iterator
in interface java.util.Set<Publication>
iterator
in class java.util.HashSet<Publication>
HashSet.iterator()
public boolean addAll(java.util.Collection<? extends Publication> coll)
AbstractCollection.addAll(Collection)
to call
when addAll(QueryResultSet)
if the specified collection is
a QueryResultSet
.addAll
in interface java.util.Collection<Publication>
addAll
in interface java.util.Set<Publication>
addAll
in class java.util.AbstractCollection<Publication>
addAll(QueryResultSet)
,
AbstractCollection.addAll(Collection)
public boolean retainAll(java.util.Collection<?> coll)
AbstractCollection.retainAll(Collection)
to call
when retainAll(QueryResultSet)
if the specified collection is
a QueryResultSet
.retainAll
in interface java.util.Collection<Publication>
retainAll
in interface java.util.Set<Publication>
retainAll
in class java.util.AbstractCollection<Publication>
retainAll(QueryResultSet)
,
AbstractCollection.retainAll(Collection)
public boolean addAll(PageResult<Publication> pr)
PageResult
to this QueryResultSet
.pr
- the PageResult
true
if this QueryResultSet
changed as a result of the call.public boolean remove(java.lang.Object o)
remove
in interface java.util.Collection<Publication>
remove
in interface java.util.Set<Publication>
remove
in class java.util.HashSet<Publication>
HashSet.remove(java.lang.Object)
public void clear()
clear
in interface java.util.Collection<Publication>
clear
in interface java.util.Set<Publication>
clear
in class java.util.HashSet<Publication>
HashSet.clear()
@Deprecated public float getScore(java.lang.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 java.util.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 java.util.SortedSet<Publication> getAsSortedSet(java.util.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 java.util.SortedSet<Publication> getAsSortedSet(java.lang.String comparatorName, boolean reverse)
QueryResultSet
as
a SortedSet
(a TreeSet
) retrieving the appropriate
Comparator
through ComparatorManager
.
Because this method sort all the result in a new TreeSet
,
this method is expensive, be careful when using it.
comparatorName
- the name of the Comparator
to use in the
SortedSet
, as available through ComparatorManager
.reverse
- a boolean indicating whether the comparator should have
its behavior reversed (true) or unchanged (false)SortedSet
public java.util.SortedSet<Publication> getAsSortedSet(java.lang.Class<? extends Publication> typeClazz, java.lang.String comparatorName, boolean reverse)
QueryResultSet
as
a SortedSet
(a TreeSet
) retrieving the appropriate
Comparator
through ComparatorManager
.
Because this method sort all the result in a new TreeSet
,
this method is expensive, be careful when using it.
typeClazz
- the Class of Publication to sortcomparatorName
- the name of the Comparator
to use in the
SortedSet
, as available through ComparatorManager
.reverse
- a boolean indicating whether the comparator should have
its behavior reversed (true) or unchanged (false)SortedSet
public static java.util.Comparator getScoreComparator(QueryResultSet resultSet, java.util.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()
QueryResultSet
(it may be much larger than getResultSize().size() with DB query).QueryResultSet
.public void setTotalSize(int totalSize)
QueryResultSet
.totalSize
- the new total size.public int getResultSize()
public boolean isHybrid()
public void setHybrid(boolean isHybrid)
public void setStatus(PageResult.Status status)
public PageResult.Status getStatus()
public boolean isTotalAccurate()
public void setTotalAccurate(boolean isTotalAccurate)
isTotalAccurate
- the valueCopyright © 2001-2017 Jalios SA. All Rights Reserved.