Methods Summary |
---|
public java.lang.String | getKeyword()
return keyword;
|
public KeywordRequest | getKeywordRequest()
KeywordRequest request = new KeywordRequest();
request.setKeyword(keyword);
request.setMode(mode);
request.setPage(page);
request.setType(type);
request.setDevtag(AMAZON_KEY);
request.setTag(AMAZON_TAG);
return request;
|
public java.lang.String | getLineSep()
return lineSep;
|
public java.lang.String | getMode()
return mode;
|
public java.lang.String | getPage()
return page;
|
public java.lang.String | getSearchResults()
endpointUrl = new URL(END_POINT);
AmazonSearchService webService = new AmazonSearchServiceLocator();
AmazonSearchPort port = webService.getAmazonSearchPort(endpointUrl);
KeywordRequest request = getKeywordRequest();
ProductInfo prodInfo = port.keywordSearchRequest(request);
setTotalResults( prodInfo.getTotalResults() );
return structureResult(prodInfo);
|
public java.lang.String | getTotalResults()
return totalResults;
|
public java.lang.String | getType()
return type;
|
public static void | main(java.lang.String[] args)
AmazonBean bean = new AmazonBean();
bean.setKeyword("Lance%20Armstrong");
bean.setType("heavy");
bean.setMode("books");
bean.setPage("1");
System.out.println( bean.getSearchResults() );
|
public void | release()
|
public void | setKeyword(java.lang.String keyword)
this.keyword = keyword;
|
public void | setLineSep(java.lang.String lineSep)
this.lineSep=lineSep;
|
public void | setMode(java.lang.String mode)
this.mode = mode;
|
public void | setPage(java.lang.String page)
this.page = page;
|
public void | setTotalResults(java.lang.String results)
totalResults = results;
|
public void | setType(java.lang.String type)
this.type = type;
|
public java.lang.String | structureResult(ProductInfo info)
Details[] details = info.getDetails();
String results = "";
String[] authors = null;
String usedP = null;
String rank = null;
for (int i = 0; i < details.length; i++){
if(mode != null && mode.equals("books")){
authors = details[i].getAuthors(); }
results += "<strong>"+(i+1)+". Product name:</strong> " + details[i].getProductName() + lineSep;
if(mode != null && mode.equals("books")){
for (int j = 0; j < authors.length; j++)
results += "Author name "+(j+1)+": " + authors[j] + lineSep;
}
usedP = details[i].getUsedPrice();
rank = details[i].getSalesRank();
results += "Sales rank: " + (rank == null ? "N/A" : rank) + lineSep +
"List price: " + details[i].getListPrice() + lineSep +
"Our price: " + details[i].getOurPrice() + lineSep +
"Used price: " + (usedP == null ? "N/A" : usedP) + lineSep + lineSep;
}
return results;
|