summaryrefslogtreecommitdiff
path: root/java/demo/Freeze/library
diff options
context:
space:
mode:
Diffstat (limited to 'java/demo/Freeze/library')
-rw-r--r--java/demo/Freeze/library/BookFactory.java6
-rw-r--r--java/demo/Freeze/library/BookI.java80
-rw-r--r--java/demo/Freeze/library/Client.java42
-rw-r--r--java/demo/Freeze/library/Collocated.java106
-rw-r--r--java/demo/Freeze/library/Grammar.java294
-rw-r--r--java/demo/Freeze/library/Library.ice16
-rw-r--r--java/demo/Freeze/library/LibraryI.java362
-rw-r--r--java/demo/Freeze/library/Parser.java530
-rw-r--r--java/demo/Freeze/library/RunParser.java122
-rw-r--r--java/demo/Freeze/library/Scanner.java464
-rw-r--r--java/demo/Freeze/library/Server.java74
-rw-r--r--java/demo/Freeze/library/Token.java8
12 files changed, 1052 insertions, 1052 deletions
diff --git a/java/demo/Freeze/library/BookFactory.java b/java/demo/Freeze/library/BookFactory.java
index c00b5812fe0..56f729549ee 100644
--- a/java/demo/Freeze/library/BookFactory.java
+++ b/java/demo/Freeze/library/BookFactory.java
@@ -12,8 +12,8 @@ class BookFactory extends Ice.LocalObjectImpl implements Ice.ObjectFactory
public Ice.Object
create(String type)
{
- assert(type.equals("::Demo::Book"));
- return new BookI(_library);
+ assert(type.equals("::Demo::Book"));
+ return new BookI(_library);
}
public void
@@ -23,7 +23,7 @@ class BookFactory extends Ice.LocalObjectImpl implements Ice.ObjectFactory
BookFactory(LibraryI library)
{
- _library = library;
+ _library = library;
}
private LibraryI _library;
diff --git a/java/demo/Freeze/library/BookI.java b/java/demo/Freeze/library/BookI.java
index e7c51f7bdb2..74188b27b1f 100644
--- a/java/demo/Freeze/library/BookI.java
+++ b/java/demo/Freeze/library/BookI.java
@@ -24,63 +24,63 @@ class BookI extends Book
throw new Ice.ObjectNotExistException();
}
- //
- // Immutable.
- //
- return description;
+ //
+ // Immutable.
+ //
+ return description;
}
synchronized public String
getRenterName(Ice.Current current)
- throws BookNotRentedException
+ throws BookNotRentedException
{
if(_destroyed)
{
throw new Ice.ObjectNotExistException();
}
- if(rentalCustomerName.length() == 0)
- {
- throw new BookNotRentedException();
- }
- return rentalCustomerName;
+ if(rentalCustomerName.length() == 0)
+ {
+ throw new BookNotRentedException();
+ }
+ return rentalCustomerName;
}
synchronized public void
rentBook(String name, Ice.Current current)
- throws BookRentedException
+ throws BookRentedException
{
if(_destroyed)
{
throw new Ice.ObjectNotExistException();
}
- if(rentalCustomerName.length() != 0)
- {
- throw new BookRentedException();
- }
- rentalCustomerName = name;
+ if(rentalCustomerName.length() != 0)
+ {
+ throw new BookRentedException();
+ }
+ rentalCustomerName = name;
}
synchronized public void
returnBook(Ice.Current current)
- throws BookNotRentedException
+ throws BookNotRentedException
{
if(_destroyed)
{
throw new Ice.ObjectNotExistException();
}
- if(rentalCustomerName.length() == 0)
- {
- throw new BookNotRentedException();
- }
- rentalCustomerName = new String();;
+ if(rentalCustomerName.length() == 0)
+ {
+ throw new BookNotRentedException();
+ }
+ rentalCustomerName = new String();;
}
synchronized public void
destroy(Ice.Current current)
- throws DatabaseException
+ throws DatabaseException
{
if(_destroyed)
{
@@ -89,29 +89,29 @@ class BookI extends Book
_destroyed = true;
- try
- {
- _library.remove(description);
- }
- catch(Freeze.DatabaseException ex)
- {
- DatabaseException e = new DatabaseException();
- e.message = ex.message;
- throw e;
- }
+ try
+ {
+ _library.remove(description);
+ }
+ catch(Freeze.DatabaseException ex)
+ {
+ DatabaseException e = new DatabaseException();
+ e.message = ex.message;
+ throw e;
+ }
}
BookI(LibraryI library)
{
- _library = library;
+ _library = library;
_destroyed = false;
- //
- // This could be avoided by having two constructors (one for
- // new creation of a book, and the other for restoring a
- // previously saved book).
- //
- rentalCustomerName = new String();
+ //
+ // This could be avoided by having two constructors (one for
+ // new creation of a book, and the other for restoring a
+ // previously saved book).
+ //
+ rentalCustomerName = new String();
}
private LibraryI _library;
diff --git a/java/demo/Freeze/library/Client.java b/java/demo/Freeze/library/Client.java
index 802acd88954..b9fb2037097 100644
--- a/java/demo/Freeze/library/Client.java
+++ b/java/demo/Freeze/library/Client.java
@@ -11,37 +11,37 @@ public class Client extends Ice.Application
{
class ShutdownHook extends Thread
{
- public void
- run()
- {
- try
- {
- communicator().destroy();
- }
- catch(Ice.LocalException ex)
- {
- ex.printStackTrace();
- }
- }
+ public void
+ run()
+ {
+ try
+ {
+ communicator().destroy();
+ }
+ catch(Ice.LocalException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
}
public int
run(String[] args)
{
- //
- // Since this is an interactive demo we want to clear the
- // Application installed interrupt callback and install our
- // own shutdown hook.
+ //
+ // Since this is an interactive demo we want to clear the
+ // Application installed interrupt callback and install our
+ // own shutdown hook.
//
- setInterruptHook(new ShutdownHook());
-
- return RunParser.runParser(appName(), args, communicator());
+ setInterruptHook(new ShutdownHook());
+
+ return RunParser.runParser(appName(), args, communicator());
}
static public void
main(String[] args)
{
- Client app = new Client();
- app.main("demo.Freeze.library.Client", args, "config.client");
+ Client app = new Client();
+ app.main("demo.Freeze.library.Client", args, "config.client");
}
}
diff --git a/java/demo/Freeze/library/Collocated.java b/java/demo/Freeze/library/Collocated.java
index a5963b4e85a..0f5f93ccb14 100644
--- a/java/demo/Freeze/library/Collocated.java
+++ b/java/demo/Freeze/library/Collocated.java
@@ -11,74 +11,74 @@ class LibraryCollocated extends Ice.Application
{
class ShutdownHook extends Thread
{
- public void
- run()
- {
- try
- {
- communicator().destroy();
- }
- catch(Ice.LocalException ex)
- {
- ex.printStackTrace();
- }
- }
+ public void
+ run()
+ {
+ try
+ {
+ communicator().destroy();
+ }
+ catch(Ice.LocalException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
}
public int
run(String[] args)
{
- //
- // Since this is an interactive demo we want to clear the
- // Application installed interrupt callback and install our
- // own shutdown hook.
- //
- setInterruptHook(new ShutdownHook());
+ //
+ // Since this is an interactive demo we want to clear the
+ // Application installed interrupt callback and install our
+ // own shutdown hook.
+ //
+ setInterruptHook(new ShutdownHook());
- Ice.Properties properties = communicator().getProperties();
+ Ice.Properties properties = communicator().getProperties();
- //
- // Create an Object Adapter
- //
- Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Library");
+ //
+ // Create an Object Adapter
+ //
+ Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Library");
- //
- // Create an Evictor for books.
- //
- Freeze.Evictor evictor = Freeze.Util.createEvictor(adapter, _envName, "books", null, null, true);
- int evictorSize = properties.getPropertyAsInt("Library.EvictorSize");
- if(evictorSize > 0)
- {
- evictor.setSize(evictorSize);
- }
+ //
+ // Create an Evictor for books.
+ //
+ Freeze.Evictor evictor = Freeze.Util.createEvictor(adapter, _envName, "books", null, null, true);
+ int evictorSize = properties.getPropertyAsInt("Library.EvictorSize");
+ if(evictorSize > 0)
+ {
+ evictor.setSize(evictorSize);
+ }
- adapter.addServantLocator(evictor, "book");
+ adapter.addServantLocator(evictor, "book");
- //
- // Create the library, and add it to the Object Adapter.
- //
- LibraryI library = new LibraryI(communicator(), _envName, "authors", evictor);
- adapter.add(library, communicator().stringToIdentity("library"));
+ //
+ // Create the library, and add it to the Object Adapter.
+ //
+ LibraryI library = new LibraryI(communicator(), _envName, "authors", evictor);
+ adapter.add(library, communicator().stringToIdentity("library"));
- //
- // Create and install a factory and initializer for books.
- //
- Ice.ObjectFactory bookFactory = new BookFactory(library);
- communicator().addObjectFactory(bookFactory, "::Demo::Book");
+ //
+ // Create and install a factory and initializer for books.
+ //
+ Ice.ObjectFactory bookFactory = new BookFactory(library);
+ communicator().addObjectFactory(bookFactory, "::Demo::Book");
- //
- // Everything ok, let's go.
- //
- int status = RunParser.runParser(appName(), args, communicator());
- adapter.destroy();
+ //
+ // Everything ok, let's go.
+ //
+ int status = RunParser.runParser(appName(), args, communicator());
+ adapter.destroy();
- library.close();
- return status;
+ library.close();
+ return status;
}
LibraryCollocated(String envName)
{
- _envName = envName;
+ _envName = envName;
}
private String _envName;
@@ -89,7 +89,7 @@ public class Collocated
static public void
main(String[] args)
{
- LibraryCollocated app = new LibraryCollocated("db");
- app.main("demo.Freeze.library.Collocated", args, "config.collocated");
+ LibraryCollocated app = new LibraryCollocated("db");
+ app.main("demo.Freeze.library.Collocated", args, "config.collocated");
}
}
diff --git a/java/demo/Freeze/library/Grammar.java b/java/demo/Freeze/library/Grammar.java
index 43749b2d67a..5c3c68c1ab9 100644
--- a/java/demo/Freeze/library/Grammar.java
+++ b/java/demo/Freeze/library/Grammar.java
@@ -11,173 +11,173 @@ class Grammar
{
Grammar(Parser p)
{
- _parser = p;
- _scanner = new Scanner(_parser);
+ _parser = p;
+ _scanner = new Scanner(_parser);
}
void
parse()
{
- while(true)
- {
- try
- {
- _token = _scanner.nextToken();
- if(_token == null)
- {
- return;
- }
- else if(_token.type == Token.TOK_SEMI)
- {
- // Continue
- }
- else if(_token.type == Token.TOK_HELP)
- {
- _token = _scanner.nextToken();
- if(_token.type != Token.TOK_SEMI)
- {
- throw new ParseError("Expected ';'");
- }
+ while(true)
+ {
+ try
+ {
+ _token = _scanner.nextToken();
+ if(_token == null)
+ {
+ return;
+ }
+ else if(_token.type == Token.TOK_SEMI)
+ {
+ // Continue
+ }
+ else if(_token.type == Token.TOK_HELP)
+ {
+ _token = _scanner.nextToken();
+ if(_token.type != Token.TOK_SEMI)
+ {
+ throw new ParseError("Expected ';'");
+ }
- _parser.usage();
- }
- else if(_token.type == Token.TOK_EXIT)
- {
- _token = _scanner.nextToken();
- if(_token.type != Token.TOK_SEMI)
- {
- throw new ParseError("Expected ';'");
- }
+ _parser.usage();
+ }
+ else if(_token.type == Token.TOK_EXIT)
+ {
+ _token = _scanner.nextToken();
+ if(_token.type != Token.TOK_SEMI)
+ {
+ throw new ParseError("Expected ';'");
+ }
- return;
- }
- else if(_token.type == Token.TOK_ADD_BOOK)
- {
- java.util.List s = strings();
- if(_token.type != Token.TOK_SEMI)
- {
- throw new ParseError("Expected ';'");
- }
- _parser.addBook(s);
- }
- else if(_token.type == Token.TOK_FIND_ISBN)
- {
- java.util.List s = strings();
- if(_token.type != Token.TOK_SEMI)
- {
- throw new ParseError("Expected ';'");
- }
- _parser.findIsbn(s);
- }
- else if(_token.type == Token.TOK_FIND_AUTHORS)
- {
- java.util.List s = strings();
- if(_token.type != Token.TOK_SEMI)
- {
- throw new ParseError("Expected ';'");
- }
- _parser.findAuthors(s);
- }
- else if(_token.type == Token.TOK_NEXT_FOUND_BOOK)
- {
- _token = _scanner.nextToken();
- if(_token.type != Token.TOK_SEMI)
- {
- throw new ParseError("Expected ';'");
- }
+ return;
+ }
+ else if(_token.type == Token.TOK_ADD_BOOK)
+ {
+ java.util.List s = strings();
+ if(_token.type != Token.TOK_SEMI)
+ {
+ throw new ParseError("Expected ';'");
+ }
+ _parser.addBook(s);
+ }
+ else if(_token.type == Token.TOK_FIND_ISBN)
+ {
+ java.util.List s = strings();
+ if(_token.type != Token.TOK_SEMI)
+ {
+ throw new ParseError("Expected ';'");
+ }
+ _parser.findIsbn(s);
+ }
+ else if(_token.type == Token.TOK_FIND_AUTHORS)
+ {
+ java.util.List s = strings();
+ if(_token.type != Token.TOK_SEMI)
+ {
+ throw new ParseError("Expected ';'");
+ }
+ _parser.findAuthors(s);
+ }
+ else if(_token.type == Token.TOK_NEXT_FOUND_BOOK)
+ {
+ _token = _scanner.nextToken();
+ if(_token.type != Token.TOK_SEMI)
+ {
+ throw new ParseError("Expected ';'");
+ }
- _parser.nextFoundBook();
- }
- else if(_token.type == Token.TOK_PRINT_CURRENT)
- {
- _token = _scanner.nextToken();
- if(_token.type != Token.TOK_SEMI)
- {
- throw new ParseError("Expected ';'");
- }
+ _parser.nextFoundBook();
+ }
+ else if(_token.type == Token.TOK_PRINT_CURRENT)
+ {
+ _token = _scanner.nextToken();
+ if(_token.type != Token.TOK_SEMI)
+ {
+ throw new ParseError("Expected ';'");
+ }
- _parser.printCurrent();
- }
- else if(_token.type == Token.TOK_RENT_BOOK)
- {
- java.util.List s = strings();
- if(_token.type != Token.TOK_SEMI)
- {
- throw new ParseError("Expected ';'");
- }
- _parser.rentCurrent(s);
- }
- else if(_token.type == Token.TOK_RETURN_BOOK)
- {
- _token = _scanner.nextToken();
- if(_token.type != Token.TOK_SEMI)
- {
- throw new ParseError("Expected ';'");
- }
- _parser.returnCurrent();
- }
- else if(_token.type == Token.TOK_REMOVE_CURRENT)
- {
- _token = _scanner.nextToken();
- if(_token.type != Token.TOK_SEMI)
- {
- throw new ParseError("Expected ';'");
- }
+ _parser.printCurrent();
+ }
+ else if(_token.type == Token.TOK_RENT_BOOK)
+ {
+ java.util.List s = strings();
+ if(_token.type != Token.TOK_SEMI)
+ {
+ throw new ParseError("Expected ';'");
+ }
+ _parser.rentCurrent(s);
+ }
+ else if(_token.type == Token.TOK_RETURN_BOOK)
+ {
+ _token = _scanner.nextToken();
+ if(_token.type != Token.TOK_SEMI)
+ {
+ throw new ParseError("Expected ';'");
+ }
+ _parser.returnCurrent();
+ }
+ else if(_token.type == Token.TOK_REMOVE_CURRENT)
+ {
+ _token = _scanner.nextToken();
+ if(_token.type != Token.TOK_SEMI)
+ {
+ throw new ParseError("Expected ';'");
+ }
- _parser.removeCurrent();
- }
- else if(_token.type == Token.TOK_SET_EVICTOR_SIZE)
- {
- java.util.List s = strings();
- if(_token.type != Token.TOK_SEMI)
- {
- throw new ParseError("Expected ';'");
- }
- _parser.setEvictorSize(s);
- }
- else if(_token.type == Token.TOK_SHUTDOWN)
- {
- _token = _scanner.nextToken();
- if(_token.type != Token.TOK_SEMI)
- {
- throw new ParseError("Expected ';'");
- }
+ _parser.removeCurrent();
+ }
+ else if(_token.type == Token.TOK_SET_EVICTOR_SIZE)
+ {
+ java.util.List s = strings();
+ if(_token.type != Token.TOK_SEMI)
+ {
+ throw new ParseError("Expected ';'");
+ }
+ _parser.setEvictorSize(s);
+ }
+ else if(_token.type == Token.TOK_SHUTDOWN)
+ {
+ _token = _scanner.nextToken();
+ if(_token.type != Token.TOK_SEMI)
+ {
+ throw new ParseError("Expected ';'");
+ }
- _parser.shutdown();
- }
- else
- {
- _parser.error("parse error");
- }
- }
- catch(ParseError e)
- {
- _parser.error("Parse error: " + e.getMessage());
- }
- }
+ _parser.shutdown();
+ }
+ else
+ {
+ _parser.error("parse error");
+ }
+ }
+ catch(ParseError e)
+ {
+ _parser.error("Parse error: " + e.getMessage());
+ }
+ }
}
private java.util.List
strings()
{
- java.util.List l = new java.util.ArrayList();
- while(true)
- {
- _token = _scanner.nextToken();
- if(_token.type != Token.TOK_STRING)
- {
- return l;
- }
- l.add(_token.value);
- }
+ java.util.List l = new java.util.ArrayList();
+ while(true)
+ {
+ _token = _scanner.nextToken();
+ if(_token.type != Token.TOK_STRING)
+ {
+ return l;
+ }
+ l.add(_token.value);
+ }
}
static private class ParseError extends RuntimeException
{
- ParseError(String msg)
- {
- super(msg);
- }
+ ParseError(String msg)
+ {
+ super(msg);
+ }
}
private Parser _parser;
diff --git a/java/demo/Freeze/library/Library.ice b/java/demo/Freeze/library/Library.ice
index 7111b0f1eac..87663189286 100644
--- a/java/demo/Freeze/library/Library.ice
+++ b/java/demo/Freeze/library/Library.ice
@@ -92,7 +92,7 @@ class Book
*
**/
["freeze:write"] void destroy()
- throws DatabaseException;
+ throws DatabaseException;
/**
*
@@ -105,7 +105,7 @@ class Book
*
**/
["freeze:write"] void rentBook(string name)
- throws BookRentedException;
+ throws BookRentedException;
/**
*
@@ -118,7 +118,7 @@ class Book
*
**/
["cpp:const"] idempotent string getRenterName()
- throws BookNotRentedException;
+ throws BookNotRentedException;
/**
*
@@ -129,7 +129,7 @@ class Book
*
**/
["freeze:write"] void returnBook()
- throws BookNotRentedException;
+ throws BookNotRentedException;
/**
*
@@ -177,7 +177,7 @@ interface Library
*
**/
Book* createBook(BookDescription description)
- throws DatabaseException, BookExistsException;
+ throws DatabaseException, BookExistsException;
/**
*
@@ -192,7 +192,7 @@ interface Library
*
**/
["cpp:const"] idempotent Book* findByIsbn(string isbn)
- throws DatabaseException;
+ throws DatabaseException;
/**
*
@@ -207,7 +207,7 @@ interface Library
*
**/
["cpp:const"] idempotent BookPrxSeq findByAuthors(string authors)
- throws DatabaseException;
+ throws DatabaseException;
/**
*
@@ -220,7 +220,7 @@ interface Library
*
**/
idempotent void setEvictorSize(int size)
- throws DatabaseException;
+ throws DatabaseException;
/**
*
diff --git a/java/demo/Freeze/library/LibraryI.java b/java/demo/Freeze/library/LibraryI.java
index 47b6064b8d1..acf10ef3d26 100644
--- a/java/demo/Freeze/library/LibraryI.java
+++ b/java/demo/Freeze/library/LibraryI.java
@@ -13,68 +13,68 @@ class LibraryI extends _LibraryDisp
{
public synchronized BookPrx
createBook(BookDescription description, Ice.Current current)
- throws DatabaseException, BookExistsException
+ throws DatabaseException, BookExistsException
{
- BookPrx book = isbnToBook(description.isbn, current.adapter);
-
- try
- {
- book.ice_ping();
-
- //
- // The book already exists.
- //
- throw new BookExistsException();
- }
- catch(Ice.ObjectNotExistException e)
- {
- //
- // Book doesn't exist, ignore the exception.
- //
- }
-
- //
- // Create a new book Servant.
- //
- BookI bookI = new BookI(this);
- bookI.description = description;
-
- Ice.Identity ident = createBookIdentity(description.isbn);
-
- //
- // Create a new Ice Object in the evictor, using the new
- // identity and the new Servant.
- //
- // This can throw EvictorDeactivatedException (which indicates
- // an internal error). The exception is currently ignored.
- //
- _evictor.add(bookI, ident);
-
- try
- {
- //
- // Add the isbn number to the authors map.
- //
- String[] isbnSeq = (String[])_authors.get(description.authors);
- int length = (isbnSeq == null) ? 0 : isbnSeq.length;
- String[] newIsbnSeq = new String[length+1];
-
- if(isbnSeq != null)
- {
- System.arraycopy(isbnSeq, 0, newIsbnSeq, 0, length);
- }
- newIsbnSeq[length] = description.isbn;
-
- _authors.fastPut(description.authors, newIsbnSeq);
-
- return book;
- }
- catch(Freeze.DatabaseException ex)
- {
- DatabaseException e = new DatabaseException();
- e.message = ex.message;
- throw e;
- }
+ BookPrx book = isbnToBook(description.isbn, current.adapter);
+
+ try
+ {
+ book.ice_ping();
+
+ //
+ // The book already exists.
+ //
+ throw new BookExistsException();
+ }
+ catch(Ice.ObjectNotExistException e)
+ {
+ //
+ // Book doesn't exist, ignore the exception.
+ //
+ }
+
+ //
+ // Create a new book Servant.
+ //
+ BookI bookI = new BookI(this);
+ bookI.description = description;
+
+ Ice.Identity ident = createBookIdentity(description.isbn);
+
+ //
+ // Create a new Ice Object in the evictor, using the new
+ // identity and the new Servant.
+ //
+ // This can throw EvictorDeactivatedException (which indicates
+ // an internal error). The exception is currently ignored.
+ //
+ _evictor.add(bookI, ident);
+
+ try
+ {
+ //
+ // Add the isbn number to the authors map.
+ //
+ String[] isbnSeq = (String[])_authors.get(description.authors);
+ int length = (isbnSeq == null) ? 0 : isbnSeq.length;
+ String[] newIsbnSeq = new String[length+1];
+
+ if(isbnSeq != null)
+ {
+ System.arraycopy(isbnSeq, 0, newIsbnSeq, 0, length);
+ }
+ newIsbnSeq[length] = description.isbn;
+
+ _authors.fastPut(description.authors, newIsbnSeq);
+
+ return book;
+ }
+ catch(Freeze.DatabaseException ex)
+ {
+ DatabaseException e = new DatabaseException();
+ e.message = ex.message;
+ throw e;
+ }
}
//
@@ -83,166 +83,166 @@ class LibraryI extends _LibraryDisp
//
public BookPrx
findByIsbn(String isbn, Ice.Current current)
- throws DatabaseException
+ throws DatabaseException
{
- try
- {
- BookPrx book = isbnToBook(isbn, current.adapter);
- book.ice_ping();
-
- return book;
- }
- catch(Ice.ObjectNotExistException ex)
- {
- //
- // Book doesn't exist, return a null proxy.
- //
- return null;
- }
+ try
+ {
+ BookPrx book = isbnToBook(isbn, current.adapter);
+ book.ice_ping();
+
+ return book;
+ }
+ catch(Ice.ObjectNotExistException ex)
+ {
+ //
+ // Book doesn't exist, return a null proxy.
+ //
+ return null;
+ }
}
public synchronized BookPrx[]
findByAuthors(String authors, Ice.Current current)
- throws DatabaseException
+ throws DatabaseException
{
- try
- {
- //
- // Lookup all books that match the given authors, and
- // return them to the caller.
- //
- String[] isbnSeq = (String[])_authors.get(authors);
-
- int length = (isbnSeq == null) ? 0 : isbnSeq.length;
- BookPrx[] books = new BookPrx[length];
-
- if(isbnSeq != null)
- {
- for(int i = 0; i < length; ++i)
- {
- books[i] = isbnToBook(isbnSeq[i], current.adapter);
- }
- }
-
- return books;
- }
- catch(Freeze.DatabaseException ex)
- {
- DatabaseException e = new DatabaseException();
- e.message = ex.message;
- throw e;
- }
+ try
+ {
+ //
+ // Lookup all books that match the given authors, and
+ // return them to the caller.
+ //
+ String[] isbnSeq = (String[])_authors.get(authors);
+
+ int length = (isbnSeq == null) ? 0 : isbnSeq.length;
+ BookPrx[] books = new BookPrx[length];
+
+ if(isbnSeq != null)
+ {
+ for(int i = 0; i < length; ++i)
+ {
+ books[i] = isbnToBook(isbnSeq[i], current.adapter);
+ }
+ }
+
+ return books;
+ }
+ catch(Freeze.DatabaseException ex)
+ {
+ DatabaseException e = new DatabaseException();
+ e.message = ex.message;
+ throw e;
+ }
}
public void
setEvictorSize(int size, Ice.Current current)
- throws DatabaseException
+ throws DatabaseException
{
- //
- // No synchronization necessary, _evictor is immutable.
- //
- _evictor.setSize(size);
+ //
+ // No synchronization necessary, _evictor is immutable.
+ //
+ _evictor.setSize(size);
}
public void
shutdown(Ice.Current current)
{
- current.adapter.getCommunicator().shutdown();
+ current.adapter.getCommunicator().shutdown();
}
protected synchronized void
remove(BookDescription description)
- throws DatabaseException
+ throws DatabaseException
{
- try
- {
- String[] isbnSeq = (String[])_authors.get(description.authors);
-
- assert isbnSeq != null;
-
-
- int i;
- for(i = 0; i < isbnSeq.length; ++i)
- {
- if(isbnSeq[i].equals(description.isbn))
- {
- break;
- }
- }
-
- assert i < isbnSeq.length;
-
- if(isbnSeq.length == 1)
- {
- //
- // If there are no further associated isbn numbers then remove
- // the record.
- //
- _authors.fastRemove(description.authors);
- }
- else
- {
- //
- // Remove the isbn number from the sequence and write
- // back the new record.
- //
- String[] newIsbnSeq = new String[isbnSeq.length-1];
- System.arraycopy(isbnSeq, 0, newIsbnSeq, 0, i);
- if(i < isbnSeq.length - 1)
- {
- System.arraycopy(isbnSeq, i+1, newIsbnSeq, i, isbnSeq.length - i - 1);
- }
-
- _authors.fastPut(description.authors, newIsbnSeq);
- }
-
- //
- // This can throw EvictorDeactivatedException (which
- // indicates an internal error). The exception is
- // currently ignored.
- //
- _evictor.remove(createBookIdentity(description.isbn));
- }
- catch(Freeze.DatabaseException ex)
- {
- DatabaseException e = new DatabaseException();
- e.message = ex.message;
- throw e;
- }
+ try
+ {
+ String[] isbnSeq = (String[])_authors.get(description.authors);
+
+ assert isbnSeq != null;
+
+
+ int i;
+ for(i = 0; i < isbnSeq.length; ++i)
+ {
+ if(isbnSeq[i].equals(description.isbn))
+ {
+ break;
+ }
+ }
+
+ assert i < isbnSeq.length;
+
+ if(isbnSeq.length == 1)
+ {
+ //
+ // If there are no further associated isbn numbers then remove
+ // the record.
+ //
+ _authors.fastRemove(description.authors);
+ }
+ else
+ {
+ //
+ // Remove the isbn number from the sequence and write
+ // back the new record.
+ //
+ String[] newIsbnSeq = new String[isbnSeq.length-1];
+ System.arraycopy(isbnSeq, 0, newIsbnSeq, 0, i);
+ if(i < isbnSeq.length - 1)
+ {
+ System.arraycopy(isbnSeq, i+1, newIsbnSeq, i, isbnSeq.length - i - 1);
+ }
+
+ _authors.fastPut(description.authors, newIsbnSeq);
+ }
+
+ //
+ // This can throw EvictorDeactivatedException (which
+ // indicates an internal error). The exception is
+ // currently ignored.
+ //
+ _evictor.remove(createBookIdentity(description.isbn));
+ }
+ catch(Freeze.DatabaseException ex)
+ {
+ DatabaseException e = new DatabaseException();
+ e.message = ex.message;
+ throw e;
+ }
}
LibraryI(Ice.Communicator communicator, String envName, String dbName, Freeze.Evictor evictor)
{
- _evictor = evictor;
- _connection = Freeze.Util.createConnection(communicator, envName);
- _authors = new StringIsbnSeqDict(_connection, dbName, true);
+ _evictor = evictor;
+ _connection = Freeze.Util.createConnection(communicator, envName);
+ _authors = new StringIsbnSeqDict(_connection, dbName, true);
}
void
close()
{
- _authors.close();
- _connection.close();
+ _authors.close();
+ _connection.close();
}
private Ice.Identity
createBookIdentity(String isbn)
{
- //
- // Note that the identity category is important since the
- // locator was installed for the category 'book'.
- //
- Ice.Identity ident = new Ice.Identity();
- ident.category = "book";
- ident.name = isbn;
-
- return ident;
+ //
+ // Note that the identity category is important since the
+ // locator was installed for the category 'book'.
+ //
+ Ice.Identity ident = new Ice.Identity();
+ ident.category = "book";
+ ident.name = isbn;
+
+ return ident;
}
private BookPrx
isbnToBook(String isbn, Ice.ObjectAdapter adapter)
{
- return BookPrxHelper.uncheckedCast(adapter.createProxy(createBookIdentity(isbn)));
+ return BookPrxHelper.uncheckedCast(adapter.createProxy(createBookIdentity(isbn)));
}
private Freeze.Evictor _evictor;
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;
diff --git a/java/demo/Freeze/library/RunParser.java b/java/demo/Freeze/library/RunParser.java
index 426f1beefe7..1fc0e095c7d 100644
--- a/java/demo/Freeze/library/RunParser.java
+++ b/java/demo/Freeze/library/RunParser.java
@@ -14,26 +14,26 @@ class RunParser
static void
usage(String appName)
{
- System.err.println("Usage: " + appName + " [options] [file...]\n");
- System.err.print(
- "Options:\n" +
- "-h, --help Show this message.\n");
- //"-v, --version Display the Ice version.\n"
+ System.err.println("Usage: " + appName + " [options] [file...]\n");
+ System.err.print(
+ "Options:\n" +
+ "-h, --help Show this message.\n");
+ //"-v, --version Display the Ice version.\n"
}
static int
runParser(String appName, String[] args, Ice.Communicator communicator)
{
- String file = null;
- int idx = 0;
+ String file = null;
+ int idx = 0;
- while(idx < args.length)
- {
- if(args[idx].equals("-h") | args[idx].equals("--help"))
- {
- usage(appName);
- return 0;
- }
+ while(idx < args.length)
+ {
+ if(args[idx].equals("-h") | args[idx].equals("--help"))
+ {
+ usage(appName);
+ return 0;
+ }
/*
else if(args[idx].equals("-v") || args[idx].equals("--version"))
{
@@ -41,56 +41,56 @@ class RunParser
return 0;
}
*/
- else if(args[idx].charAt(0) == '-')
- {
- System.err.println(appName + ": unknown option `" + args[idx] + "'");
- usage(appName);
- return 1;
- }
- else
- {
- if(file == null)
- {
- file = args[idx];
- }
- else
- {
- System.err.println(appName + ": only one file is supported.");
- usage(appName);
- return 1;
- }
- ++idx;
- }
- }
+ else if(args[idx].charAt(0) == '-')
+ {
+ System.err.println(appName + ": unknown option `" + args[idx] + "'");
+ usage(appName);
+ return 1;
+ }
+ else
+ {
+ if(file == null)
+ {
+ file = args[idx];
+ }
+ else
+ {
+ System.err.println(appName + ": only one file is supported.");
+ usage(appName);
+ return 1;
+ }
+ ++idx;
+ }
+ }
- Ice.ObjectPrx base = communicator.propertyToProxy("Library.Proxy");
- LibraryPrx library = LibraryPrxHelper.checkedCast(base);
- if(library == null)
- {
- System.err.println(appName + ": invalid object reference");
- return 1;
- }
+ Ice.ObjectPrx base = communicator.propertyToProxy("Library.Proxy");
+ LibraryPrx library = LibraryPrxHelper.checkedCast(base);
+ if(library == null)
+ {
+ System.err.println(appName + ": invalid object reference");
+ return 1;
+ }
- Parser parser = new Parser(communicator, library);
- int status;
+ Parser parser = new Parser(communicator, library);
+ int status;
- if(file == null)
- {
- status = parser.parse();
- }
- else
- {
- try
- {
- status = parser.parse(new java.io.BufferedReader(new java.io.FileReader(file)));
- }
- catch(java.io.IOException ex)
- {
- status = 1;
- ex.printStackTrace();
- }
- }
+ if(file == null)
+ {
+ status = parser.parse();
+ }
+ else
+ {
+ try
+ {
+ status = parser.parse(new java.io.BufferedReader(new java.io.FileReader(file)));
+ }
+ catch(java.io.IOException ex)
+ {
+ status = 1;
+ ex.printStackTrace();
+ }
+ }
- return status;
+ return status;
}
}
diff --git a/java/demo/Freeze/library/Scanner.java b/java/demo/Freeze/library/Scanner.java
index 27e42f2d83d..7bcf64d1862 100644
--- a/java/demo/Freeze/library/Scanner.java
+++ b/java/demo/Freeze/library/Scanner.java
@@ -11,74 +11,74 @@ class Scanner
{
Scanner(Parser p)
{
- _parser = p;
+ _parser = p;
}
Token
nextToken()
{
- String s = next();
- if(s == null)
- {
- return null;
- }
+ String s = next();
+ if(s == null)
+ {
+ return null;
+ }
- if(s.equals(";"))
- {
- return new Token(Token.TOK_SEMI);
- }
- else if(s.equals("help"))
- {
- return new Token(Token.TOK_HELP);
- }
- else if(s.equals("exit") || s.equals("quit"))
- {
- return new Token(Token.TOK_EXIT);
- }
- else if(s.equals("add"))
- {
- return new Token(Token.TOK_ADD_BOOK);
- }
- else if(s.equals("isbn"))
- {
- return new Token(Token.TOK_FIND_ISBN);
- }
- else if(s.equals("authors"))
- {
- return new Token(Token.TOK_FIND_AUTHORS);
- }
- else if(s.equals("next"))
- {
- return new Token(Token.TOK_NEXT_FOUND_BOOK);
- }
- else if(s.equals("current"))
- {
- return new Token(Token.TOK_PRINT_CURRENT);
- }
- else if(s.equals("rent"))
- {
- return new Token(Token.TOK_RENT_BOOK);
- }
- else if(s.equals("return"))
- {
- return new Token(Token.TOK_RETURN_BOOK);
- }
- else if(s.equals("remove"))
- {
- return new Token(Token.TOK_REMOVE_CURRENT);
- }
- else if(s.equals("size"))
- {
- return new Token(Token.TOK_SET_EVICTOR_SIZE);
- }
- else if(s.equals("shutdown"))
- {
- return new Token(Token.TOK_SHUTDOWN);
- }
- else
- {
- return new Token(Token.TOK_STRING, s);
- }
+ if(s.equals(";"))
+ {
+ return new Token(Token.TOK_SEMI);
+ }
+ else if(s.equals("help"))
+ {
+ return new Token(Token.TOK_HELP);
+ }
+ else if(s.equals("exit") || s.equals("quit"))
+ {
+ return new Token(Token.TOK_EXIT);
+ }
+ else if(s.equals("add"))
+ {
+ return new Token(Token.TOK_ADD_BOOK);
+ }
+ else if(s.equals("isbn"))
+ {
+ return new Token(Token.TOK_FIND_ISBN);
+ }
+ else if(s.equals("authors"))
+ {
+ return new Token(Token.TOK_FIND_AUTHORS);
+ }
+ else if(s.equals("next"))
+ {
+ return new Token(Token.TOK_NEXT_FOUND_BOOK);
+ }
+ else if(s.equals("current"))
+ {
+ return new Token(Token.TOK_PRINT_CURRENT);
+ }
+ else if(s.equals("rent"))
+ {
+ return new Token(Token.TOK_RENT_BOOK);
+ }
+ else if(s.equals("return"))
+ {
+ return new Token(Token.TOK_RETURN_BOOK);
+ }
+ else if(s.equals("remove"))
+ {
+ return new Token(Token.TOK_REMOVE_CURRENT);
+ }
+ else if(s.equals("size"))
+ {
+ return new Token(Token.TOK_SET_EVICTOR_SIZE);
+ }
+ else if(s.equals("shutdown"))
+ {
+ return new Token(Token.TOK_SHUTDOWN);
+ }
+ else
+ {
+ return new Token(Token.TOK_STRING, s);
+ }
}
static private class EndOfInput extends Exception
@@ -87,41 +87,41 @@ class Scanner
private char
get()
- throws EndOfInput
+ throws EndOfInput
{
- //
- // If there is an character in the unget buffer, return it.
- //
- if(_unget)
- {
- _unget = false;
- return _ungetChar;
- }
+ //
+ // If there is an character in the unget buffer, return it.
+ //
+ if(_unget)
+ {
+ _unget = false;
+ return _ungetChar;
+ }
- //
- // No current buffer?
- //
- if(_buf == null)
- {
- _buf = _parser.getInput();
- _pos = 0;
- if(_buf == null)
- {
- throw new EndOfInput();
- }
- }
+ //
+ // No current buffer?
+ //
+ if(_buf == null)
+ {
+ _buf = _parser.getInput();
+ _pos = 0;
+ if(_buf == null)
+ {
+ throw new EndOfInput();
+ }
+ }
- //
- // At the end-of-buffer?
- //
- while(_pos >= _buf.length())
- {
- _buf = null;
- _pos = 0;
- return '\n';
- }
+ //
+ // At the end-of-buffer?
+ //
+ while(_pos >= _buf.length())
+ {
+ _buf = null;
+ _pos = 0;
+ return '\n';
+ }
- return _buf.charAt(_pos++);
+ return _buf.charAt(_pos++);
}
//
@@ -130,153 +130,153 @@ class Scanner
private void
unget(char c)
{
- assert(!_unget);
- _unget = true;
- _ungetChar = c;
+ assert(!_unget);
+ _unget = true;
+ _ungetChar = c;
}
private String
next()
{
- //
- // Eat any whitespace.
- //
- char c;
- try
- {
- do
- {
- c = get();
- }
- while(Character.isWhitespace(c) && c != '\n');
- }
- catch(EndOfInput ignore)
- {
- return null;
- }
+ //
+ // Eat any whitespace.
+ //
+ char c;
+ try
+ {
+ do
+ {
+ c = get();
+ }
+ while(Character.isWhitespace(c) && c != '\n');
+ }
+ catch(EndOfInput ignore)
+ {
+ return null;
+ }
- StringBuffer buf = new StringBuffer();
+ StringBuffer buf = new StringBuffer();
- if(c == ';' || c == '\n')
- {
- buf.append(';');
- }
- else if(c == '\'')
- {
- try
- {
- while(true)
- {
- c = get();
- if(c == '\'')
- {
- break;
- }
- else
- {
- buf.append(c);
- }
- }
- }
- catch(EndOfInput e)
- {
- _parser.warning("EOF in string");
- }
- }
- else if(c == '\"')
- {
- try
- {
- while(true)
- {
- c = get();
- if(c == '\"')
- {
- break;
- }
- else if(c == '\\')
- {
- try
- {
- char next = get();
- switch(next)
- {
- case '\\':
- case '"':
- {
- buf.append(next);
- break;
- }
-
- case 'n':
- {
- buf.append('\n');
- break;
- }
-
- case 'r':
- {
- buf.append('\r');
- break;
- }
-
- case 't':
- {
- buf.append('\t');
- break;
- }
-
- case 'f':
- {
- buf.append('\f');
- break;
- }
-
- default:
- {
- buf.append(c);
- unget(next);
- }
- }
- }
- catch(EndOfInput e)
- {
- buf.append(c);
- }
- }
- else
- {
- buf.append(c);
- }
- }
- }
- catch(EndOfInput e)
- {
- _parser.warning("EOF in string");
- }
- }
- else
- {
- //
- // Otherwise it's a string.
- //
- try
- {
- do
- {
- buf.append(c);
- c = get();
- }
- while(!Character.isWhitespace(c) && c != ';' && c != '\n');
+ if(c == ';' || c == '\n')
+ {
+ buf.append(';');
+ }
+ else if(c == '\'')
+ {
+ try
+ {
+ while(true)
+ {
+ c = get();
+ if(c == '\'')
+ {
+ break;
+ }
+ else
+ {
+ buf.append(c);
+ }
+ }
+ }
+ catch(EndOfInput e)
+ {
+ _parser.warning("EOF in string");
+ }
+ }
+ else if(c == '\"')
+ {
+ try
+ {
+ while(true)
+ {
+ c = get();
+ if(c == '\"')
+ {
+ break;
+ }
+ else if(c == '\\')
+ {
+ try
+ {
+ char next = get();
+ switch(next)
+ {
+ case '\\':
+ case '"':
+ {
+ buf.append(next);
+ break;
+ }
+
+ case 'n':
+ {
+ buf.append('\n');
+ break;
+ }
+
+ case 'r':
+ {
+ buf.append('\r');
+ break;
+ }
+
+ case 't':
+ {
+ buf.append('\t');
+ break;
+ }
+
+ case 'f':
+ {
+ buf.append('\f');
+ break;
+ }
+
+ default:
+ {
+ buf.append(c);
+ unget(next);
+ }
+ }
+ }
+ catch(EndOfInput e)
+ {
+ buf.append(c);
+ }
+ }
+ else
+ {
+ buf.append(c);
+ }
+ }
+ }
+ catch(EndOfInput e)
+ {
+ _parser.warning("EOF in string");
+ }
+ }
+ else
+ {
+ //
+ // Otherwise it's a string.
+ //
+ try
+ {
+ do
+ {
+ buf.append(c);
+ c = get();
+ }
+ while(!Character.isWhitespace(c) && c != ';' && c != '\n');
- unget(c);
- }
- catch(EndOfInput ignore)
- {
- }
- }
-
- return buf.toString();
+ unget(c);
+ }
+ catch(EndOfInput ignore)
+ {
+ }
+ }
+
+ return buf.toString();
}
private Parser _parser;
diff --git a/java/demo/Freeze/library/Server.java b/java/demo/Freeze/library/Server.java
index 2ce57e21a78..cc94c02d2f9 100644
--- a/java/demo/Freeze/library/Server.java
+++ b/java/demo/Freeze/library/Server.java
@@ -12,53 +12,53 @@ class LibraryServer extends Ice.Application
public int
run(String[] args)
{
- Ice.Properties properties = communicator().getProperties();
+ Ice.Properties properties = communicator().getProperties();
- //
- // Create an object adapter
- //
- Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Library");
+ //
+ // Create an object adapter
+ //
+ Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Library");
- //
- // Create an evictor for books.
- //
- Freeze.Evictor evictor = Freeze.Util.createEvictor(adapter, _envName, "books", null, null, true);
- int evictorSize = properties.getPropertyAsInt("Library.EvictorSize");
- if(evictorSize > 0)
- {
- evictor.setSize(evictorSize);
- }
+ //
+ // Create an evictor for books.
+ //
+ Freeze.Evictor evictor = Freeze.Util.createEvictor(adapter, _envName, "books", null, null, true);
+ int evictorSize = properties.getPropertyAsInt("Library.EvictorSize");
+ if(evictorSize > 0)
+ {
+ evictor.setSize(evictorSize);
+ }
- adapter.addServantLocator(evictor, "book");
+ adapter.addServantLocator(evictor, "book");
- //
- // Create the library, and add it to the object adapter.
- //
- LibraryI library = new LibraryI(communicator(), _envName, "authors", evictor);
- adapter.add(library, communicator().stringToIdentity("library"));
+ //
+ // Create the library, and add it to the object adapter.
+ //
+ LibraryI library = new LibraryI(communicator(), _envName, "authors", evictor);
+ adapter.add(library, communicator().stringToIdentity("library"));
- //
- // Create and install a factory for books.
- //
- Ice.ObjectFactory bookFactory = new BookFactory(library);
- communicator().addObjectFactory(bookFactory, "::Demo::Book");
+ //
+ // Create and install a factory for books.
+ //
+ Ice.ObjectFactory bookFactory = new BookFactory(library);
+ communicator().addObjectFactory(bookFactory, "::Demo::Book");
- //
- // Everything ok, let's go.
- //
- adapter.activate();
+ //
+ // Everything ok, let's go.
+ //
+ adapter.activate();
- shutdownOnInterrupt();
- communicator().waitForShutdown();
- defaultInterrupt();
+ shutdownOnInterrupt();
+ communicator().waitForShutdown();
+ defaultInterrupt();
- library.close();
- return 0;
+ library.close();
+ return 0;
}
LibraryServer(String envName)
{
- _envName = envName;
+ _envName = envName;
}
private String _envName;
@@ -69,7 +69,7 @@ public class Server
static public void
main(String[] args)
{
- LibraryServer app = new LibraryServer("db");
- app.main("demo.Freeze.library.Server", args, "config.server");
+ LibraryServer app = new LibraryServer("db");
+ app.main("demo.Freeze.library.Server", args, "config.server");
}
}
diff --git a/java/demo/Freeze/library/Token.java b/java/demo/Freeze/library/Token.java
index 0821f42f756..a34f83b7316 100644
--- a/java/demo/Freeze/library/Token.java
+++ b/java/demo/Freeze/library/Token.java
@@ -29,13 +29,13 @@ class Token
Token(int t)
{
- type = t;
- value = null;
+ type = t;
+ value = null;
}
Token(int t, String v)
{
- type = t;
- value = v;
+ type = t;
+ value = v;
}
}