commons-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
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 GMT
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 @@
 <span class="sourceLineNo">023</span>import java.util.Date;<a name="line.23"></a>
 <span class="sourceLineNo">024</span><a name="line.24"></a>
 <span class="sourceLineNo">025</span>/**<a name="line.25"></a>
-<span class="sourceLineNo">026</span> * Allows Options to be created from a single String.<a name="line.26"></a>
+<span class="sourceLineNo">026</span> * &lt;p&gt;Allows Options to be created from a single String.<a name="line.26"></a>
 <span class="sourceLineNo">027</span> * The pattern contains various single character flags and via<a name="line.27"></a>
 <span class="sourceLineNo">028</span> * an optional punctuation character, their expected type.<a name="line.28"></a>
-<span class="sourceLineNo">029</span> * &lt;p&gt;<a name="line.29"></a>
-<span class="sourceLineNo">030</span> * &lt;table border="1"&gt;<a name="line.30"></a>
-<span class="sourceLineNo">031</span> * &lt;tr&gt;&lt;td&gt;a&lt;/td&gt;&lt;td&gt;-a flag&lt;/td&gt;&lt;/tr&gt;<a name="line.31"></a>
-<span class="sourceLineNo">032</span> * &lt;tr&gt;&lt;td&gt;b@&lt;/td&gt;&lt;td&gt;-b [classname]&lt;/td&gt;&lt;/tr&gt;<a name="line.32"></a>
-<span class="sourceLineNo">033</span> * &lt;tr&gt;&lt;td&gt;c&amp;gt;&lt;/td&gt;&lt;td&gt;-c [filename]&lt;/td&gt;&lt;/tr&gt;<a name="line.33"></a>
-<span class="sourceLineNo">034</span> * &lt;tr&gt;&lt;td&gt;d+&lt;/td&gt;&lt;td&gt;-d [classname] (creates object via empty constructor)&lt;/td&gt;&lt;/tr&gt;<a name="line.34"></a>
-<span class="sourceLineNo">035</span> * &lt;tr&gt;&lt;td&gt;e%&lt;/td&gt;&lt;td&gt;-e [number] (creates Double/Long instance depending on existing of a '.')&lt;/td&gt;&lt;/tr&gt;<a name="line.35"></a>
-<span class="sourceLineNo">036</span> * &lt;tr&gt;&lt;td&gt;f/&lt;/td&gt;&lt;td&gt;-f [url]&lt;/td&gt;&lt;/tr&gt;<a name="line.36"></a>
-<span class="sourceLineNo">037</span> * &lt;tr&gt;&lt;td&gt;g:&lt;/td&gt;&lt;td&gt;-g [string]&lt;/td&gt;&lt;/tr&gt;<a name="line.37"></a>
-<span class="sourceLineNo">038</span> * &lt;/table&gt;<a name="line.38"></a>
-<span class="sourceLineNo">039</span> * &lt;p&gt;<a name="line.39"></a>
-<span class="sourceLineNo">040</span> * For example, the following allows command line flags of '-v -p string-value -f /dir/file'.<a name="line.40"></a>
-<span class="sourceLineNo">041</span> * The exclamation mark precede a mandatory option.<a name="line.41"></a>
-<span class="sourceLineNo">042</span> *<a name="line.42"></a>
-<span class="sourceLineNo">043</span> * &lt;pre&gt;<a name="line.43"></a>
-<span class="sourceLineNo">044</span> *     Options options = PatternOptionBuilder.parsePattern("vp:!f/");<a name="line.44"></a>
-<span class="sourceLineNo">045</span> * &lt;/pre&gt;<a name="line.45"></a>
+<span class="sourceLineNo">029</span> * &lt;/p&gt;<a name="line.29"></a>
+<span class="sourceLineNo">030</span> * <a name="line.30"></a>
+<span class="sourceLineNo">031</span> * &lt;table border="1"&gt;<a name="line.31"></a>
+<span class="sourceLineNo">032</span> *   &lt;caption&gt;Overview of PatternOptionBuilder patterns&lt;/caption&gt;<a name="line.32"></a>
+<span class="sourceLineNo">033</span> *   &lt;tr&gt;&lt;td&gt;a&lt;/td&gt;&lt;td&gt;-a flag&lt;/td&gt;&lt;/tr&gt;<a name="line.33"></a>
+<span class="sourceLineNo">034</span> *   &lt;tr&gt;&lt;td&gt;b@&lt;/td&gt;&lt;td&gt;-b [classname]&lt;/td&gt;&lt;/tr&gt;<a name="line.34"></a>
+<span class="sourceLineNo">035</span> *   &lt;tr&gt;&lt;td&gt;c&amp;gt;&lt;/td&gt;&lt;td&gt;-c [filename]&lt;/td&gt;&lt;/tr&gt;<a name="line.35"></a>
+<span class="sourceLineNo">036</span> *   &lt;tr&gt;&lt;td&gt;d+&lt;/td&gt;&lt;td&gt;-d [classname] (creates object via empty constructor)&lt;/td&gt;&lt;/tr&gt;<a name="line.36"></a>
+<span class="sourceLineNo">037</span> *   &lt;tr&gt;&lt;td&gt;e%&lt;/td&gt;&lt;td&gt;-e [number] (creates Double/Long instance depending on existing of a '.')&lt;/td&gt;&lt;/tr&gt;<a name="line.37"></a>
+<span class="sourceLineNo">038</span> *   &lt;tr&gt;&lt;td&gt;f/&lt;/td&gt;&lt;td&gt;-f [url]&lt;/td&gt;&lt;/tr&gt;<a name="line.38"></a>
+<span class="sourceLineNo">039</span> *   &lt;tr&gt;&lt;td&gt;g:&lt;/td&gt;&lt;td&gt;-g [string]&lt;/td&gt;&lt;/tr&gt;<a name="line.39"></a>
+<span class="sourceLineNo">040</span> * &lt;/table&gt;<a name="line.40"></a>
+<span class="sourceLineNo">041</span> * <a name="line.41"></a>
+<span class="sourceLineNo">042</span> * &lt;p&gt;<a name="line.42"></a>
+<span class="sourceLineNo">043</span> * For example, the following allows command line flags of '-v -p string-value -f /dir/file'.<a name="line.43"></a>
+<span class="sourceLineNo">044</span> * The exclamation mark precede a mandatory option.<a name="line.44"></a>
+<span class="sourceLineNo">045</span> * &lt;/p&gt;<a name="line.45"></a>
 <span class="sourceLineNo">046</span> *<a name="line.46"></a>
-<span class="sourceLineNo">047</span> * &lt;p&gt;<a name="line.47"></a>
-<span class="sourceLineNo">048</span> * TODO These need to break out to OptionType and also to be pluggable.<a name="line.48"></a>
-<span class="sourceLineNo">049</span> *<a name="line.49"></a>
-<span class="sourceLineNo">050</span> * @version $Id: PatternOptionBuilder.java 1447005 2013-02-17 11:11:06Z tn $<a name="line.50"></a>
-<span class="sourceLineNo">051</span> */<a name="line.51"></a>
-<span class="sourceLineNo">052</span>public class PatternOptionBuilder<a name="line.52"></a>
-<span class="sourceLineNo">053</span>{<a name="line.53"></a>
-<span class="sourceLineNo">054</span>    /** String class */<a name="line.54"></a>
-<span class="sourceLineNo">055</span>    public static final Class&lt;String&gt; STRING_VALUE = String.class;<a name="line.55"></a>
-<span class="sourceLineNo">056</span><a name="line.56"></a>
-<span class="sourceLineNo">057</span>    /** Object class */<a name="line.57"></a>
-<span class="sourceLineNo">058</span>    public static final Class&lt;Object&gt; OBJECT_VALUE = Object.class;<a name="line.58"></a>
-<span class="sourceLineNo">059</span><a name="line.59"></a>
-<span class="sourceLineNo">060</span>    /** Number class */<a name="line.60"></a>
-<span class="sourceLineNo">061</span>    public static final Class&lt;Number&gt; NUMBER_VALUE = Number.class;<a name="line.61"></a>
-<span class="sourceLineNo">062</span><a name="line.62"></a>
-<span class="sourceLineNo">063</span>    /** Date class */<a name="line.63"></a>
-<span class="sourceLineNo">064</span>    public static final Class&lt;Date&gt; DATE_VALUE = Date.class;<a name="line.64"></a>
-<span class="sourceLineNo">065</span><a name="line.65"></a>
-<span class="sourceLineNo">066</span>    /** Class class */<a name="line.66"></a>
-<span class="sourceLineNo">067</span>    public static final Class&lt;?&gt; CLASS_VALUE = Class.class;<a name="line.67"></a>
-<span class="sourceLineNo">068</span><a name="line.68"></a>
-<span class="sourceLineNo">069</span>    /// can we do this one??<a name="line.69"></a>
-<span class="sourceLineNo">070</span>    // is meant to check that the file exists, else it errors.<a name="line.70"></a>
-<span class="sourceLineNo">071</span>    // ie) it's for reading not writing.<a name="line.71"></a>
-<span class="sourceLineNo">072</span><a name="line.72"></a>
-<span class="sourceLineNo">073</span>    /** FileInputStream class */<a name="line.73"></a>
-<span class="sourceLineNo">074</span>    public static final Class&lt;FileInputStream&gt; EXISTING_FILE_VALUE = FileInputStream.class;<a name="line.74"></a>
-<span class="sourceLineNo">075</span><a name="line.75"></a>
-<span class="sourceLineNo">076</span>    /** File class */<a name="line.76"></a>
-<span class="sourceLineNo">077</span>    public static final Class&lt;File&gt; FILE_VALUE = File.class;<a name="line.77"></a>
-<span class="sourceLineNo">078</span><a name="line.78"></a>
-<span class="sourceLineNo">079</span>    /** File array class */<a name="line.79"></a>
-<span class="sourceLineNo">080</span>    public static final Class&lt;File[]&gt; FILES_VALUE = File[].class;<a name="line.80"></a>
-<span class="sourceLineNo">081</span><a name="line.81"></a>
-<span class="sourceLineNo">082</span>    /** URL class */<a name="line.82"></a>
-<span class="sourceLineNo">083</span>    public static final Class&lt;URL&gt; URL_VALUE = URL.class;<a name="line.83"></a>
-<span class="sourceLineNo">084</span><a name="line.84"></a>
-<span class="sourceLineNo">085</span>    /**<a name="line.85"></a>
-<span class="sourceLineNo">086</span>     * Retrieve the class that &lt;code&gt;ch&lt;/code&gt; represents.<a name="line.86"></a>
-<span class="sourceLineNo">087</span>     *<a name="line.87"></a>
-<span class="sourceLineNo">088</span>     * @param ch the specified character<a name="line.88"></a>
-<span class="sourceLineNo">089</span>     * @return The class that &lt;code&gt;ch&lt;/code&gt; represents<a name="line.89"></a>
-<span class="sourceLineNo">090</span>     */<a name="line.90"></a>
-<span class="sourceLineNo">091</span>    public static Object getValueClass(char ch)<a name="line.91"></a>
-<span class="sourceLineNo">092</span>    {<a name="line.92"></a>
-<span class="sourceLineNo">093</span>        switch (ch)<a name="line.93"></a>
-<span class="sourceLineNo">094</span>        {<a name="line.94"></a>
-<span class="sourceLineNo">095</span>            case '@':<a name="line.95"></a>
-<span class="sourceLineNo">096</span>                return PatternOptionBuilder.OBJECT_VALUE;<a name="line.96"></a>
-<span class="sourceLineNo">097</span>            case ':':<a name="line.97"></a>
-<span class="sourceLineNo">098</span>                return PatternOptionBuilder.STRING_VALUE;<a name="line.98"></a>
-<span class="sourceLineNo">099</span>            case '%':<a name="line.99"></a>
-<span class="sourceLineNo">100</span>                return PatternOptionBuilder.NUMBER_VALUE;<a name="line.100"></a>
-<span class="sourceLineNo">101</span>            case '+':<a name="line.101"></a>
-<span class="sourceLineNo">102</span>                return PatternOptionBuilder.CLASS_VALUE;<a name="line.102"></a>
-<span class="sourceLineNo">103</span>            case '#':<a name="line.103"></a>
-<span class="sourceLineNo">104</span>                return PatternOptionBuilder.DATE_VALUE;<a name="line.104"></a>
-<span class="sourceLineNo">105</span>            case '&lt;':<a name="line.105"></a>
-<span class="sourceLineNo">106</span>                return PatternOptionBuilder.EXISTING_FILE_VALUE;<a name="line.106"></a>
-<span class="sourceLineNo">107</span>            case '&gt;':<a name="line.107"></a>
-<span class="sourceLineNo">108</span>                return PatternOptionBuilder.FILE_VALUE;<a name="line.108"></a>
-<span class="sourceLineNo">109</span>            case '*':<a name="line.109"></a>
-<span class="sourceLineNo">110</span>                return PatternOptionBuilder.FILES_VALUE;<a name="line.110"></a>
-<span class="sourceLineNo">111</span>            case '/':<a name="line.111"></a>
-<span class="sourceLineNo">112</span>                return PatternOptionBuilder.URL_VALUE;<a name="line.112"></a>
-<span class="sourceLineNo">113</span>        }<a name="line.113"></a>
-<span class="sourceLineNo">114</span><a name="line.114"></a>
-<span class="sourceLineNo">115</span>        return null;<a name="line.115"></a>
-<span class="sourceLineNo">116</span>    }<a name="line.116"></a>
-<span class="sourceLineNo">117</span><a name="line.117"></a>
-<span class="sourceLineNo">118</span>    /**<a name="line.118"></a>
-<span class="sourceLineNo">119</span>     * Returns whether &lt;code&gt;ch&lt;/code&gt; is a value code, i.e.<a name="line.119"></a>
-<span class="sourceLineNo">120</span>     * whether it represents a class in a pattern.<a name="line.120"></a>
-<span class="sourceLineNo">121</span>     *<a name="line.121"></a>
-<span class="sourceLineNo">122</span>     * @param ch the specified character<a name="line.122"></a>
-<span class="sourceLineNo">123</span>     * @return true if &lt;code&gt;ch&lt;/code&gt; is a value code, otherwise false.<a name="line.123"></a>
-<span class="sourceLineNo">124</span>     */<a name="line.124"></a>
-<span class="sourceLineNo">125</span>    public static boolean isValueCode(char ch)<a name="line.125"></a>
-<span class="sourceLineNo">126</span>    {<a name="line.126"></a>
-<span class="sourceLineNo">127</span>        return ch == '@'<a name="line.127"></a>
-<span class="sourceLineNo">128</span>                || ch == ':'<a name="line.128"></a>
-<span class="sourceLineNo">129</span>                || ch == '%'<a name="line.129"></a>
-<span class="sourceLineNo">130</span>                || ch == '+'<a name="line.130"></a>
-<span class="sourceLineNo">131</span>                || ch == '#'<a name="line.131"></a>
-<span class="sourceLineNo">132</span>                || ch == '&lt;'<a name="line.132"></a>
-<span class="sourceLineNo">133</span>                || ch == '&gt;'<a name="line.133"></a>
-<span class="sourceLineNo">134</span>                || ch == '*'<a name="line.134"></a>
-<span class="sourceLineNo">135</span>                || ch == '/'<a name="line.135"></a>
-<span class="sourceLineNo">136</span>                || ch == '!';<a name="line.136"></a>
-<span class="sourceLineNo">137</span>    }<a name="line.137"></a>
-<span class="sourceLineNo">138</span><a name="line.138"></a>
-<span class="sourceLineNo">139</span>    /**<a name="line.139"></a>
-<span class="sourceLineNo">140</span>     * Returns the {@link Options} instance represented by &lt;code&gt;pattern&lt;/code&gt;.<a name="line.140"></a>
-<span class="sourceLineNo">141</span>     *<a name="line.141"></a>
-<span class="sourceLineNo">142</span>     * @param pattern the pattern string<a name="line.142"></a>
-<span class="sourceLineNo">143</span>     * @return The {@link Options} instance<a name="line.143"></a>
-<span class="sourceLineNo">144</span>     */<a name="line.144"></a>
-<span class="sourceLineNo">145</span>    public static Options parsePattern(String pattern)<a name="line.145"></a>
-<span class="sourceLineNo">146</span>    {<a name="line.146"></a>
-<span class="sourceLineNo">147</span>        char opt = ' ';<a name="line.147"></a>
-<span class="sourceLineNo">148</span>        boolean required = false;<a name="line.148"></a>
-<span class="sourceLineNo">149</span>        Class&lt;?&gt; type = null;<a name="line.149"></a>
-<span class="sourceLineNo">150</span><a name="line.150"></a>
-<span class="sourceLineNo">151</span>        Options options = new Options();<a name="line.151"></a>
-<span class="sourceLineNo">152</span><a name="line.152"></a>
-<span class="sourceLineNo">153</span>        for (int i = 0; i &lt; pattern.length(); i++)<a name="line.153"></a>
-<span class="sourceLineNo">154</span>        {<a name="line.154"></a>
-<span class="sourceLineNo">155</span>            char ch = pattern.charAt(i);<a name="line.155"></a>
-<span class="sourceLineNo">156</span><a name="line.156"></a>
-<span class="sourceLineNo">157</span>            // a value code comes after an option and specifies<a name="line.157"></a>
-<span class="sourceLineNo">158</span>            // details about it<a name="line.158"></a>
-<span class="sourceLineNo">159</span>            if (!isValueCode(ch))<a name="line.159"></a>
-<span class="sourceLineNo">160</span>            {<a name="line.160"></a>
-<span class="sourceLineNo">161</span>                if (opt != ' ')<a name="line.161"></a>
-<span class="sourceLineNo">162</span>                {<a name="line.162"></a>
-<span class="sourceLineNo">163</span>                    final Option option = Option.builder(String.valueOf(opt))<a name="line.163"></a>
-<span class="sourceLineNo">164</span>                        .hasArg(type != null)<a name="line.164"></a>
-<span class="sourceLineNo">165</span>                        .required(required)<a name="line.165"></a>
-<span class="sourceLineNo">166</span>                        .type(type)<a name="line.166"></a>
-<span class="sourceLineNo">167</span>                        .build();<a name="line.167"></a>
-<span class="sourceLineNo">168</span>                    <a name="line.168"></a>
-<span class="sourceLineNo">169</span>                    // we have a previous one to deal with<a name="line.169"></a>
-<span class="sourceLineNo">170</span>                    options.addOption(option);<a name="line.170"></a>
-<span class="sourceLineNo">171</span>                    required = false;<a name="line.171"></a>
-<span class="sourceLineNo">172</span>                    type = null;<a name="line.172"></a>
-<span class="sourceLineNo">173</span>                    opt = ' ';<a name="line.173"></a>
-<span class="sourceLineNo">174</span>                }<a name="line.174"></a>
-<span class="sourceLineNo">175</span><a name="line.175"></a>
-<span class="sourceLineNo">176</span>                opt = ch;<a name="line.176"></a>
-<span class="sourceLineNo">177</span>            }<a name="line.177"></a>
-<span class="sourceLineNo">178</span>            else if (ch == '!')<a name="line.178"></a>
-<span class="sourceLineNo">179</span>            {<a name="line.179"></a>
-<span class="sourceLineNo">180</span>                required = true;<a name="line.180"></a>
-<span class="sourceLineNo">181</span>            }<a name="line.181"></a>
-<span class="sourceLineNo">182</span>            else<a name="line.182"></a>
-<span class="sourceLineNo">183</span>            {<a name="line.183"></a>
-<span class="sourceLineNo">184</span>                type = (Class&lt;?&gt;) getValueClass(ch);<a name="line.184"></a>
-<span class="sourceLineNo">185</span>            }<a name="line.185"></a>
-<span class="sourceLineNo">186</span>        }<a name="line.186"></a>
-<span class="sourceLineNo">187</span><a name="line.187"></a>
-<span class="sourceLineNo">188</span>        if (opt != ' ')<a name="line.188"></a>
-<span class="sourceLineNo">189</span>        {<a name="line.189"></a>
-<span class="sourceLineNo">190</span>            final Option option = Option.builder(String.valueOf(opt))<a name="line.190"></a>
-<span class="sourceLineNo">191</span>                .hasArg(type != null)<a name="line.191"></a>
-<span class="sourceLineNo">192</span>                .required(required)<a name="line.192"></a>
-<span class="sourceLineNo">193</span>                .type(type)<a name="line.193"></a>
-<span class="sourceLineNo">194</span>                .build();<a name="line.194"></a>
-<span class="sourceLineNo">195</span>            <a name="line.195"></a>
-<span class="sourceLineNo">196</span>            // we have a final one to deal with<a name="line.196"></a>
-<span class="sourceLineNo">197</span>            options.addOption(option);<a name="line.197"></a>
-<span class="sourceLineNo">198</span>        }<a name="line.198"></a>
-<span class="sourceLineNo">199</span><a name="line.199"></a>
-<span class="sourceLineNo">200</span>        return options;<a name="line.200"></a>
-<span class="sourceLineNo">201</span>    }<a name="line.201"></a>
-<span class="sourceLineNo">202</span>}<a name="line.202"></a>
+<span class="sourceLineNo">047</span> * &lt;pre&gt;<a name="line.47"></a>
+<span class="sourceLineNo">048</span> *     Options options = PatternOptionBuilder.parsePattern("vp:!f/");<a name="line.48"></a>
+<span class="sourceLineNo">049</span> * &lt;/pre&gt;<a name="line.49"></a>
+<span class="sourceLineNo">050</span> *<a name="line.50"></a>
+<span class="sourceLineNo">051</span> * &lt;p&gt;<a name="line.51"></a>
+<span class="sourceLineNo">052</span> * TODO: These need to break out to OptionType and also to be pluggable.<a name="line.52"></a>
+<span class="sourceLineNo">053</span> * &lt;/p&gt;<a name="line.53"></a>
+<span class="sourceLineNo">054</span> *<a name="line.54"></a>
+<span class="sourceLineNo">055</span> * @version $Id: PatternOptionBuilder.java 1677406 2015-05-03 14:27:31Z britter $<a name="line.55"></a>
+<span class="sourceLineNo">056</span> */<a name="line.56"></a>
+<span class="sourceLineNo">057</span>public class PatternOptionBuilder<a name="line.57"></a>
+<span class="sourceLineNo">058</span>{<a name="line.58"></a>
+<span class="sourceLineNo">059</span>    /** String class */<a name="line.59"></a>
+<span class="sourceLineNo">060</span>    public static final Class&lt;String&gt; STRING_VALUE = String.class;<a name="line.60"></a>
+<span class="sourceLineNo">061</span><a name="line.61"></a>
+<span class="sourceLineNo">062</span>    /** Object class */<a name="line.62"></a>
+<span class="sourceLineNo">063</span>    public static final Class&lt;Object&gt; OBJECT_VALUE = Object.class;<a name="line.63"></a>
+<span class="sourceLineNo">064</span><a name="line.64"></a>
+<span class="sourceLineNo">065</span>    /** Number class */<a name="line.65"></a>
+<span class="sourceLineNo">066</span>    public static final Class&lt;Number&gt; NUMBER_VALUE = Number.class;<a name="line.66"></a>
+<span class="sourceLineNo">067</span><a name="line.67"></a>
+<span class="sourceLineNo">068</span>    /** Date class */<a name="line.68"></a>
+<span class="sourceLineNo">069</span>    public static final Class&lt;Date&gt; DATE_VALUE = Date.class;<a name="line.69"></a>
+<span class="sourceLineNo">070</span><a name="line.70"></a>
+<span class="sourceLineNo">071</span>    /** Class class */<a name="line.71"></a>
+<span class="sourceLineNo">072</span>    public static final Class&lt;?&gt; CLASS_VALUE = Class.class;<a name="line.72"></a>
+<span class="sourceLineNo">073</span><a name="line.73"></a>
+<span class="sourceLineNo">074</span>    /// can we do this one??<a name="line.74"></a>
+<span class="sourceLineNo">075</span>    // is meant to check that the file exists, else it errors.<a name="line.75"></a>
+<span class="sourceLineNo">076</span>    // ie) it's for reading not writing.<a name="line.76"></a>
+<span class="sourceLineNo">077</span><a name="line.77"></a>
+<span class="sourceLineNo">078</span>    /** FileInputStream class */<a name="line.78"></a>
+<span class="sourceLineNo">079</span>    public static final Class&lt;FileInputStream&gt; EXISTING_FILE_VALUE = FileInputStream.class;<a name="line.79"></a>
+<span class="sourceLineNo">080</span><a name="line.80"></a>
+<span class="sourceLineNo">081</span>    /** File class */<a name="line.81"></a>
+<span class="sourceLineNo">082</span>    public static final Class&lt;File&gt; FILE_VALUE = File.class;<a name="line.82"></a>
+<span class="sourceLineNo">083</span><a name="line.83"></a>
+<span class="sourceLineNo">084</span>    /** File array class */<a name="line.84"></a>
+<span class="sourceLineNo">085</span>    public static final Class&lt;File[]&gt; FILES_VALUE = File[].class;<a name="line.85"></a>
+<span class="sourceLineNo">086</span><a name="line.86"></a>
+<span class="sourceLineNo">087</span>    /** URL class */<a name="line.87"></a>
+<span class="sourceLineNo">088</span>    public static final Class&lt;URL&gt; URL_VALUE = URL.class;<a name="line.88"></a>
+<span class="sourceLineNo">089</span><a name="line.89"></a>
+<span class="sourceLineNo">090</span>    /**<a name="line.90"></a>
+<span class="sourceLineNo">091</span>     * Retrieve the class that &lt;code&gt;ch&lt;/code&gt; represents.<a name="line.91"></a>
+<span class="sourceLineNo">092</span>     *<a name="line.92"></a>
+<span class="sourceLineNo">093</span>     * @param ch the specified character<a name="line.93"></a>
+<span class="sourceLineNo">094</span>     * @return The class that &lt;code&gt;ch&lt;/code&gt; represents<a name="line.94"></a>
+<span class="sourceLineNo">095</span>     */<a name="line.95"></a>
+<span class="sourceLineNo">096</span>    public static Object getValueClass(char ch)<a name="line.96"></a>
+<span class="sourceLineNo">097</span>    {<a name="line.97"></a>
+<span class="sourceLineNo">098</span>        switch (ch)<a name="line.98"></a>
+<span class="sourceLineNo">099</span>        {<a name="line.99"></a>
+<span class="sourceLineNo">100</span>            case '@':<a name="line.100"></a>
+<span class="sourceLineNo">101</span>                return PatternOptionBuilder.OBJECT_VALUE;<a name="line.101"></a>
+<span class="sourceLineNo">102</span>            case ':':<a name="line.102"></a>
+<span class="sourceLineNo">103</span>                return PatternOptionBuilder.STRING_VALUE;<a name="line.103"></a>
+<span class="sourceLineNo">104</span>            case '%':<a name="line.104"></a>
+<span class="sourceLineNo">105</span>                return PatternOptionBuilder.NUMBER_VALUE;<a name="line.105"></a>
+<span class="sourceLineNo">106</span>            case '+':<a name="line.106"></a>
+<span class="sourceLineNo">107</span>                return PatternOptionBuilder.CLASS_VALUE;<a name="line.107"></a>
+<span class="sourceLineNo">108</span>            case '#':<a name="line.108"></a>
+<span class="sourceLineNo">109</span>                return PatternOptionBuilder.DATE_VALUE;<a name="line.109"></a>
+<span class="sourceLineNo">110</span>            case '&lt;':<a name="line.110"></a>
+<span class="sourceLineNo">111</span>                return PatternOptionBuilder.EXISTING_FILE_VALUE;<a name="line.111"></a>
+<span class="sourceLineNo">112</span>            case '&gt;':<a name="line.112"></a>
+<span class="sourceLineNo">113</span>                return PatternOptionBuilder.FILE_VALUE;<a name="line.113"></a>
+<span class="sourceLineNo">114</span>            case '*':<a name="line.114"></a>
+<span class="sourceLineNo">115</span>                return PatternOptionBuilder.FILES_VALUE;<a name="line.115"></a>
+<span class="sourceLineNo">116</span>            case '/':<a name="line.116"></a>
+<span class="sourceLineNo">117</span>                return PatternOptionBuilder.URL_VALUE;<a name="line.117"></a>
+<span class="sourceLineNo">118</span>        }<a name="line.118"></a>
+<span class="sourceLineNo">119</span><a name="line.119"></a>
+<span class="sourceLineNo">120</span>        return null;<a name="line.120"></a>
+<span class="sourceLineNo">121</span>    }<a name="line.121"></a>
+<span class="sourceLineNo">122</span><a name="line.122"></a>
+<span class="sourceLineNo">123</span>    /**<a name="line.123"></a>
+<span class="sourceLineNo">124</span>     * Returns whether &lt;code&gt;ch&lt;/code&gt; is a value code, i.e.<a name="line.124"></a>
+<span class="sourceLineNo">125</span>     * whether it represents a class in a pattern.<a name="line.125"></a>
+<span class="sourceLineNo">126</span>     *<a name="line.126"></a>
+<span class="sourceLineNo">127</span>     * @param ch the specified character<a name="line.127"></a>
+<span class="sourceLineNo">128</span>     * @return true if &lt;code&gt;ch&lt;/code&gt; is a value code, otherwise false.<a name="line.128"></a>
+<span class="sourceLineNo">129</span>     */<a name="line.129"></a>
+<span class="sourceLineNo">130</span>    public static boolean isValueCode(char ch)<a name="line.130"></a>
+<span class="sourceLineNo">131</span>    {<a name="line.131"></a>
+<span class="sourceLineNo">132</span>        return ch == '@'<a name="line.132"></a>
+<span class="sourceLineNo">133</span>                || ch == ':'<a name="line.133"></a>
+<span class="sourceLineNo">134</span>                || ch == '%'<a name="line.134"></a>
+<span class="sourceLineNo">135</span>                || ch == '+'<a name="line.135"></a>
+<span class="sourceLineNo">136</span>                || ch == '#'<a name="line.136"></a>
+<span class="sourceLineNo">137</span>                || ch == '&lt;'<a name="line.137"></a>
+<span class="sourceLineNo">138</span>                || ch == '&gt;'<a name="line.138"></a>
+<span class="sourceLineNo">139</span>                || ch == '*'<a name="line.139"></a>
+<span class="sourceLineNo">140</span>                || ch == '/'<a name="line.140"></a>
+<span class="sourceLineNo">141</span>                || ch == '!';<a name="line.141"></a>
+<span class="sourceLineNo">142</span>    }<a name="line.142"></a>
+<span class="sourceLineNo">143</span><a name="line.143"></a>
+<span class="sourceLineNo">144</span>    /**<a name="line.144"></a>
+<span class="sourceLineNo">145</span>     * Returns the {@link Options} instance represented by &lt;code&gt;pattern&lt;/code&gt;.<a name="line.145"></a>
+<span class="sourceLineNo">146</span>     *<a name="line.146"></a>
+<span class="sourceLineNo">147</span>     * @param pattern the pattern string<a name="line.147"></a>
+<span class="sourceLineNo">148</span>     * @return The {@link Options} instance<a name="line.148"></a>
+<span class="sourceLineNo">149</span>     */<a name="line.149"></a>
+<span class="sourceLineNo">150</span>    public static Options parsePattern(String pattern)<a name="line.150"></a>
+<span class="sourceLineNo">151</span>    {<a name="line.151"></a>
+<span class="sourceLineNo">152</span>        char opt = ' ';<a name="line.152"></a>
+<span class="sourceLineNo">153</span>        boolean required = false;<a name="line.153"></a>
+<span class="sourceLineNo">154</span>        Class&lt;?&gt; type = null;<a name="line.154"></a>
+<span class="sourceLineNo">155</span><a name="line.155"></a>
+<span class="sourceLineNo">156</span>        Options options = new Options();<a name="line.156"></a>
+<span class="sourceLineNo">157</span><a name="line.157"></a>
+<span class="sourceLineNo">158</span>        for (int i = 0; i &lt; pattern.length(); i++)<a name="line.158"></a>
+<span class="sourceLineNo">159</span>        {<a name="line.159"></a>
+<span class="sourceLineNo">160</span>            char ch = pattern.charAt(i);<a name="line.160"></a>
+<span class="sourceLineNo">161</span><a name="line.161"></a>
+<span class="sourceLineNo">162</span>            // a value code comes after an option and specifies<a name="line.162"></a>
+<span class="sourceLineNo">163</span>            // details about it<a name="line.163"></a>
+<span class="sourceLineNo">164</span>            if (!isValueCode(ch))<a name="line.164"></a>
+<span class="sourceLineNo">165</span>            {<a name="line.165"></a>
+<span class="sourceLineNo">166</span>                if (opt != ' ')<a name="line.166"></a>
+<span class="sourceLineNo">167</span>                {<a name="line.167"></a>
+<span class="sourceLineNo">168</span>                    final Option option = Option.builder(String.valueOf(opt))<a name="line.168"></a>
+<span class="sourceLineNo">169</span>                        .hasArg(type != null)<a name="line.169"></a>
+<span class="sourceLineNo">170</span>                        .required(required)<a name="line.170"></a>
+<span class="sourceLineNo">171</span>                        .type(type)<a name="line.171"></a>
+<span class="sourceLineNo">172</span>                        .build();<a name="line.172"></a>
+<span class="sourceLineNo">173</span>                    <a name="line.173"></a>
+<span class="sourceLineNo">174</span>                    // we have a previous one to deal with<a name="line.174"></a>
+<span class="sourceLineNo">175</span>                    options.addOption(option);<a name="line.175"></a>
+<span class="sourceLineNo">176</span>                    required = false;<a name="line.176"></a>
+<span class="sourceLineNo">177</span>                    type = null;<a name="line.177"></a>
+<span class="sourceLineNo">178</span>                    opt = ' ';<a name="line.178"></a>
+<span class="sourceLineNo">179</span>                }<a name="line.179"></a>
+<span class="sourceLineNo">180</span><a name="line.180"></a>
+<span class="sourceLineNo">181</span>                opt = ch;<a name="line.181"></a>
+<span class="sourceLineNo">182</span>            }<a name="line.182"></a>
+<span class="sourceLineNo">183</span>            else if (ch == '!')<a name="line.183"></a>
+<span class="sourceLineNo">184</span>            {<a name="line.184"></a>
+<span class="sourceLineNo">185</span>                required = true;<a name="line.185"></a>
+<span class="sourceLineNo">186</span>            }<a name="line.186"></a>
+<span class="sourceLineNo">187</span>            else<a name="line.187"></a>
+<span class="sourceLineNo">188</span>            {<a name="line.188"></a>
+<span class="sourceLineNo">189</span>                type = (Class&lt;?&gt;) getValueClass(ch);<a name="line.189"></a>
+<span class="sourceLineNo">190</span>            }<a name="line.190"></a>
+<span class="sourceLineNo">191</span>        }<a name="line.191"></a>
+<span class="sourceLineNo">192</span><a name="line.192"></a>
+<span class="sourceLineNo">193</span>        if (opt != ' ')<a name="line.193"></a>
+<span class="sourceLineNo">194</span>        {<a name="line.194"></a>
+<span class="sourceLineNo">195</span>            final Option option = Option.builder(String.valueOf(opt))<a name="line.195"></a>
+<span class="sourceLineNo">196</span>                .hasArg(type != null)<a name="line.196"></a>
+<span class="sourceLineNo">197</span>                .required(required)<a name="line.197"></a>
+<span class="sourceLineNo">198</span>                .type(type)<a name="line.198"></a>
+<span class="sourceLineNo">199</span>                .build();<a name="line.199"></a>
+<span class="sourceLineNo">200</span>            <a name="line.200"></a>
+<span class="sourceLineNo">201</span>            // we have a final one to deal with<a name="line.201"></a>
+<span class="sourceLineNo">202</span>            options.addOption(option);<a name="line.202"></a>
+<span class="sourceLineNo">203</span>        }<a name="line.203"></a>
+<span class="sourceLineNo">204</span><a name="line.204"></a>
+<span class="sourceLineNo">205</span>        return options;<a name="line.205"></a>
+<span class="sourceLineNo">206</span>    }<a name="line.206"></a>
+<span class="sourceLineNo">207</span>}<a name="line.207"></a>
 
 
 

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 @@
 <span class="sourceLineNo">026</span> * The class PosixParser provides an implementation of the<a name="line.26"></a>
 <span class="sourceLineNo">027</span> * {@link Parser#flatten(Options,String[],boolean) flatten} method.<a name="line.27"></a>
 <span class="sourceLineNo">028</span> *<a name="line.28"></a>
-<span class="sourceLineNo">029</span> * @version $Id: PosixParser.java 1669814 2015-03-28 18:09:26Z britter $<a name="line.29"></a>
+<span class="sourceLineNo">029</span> * @version $Id: PosixParser.java 1677406 2015-05-03 14:27:31Z britter $<a name="line.29"></a>
 <span class="sourceLineNo">030</span> * @deprecated since 1.3, use the {@link DefaultParser} instead<a name="line.30"></a>
 <span class="sourceLineNo">031</span> */<a name="line.31"></a>
 <span class="sourceLineNo">032</span>@Deprecated<a name="line.32"></a>
@@ -67,7 +67,7 @@
 <span class="sourceLineNo">059</span>     * &lt;p&gt;An implementation of {@link Parser}'s abstract<a name="line.59"></a>
 <span class="sourceLineNo">060</span>     * {@link Parser#flatten(Options,String[],boolean) flatten} method.&lt;/p&gt;<a name="line.60"></a>
 <span class="sourceLineNo">061</span>     *<a name="line.61"></a>
-<span class="sourceLineNo">062</span>     * &lt;p&gt;The following are the rules used by this flatten method.<a name="line.62"></a>
+<span class="sourceLineNo">062</span>     * &lt;p&gt;The following are the rules used by this flatten method.&lt;/p&gt;<a name="line.62"></a>
 <span class="sourceLineNo">063</span>     * &lt;ol&gt;<a name="line.63"></a>
 <span class="sourceLineNo">064</span>     *  &lt;li&gt;if &lt;code&gt;stopAtNonOption&lt;/code&gt; is &lt;b&gt;true&lt;/b&gt; then do not<a name="line.64"></a>
 <span class="sourceLineNo">065</span>     *  burst anymore of &lt;code&gt;arguments&lt;/code&gt; entries, just add each<a name="line.65"></a>
@@ -93,217 +93,216 @@
 <span class="sourceLineNo">085</span>     *  by any of the previous rules, then the entry is added to the list<a name="line.85"></a>
 <span class="sourceLineNo">086</span>     *  of processed tokens.&lt;/li&gt;<a name="line.86"></a>
 <span class="sourceLineNo">087</span>     * &lt;/ol&gt;<a name="line.87"></a>
-<span class="sourceLineNo">088</span>     * &lt;/p&gt;<a name="line.88"></a>
-<span class="sourceLineNo">089</span>     *<a name="line.89"></a>
-<span class="sourceLineNo">090</span>     * @param options The command line {@link Options}<a name="line.90"></a>
-<span class="sourceLineNo">091</span>     * @param arguments The command line arguments to be parsed<a name="line.91"></a>
-<span class="sourceLineNo">092</span>     * @param stopAtNonOption Specifies whether to stop flattening<a name="line.92"></a>
-<span class="sourceLineNo">093</span>     * when an non option is found.<a name="line.93"></a>
-<span class="sourceLineNo">094</span>     * @return The flattened &lt;code&gt;arguments&lt;/code&gt; String array.<a name="line.94"></a>
-<span class="sourceLineNo">095</span>     */<a name="line.95"></a>
-<span class="sourceLineNo">096</span>    @Override<a name="line.96"></a>
-<span class="sourceLineNo">097</span>    protected String[] flatten(Options options, String[] arguments, boolean stopAtNonOption) throws ParseException<a name="line.97"></a>
-<span class="sourceLineNo">098</span>    {<a name="line.98"></a>
-<span class="sourceLineNo">099</span>        init();<a name="line.99"></a>
-<span class="sourceLineNo">100</span>        this.options = options;<a name="line.100"></a>
-<span class="sourceLineNo">101</span><a name="line.101"></a>
-<span class="sourceLineNo">102</span>        // an iterator for the command line tokens<a name="line.102"></a>
-<span class="sourceLineNo">103</span>        Iterator&lt;String&gt; iter = Arrays.asList(arguments).iterator();<a name="line.103"></a>
-<span class="sourceLineNo">104</span><a name="line.104"></a>
-<span class="sourceLineNo">105</span>        // process each command line token<a name="line.105"></a>
-<span class="sourceLineNo">106</span>        while (iter.hasNext())<a name="line.106"></a>
-<span class="sourceLineNo">107</span>        {<a name="line.107"></a>
-<span class="sourceLineNo">108</span>            // get the next command line token<a name="line.108"></a>
-<span class="sourceLineNo">109</span>            String token = iter.next();<a name="line.109"></a>
-<span class="sourceLineNo">110</span><a name="line.110"></a>
-<span class="sourceLineNo">111</span>            // single or double hyphen<a name="line.111"></a>
-<span class="sourceLineNo">112</span>            if ("-".equals(token) || "--".equals(token))<a name="line.112"></a>
-<span class="sourceLineNo">113</span>            {<a name="line.113"></a>
-<span class="sourceLineNo">114</span>                tokens.add(token);<a name="line.114"></a>
-<span class="sourceLineNo">115</span>            }<a name="line.115"></a>
-<span class="sourceLineNo">116</span>            <a name="line.116"></a>
-<span class="sourceLineNo">117</span>            // handle long option --foo or --foo=bar<a name="line.117"></a>
-<span class="sourceLineNo">118</span>            else if (token.startsWith("--"))<a name="line.118"></a>
-<span class="sourceLineNo">119</span>            {<a name="line.119"></a>
-<span class="sourceLineNo">120</span>                int pos = token.indexOf('=');<a name="line.120"></a>
-<span class="sourceLineNo">121</span>                String opt = pos == -1 ? token : token.substring(0, pos); // --foo<a name="line.121"></a>
-<span class="sourceLineNo">122</span>                <a name="line.122"></a>
-<span class="sourceLineNo">123</span>                List&lt;String&gt; matchingOpts = options.getMatchingOptions(opt);<a name="line.123"></a>
-<span class="sourceLineNo">124</span><a name="line.124"></a>
-<span class="sourceLineNo">125</span>                if (matchingOpts.isEmpty())<a name="line.125"></a>
-<span class="sourceLineNo">126</span>                {<a name="line.126"></a>
-<span class="sourceLineNo">127</span>                    processNonOptionToken(token, stopAtNonOption);<a name="line.127"></a>
-<span class="sourceLineNo">128</span>                }<a name="line.128"></a>
-<span class="sourceLineNo">129</span>                else if (matchingOpts.size() &gt; 1)<a name="line.129"></a>
-<span class="sourceLineNo">130</span>                {<a name="line.130"></a>
-<span class="sourceLineNo">131</span>                    throw new AmbiguousOptionException(opt, matchingOpts);<a name="line.131"></a>
-<span class="sourceLineNo">132</span>                }<a name="line.132"></a>
-<span class="sourceLineNo">133</span>                else<a name="line.133"></a>
-<span class="sourceLineNo">134</span>                {<a name="line.134"></a>
-<span class="sourceLineNo">135</span>                    currentOption = options.getOption(matchingOpts.get(0));<a name="line.135"></a>
-<span class="sourceLineNo">136</span>                    <a name="line.136"></a>
-<span class="sourceLineNo">137</span>                    tokens.add("--" + currentOption.getLongOpt());<a name="line.137"></a>
-<span class="sourceLineNo">138</span>                    if (pos != -1)<a name="line.138"></a>
-<span class="sourceLineNo">139</span>                    {<a name="line.139"></a>
-<span class="sourceLineNo">140</span>                        tokens.add(token.substring(pos + 1));<a name="line.140"></a>
-<span class="sourceLineNo">141</span>                    }<a name="line.141"></a>
-<span class="sourceLineNo">142</span>                }<a name="line.142"></a>
-<span class="sourceLineNo">143</span>            }<a name="line.143"></a>
-<span class="sourceLineNo">144</span><a name="line.144"></a>
-<span class="sourceLineNo">145</span>            else if (token.startsWith("-"))<a name="line.145"></a>
-<span class="sourceLineNo">146</span>            {<a name="line.146"></a>
-<span class="sourceLineNo">147</span>                if (token.length() == 2 || options.hasOption(token))<a name="line.147"></a>
-<span class="sourceLineNo">148</span>                {<a name="line.148"></a>
-<span class="sourceLineNo">149</span>                    processOptionToken(token, stopAtNonOption);<a name="line.149"></a>
-<span class="sourceLineNo">150</span>                }<a name="line.150"></a>
-<span class="sourceLineNo">151</span>                else if (!options.getMatchingOptions(token).isEmpty())<a name="line.151"></a>
-<span class="sourceLineNo">152</span>                {<a name="line.152"></a>
-<span class="sourceLineNo">153</span>                    List&lt;String&gt; matchingOpts = options.getMatchingOptions(token);<a name="line.153"></a>
-<span class="sourceLineNo">154</span>                    if (matchingOpts.size() &gt; 1)<a name="line.154"></a>
-<span class="sourceLineNo">155</span>                    {<a name="line.155"></a>
-<span class="sourceLineNo">156</span>                        throw new AmbiguousOptionException(token, matchingOpts);<a name="line.156"></a>
-<span class="sourceLineNo">157</span>                    }<a name="line.157"></a>
-<span class="sourceLineNo">158</span>                    else<a name="line.158"></a>
-<span class="sourceLineNo">159</span>                    {<a name="line.159"></a>
-<span class="sourceLineNo">160</span>                        Option opt = options.getOption(matchingOpts.get(0));<a name="line.160"></a>
-<span class="sourceLineNo">161</span>                        processOptionToken("-" + opt.getLongOpt(), stopAtNonOption);<a name="line.161"></a>
-<span class="sourceLineNo">162</span>                    }<a name="line.162"></a>
-<span class="sourceLineNo">163</span>                }<a name="line.163"></a>
-<span class="sourceLineNo">164</span>                // requires bursting<a name="line.164"></a>
-<span class="sourceLineNo">165</span>                else<a name="line.165"></a>
-<span class="sourceLineNo">166</span>                {<a name="line.166"></a>
-<span class="sourceLineNo">167</span>                    burstToken(token, stopAtNonOption);<a name="line.167"></a>
-<span class="sourceLineNo">168</span>                }<a name="line.168"></a>
-<span class="sourceLineNo">169</span>            }<a name="line.169"></a>
-<span class="sourceLineNo">170</span>            else<a name="line.170"></a>
-<span class="sourceLineNo">171</span>            {<a name="line.171"></a>
-<span class="sourceLineNo">172</span>                processNonOptionToken(token, stopAtNonOption);<a name="line.172"></a>
-<span class="sourceLineNo">173</span>            }<a name="line.173"></a>
-<span class="sourceLineNo">174</span><a name="line.174"></a>
-<span class="sourceLineNo">175</span>            gobble(iter);<a name="line.175"></a>
-<span class="sourceLineNo">176</span>        }<a name="line.176"></a>
-<span class="sourceLineNo">177</span><a name="line.177"></a>
-<span class="sourceLineNo">178</span>        return tokens.toArray(new String[tokens.size()]);<a name="line.178"></a>
-<span class="sourceLineNo">179</span>    }<a name="line.179"></a>
-<span class="sourceLineNo">180</span><a name="line.180"></a>
-<span class="sourceLineNo">181</span>    /**<a name="line.181"></a>
-<span class="sourceLineNo">182</span>     * Adds the remaining tokens to the processed tokens list.<a name="line.182"></a>
-<span class="sourceLineNo">183</span>     *<a name="line.183"></a>
-<span class="sourceLineNo">184</span>     * @param iter An iterator over the remaining tokens<a name="line.184"></a>
-<span class="sourceLineNo">185</span>     */<a name="line.185"></a>
-<span class="sourceLineNo">186</span>    private void gobble(Iterator&lt;String&gt; iter)<a name="line.186"></a>
-<span class="sourceLineNo">187</span>    {<a name="line.187"></a>
-<span class="sourceLineNo">188</span>        if (eatTheRest)<a name="line.188"></a>
-<span class="sourceLineNo">189</span>        {<a name="line.189"></a>
-<span class="sourceLineNo">190</span>            while (iter.hasNext())<a name="line.190"></a>
-<span class="sourceLineNo">191</span>            {<a name="line.191"></a>
-<span class="sourceLineNo">192</span>                tokens.add(iter.next());<a name="line.192"></a>
-<span class="sourceLineNo">193</span>            }<a name="line.193"></a>
-<span class="sourceLineNo">194</span>        }<a name="line.194"></a>
-<span class="sourceLineNo">195</span>    }<a name="line.195"></a>
-<span class="sourceLineNo">196</span><a name="line.196"></a>
-<span class="sourceLineNo">197</span>    /**<a name="line.197"></a>
-<span class="sourceLineNo">198</span>     * Add the special token "&lt;b&gt;--&lt;/b&gt;" and the current &lt;code&gt;value&lt;/code&gt;<a name="line.198"></a>
-<span class="sourceLineNo">199</span>     * to the processed tokens list. Then add all the remaining<a name="line.199"></a>
-<span class="sourceLineNo">200</span>     * &lt;code&gt;argument&lt;/code&gt; values to the processed tokens list.<a name="line.200"></a>
-<span class="sourceLineNo">201</span>     *<a name="line.201"></a>
-<span class="sourceLineNo">202</span>     * @param value The current token<a name="line.202"></a>
-<span class="sourceLineNo">203</span>     */<a name="line.203"></a>
-<span class="sourceLineNo">204</span>    private void processNonOptionToken(String value, boolean stopAtNonOption)<a name="line.204"></a>
-<span class="sourceLineNo">205</span>    {<a name="line.205"></a>
-<span class="sourceLineNo">206</span>        if (stopAtNonOption &amp;&amp; (currentOption == null || !currentOption.hasArg()))<a name="line.206"></a>
-<span class="sourceLineNo">207</span>        {<a name="line.207"></a>
-<span class="sourceLineNo">208</span>            eatTheRest = true;<a name="line.208"></a>
-<span class="sourceLineNo">209</span>            tokens.add("--");<a name="line.209"></a>
-<span class="sourceLineNo">210</span>        }<a name="line.210"></a>
-<span class="sourceLineNo">211</span><a name="line.211"></a>
-<span class="sourceLineNo">212</span>        tokens.add(value);<a name="line.212"></a>
-<span class="sourceLineNo">213</span>    }<a name="line.213"></a>
-<span class="sourceLineNo">214</span><a name="line.214"></a>
-<span class="sourceLineNo">215</span>    /**<a name="line.215"></a>
-<span class="sourceLineNo">216</span>     * &lt;p&gt;If an {@link Option} exists for &lt;code&gt;token&lt;/code&gt; then<a name="line.216"></a>
-<span class="sourceLineNo">217</span>     * add the token to the processed list.&lt;/p&gt;<a name="line.217"></a>
-<span class="sourceLineNo">218</span>     *<a name="line.218"></a>
-<span class="sourceLineNo">219</span>     * &lt;p&gt;If an {@link Option} does not exist and &lt;code&gt;stopAtNonOption&lt;/code&gt;<a name="line.219"></a>
-<span class="sourceLineNo">220</span>     * is set then add the remaining tokens to the processed tokens list<a name="line.220"></a>
-<span class="sourceLineNo">221</span>     * directly.&lt;/p&gt;<a name="line.221"></a>
-<span class="sourceLineNo">222</span>     *<a name="line.222"></a>
-<span class="sourceLineNo">223</span>     * @param token The current option token<a name="line.223"></a>
-<span class="sourceLineNo">224</span>     * @param stopAtNonOption Specifies whether flattening should halt<a name="line.224"></a>
-<span class="sourceLineNo">225</span>     * at the first non option.<a name="line.225"></a>
-<span class="sourceLineNo">226</span>     */<a name="line.226"></a>
-<span class="sourceLineNo">227</span>    private void processOptionToken(String token, boolean stopAtNonOption)<a name="line.227"></a>
-<span class="sourceLineNo">228</span>    {<a name="line.228"></a>
-<span class="sourceLineNo">229</span>        if (stopAtNonOption &amp;&amp; !options.hasOption(token))<a name="line.229"></a>
-<span class="sourceLineNo">230</span>        {<a name="line.230"></a>
-<span class="sourceLineNo">231</span>            eatTheRest = true;<a name="line.231"></a>
-<span class="sourceLineNo">232</span>        }<a name="line.232"></a>
-<span class="sourceLineNo">233</span><a name="line.233"></a>
-<span class="sourceLineNo">234</span>        if (options.hasOption(token))<a name="line.234"></a>
-<span class="sourceLineNo">235</span>        {<a name="line.235"></a>
-<span class="sourceLineNo">236</span>            currentOption = options.getOption(token);<a name="line.236"></a>
-<span class="sourceLineNo">237</span>        }<a name="line.237"></a>
-<span class="sourceLineNo">238</span><a name="line.238"></a>
-<span class="sourceLineNo">239</span>        tokens.add(token);<a name="line.239"></a>
-<span class="sourceLineNo">240</span>    }<a name="line.240"></a>
-<span class="sourceLineNo">241</span><a name="line.241"></a>
-<span class="sourceLineNo">242</span>    /**<a name="line.242"></a>
-<span class="sourceLineNo">243</span>     * Breaks &lt;code&gt;token&lt;/code&gt; into its constituent parts<a name="line.243"></a>
-<span class="sourceLineNo">244</span>     * using the following algorithm.<a name="line.244"></a>
-<span class="sourceLineNo">245</span>     *<a name="line.245"></a>
-<span class="sourceLineNo">246</span>     * &lt;ul&gt;<a name="line.246"></a>
-<span class="sourceLineNo">247</span>     *  &lt;li&gt;ignore the first character ("&lt;b&gt;-&lt;/b&gt;")&lt;/li&gt;<a name="line.247"></a>
-<span class="sourceLineNo">248</span>     *  &lt;li&gt;foreach remaining character check if an {@link Option}<a name="line.248"></a>
-<span class="sourceLineNo">249</span>     *  exists with that id.&lt;/li&gt;<a name="line.249"></a>
-<span class="sourceLineNo">250</span>     *  &lt;li&gt;if an {@link Option} does exist then add that character<a name="line.250"></a>
-<span class="sourceLineNo">251</span>     *  prepended with "&lt;b&gt;-&lt;/b&gt;" to the list of processed tokens.&lt;/li&gt;<a name="line.251"></a>
-<span class="sourceLineNo">252</span>     *  &lt;li&gt;if the {@link Option} can have an argument value and there<a name="line.252"></a>
-<span class="sourceLineNo">253</span>     *  are remaining characters in the token then add the remaining<a name="line.253"></a>
-<span class="sourceLineNo">254</span>     *  characters as a token to the list of processed tokens.&lt;/li&gt;<a name="line.254"></a>
-<span class="sourceLineNo">255</span>     *  &lt;li&gt;if an {@link Option} does &lt;b&gt;NOT&lt;/b&gt; exist &lt;b&gt;AND&lt;/b&gt;<a name="line.255"></a>
-<span class="sourceLineNo">256</span>     *  &lt;code&gt;stopAtNonOption&lt;/code&gt; &lt;b&gt;IS&lt;/b&gt; set then add the special token<a name="line.256"></a>
-<span class="sourceLineNo">257</span>     *  "&lt;b&gt;--&lt;/b&gt;" followed by the remaining characters and also<a name="line.257"></a>
-<span class="sourceLineNo">258</span>     *  the remaining tokens directly to the processed tokens list.&lt;/li&gt;<a name="line.258"></a>
-<span class="sourceLineNo">259</span>     *  &lt;li&gt;if an {@link Option} does &lt;b&gt;NOT&lt;/b&gt; exist &lt;b&gt;AND&lt;/b&gt;<a name="line.259"></a>
-<span class="sourceLineNo">260</span>     *  &lt;code&gt;stopAtNonOption&lt;/code&gt; &lt;b&gt;IS NOT&lt;/b&gt; set then add that<a name="line.260"></a>
-<span class="sourceLineNo">261</span>     *  character prepended with "&lt;b&gt;-&lt;/b&gt;".&lt;/li&gt;<a name="line.261"></a>
-<span class="sourceLineNo">262</span>     * &lt;/ul&gt;<a name="line.262"></a>
-<span class="sourceLineNo">263</span>     *<a name="line.263"></a>
-<span class="sourceLineNo">264</span>     * @param token The current token to be &lt;b&gt;burst&lt;/b&gt;<a name="line.264"></a>
-<span class="sourceLineNo">265</span>     * @param stopAtNonOption Specifies whether to stop processing<a name="line.265"></a>
-<span class="sourceLineNo">266</span>     * at the first non-Option encountered.<a name="line.266"></a>
-<span class="sourceLineNo">267</span>     */<a name="line.267"></a>
-<span class="sourceLineNo">268</span>    protected void burstToken(String token, boolean stopAtNonOption)<a name="line.268"></a>
-<span class="sourceLineNo">269</span>    {<a name="line.269"></a>
-<span class="sourceLineNo">270</span>        for (int i = 1; i &lt; token.length(); i++)<a name="line.270"></a>
-<span class="sourceLineNo">271</span>        {<a name="line.271"></a>
-<span class="sourceLineNo">272</span>            String ch = String.valueOf(token.charAt(i));<a name="line.272"></a>
-<span class="sourceLineNo">273</span><a name="line.273"></a>
-<span class="sourceLineNo">274</span>            if (options.hasOption(ch))<a name="line.274"></a>
-<span class="sourceLineNo">275</span>            {<a name="line.275"></a>
-<span class="sourceLineNo">276</span>                tokens.add("-" + ch);<a name="line.276"></a>
-<span class="sourceLineNo">277</span>                currentOption = options.getOption(ch);<a name="line.277"></a>
-<span class="sourceLineNo">278</span><a name="line.278"></a>
-<span class="sourceLineNo">279</span>                if (currentOption.hasArg() &amp;&amp; (token.length() != (i + 1)))<a name="line.279"></a>
-<span class="sourceLineNo">280</span>                {<a name="line.280"></a>
-<span class="sourceLineNo">281</span>                    tokens.add(token.substring(i + 1));<a name="line.281"></a>
-<span class="sourceLineNo">282</span><a name="line.282"></a>
-<span class="sourceLineNo">283</span>                    break;<a name="line.283"></a>
-<span class="sourceLineNo">284</span>                }<a name="line.284"></a>
-<span class="sourceLineNo">285</span>            }<a name="line.285"></a>
-<span class="sourceLineNo">286</span>            else if (stopAtNonOption)<a name="line.286"></a>
-<span class="sourceLineNo">287</span>            {<a name="line.287"></a>
-<span class="sourceLineNo">288</span>                processNonOptionToken(token.substring(i), true);<a name="line.288"></a>
-<span class="sourceLineNo">289</span>                break;<a name="line.289"></a>
-<span class="sourceLineNo">290</span>            }<a name="line.290"></a>
-<span class="sourceLineNo">291</span>            else<a name="line.291"></a>
-<span class="sourceLineNo">292</span>            {<a name="line.292"></a>
-<span class="sourceLineNo">293</span>                tokens.add(token);<a name="line.293"></a>
-<span class="sourceLineNo">294</span>                break;<a name="line.294"></a>
-<span class="sourceLineNo">295</span>            }<a name="line.295"></a>
-<span class="sourceLineNo">296</span>        }<a name="line.296"></a>
-<span class="sourceLineNo">297</span>    }<a name="line.297"></a>
-<span class="sourceLineNo">298</span>}<a name="line.298"></a>
+<span class="sourceLineNo">088</span>     *<a name="line.88"></a>
+<span class="sourceLineNo">089</span>     * @param options The command line {@link Options}<a name="line.89"></a>
+<span class="sourceLineNo">090</span>     * @param arguments The command line arguments to be parsed<a name="line.90"></a>
+<span class="sourceLineNo">091</span>     * @param stopAtNonOption Specifies whether to stop flattening<a name="line.91"></a>
+<span class="sourceLineNo">092</span>     * when an non option is found.<a name="line.92"></a>
+<span class="sourceLineNo">093</span>     * @return The flattened &lt;code&gt;arguments&lt;/code&gt; String array.<a name="line.93"></a>
+<span class="sourceLineNo">094</span>     */<a name="line.94"></a>
+<span class="sourceLineNo">095</span>    @Override<a name="line.95"></a>
+<span class="sourceLineNo">096</span>    protected String[] flatten(Options options, String[] arguments, boolean stopAtNonOption) throws ParseException<a name="line.96"></a>
+<span class="sourceLineNo">097</span>    {<a name="line.97"></a>
+<span class="sourceLineNo">098</span>        init();<a name="line.98"></a>
+<span class="sourceLineNo">099</span>        this.options = options;<a name="line.99"></a>
+<span class="sourceLineNo">100</span><a name="line.100"></a>
+<span class="sourceLineNo">101</span>        // an iterator for the command line tokens<a name="line.101"></a>
+<span class="sourceLineNo">102</span>        Iterator&lt;String&gt; iter = Arrays.asList(arguments).iterator();<a name="line.102"></a>
+<span class="sourceLineNo">103</span><a name="line.103"></a>
+<span class="sourceLineNo">104</span>        // process each command line token<a name="line.104"></a>
+<span class="sourceLineNo">105</span>        while (iter.hasNext())<a name="line.105"></a>
+<span class="sourceLineNo">106</span>        {<a name="line.106"></a>
+<span class="sourceLineNo">107</span>            // get the next command line token<a name="line.107"></a>
+<span class="sourceLineNo">108</span>            String token = iter.next();<a name="line.108"></a>
+<span class="sourceLineNo">109</span><a name="line.109"></a>
+<span class="sourceLineNo">110</span>            // single or double hyphen<a name="line.110"></a>
+<span class="sourceLineNo">111</span>            if ("-".equals(token) || "--".equals(token))<a name="line.111"></a>
+<span class="sourceLineNo">112</span>            {<a name="line.112"></a>
+<span class="sourceLineNo">113</span>                tokens.add(token);<a name="line.113"></a>
+<span class="sourceLineNo">114</span>            }<a name="line.114"></a>
+<span class="sourceLineNo">115</span>            <a name="line.115"></a>
+<span class="sourceLineNo">116</span>            // handle long option --foo or --foo=bar<a name="line.116"></a>
+<span class="sourceLineNo">117</span>            else if (token.startsWith("--"))<a name="line.117"></a>
+<span class="sourceLineNo">118</span>            {<a name="line.118"></a>
+<span class="sourceLineNo">119</span>                int pos = token.indexOf('=');<a name="line.119"></a>
+<span class="sourceLineNo">120</span>                String opt = pos == -1 ? token : token.substring(0, pos); // --foo<a name="line.120"></a>
+<span class="sourceLineNo">121</span>                <a name="line.121"></a>
+<span class="sourceLineNo">122</span>                List&lt;String&gt; matchingOpts = options.getMatchingOptions(opt);<a name="line.122"></a>
+<span class="sourceLineNo">123</span><a name="line.123"></a>
+<span class="sourceLineNo">124</span>                if (matchingOpts.isEmpty())<a name="line.124"></a>
+<span class="sourceLineNo">125</span>                {<a name="line.125"></a>
+<span class="sourceLineNo">126</span>                    processNonOptionToken(token, stopAtNonOption);<a name="line.126"></a>
+<span class="sourceLineNo">127</span>                }<a name="line.127"></a>
+<span class="sourceLineNo">128</span>                else if (matchingOpts.size() &gt; 1)<a name="line.128"></a>
+<span class="sourceLineNo">129</span>                {<a name="line.129"></a>
+<span class="sourceLineNo">130</span>                    throw new AmbiguousOptionException(opt, matchingOpts);<a name="line.130"></a>
+<span class="sourceLineNo">131</span>                }<a name="line.131"></a>
+<span class="sourceLineNo">132</span>                else<a name="line.132"></a>
+<span class="sourceLineNo">133</span>                {<a name="line.133"></a>
+<span class="sourceLineNo">134</span>                    currentOption = options.getOption(matchingOpts.get(0));<a name="line.134"></a>
+<span class="sourceLineNo">135</span>                    <a name="line.135"></a>
+<span class="sourceLineNo">136</span>                    tokens.add("--" + currentOption.getLongOpt());<a name="line.136"></a>
+<span class="sourceLineNo">137</span>                    if (pos != -1)<a name="line.137"></a>
+<span class="sourceLineNo">138</span>                    {<a name="line.138"></a>
+<span class="sourceLineNo">139</span>                        tokens.add(token.substring(pos + 1));<a name="line.139"></a>
+<span class="sourceLineNo">140</span>                    }<a name="line.140"></a>
+<span class="sourceLineNo">141</span>                }<a name="line.141"></a>
+<span class="sourceLineNo">142</span>            }<a name="line.142"></a>
+<span class="sourceLineNo">143</span><a name="line.143"></a>
+<span class="sourceLineNo">144</span>            else if (token.startsWith("-"))<a name="line.144"></a>
+<span class="sourceLineNo">145</span>            {<a name="line.145"></a>
+<span class="sourceLineNo">146</span>                if (token.length() == 2 || options.hasOption(token))<a name="line.146"></a>
+<span class="sourceLineNo">147</span>                {<a name="line.147"></a>
+<span class="sourceLineNo">148</span>                    processOptionToken(token, stopAtNonOption);<a name="line.148"></a>
+<span class="sourceLineNo">149</span>                }<a name="line.149"></a>
+<span class="sourceLineNo">150</span>                else if (!options.getMatchingOptions(token).isEmpty())<a name="line.150"></a>
+<span class="sourceLineNo">151</span>                {<a name="line.151"></a>
+<span class="sourceLineNo">152</span>                    List&lt;String&gt; matchingOpts = options.getMatchingOptions(token);<a name="line.152"></a>
+<span class="sourceLineNo">153</span>                    if (matchingOpts.size() &gt; 1)<a name="line.153"></a>
+<span class="sourceLineNo">154</span>                    {<a name="line.154"></a>
+<span class="sourceLineNo">155</span>                        throw new AmbiguousOptionException(token, matchingOpts);<a name="line.155"></a>
+<span class="sourceLineNo">156</span>                    }<a name="line.156"></a>
+<span class="sourceLineNo">157</span>                    else<a name="line.157"></a>
+<span class="sourceLineNo">158</span>                    {<a name="line.158"></a>
+<span class="sourceLineNo">159</span>                        Option opt = options.getOption(matchingOpts.get(0));<a name="line.159"></a>
+<span class="sourceLineNo">160</span>                        processOptionToken("-" + opt.getLongOpt(), stopAtNonOption);<a name="line.160"></a>
+<span class="sourceLineNo">161</span>                    }<a name="line.161"></a>
+<span class="sourceLineNo">162</span>                }<a name="line.162"></a>
+<span class="sourceLineNo">163</span>                // requires bursting<a name="line.163"></a>
+<span class="sourceLineNo">164</span>                else<a name="line.164"></a>
+<span class="sourceLineNo">165</span>                {<a name="line.165"></a>
+<span class="sourceLineNo">166</span>                    burstToken(token, stopAtNonOption);<a name="line.166"></a>
+<span class="sourceLineNo">167</span>                }<a name="line.167"></a>
+<span class="sourceLineNo">168</span>            }<a name="line.168"></a>
+<span class="sourceLineNo">169</span>            else<a name="line.169"></a>
+<span class="sourceLineNo">170</span>            {<a name="line.170"></a>
+<span class="sourceLineNo">171</span>                processNonOptionToken(token, stopAtNonOption);<a name="line.171"></a>
+<span class="sourceLineNo">172</span>            }<a name="line.172"></a>
+<span class="sourceLineNo">173</span><a name="line.173"></a>
+<span class="sourceLineNo">174</span>            gobble(iter);<a name="line.174"></a>
+<span class="sourceLineNo">175</span>        }<a name="line.175"></a>
+<span class="sourceLineNo">176</span><a name="line.176"></a>
+<span class="sourceLineNo">177</span>        return tokens.toArray(new String[tokens.size()]);<a name="line.177"></a>
+<span class="sourceLineNo">178</span>    }<a name="line.178"></a>
+<span class="sourceLineNo">179</span><a name="line.179"></a>
+<span class="sourceLineNo">180</span>    /**<a name="line.180"></a>
+<span class="sourceLineNo">181</span>     * Adds the remaining tokens to the processed tokens list.<a name="line.181"></a>
+<span class="sourceLineNo">182</span>     *<a name="line.182"></a>
+<span class="sourceLineNo">183</span>     * @param iter An iterator over the remaining tokens<a name="line.183"></a>
+<span class="sourceLineNo">184</span>     */<a name="line.184"></a>
+<span class="sourceLineNo">185</span>    private void gobble(Iterator&lt;String&gt; iter)<a name="line.185"></a>
+<span class="sourceLineNo">186</span>    {<a name="line.186"></a>
+<span class="sourceLineNo">187</span>        if (eatTheRest)<a name="line.187"></a>
+<span class="sourceLineNo">188</span>        {<a name="line.188"></a>
+<span class="sourceLineNo">189</span>            while (iter.hasNext())<a name="line.189"></a>
+<span class="sourceLineNo">190</span>            {<a name="line.190"></a>
+<span class="sourceLineNo">191</span>                tokens.add(iter.next());<a name="line.191"></a>
+<span class="sourceLineNo">192</span>            }<a name="line.192"></a>
+<span class="sourceLineNo">193</span>        }<a name="line.193"></a>
+<span class="sourceLineNo">194</span>    }<a name="line.194"></a>
+<span class="sourceLineNo">195</span><a name="line.195"></a>
+<span class="sourceLineNo">196</span>    /**<a name="line.196"></a>
+<span class="sourceLineNo">197</span>     * Add the special token "&lt;b&gt;--&lt;/b&gt;" and the current &lt;code&gt;value&lt;/code&gt;<a name="line.197"></a>
+<span class="sourceLineNo">198</span>     * to the processed tokens list. Then add all the remaining<a name="line.198"></a>
+<span class="sourceLineNo">199</span>     * &lt;code&gt;argument&lt;/code&gt; values to the processed tokens list.<a name="line.199"></a>
+<span class="sourceLineNo">200</span>     *<a name="line.200"></a>
+<span class="sourceLineNo">201</span>     * @param value The current token<a name="line.201"></a>
+<span class="sourceLineNo">202</span>     */<a name="line.202"></a>
+<span class="sourceLineNo">203</span>    private void processNonOptionToken(String value, boolean stopAtNonOption)<a name="line.203"></a>
+<span class="sourceLineNo">204</span>    {<a name="line.204"></a>
+<span class="sourceLineNo">205</span>        if (stopAtNonOption &amp;&amp; (currentOption == null || !currentOption.hasArg()))<a name="line.205"></a>
+<span class="sourceLineNo">206</span>        {<a name="line.206"></a>
+<span class="sourceLineNo">207</span>            eatTheRest = true;<a name="line.207"></a>
+<span class="sourceLineNo">208</span>            tokens.add("--");<a name="line.208"></a>
+<span class="sourceLineNo">209</span>        }<a name="line.209"></a>
+<span class="sourceLineNo">210</span><a name="line.210"></a>
+<span class="sourceLineNo">211</span>        tokens.add(value);<a name="line.211"></a>
+<span class="sourceLineNo">212</span>    }<a name="line.212"></a>
+<span class="sourceLineNo">213</span><a name="line.213"></a>
+<span class="sourceLineNo">214</span>    /**<a name="line.214"></a>
+<span class="sourceLineNo">215</span>     * &lt;p&gt;If an {@link Option} exists for &lt;code&gt;token&lt;/code&gt; then<a name="line.215"></a>
+<span class="sourceLineNo">216</span>     * add the token to the processed list.&lt;/p&gt;<a name="line.216"></a>
+<span class="sourceLineNo">217</span>     *<a name="line.217"></a>
+<span class="sourceLineNo">218</span>     * &lt;p&gt;If an {@link Option} does not exist and &lt;code&gt;stopAtNonOption&lt;/code&gt;<a name="line.218"></a>
+<span class="sourceLineNo">219</span>     * is set then add the remaining tokens to the processed tokens list<a name="line.219"></a>
+<span class="sourceLineNo">220</span>     * directly.&lt;/p&gt;<a name="line.220"></a>
+<span class="sourceLineNo">221</span>     *<a name="line.221"></a>
+<span class="sourceLineNo">222</span>     * @param token The current option token<a name="line.222"></a>
+<span class="sourceLineNo">223</span>     * @param stopAtNonOption Specifies whether flattening should halt<a name="line.223"></a>
+<span class="sourceLineNo">224</span>     * at the first non option.<a name="line.224"></a>
+<span class="sourceLineNo">225</span>     */<a name="line.225"></a>
+<span class="sourceLineNo">226</span>    private void processOptionToken(String token, boolean stopAtNonOption)<a name="line.226"></a>
+<span class="sourceLineNo">227</span>    {<a name="line.227"></a>
+<span class="sourceLineNo">228</span>        if (stopAtNonOption &amp;&amp; !options.hasOption(token))<a name="line.228"></a>
+<span class="sourceLineNo">229</span>        {<a name="line.229"></a>
+<span class="sourceLineNo">230</span>            eatTheRest = true;<a name="line.230"></a>
+<span class="sourceLineNo">231</span>        }<a name="line.231"></a>
+<span class="sourceLineNo">232</span><a name="line.232"></a>
+<span class="sourceLineNo">233</span>        if (options.hasOption(token))<a name="line.233"></a>
+<span class="sourceLineNo">234</span>        {<a name="line.234"></a>
+<span class="sourceLineNo">235</span>            currentOption = options.getOption(token);<a name="line.235"></a>
+<span class="sourceLineNo">236</span>        }<a name="line.236"></a>
+<span class="sourceLineNo">237</span><a name="line.237"></a>
+<span class="sourceLineNo">238</span>        tokens.add(token);<a name="line.238"></a>
+<span class="sourceLineNo">239</span>    }<a name="line.239"></a>
+<span class="sourceLineNo">240</span><a name="line.240"></a>
+<span class="sourceLineNo">241</span>    /**<a name="line.241"></a>
+<span class="sourceLineNo">242</span>     * Breaks &lt;code&gt;token&lt;/code&gt; into its constituent parts<a name="line.242"></a>
+<span class="sourceLineNo">243</span>     * using the following algorithm.<a name="line.243"></a>
+<span class="sourceLineNo">244</span>     *<a name="line.244"></a>
+<span class="sourceLineNo">245</span>     * &lt;ul&gt;<a name="line.245"></a>
+<span class="sourceLineNo">246</span>     *  &lt;li&gt;ignore the first character ("&lt;b&gt;-&lt;/b&gt;")&lt;/li&gt;<a name="line.246"></a>
+<span class="sourceLineNo">247</span>     *  &lt;li&gt;foreach remaining character check if an {@link Option}<a name="line.247"></a>
+<span class="sourceLineNo">248</span>     *  exists with that id.&lt;/li&gt;<a name="line.248"></a>
+<span class="sourceLineNo">249</span>     *  &lt;li&gt;if an {@link Option} does exist then add that character<a name="line.249"></a>
+<span class="sourceLineNo">250</span>     *  prepended with "&lt;b&gt;-&lt;/b&gt;" to the list of processed tokens.&lt;/li&gt;<a name="line.250"></a>
+<span class="sourceLineNo">251</span>     *  &lt;li&gt;if the {@link Option} can have an argument value and there<a name="line.251"></a>
+<span class="sourceLineNo">252</span>     *  are remaining characters in the token then add the remaining<a name="line.252"></a>
+<span class="sourceLineNo">253</span>     *  characters as a token to the list of processed tokens.&lt;/li&gt;<a name="line.253"></a>
+<span class="sourceLineNo">254</span>     *  &lt;li&gt;if an {@link Option} does &lt;b&gt;NOT&lt;/b&gt; exist &lt;b&gt;AND&lt;/b&gt;<a name="line.254"></a>
+<span class="sourceLineNo">255</span>     *  &lt;code&gt;stopAtNonOption&lt;/code&gt; &lt;b&gt;IS&lt;/b&gt; set then add the special token<a name="line.255"></a>
+<span class="sourceLineNo">256</span>     *  "&lt;b&gt;--&lt;/b&gt;" followed by the remaining characters and also<a name="line.256"></a>
+<span class="sourceLineNo">257</span>     *  the remaining tokens directly to the processed tokens list.&lt;/li&gt;<a name="line.257"></a>
+<span class="sourceLineNo">258</span>     *  &lt;li&gt;if an {@link Option} does &lt;b&gt;NOT&lt;/b&gt; exist &lt;b&gt;AND&lt;/b&gt;<a name="line.258"></a>
+<span class="sourceLineNo">259</span>     *  &lt;code&gt;stopAtNonOption&lt;/code&gt; &lt;b&gt;IS NOT&lt;/b&gt; set then add that<a name="line.259"></a>
+<span class="sourceLineNo">260</span>     *  character prepended with "&lt;b&gt;-&lt;/b&gt;".&lt;/li&gt;<a name="line.260"></a>
+<span class="sourceLineNo">261</span>     * &lt;/ul&gt;<a name="line.261"></a>
+<span class="sourceLineNo">262</span>     *<a name="line.262"></a>
+<span class="sourceLineNo">263</span>     * @param token The current token to be &lt;b&gt;burst&lt;/b&gt;<a name="line.263"></a>
+<span class="sourceLineNo">264</span>     * @param stopAtNonOption Specifies whether to stop processing<a name="line.264"></a>
+<span class="sourceLineNo">265</span>     * at the first non-Option encountered.<a name="line.265"></a>
+<span class="sourceLineNo">266</span>     */<a name="line.266"></a>
+<span class="sourceLineNo">267</span>    protected void burstToken(String token, boolean stopAtNonOption)<a name="line.267"></a>
+<span class="sourceLineNo">268</span>    {<a name="line.268"></a>
+<span class="sourceLineNo">269</span>        for (int i = 1; i &lt; token.length(); i++)<a name="line.269"></a>
+<span class="sourceLineNo">270</span>        {<a name="line.270"></a>
+<span class="sourceLineNo">271</span>            String ch = String.valueOf(token.charAt(i));<a name="line.271"></a>
+<span class="sourceLineNo">272</span><a name="line.272"></a>
+<span class="sourceLineNo">273</span>            if (options.hasOption(ch))<a name="line.273"></a>
+<span class="sourceLineNo">274</span>            {<a name="line.274"></a>
+<span class="sourceLineNo">275</span>                tokens.add("-" + ch);<a name="line.275"></a>
+<span class="sourceLineNo">276</span>                currentOption = options.getOption(ch);<a name="line.276"></a>
+<span class="sourceLineNo">277</span><a name="line.277"></a>
+<span class="sourceLineNo">278</span>                if (currentOption.hasArg() &amp;&amp; token.length() != i + 1)<a name="line.278"></a>
+<span class="sourceLineNo">279</span>                {<a name="line.279"></a>
+<span class="sourceLineNo">280</span>                    tokens.add(token.substring(i + 1));<a name="line.280"></a>
+<span class="sourceLineNo">281</span><a name="line.281"></a>
+<span class="sourceLineNo">282</span>                    break;<a name="line.282"></a>
+<span class="sourceLineNo">283</span>                }<a name="line.283"></a>
+<span class="sourceLineNo">284</span>            }<a name="line.284"></a>
+<span class="sourceLineNo">285</span>            else if (stopAtNonOption)<a name="line.285"></a>
+<span class="sourceLineNo">286</span>            {<a name="line.286"></a>
+<span class="sourceLineNo">287</span>                processNonOptionToken(token.substring(i), true);<a name="line.287"></a>
+<span class="sourceLineNo">288</span>                break;<a name="line.288"></a>
+<span class="sourceLineNo">289</span>            }<a name="line.289"></a>
+<span class="sourceLineNo">290</span>            else<a name="line.290"></a>
+<span class="sourceLineNo">291</span>            {<a name="line.291"></a>
+<span class="sourceLineNo">292</span>                tokens.add(token);<a name="line.292"></a>
+<span class="sourceLineNo">293</span>                break;<a name="line.293"></a>
+<span class="sourceLineNo">294</span>            }<a name="line.294"></a>
+<span class="sourceLineNo">295</span>        }<a name="line.295"></a>
+<span class="sourceLineNo">296</span>    }<a name="line.296"></a>
+<span class="sourceLineNo">297</span>}<a name="line.297"></a>
 
 
 



Mime
View raw message