|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.esri.adf.web.data.results.WebResults
public class WebResults
The WebResults object is a container of arbitrary result objects. Any POJO representing a result can
be added to WebResults
. Result objects shipped out of the box include
QueryResult
, AddressCandidate
,
GPTaskResult
, etc.
A WebResults
object is maintained by the WebContext
and can be accessed by
using the WebContext.getWebResults()
method. The result objects that you add to
WebResults
can provide 4 pieces of information for the user (The first one is required, the rest are
optional):
java.util.Map
of name-value attribute pairs)
So, for instance, the QueryResult
provides these 4 pieces of information with
these methods:
QueryResult.getName()
QueryResult.getDetails()
QueryResult.zoom()
,
QueryResult.highlight()
,
QueryResult.clearGraphic()
QueryResult.clearGraphic()
java.util.List
of QueryResult
s to
WebResults
:
WebResults wresults = ctx.getWebResults(); //a List of QueryResult objects List queryResults = ...; //perform queries such as find, identify, etc. wresults.addResultsWithActionArray("Query Results", queryResults, "getName", "getDetails", new String[]{"zoom", "highlight", "clearGraphic"});
All results are wrapped in ResultNode
objects. The WebResults
internally maintains a tree of
these ResultNode
objects. The ResultNode
is the one which actually invokes the appropriate methods on
the actual results to retrieve the 4 pieces of information mentioned above.
The WebResultsObserver
s registered with WebResults
using the
addObserver(WebResultsObserver)
method will be notified whenever results are added, modified, replaced or
removed.
Constructor Summary | |
---|---|
WebResults()
|
Method Summary | |
---|---|
ResultNode |
addAddressCandidates(List<? extends AddressCandidate> candidates,
ResultDefinition definition)
|
void |
addObserver(WebResultsObserver observer)
Registers the observer as an observer of this instance of WebResults . |
ResultNode |
addQueryResults(List<? extends QueryResult> results,
ResultDefinition definition)
|
void |
addResultNode(ResultNode resultNode)
Adds a ResultNode to this instance of WebResults . |
ResultNode |
addResults(String groupHeader,
List<?> results)
Adds a List of results to this WebResults object. |
ResultNode |
addResultsWithActionArray(String groupHeader,
List<?> results,
String displayNameMethodName,
String detailsMethodName,
String[] actionMethodNames)
Adds a List of results to this WebResults object. |
ResultNode |
addResultsWithActionArray(String groupHeader,
List<?> results,
String displayNameMethodName,
String detailsMethodName,
String[] actionMethodNames,
String onRemoveMethodName)
Adds a List of results to this WebResults object. |
ResultNode |
addResultsWithActionMap(String groupHeader,
List<?> results,
String displayNameMethodName,
String detailsMethodName,
Map<String,String> actionMethodNames)
Adds a List of results to this WebResults object. |
ResultNode |
addResultsWithActionMap(String groupHeader,
List<?> results,
String displayNameMethodName,
String detailsMethodName,
Map<String,String> actionMethodNames,
String onRemoveMethodName)
Adds a List of results to this WebResults object. |
void |
clearAll()
Removes all results from this instance of WebResults . |
static String |
formatDate(Date d)
|
static String |
formatValue(Object o)
|
List<ResultNode> |
getResultNodes()
Returns an unmodifiable List of top-level ResultNode s maintained by this instance of
WebResults . |
boolean |
isShowOpenResultLink()
Returns true if the renderer for this WebResults object should display a link to open results. |
void |
notifyObservers(int updateType,
ResultNode affectedNode,
Object args)
Notifies all WebResultsObserver s registered with this instance of WebResults . |
boolean |
removeObserver(WebResultsObserver observer)
Removes the observer from the list of registered WebResultsObserver s. |
boolean |
removeResultNode(ResultNode resultNode)
Removes a ResultNode to this instance of WebResults . |
boolean |
replaceResultNode(ResultNode newNode,
ResultNode oldNode)
Replaces an existing ResultNode with a new node. |
void |
setShowOpenResultLink(boolean showOpenResultLink)
Set to true if the renderer for this WebResults object should display a link to open results. |
String |
toString()
|
boolean |
updateQueryResults(ResultNode updateNode,
List<?> results)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public WebResults()
Method Detail |
---|
public ResultNode addResults(String groupHeader, List<?> results)
Adds a List
of results to this WebResults
object.
Calling this method is equivalent to:
wresults.addResultsWithActionMap(groupHeader, results, "toString", null, null);
The registered WebResultsObserver
s will be notified with an update of type
WebResultsObserver.RESULT_ADDED
.
groupHeader
- the header for this List
of resultsresults
- the List
of results to be maintained by this instance of WebResults
ResultNode
for the node representing this set of resultspublic ResultNode addResultsWithActionArray(String groupHeader, List<?> results, String displayNameMethodName, String detailsMethodName, String[] actionMethodNames, String onRemoveMethodName)
Adds a List
of results to this WebResults
object.
Calling this method is equivalent to:
Map actionMethodsMap = new LinkedHashMap(); for (int i = 0; i < actionMethodNames.length; i++) actionMethodsMap.put(actionMethodNames[i], actionMethodNames[i]); wresults.addResultsWithActionMap(groupHeader, results, displayNameMethodName, detailsMethodName, actionMethodsMap);
The registered WebResultsObserver
s will be notified with an update of type
WebResultsObserver.RESULT_ADDED
.
groupHeader
- the header for this List
of resultsresults
- the List
of results to be maintained by this instance of WebResults
displayNameMethodName
- the name of the method which returns the display text for the resultdetailsMethodName
- the name of the method which returns the result details as a java.util.Map
of
name-value pairsactionMethodNames
- an array of names of methods for performing actions on the resultonRemoveMethodName
- the name of the method to be called when the result is removed
ResultNode
for the node representing this set of resultspublic ResultNode addResultsWithActionArray(String groupHeader, List<?> results, String displayNameMethodName, String detailsMethodName, String[] actionMethodNames)
Adds a List
of results to this WebResults
object.
Calling this method is equivalent to:
Map actionMethodsMap = new LinkedHashMap(); for (int i = 0; i < actionMethodNames.length; i++) actionMethodsMap.put(actionMethodNames[i], actionMethodNames[i]); wresults.addResultsWithActionMap(groupHeader, results, displayNameMethodName, detailsMethodName, actionMethodsMap);
The registered WebResultsObserver
s will be notified with an update of type
WebResultsObserver.RESULT_ADDED
.
groupHeader
- the header for this List
of resultsresults
- the List
of results to be maintained by this instance of WebResults
displayNameMethodName
- the name of the method which returns the display text for the resultdetailsMethodName
- the name of the method which returns the result details as a java.util.Map
of
name-value pairsactionMethodNames
- an array of names of methods for performing actions on the result
ResultNode
for the node representing this set of resultspublic ResultNode addResultsWithActionMap(String groupHeader, List<?> results, String displayNameMethodName, String detailsMethodName, Map<String,String> actionMethodNames, String onRemoveMethodName)
Adds a List
of results to this WebResults
object.
The registered WebResultsObserver
s will be notified with an update of type
WebResultsObserver.RESULT_ADDED
.
The actionMethodNames
is a java.util.Map
of <action display name>-<action method
name> pairs.
groupHeader
- the header for this List
of resultsresults
- the List
of results to be maintained by this instance of WebResults
displayNameMethodName
- the name of the method which returns the display text for the resultdetailsMethodName
- the name of the method which returns the result details as a java.util.Map
of
name-value pairsactionMethodNames
- a java.util.Map
of <action display name>-<action method name>
pairsonRemoveMethodName
- the name of the method to be called when the result is removed
ResultNode
for the node representing this set of resultspublic ResultNode addResultsWithActionMap(String groupHeader, List<?> results, String displayNameMethodName, String detailsMethodName, Map<String,String> actionMethodNames)
Adds a List
of results to this WebResults
object.
The registered WebResultsObserver
s will be notified with an update of type
WebResultsObserver.RESULT_ADDED
.
The actionMethodNames
is a java.util.Map
of <action display name>-<action method
name> pairs.
groupHeader
- the header for this List
of resultsresults
- the List
of results to be maintained by this instance of WebResults
displayNameMethodName
- the name of the method which returns the display text for the resultdetailsMethodName
- the name of the method which returns the result details as a java.util.Map
of
name-value pairsactionMethodNames
- a java.util.Map
of <action display name>-<action method name>
pairs
ResultNode
for the node representing this set of resultspublic void addResultNode(ResultNode resultNode)
Adds a ResultNode
to this instance of WebResults
.
resultNode
- the ResultNode
to be added to this instance of WebResults
public boolean removeResultNode(ResultNode resultNode)
Removes a ResultNode
to this instance of WebResults
.
The onRemove methods of this result and its children will be called before the result is actually removed.
The registered WebResultsObserver
s will be notified with an update of type
WebResultsObserver.RESULT_REMOVED
.
resultNode
- the ResultNode
to be removed from this instance of WebResults
public boolean replaceResultNode(ResultNode newNode, ResultNode oldNode)
Replaces an existing ResultNode
with a new node.
The newNode
will not be added if the oldNode
was not found.
The registered WebResultsObserver
s will be notified with an update of type
WebResultsObserver.RESULT_REPLACED
.
newNode
- the new ResultNode
which replaces the oldNode
oldNode
- the ResultNode
to be replaced with the newNode
public void clearAll()
Removes all results from this instance of WebResults
.
The registered WebResultsObserver
s will be notified with an update of type
WebResultsObserver.ALL_RESULTS_CLEARED
.
public List<ResultNode> getResultNodes()
Returns an unmodifiable List
of top-level ResultNode
s maintained by this instance of
WebResults
.
List
of top-level ResultNode
spublic void addObserver(WebResultsObserver observer)
Registers the observer
as an observer of this instance of WebResults
.
This observer
along with the other registered observers will be notified whenever results are added,
modified, replaced or removed.
observer
- the WebResultsObserver
to be registeredpublic boolean removeObserver(WebResultsObserver observer)
Removes the observer
from the list of registered WebResultsObserver
s.
observer
- the WebResultsObserver
to be removed
observer
was successfully removedpublic void notifyObservers(int updateType, ResultNode affectedNode, Object args)
Notifies all WebResultsObserver
s registered with this instance of WebResults
.
This method iterates through all the registered observers and calls their
WebResultsObserver.webResultsUpdate(WebResults, int, ResultNode, Object)
method.
updateType
- the type of update (e.g. WebResultsObserver.RESULT_ADDED
,
WebResultsObserver.RESULT_REMOVED
, etc.affectedNode
- the affected ResultNode
(e.g. the node that was added, the node that was removed, etc.)args
- an arbitrary argument object for observers to fine tune their reactions to this notificationpublic boolean isShowOpenResultLink()
Returns true if the renderer for this WebResults
object should display a link to open results.
Certain results (such as GP results) can be downloaded to and then uploaded (opened) from the client. Clients can add an "Open Result" link to open such results. They can make that decision based on this property.
WebResults
object should display a link to open resultspublic void setShowOpenResultLink(boolean showOpenResultLink)
Set to true if the renderer for this WebResults
object should display a link to open results.
Certain results (such as GP results) can be downloaded to and then uploaded (opened) from the client. Clients can add an "Open Result" link to open such results. They can make that decision based on this property.
showOpenResultLink
- true if the renderer for this WebResults
object should display a link to open
resultspublic String toString()
toString
in class Object
public ResultNode addQueryResults(List<? extends QueryResult> results, ResultDefinition definition)
public boolean updateQueryResults(ResultNode updateNode, List<?> results)
public ResultNode addAddressCandidates(List<? extends AddressCandidate> candidates, ResultDefinition definition)
public static String formatValue(Object o)
public static String formatDate(Date d)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |