summaryrefslogtreecommitdiff
path: root/java/demo/Database/library/Parser.java
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2008-09-11 15:20:13 -0230
committerMatthew Newhook <matthew@zeroc.com>2008-09-11 15:20:13 -0230
commite7702eab9c158c4578b2804993d696c2aebbdf3a (patch)
tree2a3e56c739ac355c23e1d0d9d902734c03943e07 /java/demo/Database/library/Parser.java
parentPHP bug fix for ice_router/ice_locator (diff)
downloadice-e7702eab9c158c4578b2804993d696c2aebbdf3a.tar.bz2
ice-e7702eab9c158c4578b2804993d696c2aebbdf3a.tar.xz
ice-e7702eab9c158c4578b2804993d696c2aebbdf3a.zip
- Added queryByTitle.
- Removed NoResultsException. - Added nrows to the query operations. - Added setTitle, setAuthors.
Diffstat (limited to 'java/demo/Database/library/Parser.java')
-rw-r--r--java/demo/Database/library/Parser.java81
1 files changed, 69 insertions, 12 deletions
diff --git a/java/demo/Database/library/Parser.java b/java/demo/Database/library/Parser.java
index 83c1c78ff3b..772dbfde349 100644
--- a/java/demo/Database/library/Parser.java
+++ b/java/demo/Database/library/Parser.java
@@ -23,8 +23,9 @@ class Parser
"help Print this message.\n" +
"exit, quit Exit this program.\n" +
"add isbn title authors Create new book.\n" +
- "isbn NUMBER Find the book with given ISBN number.\n" +
+ "isbn NUMBER Find the book that start with the given ISBN number.\n" +
"authors NAME Find all books by the given authors.\n" +
+ "title NAME Find all books which have the given title.\n" +
"next Set the current book to the next one that was found.\n" +
"current Display the current book.\n" +
"rent NAME Rent the current book for customer NAME.\n" +
@@ -91,18 +92,21 @@ class Parser
_current = null;
}
- BookDescriptionHolder first = new BookDescriptionHolder();
+ BookDescriptionSeqHolder first = new BookDescriptionSeqHolder();
+ Ice.IntHolder nrows = new Ice.IntHolder();
BookQueryResultPrxHolder result = new BookQueryResultPrxHolder();
- _library.queryByIsbn((String)args.get(0), first, result);
+ _library.queryByIsbn((String)args.get(0), 1, first, nrows, result);
- _current = first.value;
+ System.out.println(nrows.value + " results");
+ if(nrows.value == 0)
+ {
+ return;
+ }
+
+ _current = first.value.get(0);
_query = result.value;
printCurrent();
}
- catch(NoResultsException ex)
- {
- error(ex.toString());
- }
catch(Ice.LocalException ex)
{
error(ex.toString());
@@ -134,18 +138,67 @@ class Parser
_current = null;
}
- BookDescriptionHolder first = new BookDescriptionHolder();
+ BookDescriptionSeqHolder first = new BookDescriptionSeqHolder();
+ Ice.IntHolder nrows = new Ice.IntHolder();
BookQueryResultPrxHolder result = new BookQueryResultPrxHolder();
- _library.queryByAuthor((String)args.get(0), first, result);
+ _library.queryByAuthor((String)args.get(0), 1, first, nrows, result);
- _current = first.value;
+ System.out.println(nrows.value + " results");
+ if(nrows.value == 0)
+ {
+ return;
+ }
+
+ _current = first.value.get(0);
_query = result.value;
printCurrent();
}
- catch(NoResultsException ex)
+ catch(Ice.LocalException ex)
{
error(ex.toString());
}
+ }
+
+ void
+ findTitle(java.util.List args)
+ {
+ if(args.size() != 1)
+ {
+ error("`title' requires exactly one argument (type `help' for more info)");
+ return;
+ }
+
+ try
+ {
+ if(_query != null)
+ {
+ try
+ {
+ _query.destroy();
+ }
+ catch(Exception e)
+ {
+ // Ignore
+ }
+ _query = null;
+ _current = null;
+ }
+
+ BookDescriptionSeqHolder first = new BookDescriptionSeqHolder();
+ Ice.IntHolder nrows = new Ice.IntHolder();
+ BookQueryResultPrxHolder result = new BookQueryResultPrxHolder();
+ _library.queryByTitle((String)args.get(0), 1, first, nrows, result);
+
+ System.out.println(nrows.value + " results");
+ if(nrows.value == 0)
+ {
+ return;
+ }
+
+ _current = first.value.get(0);
+ _query = result.value;
+ printCurrent();
+ }
catch(Ice.LocalException ex)
{
error(ex.toString());
@@ -236,6 +289,10 @@ class Parser
{
System.out.println("the book has already been rented");
}
+ catch(InvalidCustomerException ex)
+ {
+ System.out.println("the customer name is invalid");
+ }
catch(Ice.ObjectNotExistException ex)
{
System.out.println("current book no longer exists");