Return-Path: X-Original-To: apmail-commons-notifications-archive@minotaur.apache.org Delivered-To: apmail-commons-notifications-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EB34E100A5 for ; Sat, 9 May 2015 18:19:21 +0000 (UTC) Received: (qmail 35768 invoked by uid 500); 9 May 2015 18:19:21 -0000 Delivered-To: apmail-commons-notifications-archive@commons.apache.org Received: (qmail 35732 invoked by uid 500); 9 May 2015 18:19:21 -0000 Mailing-List: contact notifications-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list notifications@commons.apache.org Received: (qmail 35597 invoked by uid 99); 9 May 2015 18:19:21 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 May 2015 18:19:21 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id ABD99AC0FE5 for ; Sat, 9 May 2015 18:19:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r950741 [21/40] - in /websites/production/commons/content/proper/commons-cli: ./ apidocs/ apidocs/org/apache/commons/cli/ apidocs/org/apache/commons/cli/class-use/ apidocs/resources/ apidocs/src-html/org/apache/commons/cli/ cobertura/ jacoc... Date: Sat, 09 May 2015 18:19:17 -0000 To: notifications@commons.apache.org From: britter@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150509181921.ABD99AC0FE5@hades.apache.org> Modified: websites/production/commons/content/proper/commons-cli/apidocs/src-html/org/apache/commons/cli/PatternOptionBuilder.html ============================================================================== --- websites/production/commons/content/proper/commons-cli/apidocs/src-html/org/apache/commons/cli/PatternOptionBuilder.html (original) +++ websites/production/commons/content/proper/commons-cli/apidocs/src-html/org/apache/commons/cli/PatternOptionBuilder.html Sat May 9 18:19:15 2015 @@ -31,183 +31,188 @@ 023import java.util.Date; 024 025/** -026 * Allows Options to be created from a single String. +026 * <p>Allows Options to be created from a single String. 027 * The pattern contains various single character flags and via 028 * an optional punctuation character, their expected type. -029 * <p> -030 * <table border="1"> -031 * <tr><td>a</td><td>-a flag</td></tr> -032 * <tr><td>b@</td><td>-b [classname]</td></tr> -033 * <tr><td>c&gt;</td><td>-c [filename]</td></tr> -034 * <tr><td>d+</td><td>-d [classname] (creates object via empty constructor)</td></tr> -035 * <tr><td>e%</td><td>-e [number] (creates Double/Long instance depending on existing of a '.')</td></tr> -036 * <tr><td>f/</td><td>-f [url]</td></tr> -037 * <tr><td>g:</td><td>-g [string]</td></tr> -038 * </table> -039 * <p> -040 * For example, the following allows command line flags of '-v -p string-value -f /dir/file'. -041 * The exclamation mark precede a mandatory option. -042 * -043 * <pre> -044 * Options options = PatternOptionBuilder.parsePattern("vp:!f/"); -045 * </pre> +029 * </p> +030 * +031 * <table border="1"> +032 * <caption>Overview of PatternOptionBuilder patterns</caption> +033 * <tr><td>a</td><td>-a flag</td></tr> +034 * <tr><td>b@</td><td>-b [classname]</td></tr> +035 * <tr><td>c&gt;</td><td>-c [filename]</td></tr> +036 * <tr><td>d+</td><td>-d [classname] (creates object via empty constructor)</td></tr> +037 * <tr><td>e%</td><td>-e [number] (creates Double/Long instance depending on existing of a '.')</td></tr> +038 * <tr><td>f/</td><td>-f [url]</td></tr> +039 * <tr><td>g:</td><td>-g [string]</td></tr> +040 * </table> +041 * +042 * <p> +043 * For example, the following allows command line flags of '-v -p string-value -f /dir/file'. +044 * The exclamation mark precede a mandatory option. +045 * </p> 046 * -047 * <p> -048 * TODO These need to break out to OptionType and also to be pluggable. -049 * -050 * @version $Id: PatternOptionBuilder.java 1447005 2013-02-17 11:11:06Z tn $ -051 */ -052public class PatternOptionBuilder -053{ -054 /** String class */ -055 public static final Class<String> STRING_VALUE = String.class; -056 -057 /** Object class */ -058 public static final Class<Object> OBJECT_VALUE = Object.class; -059 -060 /** Number class */ -061 public static final Class<Number> NUMBER_VALUE = Number.class; -062 -063 /** Date class */ -064 public static final Class<Date> DATE_VALUE = Date.class; -065 -066 /** Class class */ -067 public static final Class<?> CLASS_VALUE = Class.class; -068 -069 /// can we do this one?? -070 // is meant to check that the file exists, else it errors. -071 // ie) it's for reading not writing. -072 -073 /** FileInputStream class */ -074 public static final Class<FileInputStream> EXISTING_FILE_VALUE = FileInputStream.class; -075 -076 /** File class */ -077 public static final Class<File> FILE_VALUE = File.class; -078 -079 /** File array class */ -080 public static final Class<File[]> FILES_VALUE = File[].class; -081 -082 /** URL class */ -083 public static final Class<URL> URL_VALUE = URL.class; -084 -085 /** -086 * Retrieve the class that <code>ch</code> represents. -087 * -088 * @param ch the specified character -089 * @return The class that <code>ch</code> represents -090 */ -091 public static Object getValueClass(char ch) -092 { -093 switch (ch) -094 { -095 case '@': -096 return PatternOptionBuilder.OBJECT_VALUE; -097 case ':': -098 return PatternOptionBuilder.STRING_VALUE; -099 case '%': -100 return PatternOptionBuilder.NUMBER_VALUE; -101 case '+': -102 return PatternOptionBuilder.CLASS_VALUE; -103 case '#': -104 return PatternOptionBuilder.DATE_VALUE; -105 case '<': -106 return PatternOptionBuilder.EXISTING_FILE_VALUE; -107 case '>': -108 return PatternOptionBuilder.FILE_VALUE; -109 case '*': -110 return PatternOptionBuilder.FILES_VALUE; -111 case '/': -112 return PatternOptionBuilder.URL_VALUE; -113 } -114 -115 return null; -116 } -117 -118 /** -119 * Returns whether <code>ch</code> is a value code, i.e. -120 * whether it represents a class in a pattern. -121 * -122 * @param ch the specified character -123 * @return true if <code>ch</code> is a value code, otherwise false. -124 */ -125 public static boolean isValueCode(char ch) -126 { -127 return ch == '@' -128 || ch == ':' -129 || ch == '%' -130 || ch == '+' -131 || ch == '#' -132 || ch == '<' -133 || ch == '>' -134 || ch == '*' -135 || ch == '/' -136 || ch == '!'; -137 } -138 -139 /** -140 * Returns the {@link Options} instance represented by <code>pattern</code>. -141 * -142 * @param pattern the pattern string -143 * @return The {@link Options} instance -144 */ -145 public static Options parsePattern(String pattern) -146 { -147 char opt = ' '; -148 boolean required = false; -149 Class<?> type = null; -150 -151 Options options = new Options(); -152 -153 for (int i = 0; i < pattern.length(); i++) -154 { -155 char ch = pattern.charAt(i); -156 -157 // a value code comes after an option and specifies -158 // details about it -159 if (!isValueCode(ch)) -160 { -161 if (opt != ' ') -162 { -163 final Option option = Option.builder(String.valueOf(opt)) -164 .hasArg(type != null) -165 .required(required) -166 .type(type) -167 .build(); -168 -169 // we have a previous one to deal with -170 options.addOption(option); -171 required = false; -172 type = null; -173 opt = ' '; -174 } -175 -176 opt = ch; -177 } -178 else if (ch == '!') -179 { -180 required = true; -181 } -182 else -183 { -184 type = (Class<?>) getValueClass(ch); -185 } -186 } -187 -188 if (opt != ' ') -189 { -190 final Option option = Option.builder(String.valueOf(opt)) -191 .hasArg(type != null) -192 .required(required) -193 .type(type) -194 .build(); -195 -196 // we have a final one to deal with -197 options.addOption(option); -198 } -199 -200 return options; -201 } -202} +047 * <pre> +048 * Options options = PatternOptionBuilder.parsePattern("vp:!f/"); +049 * </pre> +050 * +051 * <p> +052 * TODO: These need to break out to OptionType and also to be pluggable. +053 * </p> +054 * +055 * @version $Id: PatternOptionBuilder.java 1677406 2015-05-03 14:27:31Z britter $ +056 */ +057public class PatternOptionBuilder +058{ +059 /** String class */ +060 public static final Class<String> STRING_VALUE = String.class; +061 +062 /** Object class */ +063 public static final Class<Object> OBJECT_VALUE = Object.class; +064 +065 /** Number class */ +066 public static final Class<Number> NUMBER_VALUE = Number.class; +067 +068 /** Date class */ +069 public static final Class<Date> DATE_VALUE = Date.class; +070 +071 /** Class class */ +072 public static final Class<?> CLASS_VALUE = Class.class; +073 +074 /// can we do this one?? +075 // is meant to check that the file exists, else it errors. +076 // ie) it's for reading not writing. +077 +078 /** FileInputStream class */ +079 public static final Class<FileInputStream> EXISTING_FILE_VALUE = FileInputStream.class; +080 +081 /** File class */ +082 public static final Class<File> FILE_VALUE = File.class; +083 +084 /** File array class */ +085 public static final Class<File[]> FILES_VALUE = File[].class; +086 +087 /** URL class */ +088 public static final Class<URL> URL_VALUE = URL.class; +089 +090 /** +091 * Retrieve the class that <code>ch</code> represents. +092 * +093 * @param ch the specified character +094 * @return The class that <code>ch</code> represents +095 */ +096 public static Object getValueClass(char ch) +097 { +098 switch (ch) +099 { +100 case '@': +101 return PatternOptionBuilder.OBJECT_VALUE; +102 case ':': +103 return PatternOptionBuilder.STRING_VALUE; +104 case '%': +105 return PatternOptionBuilder.NUMBER_VALUE; +106 case '+': +107 return PatternOptionBuilder.CLASS_VALUE; +108 case '#': +109 return PatternOptionBuilder.DATE_VALUE; +110 case '<': +111 return PatternOptionBuilder.EXISTING_FILE_VALUE; +112 case '>': +113 return PatternOptionBuilder.FILE_VALUE; +114 case '*': +115 return PatternOptionBuilder.FILES_VALUE; +116 case '/': +117 return PatternOptionBuilder.URL_VALUE; +118 } +119 +120 return null; +121 } +122 +123 /** +124 * Returns whether <code>ch</code> is a value code, i.e. +125 * whether it represents a class in a pattern. +126 * +127 * @param ch the specified character +128 * @return true if <code>ch</code> is a value code, otherwise false. +129 */ +130 public static boolean isValueCode(char ch) +131 { +132 return ch == '@' +133 || ch == ':' +134 || ch == '%' +135 || ch == '+' +136 || ch == '#' +137 || ch == '<' +138 || ch == '>' +139 || ch == '*' +140 || ch == '/' +141 || ch == '!'; +142 } +143 +144 /** +145 * Returns the {@link Options} instance represented by <code>pattern</code>. +146 * +147 * @param pattern the pattern string +148 * @return The {@link Options} instance +149 */ +150 public static Options parsePattern(String pattern) +151 { +152 char opt = ' '; +153 boolean required = false; +154 Class<?> type = null; +155 +156 Options options = new Options(); +157 +158 for (int i = 0; i < pattern.length(); i++) +159 { +160 char ch = pattern.charAt(i); +161 +162 // a value code comes after an option and specifies +163 // details about it +164 if (!isValueCode(ch)) +165 { +166 if (opt != ' ') +167 { +168 final Option option = Option.builder(String.valueOf(opt)) +169 .hasArg(type != null) +170 .required(required) +171 .type(type) +172 .build(); +173 +174 // we have a previous one to deal with +175 options.addOption(option); +176 required = false; +177 type = null; +178 opt = ' '; +179 } +180 +181 opt = ch; +182 } +183 else if (ch == '!') +184 { +185 required = true; +186 } +187 else +188 { +189 type = (Class<?>) getValueClass(ch); +190 } +191 } +192 +193 if (opt != ' ') +194 { +195 final Option option = Option.builder(String.valueOf(opt)) +196 .hasArg(type != null) +197 .required(required) +198 .type(type) +199 .build(); +200 +201 // we have a final one to deal with +202 options.addOption(option); +203 } +204 +205 return options; +206 } +207} Modified: websites/production/commons/content/proper/commons-cli/apidocs/src-html/org/apache/commons/cli/PosixParser.html ============================================================================== --- websites/production/commons/content/proper/commons-cli/apidocs/src-html/org/apache/commons/cli/PosixParser.html (original) +++ websites/production/commons/content/proper/commons-cli/apidocs/src-html/org/apache/commons/cli/PosixParser.html Sat May 9 18:19:15 2015 @@ -34,7 +34,7 @@ 026 * The class PosixParser provides an implementation of the 027 * {@link Parser#flatten(Options,String[],boolean) flatten} method. 028 * -029 * @version $Id: PosixParser.java 1669814 2015-03-28 18:09:26Z britter $ +029 * @version $Id: PosixParser.java 1677406 2015-05-03 14:27:31Z britter $ 030 * @deprecated since 1.3, use the {@link DefaultParser} instead 031 */ 032@Deprecated @@ -67,7 +67,7 @@ 059 * <p>An implementation of {@link Parser}'s abstract 060 * {@link Parser#flatten(Options,String[],boolean) flatten} method.</p> 061 * -062 * <p>The following are the rules used by this flatten method. +062 * <p>The following are the rules used by this flatten method.</p> 063 * <ol> 064 * <li>if <code>stopAtNonOption</code> is <b>true</b> then do not 065 * burst anymore of <code>arguments</code> entries, just add each @@ -93,217 +93,216 @@ 085 * by any of the previous rules, then the entry is added to the list 086 * of processed tokens.</li> 087 * </ol> -088 * </p> -089 * -090 * @param options The command line {@link Options} -091 * @param arguments The command line arguments to be parsed -092 * @param stopAtNonOption Specifies whether to stop flattening -093 * when an non option is found. -094 * @return The flattened <code>arguments</code> String array. -095 */ -096 @Override -097 protected String[] flatten(Options options, String[] arguments, boolean stopAtNonOption) throws ParseException -098 { -099 init(); -100 this.options = options; -101 -102 // an iterator for the command line tokens -103 Iterator<String> iter = Arrays.asList(arguments).iterator(); -104 -105 // process each command line token -106 while (iter.hasNext()) -107 { -108 // get the next command line token -109 String token = iter.next(); -110 -111 // single or double hyphen -112 if ("-".equals(token) || "--".equals(token)) -113 { -114 tokens.add(token); -115 } -116 -117 // handle long option --foo or --foo=bar -118 else if (token.startsWith("--")) -119 { -120 int pos = token.indexOf('='); -121 String opt = pos == -1 ? token : token.substring(0, pos); // --foo -122 -123 List<String> matchingOpts = options.getMatchingOptions(opt); -124 -125 if (matchingOpts.isEmpty()) -126 { -127 processNonOptionToken(token, stopAtNonOption); -128 } -129 else if (matchingOpts.size() > 1) -130 { -131 throw new AmbiguousOptionException(opt, matchingOpts); -132 } -133 else -134 { -135 currentOption = options.getOption(matchingOpts.get(0)); -136 -137 tokens.add("--" + currentOption.getLongOpt()); -138 if (pos != -1) -139 { -140 tokens.add(token.substring(pos + 1)); -141 } -142 } -143 } -144 -145 else if (token.startsWith("-")) -146 { -147 if (token.length() == 2 || options.hasOption(token)) -148 { -149 processOptionToken(token, stopAtNonOption); -150 } -151 else if (!options.getMatchingOptions(token).isEmpty()) -152 { -153 List<String> matchingOpts = options.getMatchingOptions(token); -154 if (matchingOpts.size() > 1) -155 { -156 throw new AmbiguousOptionException(token, matchingOpts); -157 } -158 else -159 { -160 Option opt = options.getOption(matchingOpts.get(0)); -161 processOptionToken("-" + opt.getLongOpt(), stopAtNonOption); -162 } -163 } -164 // requires bursting -165 else -166 { -167 burstToken(token, stopAtNonOption); -168 } -169 } -170 else -171 { -172 processNonOptionToken(token, stopAtNonOption); -173 } -174 -175 gobble(iter); -176 } -177 -178 return tokens.toArray(new String[tokens.size()]); -179 } -180 -181 /** -182 * Adds the remaining tokens to the processed tokens list. -183 * -184 * @param iter An iterator over the remaining tokens -185 */ -186 private void gobble(Iterator<String> iter) -187 { -188 if (eatTheRest) -189 { -190 while (iter.hasNext()) -191 { -192 tokens.add(iter.next()); -193 } -194 } -195 } -196 -197 /** -198 * Add the special token "<b>--</b>" and the current <code>value</code> -199 * to the processed tokens list. Then add all the remaining -200 * <code>argument</code> values to the processed tokens list. -201 * -202 * @param value The current token -203 */ -204 private void processNonOptionToken(String value, boolean stopAtNonOption) -205 { -206 if (stopAtNonOption && (currentOption == null || !currentOption.hasArg())) -207 { -208 eatTheRest = true; -209 tokens.add("--"); -210 } -211 -212 tokens.add(value); -213 } -214 -215 /** -216 * <p>If an {@link Option} exists for <code>token</code> then -217 * add the token to the processed list.</p> -218 * -219 * <p>If an {@link Option} does not exist and <code>stopAtNonOption</code> -220 * is set then add the remaining tokens to the processed tokens list -221 * directly.</p> -222 * -223 * @param token The current option token -224 * @param stopAtNonOption Specifies whether flattening should halt -225 * at the first non option. -226 */ -227 private void processOptionToken(String token, boolean stopAtNonOption) -228 { -229 if (stopAtNonOption && !options.hasOption(token)) -230 { -231 eatTheRest = true; -232 } -233 -234 if (options.hasOption(token)) -235 { -236 currentOption = options.getOption(token); -237 } -238 -239 tokens.add(token); -240 } -241 -242 /** -243 * Breaks <code>token</code> into its constituent parts -244 * using the following algorithm. -245 * -246 * <ul> -247 * <li>ignore the first character ("<b>-</b>")</li> -248 * <li>foreach remaining character check if an {@link Option} -249 * exists with that id.</li> -250 * <li>if an {@link Option} does exist then add that character -251 * prepended with "<b>-</b>" to the list of processed tokens.</li> -252 * <li>if the {@link Option} can have an argument value and there -253 * are remaining characters in the token then add the remaining -254 * characters as a token to the list of processed tokens.</li> -255 * <li>if an {@link Option} does <b>NOT</b> exist <b>AND</b> -256 * <code>stopAtNonOption</code> <b>IS</b> set then add the special token -257 * "<b>--</b>" followed by the remaining characters and also -258 * the remaining tokens directly to the processed tokens list.</li> -259 * <li>if an {@link Option} does <b>NOT</b> exist <b>AND</b> -260 * <code>stopAtNonOption</code> <b>IS NOT</b> set then add that -261 * character prepended with "<b>-</b>".</li> -262 * </ul> -263 * -264 * @param token The current token to be <b>burst</b> -265 * @param stopAtNonOption Specifies whether to stop processing -266 * at the first non-Option encountered. -267 */ -268 protected void burstToken(String token, boolean stopAtNonOption) -269 { -270 for (int i = 1; i < token.length(); i++) -271 { -272 String ch = String.valueOf(token.charAt(i)); -273 -274 if (options.hasOption(ch)) -275 { -276 tokens.add("-" + ch); -277 currentOption = options.getOption(ch); -278 -279 if (currentOption.hasArg() && (token.length() != (i + 1))) -280 { -281 tokens.add(token.substring(i + 1)); -282 -283 break; -284 } -285 } -286 else if (stopAtNonOption) -287 { -288 processNonOptionToken(token.substring(i), true); -289 break; -290 } -291 else -292 { -293 tokens.add(token); -294 break; -295 } -296 } -297 } -298} +088 * +089 * @param options The command line {@link Options} +090 * @param arguments The command line arguments to be parsed +091 * @param stopAtNonOption Specifies whether to stop flattening +092 * when an non option is found. +093 * @return The flattened <code>arguments</code> String array. +094 */ +095 @Override +096 protected String[] flatten(Options options, String[] arguments, boolean stopAtNonOption) throws ParseException +097 { +098 init(); +099 this.options = options; +100 +101 // an iterator for the command line tokens +102 Iterator<String> iter = Arrays.asList(arguments).iterator(); +103 +104 // process each command line token +105 while (iter.hasNext()) +106 { +107 // get the next command line token +108 String token = iter.next(); +109 +110 // single or double hyphen +111 if ("-".equals(token) || "--".equals(token)) +112 { +113 tokens.add(token); +114 } +115 +116 // handle long option --foo or --foo=bar +117 else if (token.startsWith("--")) +118 { +119 int pos = token.indexOf('='); +120 String opt = pos == -1 ? token : token.substring(0, pos); // --foo +121 +122 List<String> matchingOpts = options.getMatchingOptions(opt); +123 +124 if (matchingOpts.isEmpty()) +125 { +126 processNonOptionToken(token, stopAtNonOption); +127 } +128 else if (matchingOpts.size() > 1) +129 { +130 throw new AmbiguousOptionException(opt, matchingOpts); +131 } +132 else +133 { +134 currentOption = options.getOption(matchingOpts.get(0)); +135 +136 tokens.add("--" + currentOption.getLongOpt()); +137 if (pos != -1) +138 { +139 tokens.add(token.substring(pos + 1)); +140 } +141 } +142 } +143 +144 else if (token.startsWith("-")) +145 { +146 if (token.length() == 2 || options.hasOption(token)) +147 { +148 processOptionToken(token, stopAtNonOption); +149 } +150 else if (!options.getMatchingOptions(token).isEmpty()) +151 { +152 List<String> matchingOpts = options.getMatchingOptions(token); +153 if (matchingOpts.size() > 1) +154 { +155 throw new AmbiguousOptionException(token, matchingOpts); +156 } +157 else +158 { +159 Option opt = options.getOption(matchingOpts.get(0)); +160 processOptionToken("-" + opt.getLongOpt(), stopAtNonOption); +161 } +162 } +163 // requires bursting +164 else +165 { +166 burstToken(token, stopAtNonOption); +167 } +168 } +169 else +170 { +171 processNonOptionToken(token, stopAtNonOption); +172 } +173 +174 gobble(iter); +175 } +176 +177 return tokens.toArray(new String[tokens.size()]); +178 } +179 +180 /** +181 * Adds the remaining tokens to the processed tokens list. +182 * +183 * @param iter An iterator over the remaining tokens +184 */ +185 private void gobble(Iterator<String> iter) +186 { +187 if (eatTheRest) +188 { +189 while (iter.hasNext()) +190 { +191 tokens.add(iter.next()); +192 } +193 } +194 } +195 +196 /** +197 * Add the special token "<b>--</b>" and the current <code>value</code> +198 * to the processed tokens list. Then add all the remaining +199 * <code>argument</code> values to the processed tokens list. +200 * +201 * @param value The current token +202 */ +203 private void processNonOptionToken(String value, boolean stopAtNonOption) +204 { +205 if (stopAtNonOption && (currentOption == null || !currentOption.hasArg())) +206 { +207 eatTheRest = true; +208 tokens.add("--"); +209 } +210 +211 tokens.add(value); +212 } +213 +214 /** +215 * <p>If an {@link Option} exists for <code>token</code> then +216 * add the token to the processed list.</p> +217 * +218 * <p>If an {@link Option} does not exist and <code>stopAtNonOption</code> +219 * is set then add the remaining tokens to the processed tokens list +220 * directly.</p> +221 * +222 * @param token The current option token +223 * @param stopAtNonOption Specifies whether flattening should halt +224 * at the first non option. +225 */ +226 private void processOptionToken(String token, boolean stopAtNonOption) +227 { +228 if (stopAtNonOption && !options.hasOption(token)) +229 { +230 eatTheRest = true; +231 } +232 +233 if (options.hasOption(token)) +234 { +235 currentOption = options.getOption(token); +236 } +237 +238 tokens.add(token); +239 } +240 +241 /** +242 * Breaks <code>token</code> into its constituent parts +243 * using the following algorithm. +244 * +245 * <ul> +246 * <li>ignore the first character ("<b>-</b>")</li> +247 * <li>foreach remaining character check if an {@link Option} +248 * exists with that id.</li> +249 * <li>if an {@link Option} does exist then add that character +250 * prepended with "<b>-</b>" to the list of processed tokens.</li> +251 * <li>if the {@link Option} can have an argument value and there +252 * are remaining characters in the token then add the remaining +253 * characters as a token to the list of processed tokens.</li> +254 * <li>if an {@link Option} does <b>NOT</b> exist <b>AND</b> +255 * <code>stopAtNonOption</code> <b>IS</b> set then add the special token +256 * "<b>--</b>" followed by the remaining characters and also +257 * the remaining tokens directly to the processed tokens list.</li> +258 * <li>if an {@link Option} does <b>NOT</b> exist <b>AND</b> +259 * <code>stopAtNonOption</code> <b>IS NOT</b> set then add that +260 * character prepended with "<b>-</b>".</li> +261 * </ul> +262 * +263 * @param token The current token to be <b>burst</b> +264 * @param stopAtNonOption Specifies whether to stop processing +265 * at the first non-Option encountered. +266 */ +267 protected void burstToken(String token, boolean stopAtNonOption) +268 { +269 for (int i = 1; i < token.length(); i++) +270 { +271 String ch = String.valueOf(token.charAt(i)); +272 +273 if (options.hasOption(ch)) +274 { +275 tokens.add("-" + ch); +276 currentOption = options.getOption(ch); +277 +278 if (currentOption.hasArg() && token.length() != i + 1) +279 { +280 tokens.add(token.substring(i + 1)); +281 +282 break; +283 } +284 } +285 else if (stopAtNonOption) +286 { +287 processNonOptionToken(token.substring(i), true); +288 break; +289 } +290 else +291 { +292 tokens.add(token); +293 break; +294 } +295 } +296 } +297}