summaryrefslogtreecommitdiff
path: root/java/demo/Freeze/library/Parser.java
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2007-02-01 17:09:49 +0000
committerBernard Normier <bernard@zeroc.com>2007-02-01 17:09:49 +0000
commitabada90e3f84dc703b8ddc9efcbed8a946fadead (patch)
tree2c6f9dccd510ea97cb927a7bd635422efaae547a /java/demo/Freeze/library/Parser.java
parentremoving trace message (diff)
downloadice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.bz2
ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.xz
ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.zip
Expanded tabs into spaces
Diffstat (limited to 'java/demo/Freeze/library/Parser.java')
-rw-r--r--java/demo/Freeze/library/Parser.java530
1 files changed, 265 insertions, 265 deletions
diff --git a/java/demo/Freeze/library/Parser.java b/java/demo/Freeze/library/Parser.java
index dc0d641084a..b320cb1049e 100644
--- a/java/demo/Freeze/library/Parser.java
+++ b/java/demo/Freeze/library/Parser.java
@@ -13,366 +13,366 @@ class Parser
{
Parser(Ice.Communicator communicator, LibraryPrx library)
{
- _library = library;
+ _library = library;
}
void
usage()
{
- System.err.print(
- "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" +
- "authors NAME Find all books by the given authors.\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" +
- "return Return the currently rented book.\n" +
- "remove Permanently remove the current book from the library.\n" +
- "size SIZE Set the evictor size for books to SIZE.\n" +
- "shutdown Shut the library server down.\n");
+ System.err.print(
+ "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" +
+ "authors NAME Find all books by the given authors.\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" +
+ "return Return the currently rented book.\n" +
+ "remove Permanently remove the current book from the library.\n" +
+ "size SIZE Set the evictor size for books to SIZE.\n" +
+ "shutdown Shut the library server down.\n");
}
void
addBook(java.util.List args)
{
- if(args.size() != 3)
- {
- error("`add' requires at exactly three arguments (type `help' for more info)");
- return;
- }
-
- try
- {
- BookDescription desc = new BookDescription();
- desc.isbn = (String)args.get(0);
- desc.title = (String)args.get(1);
- desc.authors = (String)args.get(2);
-
- BookPrx book = _library.createBook(desc);
- System.out.println("added new book with isbn " + desc.isbn);
- }
- catch(DatabaseException ex)
- {
- error(ex.message);
- }
- catch(BookExistsException ex)
- {
- error("the book already exists.");
- }
- catch(Ice.LocalException ex)
- {
- error(ex.toString());
- }
+ if(args.size() != 3)
+ {
+ error("`add' requires at exactly three arguments (type `help' for more info)");
+ return;
+ }
+
+ try
+ {
+ BookDescription desc = new BookDescription();
+ desc.isbn = (String)args.get(0);
+ desc.title = (String)args.get(1);
+ desc.authors = (String)args.get(2);
+
+ BookPrx book = _library.createBook(desc);
+ System.out.println("added new book with isbn " + desc.isbn);
+ }
+ catch(DatabaseException ex)
+ {
+ error(ex.message);
+ }
+ catch(BookExistsException ex)
+ {
+ error("the book already exists.");
+ }
+ catch(Ice.LocalException ex)
+ {
+ error(ex.toString());
+ }
}
void
findIsbn(java.util.List args)
{
- if(args.size() != 1)
- {
- error("`isbn' requires exactly one argument (type `help' for more info)");
- return;
- }
-
- try
- {
- _foundBooks = null;
- _current = 0;
+ if(args.size() != 1)
+ {
+ error("`isbn' requires exactly one argument (type `help' for more info)");
+ return;
+ }
+
+ try
+ {
+ _foundBooks = null;
+ _current = 0;
- BookPrx book = _library.findByIsbn((String)args.get(0));
- if(book == null)
- {
- System.out.println("no book with that ISBN number exists.");
- }
- else
- {
- _foundBooks = new BookPrx[1];
- _foundBooks[0] = book;
- printCurrent();
- }
- }
- catch(DatabaseException ex)
- {
- error(ex.message);
- }
- catch(Ice.LocalException ex)
- {
- error(ex.toString());
- }
+ BookPrx book = _library.findByIsbn((String)args.get(0));
+ if(book == null)
+ {
+ System.out.println("no book with that ISBN number exists.");
+ }
+ else
+ {
+ _foundBooks = new BookPrx[1];
+ _foundBooks[0] = book;
+ printCurrent();
+ }
+ }
+ catch(DatabaseException ex)
+ {
+ error(ex.message);
+ }
+ catch(Ice.LocalException ex)
+ {
+ error(ex.toString());
+ }
}
void
findAuthors(java.util.List args)
{
- if(args.size() != 1)
- {
- error("`authors' requires exactly one argument (type `help' for more info)");
- return;
- }
-
- try
- {
- _foundBooks = _library.findByAuthors((String)args.get(0));
- _current = 0;
- System.out.println("number of books found: " + _foundBooks.length);
- printCurrent();
- }
- catch(DatabaseException ex)
- {
- error(ex.message);
- }
- catch(Ice.LocalException ex)
- {
- error(ex.toString());
- }
+ if(args.size() != 1)
+ {
+ error("`authors' requires exactly one argument (type `help' for more info)");
+ return;
+ }
+
+ try
+ {
+ _foundBooks = _library.findByAuthors((String)args.get(0));
+ _current = 0;
+ System.out.println("number of books found: " + _foundBooks.length);
+ printCurrent();
+ }
+ catch(DatabaseException ex)
+ {
+ error(ex.message);
+ }
+ catch(Ice.LocalException ex)
+ {
+ error(ex.toString());
+ }
}
void
nextFoundBook()
{
- if(_foundBooks != null && _current != _foundBooks.length)
- {
- ++_current;
- }
- printCurrent();
+ if(_foundBooks != null && _current != _foundBooks.length)
+ {
+ ++_current;
+ }
+ printCurrent();
}
void
printCurrent()
{
- try
- {
- if(_foundBooks != null && _current != _foundBooks.length)
- {
- BookDescription desc = _foundBooks[_current].getBookDescription();
- String renter = null;
- try
- {
- renter = _foundBooks[_current].getRenterName();
- }
- catch(BookNotRentedException ex)
- {
- }
+ try
+ {
+ if(_foundBooks != null && _current != _foundBooks.length)
+ {
+ BookDescription desc = _foundBooks[_current].getBookDescription();
+ String renter = null;
+ try
+ {
+ renter = _foundBooks[_current].getRenterName();
+ }
+ catch(BookNotRentedException ex)
+ {
+ }
- System.out.println("current book is:" );
- System.out.println("isbn: " + desc.isbn);
- System.out.println("title: " + desc.title);
- System.out.println("authors: " + desc.authors);
- if(renter != null)
- {
- System.out.println("rented: " + renter);
- }
- }
- else
- {
- System.out.println("no current book");
- }
- }
- catch(Ice.ObjectNotExistException ex)
- {
+ System.out.println("current book is:" );
+ System.out.println("isbn: " + desc.isbn);
+ System.out.println("title: " + desc.title);
+ System.out.println("authors: " + desc.authors);
+ if(renter != null)
+ {
+ System.out.println("rented: " + renter);
+ }
+ }
+ else
+ {
+ System.out.println("no current book");
+ }
+ }
+ catch(Ice.ObjectNotExistException ex)
+ {
System.out.println("current book no longer exists");
- }
- catch(Ice.LocalException ex)
- {
- error(ex.toString());
- }
+ }
+ catch(Ice.LocalException ex)
+ {
+ error(ex.toString());
+ }
}
void
rentCurrent(java.util.List args)
{
- if(args.size() != 1)
- {
- error("`rent' requires exactly one argument (type `help' for more info)");
- return;
- }
+ if(args.size() != 1)
+ {
+ error("`rent' requires exactly one argument (type `help' for more info)");
+ return;
+ }
- try
- {
- if(_foundBooks != null && _current != _foundBooks.length)
- {
- _foundBooks[_current].rentBook((String)args.get(0));
- System.out.println("the book is now rented by `" + (String)args.get(0) + "'");
- }
- else
- {
- System.out.println("no current book");
- }
- }
- catch(BookRentedException ex)
- {
- System.out.println("the book has already been rented.");
- }
- catch(Ice.ObjectNotExistException ex)
- {
+ try
+ {
+ if(_foundBooks != null && _current != _foundBooks.length)
+ {
+ _foundBooks[_current].rentBook((String)args.get(0));
+ System.out.println("the book is now rented by `" + (String)args.get(0) + "'");
+ }
+ else
+ {
+ System.out.println("no current book");
+ }
+ }
+ catch(BookRentedException ex)
+ {
+ System.out.println("the book has already been rented.");
+ }
+ catch(Ice.ObjectNotExistException ex)
+ {
System.out.println("current book no longer exists");
- }
- catch(Ice.LocalException ex)
- {
- error(ex.toString());
- }
+ }
+ catch(Ice.LocalException ex)
+ {
+ error(ex.toString());
+ }
}
void
returnCurrent()
{
- try
- {
- if(_foundBooks != null && _current != _foundBooks.length)
- {
- _foundBooks[_current].returnBook();
- System.out.println( "the book has been returned.");
- }
- else
- {
- System.out.println("no current book");
- }
- }
- catch(BookNotRentedException ex)
- {
- System.out.println("the book is not currently rented.");
- }
- catch(Ice.ObjectNotExistException ex)
- {
+ try
+ {
+ if(_foundBooks != null && _current != _foundBooks.length)
+ {
+ _foundBooks[_current].returnBook();
+ System.out.println( "the book has been returned.");
+ }
+ else
+ {
+ System.out.println("no current book");
+ }
+ }
+ catch(BookNotRentedException ex)
+ {
+ System.out.println("the book is not currently rented.");
+ }
+ catch(Ice.ObjectNotExistException ex)
+ {
System.out.println("current book no longer exists");
- }
- catch(Ice.LocalException ex)
- {
- error(ex.toString());
- }
+ }
+ catch(Ice.LocalException ex)
+ {
+ error(ex.toString());
+ }
}
void
removeCurrent()
{
- try
- {
- if(_foundBooks != null && _current != _foundBooks.length)
- {
- _foundBooks[_current].destroy();
- System.out.println("removed current book" );
- }
- else
- {
- System.out.println("no current book" );
- }
- }
- catch(DatabaseException ex)
- {
- error(ex.message);
- }
- catch(Ice.ObjectNotExistException ex)
- {
+ try
+ {
+ if(_foundBooks != null && _current != _foundBooks.length)
+ {
+ _foundBooks[_current].destroy();
+ System.out.println("removed current book" );
+ }
+ else
+ {
+ System.out.println("no current book" );
+ }
+ }
+ catch(DatabaseException ex)
+ {
+ error(ex.message);
+ }
+ catch(Ice.ObjectNotExistException ex)
+ {
System.out.println("current book no longer exists");
- }
- catch(Ice.LocalException ex)
- {
- error(ex.toString());
- }
+ }
+ catch(Ice.LocalException ex)
+ {
+ error(ex.toString());
+ }
}
void
setEvictorSize(java.util.List args)
{
- if(args.size() != 1)
- {
- error("`size' requires exactly one argument (type `help' for more info)");
- return;
- }
+ if(args.size() != 1)
+ {
+ error("`size' requires exactly one argument (type `help' for more info)");
+ return;
+ }
- String s = (String)args.get(0);
- try
- {
- _library.setEvictorSize(Integer.parseInt(s));
- }
- catch(NumberFormatException ex)
- {
- error("not a number " + s);
- }
- catch(DatabaseException ex)
- {
- error(ex.message);
- }
- catch(Ice.LocalException ex)
- {
- error(ex.toString());
- }
+ String s = (String)args.get(0);
+ try
+ {
+ _library.setEvictorSize(Integer.parseInt(s));
+ }
+ catch(NumberFormatException ex)
+ {
+ error("not a number " + s);
+ }
+ catch(DatabaseException ex)
+ {
+ error(ex.message);
+ }
+ catch(Ice.LocalException ex)
+ {
+ error(ex.toString());
+ }
}
void
shutdown()
{
- try
- {
- _library.shutdown();
- }
- catch(Ice.LocalException ex)
- {
- error(ex.toString());
- }
+ try
+ {
+ _library.shutdown();
+ }
+ catch(Ice.LocalException ex)
+ {
+ error(ex.toString());
+ }
}
void
error(String s)
{
- System.err.println("error: " + s);
+ System.err.println("error: " + s);
}
void
warning(String s)
{
- System.err.println("warning: " + s);
+ System.err.println("warning: " + s);
}
String
getInput()
{
- if(_interactive)
- {
- System.out.print(">>> ");
- System.out.flush();
- }
+ if(_interactive)
+ {
+ System.out.print(">>> ");
+ System.out.flush();
+ }
- try
- {
- return _in.readLine();
- }
- catch(java.io.IOException e)
- {
- return null;
- }
+ try
+ {
+ return _in.readLine();
+ }
+ catch(java.io.IOException e)
+ {
+ return null;
+ }
}
int
parse()
{
- _foundBooks = new BookPrx[0];
- _current = 0;
+ _foundBooks = new BookPrx[0];
+ _current = 0;
- _in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
- _interactive = true;
+ _in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
+ _interactive = true;
- Grammar g = new Grammar(this);
- g.parse();
+ Grammar g = new Grammar(this);
+ g.parse();
- return 0;
+ return 0;
}
int
parse(java.io.BufferedReader in)
{
- _foundBooks = new BookPrx[0];
- _current = 0;
+ _foundBooks = new BookPrx[0];
+ _current = 0;
- _in = in;
- _interactive = false;
+ _in = in;
+ _interactive = false;
- Grammar g = new Grammar(this);
- g.parse();
+ Grammar g = new Grammar(this);
+ g.parse();
- return 0;
+ return 0;
}
private BookPrx[] _foundBooks;