diff options
author | Matthew Newhook <matthew@zeroc.com> | 2008-08-27 15:43:37 -0230 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2008-08-27 15:43:37 -0230 |
commit | 04c146721b33071c88a39bdcd52eca45550c7cb2 (patch) | |
tree | f4d5402637885b5615041c3f52285a1206c96764 /java/demo/Database/library/Parser.java | |
parent | probe connection before returning it. (diff) | |
download | ice-04c146721b33071c88a39bdcd52eca45550c7cb2.tar.bz2 ice-04c146721b33071c88a39bdcd52eca45550c7cb2.tar.xz ice-04c146721b33071c88a39bdcd52eca45550c7cb2.zip |
bug fixes. Align with the objc demo.
Diffstat (limited to 'java/demo/Database/library/Parser.java')
-rw-r--r-- | java/demo/Database/library/Parser.java | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/java/demo/Database/library/Parser.java b/java/demo/Database/library/Parser.java index 4a845042d23..83c1c78ff3b 100644 --- a/java/demo/Database/library/Parser.java +++ b/java/demo/Database/library/Parser.java @@ -58,7 +58,7 @@ class Parser } catch(BookExistsException ex) { - error("the book already exists."); + error("the book already exists"); } catch(Ice.LocalException ex) { @@ -87,14 +87,14 @@ class Parser { // Ignore } + _query = null; + _current = null; } - _query = null; - _current = null; BookDescriptionHolder first = new BookDescriptionHolder(); BookQueryResultPrxHolder result = new BookQueryResultPrxHolder(); - _library.queryByIsbn((String)args.get(0), first, result); + _current = first.value; _query = result.value; printCurrent(); @@ -130,14 +130,14 @@ class Parser { // Ignore } + _query = null; + _current = null; } - _query = null; - _current = null; BookDescriptionHolder first = new BookDescriptionHolder(); BookQueryResultPrxHolder result = new BookQueryResultPrxHolder(); - _library.queryByAuthor((String)args.get(0), first, result); + _current = first.value; _query = result.value; printCurrent(); @@ -155,26 +155,39 @@ class Parser void nextFoundBook() { - if(_query != null) + if(_query == null) + { + System.out.println("no next book"); + return; + } + + try { - Ice.IntHolder remaining = new Ice.IntHolder(); Ice.BooleanHolder destroyed = new Ice.BooleanHolder(); java.util.List<BookDescription> next = _query.next(1, destroyed); - if(destroyed.value) + if(next.size() > 0) { - _query = null; - _current = null; + _current = next.get(0); } else { - _current = next.get(0); + assert destroyed.value; + _current = null; + } + if(destroyed.value) + { + _query = null; } + printCurrent(); } - else + catch(Ice.ObjectNotExistException ex) { - _current = null; + System.out.println("the query object no longer exists"); + } + catch(Ice.LocalException ex) + { + error(ex.toString()); } - printCurrent(); } void @@ -212,6 +225,7 @@ class Parser { _current.proxy.rentBook((String)args.get(0)); System.out.println("the book is now rented by `" + (String)args.get(0) + "'"); + _current = _current.proxy.describe(); } else { @@ -220,7 +234,7 @@ class Parser } catch(BookRentedException ex) { - System.out.println("the book has already been rented."); + System.out.println("the book has already been rented"); } catch(Ice.ObjectNotExistException ex) { @@ -240,7 +254,8 @@ class Parser if(_current != null) { _current.proxy.returnBook(); - System.out.println( "the book has been returned."); + System.out.println( "the book has been returned"); + _current = _current.proxy.describe(); } else { @@ -249,7 +264,7 @@ class Parser } catch(BookNotRentedException ex) { - System.out.println("the book is not currently rented."); + System.out.println("the book is not currently rented"); } catch(Ice.ObjectNotExistException ex) { |