[Arakhnę-Dev] [76] Add a command which permits to shift command line parameters.

[ Thread Index | Date Index | More arakhne.org/dev Archives ]


Revision: 76
Author:   galland
Date:     2009-08-04 14:26:54 +0200 (Tue, 04 Aug 2009)

Log Message:
-----------
Add a command which permits to shift command line parameters.

Modified Paths:
--------------
    trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/VMCommandLine.java


Modified: trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/VMCommandLine.java
===================================================================
--- trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/VMCommandLine.java	2009-08-04 12:25:40 UTC (rev 75)
+++ trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/VMCommandLine.java	2009-08-04 12:26:54 UTC (rev 76)
@@ -169,6 +169,31 @@
 		return __parameters==null ? new String[0] : __parameters;
 	}
 	
+	/** Shift the command line parameters by one on the left.
+	 * The first parameter is removed from the list.
+	 * 
+	 * @return the removed element or <code>null</code>
+	 */
+	public static String shiftCommandLineParameters() {
+		String removed = null;
+		if (__parameters!=null) {
+			if (__parameters.length==0) {
+				__parameters = null;
+			}
+			else if (__parameters.length==1) {
+				removed = __parameters[0];
+				__parameters = null;
+			}
+			else {
+				removed = __parameters[0];
+				String[] newTab = new String[__parameters.length-1];
+				System.arraycopy(__parameters,1,newTab,0,__parameters.length-1);
+				__parameters = newTab;
+			}
+		}
+		return removed;
+	}
+
 	/** Replies the command line parameters.
 	 * 
 	 * @return the list of options passed on the command line
@@ -340,6 +365,15 @@
 		return getCommandLineParameters();
 	}
 
+	/** Shift the command line parameters by one on the left.
+	 * The first parameter is removed from the list.
+	 * 
+	 * @return the removed element or <code>null</code>
+	 */
+	public String shiftParameters() {
+		return shiftCommandLineParameters();
+	}
+
 	/** Replies the count of parameters on the command line that are not options.
 	 * 
 	 * @return the count of parameters


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/