Methods Summary |
---|
private BookInfo | findBook(java.lang.String name)Looks for a book whose title matches a given string.
The comparison is case-insensitive.
BookInfo[] books = DocBookServiceServantData.getBookInfo();
for (int i = 0; i < books.length; i++) {
if (books[i].getTitle().equalsIgnoreCase(name)) {
// Found a match
return books[i];
}
}
return null; // No match
|
public java.lang.String | getBookAuthor(java.lang.String name)Get the author for a book with a given name.
BookInfo book = findBook(name);
return book == null ? null : book.getAuthor();
|
public int | getBookCount()Gets the number of books known to the service
return DocBookServiceServantData.getBookInfo().length;
|
public BookInfo | getBookInfo(java.lang.String title)Gets all details for a book with a given title.
return findBook(title);
|
public java.lang.String | getBookTitle(int index)Gets the title for a book with a given index.
int count = getBookCount();
String title = null;
if (index >= 0 || index < count) {
title = DocBookServiceServantData.getBookInfo()[index].getTitle();
}
return title;
|
public javax.xml.soap.SOAPElement | getStockInfo(java.lang.String title)Gets the stock level for a book with a given title.
BookInfo book = findBook(title);
SOAPElement element = null;
if (book != null) {
try {
if (factory == null) {
factory = SOAPFactory.newInstance();
}
element = factory.createElement("stock");
element.addTextNode(String.valueOf(book.getStock()));
} catch (SOAPException ex) {
// Just return null in this case
element = null;
}
}
return element;
|