1 package org.eclipse.equinox.internal.app; 2 3 public class CommandLineArgs { 4 private static final String NO_PACKAGE_PREFIXES = "-noPackagePrefixes"; private static final String NO_UPDATE = "-noUpdate"; private static final String BOOT = "-boot"; private static final String CLASSLOADER_PROPERTIES = "-classloaderProperties"; private static final String PLUGINS = "-plugins"; private static final String FIRST_USE = "-firstUse"; private static final String NEW_UPDATES = "-newUpdates"; private static final String UPDATE = "-update"; private static final String PASSWORD = "-password"; private static final String KEYRING = "-keyring"; 16 private static final String PRODUCT = "-product"; private static final String FEATURE = "-feature"; private static final String APPLICATION = "-application"; 21 private static String [] appArgs = new String [0]; 24 private static String [] allArgs = new String [0]; 25 private static String product; 26 private static String application; 27 28 static String [] processCommandLine(String [] args) { 29 if (args == null) 30 return args; 31 if (args.length == 0) 32 return args; 33 allArgs = args; 34 int[] configArgs = new int[args.length]; 35 configArgs[0] = -1; 37 int configArgIndex = 0; 38 for (int i = 0; i < args.length; i++) { 39 boolean found = false; 40 42 if (args[i].equalsIgnoreCase(CLASSLOADER_PROPERTIES)) 44 found = true; if (args[i].equalsIgnoreCase(NO_PACKAGE_PREFIXES)) 46 found = true; if (args[i].equalsIgnoreCase(PLUGINS)) 48 found = true; if (args[i].equalsIgnoreCase(FIRST_USE)) 50 found = true; if (args[i].equalsIgnoreCase(NO_UPDATE)) 52 found = true; if (args[i].equalsIgnoreCase(NEW_UPDATES)) 54 found = true; if (args[i].equalsIgnoreCase(UPDATE)) 56 found = true; if (args[i].equalsIgnoreCase(BOOT)) 58 found = true; if (args[i].equalsIgnoreCase(KEYRING)) 60 found = true; if (args[i].equalsIgnoreCase(PASSWORD)) 62 found = true; 64 if (found) { 66 configArgs[configArgIndex++] = i; 67 if (i < (args.length -1) && !args[i + 1].startsWith("-")) configArgs[configArgIndex++] = ++i; 70 continue; 71 } 72 73 if (i == args.length - 1 || args[i + 1].startsWith("-")) continue; 76 String arg = args[++i]; 77 78 if (args[i - 1].equalsIgnoreCase(PRODUCT) || args[i - 1].equalsIgnoreCase(FEATURE)) { 81 product = arg; 83 found = true; 84 } 85 86 if (args[i - 1].equalsIgnoreCase(APPLICATION)) { 88 application = arg; 90 found = true; 91 } 92 93 if (found) { 95 configArgs[configArgIndex++] = i - 1; 96 configArgs[configArgIndex++] = i; 97 } 98 } 99 100 if (configArgIndex == 0) { 102 appArgs = args; 103 return args; 104 } 105 appArgs = new String [args.length - configArgIndex]; 106 configArgIndex = 0; 107 int j = 0; 108 for (int i = 0; i < args.length; i++) { 109 if (i == configArgs[configArgIndex]) 110 configArgIndex++; 111 else 112 appArgs[j++] = args[i]; 113 } 114 return appArgs; 115 } 116 117 static String getApplication() { 118 return application; 119 } 120 121 static String getProduct() { 122 return product; 123 } 124 125 public static String [] getApplicationArgs() { 126 return appArgs; 127 } 128 129 public static String [] getAllArgs() { 130 return allArgs; 131 } 132 } 133 | Popular Tags |