summaryrefslogtreecommitdiff
path: root/java/demo/Freeze/library/RunParser.java
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2002-03-13 17:40:34 +0000
committerMatthew Newhook <matthew@zeroc.com>2002-03-13 17:40:34 +0000
commit56ff80265761eda3f54ef343c3654dd1aa4cce0c (patch)
tree56ca3d6b054f7edfe5c1f06f131d81656f2111ed /java/demo/Freeze/library/RunParser.java
parentAdded project files for Freeze/library demo (diff)
downloadice-56ff80265761eda3f54ef343c3654dd1aa4cce0c.tar.bz2
ice-56ff80265761eda3f54ef343c3654dd1aa4cce0c.tar.xz
ice-56ff80265761eda3f54ef343c3654dd1aa4cce0c.zip
Added Freeze/library demo.
Diffstat (limited to 'java/demo/Freeze/library/RunParser.java')
-rw-r--r--java/demo/Freeze/library/RunParser.java104
1 files changed, 104 insertions, 0 deletions
diff --git a/java/demo/Freeze/library/RunParser.java b/java/demo/Freeze/library/RunParser.java
new file mode 100644
index 00000000000..ec2d045de3b
--- /dev/null
+++ b/java/demo/Freeze/library/RunParser.java
@@ -0,0 +1,104 @@
+// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+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"
+ }
+
+ static int
+ runParser(String appName, String[] args, Ice.Communicator communicator)
+ {
+ String file = null;
+ int idx = 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"))
+ {
+ cout + ICE_STRING_VERSION + endl;
+ 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;
+ }
+ }
+
+ Ice.Properties properties = communicator.getProperties();
+ String refProperty = "Library.Library";
+ String ref = properties.getProperty(refProperty);
+ if (ref.length() == 0)
+ {
+ System.err.println(appName + ": property `" + refProperty + "' not set");
+ return 1;
+ }
+
+ Ice.ObjectPrx base = communicator.stringToProxy(ref);
+ 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;
+
+ 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;
+ }
+}