db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fuzzylo...@apache.org
Subject svn commit: r395088 - in /db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij: Main.java util.java
Date Tue, 18 Apr 2006 23:52:24 GMT
Author: fuzzylogic
Date: Tue Apr 18 16:52:22 2006
New Revision: 395088

URL: http://svn.apache.org/viewcvs?rev=395088&view=rev
Log:
DERBY-1216: Add --help option to ij. Cleanup Main.mainCore and util.invalidArgs.

Modified:
    db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/Main.java
    db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java

Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/Main.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/Main.java?rev=395088&r1=395087&r2=395088&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/Main.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/Main.java Tue Apr 18 16:52:22
2006
@@ -84,28 +84,29 @@
 		String file;
 		String inputResourceName;
 		boolean gotProp;
-
 		Properties connAttributeDefaults = null;
 
+		LocalizedResource langUtil = LocalizedResource.getInstance();
+		LocalizedOutput out = langUtil.getNewOutput(System.out);
+
+                // Validate arguments, check for --help.
+		if (util.invalidArgs(args)) {
+			util.Usage(out);
+      		return;
+		}
+
 		// load the property file if specified
 		gotProp = util.getPropertyArg(args);
 
 		// get the default connection attributes
 		connAttributeDefaults = util.getConnAttributeArg(args);
-		// adjust the application in accordance with derby.ui.locale and derby.ui.codeset
-    main.initAppUI();
 
-		LocalizedResource langUtil = LocalizedResource.getInstance();
-        
-		LocalizedOutput out = langUtil.getNewOutput(System.out);
+		// adjust the application in accordance with derby.ui.locale and derby.ui.codeset
+                main.initAppUI();
 
 		file = util.getFileArg(args);
 		inputResourceName = util.getInputResourceNameArg(args);
-		if (util.invalidArgs(args, gotProp, file, inputResourceName)) {
-			util.Usage(out);
-      		return;
-		}
-		else if (inputResourceName != null) {
+		if (inputResourceName != null) {
 			in = langUtil.getNewInput(util.getResourceAsStream(inputResourceName));
 			if (in == null) {
 				out.println(langUtil.getTextMessage("IJ_IjErroResoNo",inputResourceName));
@@ -113,24 +114,24 @@
 			}
 		} else if (file == null) {
 			in = langUtil.getNewInput(System.in);
-            out.flush();
-    	} else {
-      		try {
-				in1 = new FileInputStream(file);
-				if (in1 != null) {
-                    in1 = new BufferedInputStream(in1, utilMain.BUFFEREDFILESIZE);
-					in = langUtil.getNewInput(in1);
-                }
-      		} catch (FileNotFoundException e) {
-				if (Boolean.getBoolean("ij.searchClassPath")) {
-					in = langUtil.getNewInput(util.getResourceAsStream(file));
+                        out.flush();
+    	        } else {
+                    try {
+                        in1 = new FileInputStream(file);
+                        if (in1 != null) {
+                            in1 = new BufferedInputStream(in1, utilMain.BUFFEREDFILESIZE);
+                            in = langUtil.getNewInput(in1);
+                        }
+                    } catch (FileNotFoundException e) {
+                        if (Boolean.getBoolean("ij.searchClassPath")) {
+                            in = langUtil.getNewInput(util.getResourceAsStream(file));
+                        }
+                        if (in == null) {
+                        out.println(langUtil.getTextMessage("IJ_IjErroFileNo",file));
+            		  return;
+                        }
+                    }
                 }
-				if (in == null) {
-				  out.println(langUtil.getTextMessage("IJ_IjErroFileNo",file));
-        		  return;
-				}
-      		}
-    	}
 
 		String outFile = util.getSystemProperty("ij.outfile");
 		if (outFile != null && outFile.length()>0) {

Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java?rev=395088&r1=395087&r2=395088&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java Tue Apr 18 16:52:22
2006
@@ -275,15 +275,14 @@
 	}
 
 	/**
-	  Verify the ij line arguments command arguments.
+	  Verify the ij line arguments command arguments. Also used to detect --help.
 	  @return true if the args are invalid
 	  <UL>
 	  <LI>Only legal argument provided.
 	  <LI>Only specify a quantity once.
 	  </UL>
 	 */
-	static public boolean invalidArgs(String[] args, boolean gotProp, String file,
-									   String inputResourceName) {
+	static public boolean invalidArgs(String[] args) {
 		int countSupported = 0;
 		boolean haveInput = false;
 		for (int ix=0; ix < args.length; ix++)
@@ -303,8 +302,7 @@
 				// next arg is the file/resource name
 				ix++;
 				if (ix >= args.length) return true;
-			}
-
+			} else if (args[ix].equals("--help")) { return true; }
 
 			//
 			//Assume the first unknown arg is a file name.



Mime
View raw message