com.bigllc.retsiq.simpleclient
Class ColumnRenameResponseHandler

java.lang.Object
  extended by com.bigllc.retsiq.simpleclient.ColumnRenameResponseHandler
All Implemented Interfaces:
SearchResponseHandler

public class ColumnRenameResponseHandler
extends java.lang.Object
implements SearchResponseHandler

Search handler that allows column names to be renamed. Accepts a delegate handler and mappings. If a mapping doesn't exist then the original column header will be used.

Author:
Marc G. Smith

Constructor Summary
ColumnRenameResponseHandler(SearchResponseHandler delegate, java.util.Map<java.lang.String,java.lang.String> mappings)
          Construct a column rename response handler.
 
Method Summary
 void columns(java.util.List<java.lang.String> columns)
          If results are returned then this method is called with the column headers returned.
 void count(int count)
          If a count was returned in the search response.
 void data(java.util.List<java.lang.String> data)
          If results are returned then the this method is called for each record returned.
 void delimiter(java.lang.String hex)
          If a delimiter is specified in the response then this method is called with the byte delimiter as hexidecimal string.
 void done()
          On completion of processing of the search results or if a parsing error occurs then this called.
 java.lang.String getPath()
          Get the path requested for the search.
 java.lang.String getQuery()
          Get the query requested for the search.
 int getRecordsInResponse()
          Return the number of records processed in this search response.
 java.util.List<java.lang.String> getSelect()
          Get the columns requested for the search.
 RETSUserSession getSession()
          Get the user session used for the search.
 void hasMoreData()
          If the results returned have been limited by either the user or the server and more results are available then this method will be called.
 void noRecordsFound()
          Callback when search was successful but specifically no records were found.
 void responseCode(int code, java.lang.String text, java.lang.String description)
          Callback for search RETS response code.
 void setContext(RETSUserSession session, java.lang.String path, java.lang.String query, java.util.List<java.lang.String> select)
          Set the search context for the results being parsed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColumnRenameResponseHandler

public ColumnRenameResponseHandler(SearchResponseHandler delegate,
                                   java.util.Map<java.lang.String,java.lang.String> mappings)
Construct a column rename response handler. The delegate does the actual work and can be any implementation of a SearchResponseHandler. The mapping should be a map with the key as the original name and the value as the new name of the column.

Method Detail

columns

public void columns(java.util.List<java.lang.String> columns)
             throws RETSClientException
Description copied from interface: SearchResponseHandler
If results are returned then this method is called with the column headers returned. The order of the list is maintained as per the search results. If no results or an error occurs then this method will not be called.

Specified by:
columns in interface SearchResponseHandler
Parameters:
columns - A list of column names.
Throws:
RETSClientException
See Also:
SearchResponseHandler.columns(List)

count

public void count(int count)
Description copied from interface: SearchResponseHandler
If a count was returned in the search response. This method will be called with the value. The count represents the number of records that match the query not necessarily the number of records in the response.

Specified by:
count in interface SearchResponseHandler
See Also:
SearchResponseHandler.count(int)

data

public void data(java.util.List<java.lang.String> data)
          throws RETSClientException
Description copied from interface: SearchResponseHandler
If results are returned then the this method is called for each record returned. The order of the list is maintained as per the search results and will match the indexes of the list of column headers. If no results or an error occurs then this method will not be called.

Specified by:
data in interface SearchResponseHandler
Parameters:
data - A list of the record fields.
Throws:
RETSClientException
See Also:
SearchResponseHandler.data(List)

delimiter

public void delimiter(java.lang.String hex)
Description copied from interface: SearchResponseHandler
If a delimiter is specified in the response then this method is called with the byte delimiter as hexidecimal string.

Specified by:
delimiter in interface SearchResponseHandler
Parameters:
hex - The byte delimiter as a hexidecimal string.
See Also:
SearchResponseHandler.delimiter(String)

done

public void done()
Description copied from interface: SearchResponseHandler
On completion of processing of the search results or if a parsing error occurs then this called.

Specified by:
done in interface SearchResponseHandler
See Also:
SearchResponseHandler.done()

getPath

public java.lang.String getPath()
Description copied from interface: SearchResponseHandler
Get the path requested for the search.

Specified by:
getPath in interface SearchResponseHandler
Returns:
A search path as defined in RETSUserSession.
See Also:
SearchResponseHandler.getPath()

getQuery

public java.lang.String getQuery()
Description copied from interface: SearchResponseHandler
Get the query requested for the search.

Specified by:
getQuery in interface SearchResponseHandler
Returns:
The DMQL2 query.
See Also:
SearchResponseHandler.getQuery()

getSelect

public java.util.List<java.lang.String> getSelect()
Description copied from interface: SearchResponseHandler
Get the columns requested for the search.

Specified by:
getSelect in interface SearchResponseHandler
Returns:
A list of columns that were requested. An empty list or null may be returned if all columns were specified.
See Also:
SearchResponseHandler.getSelect()

getSession

public RETSUserSession getSession()
Description copied from interface: SearchResponseHandler
Get the user session used for the search.

Specified by:
getSession in interface SearchResponseHandler
Returns:
The user session.
See Also:
SearchResponseHandler.getSession()

hasMoreData

public void hasMoreData()
Description copied from interface: SearchResponseHandler
If the results returned have been limited by either the user or the server and more results are available then this method will be called.

Specified by:
hasMoreData in interface SearchResponseHandler
See Also:
SearchResponseHandler.hasMoreData()

noRecordsFound

public void noRecordsFound()
Description copied from interface: SearchResponseHandler
Callback when search was successful but specifically no records were found.

Specified by:
noRecordsFound in interface SearchResponseHandler
See Also:
SearchResponseHandler.noRecordsFound()

responseCode

public void responseCode(int code,
                         java.lang.String text,
                         java.lang.String description)
Description copied from interface: SearchResponseHandler
Callback for search RETS response code. A code of 0 represents search was successful, a code of 20201 means no records were found.

Specified by:
responseCode in interface SearchResponseHandler
Parameters:
code - The RETS response code.
text - The text associated with the response code.
description - An associated long description of the response code.
See Also:
SearchResponseHandler.responseCode(int, String, String)

setContext

public void setContext(RETSUserSession session,
                       java.lang.String path,
                       java.lang.String query,
                       java.util.List<java.lang.String> select)
Description copied from interface: SearchResponseHandler
Set the search context for the results being parsed. This will be called by the parser and should not be called directly by any implementing classes.

Specified by:
setContext in interface SearchResponseHandler
Parameters:
session - The user session.
path - The search path.
query - The DMQL2 query.
select - The columns selected to be returned or null for all.
See Also:
SearchResponseHandler.setContext(RETSUserSession, String, String, List)

getRecordsInResponse

public int getRecordsInResponse()
Description copied from interface: SearchResponseHandler
Return the number of records processed in this search response.

Specified by:
getRecordsInResponse in interface SearchResponseHandler
Returns:
The number of records in the response.
See Also:
SearchResponseHandler.getRecordsInResponse()