commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject svn commit: r934044 [16/18] - in /websites/production/commons/content/proper/commons-validator: ./ apidocs/ apidocs/org/apache/commons/validator/ apidocs/org/apache/commons/validator/routines/ apidocs/org/apache/commons/validator/routines/checkdigit/ a...
Date Fri, 26 Dec 2014 12:51:04 GMT
Modified: websites/production/commons/content/proper/commons-validator/xref/org/apache/commons/validator/UrlValidator.html
==============================================================================
--- websites/production/commons/content/proper/commons-validator/xref/org/apache/commons/validator/UrlValidator.html (original)
+++ websites/production/commons/content/proper/commons-validator/xref/org/apache/commons/validator/UrlValidator.html Fri Dec 26 12:51:02 2014
@@ -79,7 +79,7 @@
 <a class="jxr_linenumber" name="L71" href="#L71">71</a>  <em class="jxr_javadoccomment"> *  Uniform Resource Identifiers (URI): Generic Syntax</em>
 <a class="jxr_linenumber" name="L72" href="#L72">72</a>  <em class="jxr_javadoccomment"> * &lt;/a&gt;</em>
 <a class="jxr_linenumber" name="L73" href="#L73">73</a>  <em class="jxr_javadoccomment"> *</em>
-<a class="jxr_linenumber" name="L74" href="#L74">74</a>  <em class="jxr_javadoccomment"> * @version $Revision: 1647900 $ $Date: 2014-12-25 16:03:53 +0100 (Do, 25 Dez 2014) $</em>
+<a class="jxr_linenumber" name="L74" href="#L74">74</a>  <em class="jxr_javadoccomment"> * @version $Revision: 1647964 $ $Date: 2014-12-26 13:33:35 +0100 (Fr, 26 Dez 2014) $</em>
 <a class="jxr_linenumber" name="L75" href="#L75">75</a>  <em class="jxr_javadoccomment"> * @since Validator 1.1</em>
 <a class="jxr_linenumber" name="L76" href="#L76">76</a>  <em class="jxr_javadoccomment"> * @deprecated Use the new UrlValidator in the routines package. This class</em>
 <a class="jxr_linenumber" name="L77" href="#L77">77</a>  <em class="jxr_javadoccomment"> * will be removed in a future release.</em>
@@ -301,185 +301,178 @@
 <a class="jxr_linenumber" name="L293" href="#L293">293</a>             <strong class="jxr_keyword">return</strong> false;
 <a class="jxr_linenumber" name="L294" href="#L294">294</a>         }
 <a class="jxr_linenumber" name="L295" href="#L295">295</a> 
-<a class="jxr_linenumber" name="L296" href="#L296">296</a>         <strong class="jxr_keyword">if</strong> (<strong class="jxr_keyword">this</strong>.options.isOff(ALLOW_ALL_SCHEMES)) {
-<a class="jxr_linenumber" name="L297" href="#L297">297</a> 
-<a class="jxr_linenumber" name="L298" href="#L298">298</a>             <strong class="jxr_keyword">if</strong> (!<strong class="jxr_keyword">this</strong>.allowedSchemes.contains(scheme)) {
-<a class="jxr_linenumber" name="L299" href="#L299">299</a>                 <strong class="jxr_keyword">return</strong> false;
-<a class="jxr_linenumber" name="L300" href="#L300">300</a>             }
-<a class="jxr_linenumber" name="L301" href="#L301">301</a>         }
+<a class="jxr_linenumber" name="L296" href="#L296">296</a>         <strong class="jxr_keyword">if</strong> (options.isOff(ALLOW_ALL_SCHEMES) &amp;&amp; !allowedSchemes.contains(scheme)) {
+<a class="jxr_linenumber" name="L297" href="#L297">297</a>             <strong class="jxr_keyword">return</strong> false;
+<a class="jxr_linenumber" name="L298" href="#L298">298</a>         }
+<a class="jxr_linenumber" name="L299" href="#L299">299</a> 
+<a class="jxr_linenumber" name="L300" href="#L300">300</a>         <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>;
+<a class="jxr_linenumber" name="L301" href="#L301">301</a>     }
 <a class="jxr_linenumber" name="L302" href="#L302">302</a> 
-<a class="jxr_linenumber" name="L303" href="#L303">303</a>         <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>;
-<a class="jxr_linenumber" name="L304" href="#L304">304</a>     }
-<a class="jxr_linenumber" name="L305" href="#L305">305</a> 
-<a class="jxr_linenumber" name="L306" href="#L306">306</a>     <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="L307" href="#L307">307</a> <em class="jxr_javadoccomment">     * Returns true if the authority is properly formatted.  An authority is the combination</em>
-<a class="jxr_linenumber" name="L308" href="#L308">308</a> <em class="jxr_javadoccomment">     * of hostname and port.  A &lt;code&gt;null&lt;/code&gt; authority value is considered invalid.</em>
-<a class="jxr_linenumber" name="L309" href="#L309">309</a> <em class="jxr_javadoccomment">     * @param authority Authority value to validate.</em>
-<a class="jxr_linenumber" name="L310" href="#L310">310</a> <em class="jxr_javadoccomment">     * @return true if authority (hostname and port) is valid.</em>
-<a class="jxr_linenumber" name="L311" href="#L311">311</a> <em class="jxr_javadoccomment">     */</em>
-<a class="jxr_linenumber" name="L312" href="#L312">312</a>     <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">boolean</strong> isValidAuthority(String authority) {
-<a class="jxr_linenumber" name="L313" href="#L313">313</a>         <strong class="jxr_keyword">if</strong> (authority == <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="L314" href="#L314">314</a>             <strong class="jxr_keyword">return</strong> false;
-<a class="jxr_linenumber" name="L315" href="#L315">315</a>         }
+<a class="jxr_linenumber" name="L303" href="#L303">303</a>     <em class="jxr_javadoccomment">/**</em>
+<a class="jxr_linenumber" name="L304" href="#L304">304</a> <em class="jxr_javadoccomment">     * Returns true if the authority is properly formatted.  An authority is the combination</em>
+<a class="jxr_linenumber" name="L305" href="#L305">305</a> <em class="jxr_javadoccomment">     * of hostname and port.  A &lt;code&gt;null&lt;/code&gt; authority value is considered invalid.</em>
+<a class="jxr_linenumber" name="L306" href="#L306">306</a> <em class="jxr_javadoccomment">     * @param authority Authority value to validate.</em>
+<a class="jxr_linenumber" name="L307" href="#L307">307</a> <em class="jxr_javadoccomment">     * @return true if authority (hostname and port) is valid.</em>
+<a class="jxr_linenumber" name="L308" href="#L308">308</a> <em class="jxr_javadoccomment">     */</em>
+<a class="jxr_linenumber" name="L309" href="#L309">309</a>     <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">boolean</strong> isValidAuthority(String authority) {
+<a class="jxr_linenumber" name="L310" href="#L310">310</a>         <strong class="jxr_keyword">if</strong> (authority == <strong class="jxr_keyword">null</strong>) {
+<a class="jxr_linenumber" name="L311" href="#L311">311</a>             <strong class="jxr_keyword">return</strong> false;
+<a class="jxr_linenumber" name="L312" href="#L312">312</a>         }
+<a class="jxr_linenumber" name="L313" href="#L313">313</a> 
+<a class="jxr_linenumber" name="L314" href="#L314">314</a>         <a href="../../../../org/apache/commons/validator/routines/InetAddressValidator.html">InetAddressValidator</a> inetAddressValidator =
+<a class="jxr_linenumber" name="L315" href="#L315">315</a>                 InetAddressValidator.getInstance();
 <a class="jxr_linenumber" name="L316" href="#L316">316</a> 
-<a class="jxr_linenumber" name="L317" href="#L317">317</a>         <a href="../../../../org/apache/commons/validator/routines/InetAddressValidator.html">InetAddressValidator</a> inetAddressValidator =
-<a class="jxr_linenumber" name="L318" href="#L318">318</a>                 InetAddressValidator.getInstance();
-<a class="jxr_linenumber" name="L319" href="#L319">319</a> 
-<a class="jxr_linenumber" name="L320" href="#L320">320</a>         Matcher authorityMatcher = AUTHORITY_PATTERN.matcher(authority);
-<a class="jxr_linenumber" name="L321" href="#L321">321</a>         <strong class="jxr_keyword">if</strong> (!authorityMatcher.matches()) {
-<a class="jxr_linenumber" name="L322" href="#L322">322</a>             <strong class="jxr_keyword">return</strong> false;
-<a class="jxr_linenumber" name="L323" href="#L323">323</a>         }
-<a class="jxr_linenumber" name="L324" href="#L324">324</a> 
-<a class="jxr_linenumber" name="L325" href="#L325">325</a>         <strong class="jxr_keyword">boolean</strong> hostname = false;
-<a class="jxr_linenumber" name="L326" href="#L326">326</a>         <em class="jxr_comment">// check if authority is IP address or hostname</em>
-<a class="jxr_linenumber" name="L327" href="#L327">327</a>         String hostIP = authorityMatcher.group(PARSE_AUTHORITY_HOST_IP);
-<a class="jxr_linenumber" name="L328" href="#L328">328</a>         <strong class="jxr_keyword">boolean</strong> ipV4Address = inetAddressValidator.isValid(hostIP);
-<a class="jxr_linenumber" name="L329" href="#L329">329</a> 
-<a class="jxr_linenumber" name="L330" href="#L330">330</a>         <strong class="jxr_keyword">if</strong> (!ipV4Address) {
-<a class="jxr_linenumber" name="L331" href="#L331">331</a>             <em class="jxr_comment">// Domain is hostname name</em>
-<a class="jxr_linenumber" name="L332" href="#L332">332</a>             hostname = DOMAIN_PATTERN.matcher(hostIP).matches();
-<a class="jxr_linenumber" name="L333" href="#L333">333</a>         }
-<a class="jxr_linenumber" name="L334" href="#L334">334</a> 
-<a class="jxr_linenumber" name="L335" href="#L335">335</a>         <em class="jxr_comment">//rightmost hostname will never start with a digit.</em>
-<a class="jxr_linenumber" name="L336" href="#L336">336</a>         <strong class="jxr_keyword">if</strong> (hostname) {
-<a class="jxr_linenumber" name="L337" href="#L337">337</a>             <em class="jxr_comment">// LOW-TECH FIX FOR VALIDATOR-202</em>
-<a class="jxr_linenumber" name="L338" href="#L338">338</a>             <em class="jxr_comment">// TODO: Rewrite to use ArrayList and .add semantics: see VALIDATOR-203</em>
-<a class="jxr_linenumber" name="L339" href="#L339">339</a>             <strong class="jxr_keyword">char</strong>[] chars = hostIP.toCharArray();
-<a class="jxr_linenumber" name="L340" href="#L340">340</a>             <strong class="jxr_keyword">int</strong> size = 1;
-<a class="jxr_linenumber" name="L341" href="#L341">341</a>             <strong class="jxr_keyword">for</strong>(<strong class="jxr_keyword">int</strong> i=0; i&lt;chars.length; i++) {
-<a class="jxr_linenumber" name="L342" href="#L342">342</a>                 <strong class="jxr_keyword">if</strong>(chars[i] == '.') {
-<a class="jxr_linenumber" name="L343" href="#L343">343</a>                     size++;
-<a class="jxr_linenumber" name="L344" href="#L344">344</a>                 }
-<a class="jxr_linenumber" name="L345" href="#L345">345</a>             }
-<a class="jxr_linenumber" name="L346" href="#L346">346</a>             String[] domainSegment = <strong class="jxr_keyword">new</strong> String[size];
-<a class="jxr_linenumber" name="L347" href="#L347">347</a>             <strong class="jxr_keyword">boolean</strong> match = <strong class="jxr_keyword">true</strong>;
-<a class="jxr_linenumber" name="L348" href="#L348">348</a>             <strong class="jxr_keyword">int</strong> segmentCount = 0;
-<a class="jxr_linenumber" name="L349" href="#L349">349</a>             <strong class="jxr_keyword">int</strong> segmentLength = 0;
-<a class="jxr_linenumber" name="L350" href="#L350">350</a> 
-<a class="jxr_linenumber" name="L351" href="#L351">351</a>             <strong class="jxr_keyword">while</strong> (match) {
-<a class="jxr_linenumber" name="L352" href="#L352">352</a>                 Matcher atomMatcher = ATOM_PATTERN.matcher(hostIP);
-<a class="jxr_linenumber" name="L353" href="#L353">353</a>                 match = atomMatcher.matches();
-<a class="jxr_linenumber" name="L354" href="#L354">354</a>                 <strong class="jxr_keyword">if</strong> (match) {
-<a class="jxr_linenumber" name="L355" href="#L355">355</a>                     domainSegment[segmentCount] = atomMatcher.group(1);
-<a class="jxr_linenumber" name="L356" href="#L356">356</a>                     segmentLength = domainSegment[segmentCount].length() + 1;
-<a class="jxr_linenumber" name="L357" href="#L357">357</a>                     hostIP =
-<a class="jxr_linenumber" name="L358" href="#L358">358</a>                             (segmentLength &gt;= hostIP.length())
-<a class="jxr_linenumber" name="L359" href="#L359">359</a>                             ? <span class="jxr_string">""</span>
-<a class="jxr_linenumber" name="L360" href="#L360">360</a>                             : hostIP.substring(segmentLength);
-<a class="jxr_linenumber" name="L361" href="#L361">361</a> 
-<a class="jxr_linenumber" name="L362" href="#L362">362</a>                     segmentCount++;
-<a class="jxr_linenumber" name="L363" href="#L363">363</a>                 }
-<a class="jxr_linenumber" name="L364" href="#L364">364</a>             }
-<a class="jxr_linenumber" name="L365" href="#L365">365</a>             String topLevel = domainSegment[segmentCount - 1];
-<a class="jxr_linenumber" name="L366" href="#L366">366</a>             <strong class="jxr_keyword">if</strong> (topLevel.length() &lt; 2 || topLevel.length() &gt; 4) {
-<a class="jxr_linenumber" name="L367" href="#L367">367</a>                 <strong class="jxr_keyword">return</strong> false;
-<a class="jxr_linenumber" name="L368" href="#L368">368</a>             }
-<a class="jxr_linenumber" name="L369" href="#L369">369</a> 
-<a class="jxr_linenumber" name="L370" href="#L370">370</a>             <em class="jxr_comment">// First letter of top level must be a alpha</em>
-<a class="jxr_linenumber" name="L371" href="#L371">371</a>             <strong class="jxr_keyword">if</strong> (!ALPHA_PATTERN.matcher(topLevel.substring(0, 1)).matches()) {
-<a class="jxr_linenumber" name="L372" href="#L372">372</a>                 <strong class="jxr_keyword">return</strong> false;
-<a class="jxr_linenumber" name="L373" href="#L373">373</a>             }
-<a class="jxr_linenumber" name="L374" href="#L374">374</a> 
-<a class="jxr_linenumber" name="L375" href="#L375">375</a>             <em class="jxr_comment">// Make sure there's a host name preceding the authority.</em>
-<a class="jxr_linenumber" name="L376" href="#L376">376</a>             <strong class="jxr_keyword">if</strong> (segmentCount &lt; 2) {
-<a class="jxr_linenumber" name="L377" href="#L377">377</a>                 <strong class="jxr_keyword">return</strong> false;
-<a class="jxr_linenumber" name="L378" href="#L378">378</a>             }
-<a class="jxr_linenumber" name="L379" href="#L379">379</a>         }
-<a class="jxr_linenumber" name="L380" href="#L380">380</a> 
-<a class="jxr_linenumber" name="L381" href="#L381">381</a>         <strong class="jxr_keyword">if</strong> (!hostname &amp;&amp; !ipV4Address) {
-<a class="jxr_linenumber" name="L382" href="#L382">382</a>             <strong class="jxr_keyword">return</strong> false;
-<a class="jxr_linenumber" name="L383" href="#L383">383</a>         }
-<a class="jxr_linenumber" name="L384" href="#L384">384</a> 
-<a class="jxr_linenumber" name="L385" href="#L385">385</a>         String port = authorityMatcher.group(PARSE_AUTHORITY_PORT);
-<a class="jxr_linenumber" name="L386" href="#L386">386</a>         <strong class="jxr_keyword">if</strong> (port != <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="L387" href="#L387">387</a>             <strong class="jxr_keyword">if</strong> (!PORT_PATTERN.matcher(port).matches()) {
-<a class="jxr_linenumber" name="L388" href="#L388">388</a>                 <strong class="jxr_keyword">return</strong> false;
-<a class="jxr_linenumber" name="L389" href="#L389">389</a>             }
+<a class="jxr_linenumber" name="L317" href="#L317">317</a>         Matcher authorityMatcher = AUTHORITY_PATTERN.matcher(authority);
+<a class="jxr_linenumber" name="L318" href="#L318">318</a>         <strong class="jxr_keyword">if</strong> (!authorityMatcher.matches()) {
+<a class="jxr_linenumber" name="L319" href="#L319">319</a>             <strong class="jxr_keyword">return</strong> false;
+<a class="jxr_linenumber" name="L320" href="#L320">320</a>         }
+<a class="jxr_linenumber" name="L321" href="#L321">321</a> 
+<a class="jxr_linenumber" name="L322" href="#L322">322</a>         <strong class="jxr_keyword">boolean</strong> hostname = false;
+<a class="jxr_linenumber" name="L323" href="#L323">323</a>         <em class="jxr_comment">// check if authority is IP address or hostname</em>
+<a class="jxr_linenumber" name="L324" href="#L324">324</a>         String hostIP = authorityMatcher.group(PARSE_AUTHORITY_HOST_IP);
+<a class="jxr_linenumber" name="L325" href="#L325">325</a>         <strong class="jxr_keyword">boolean</strong> ipV4Address = inetAddressValidator.isValid(hostIP);
+<a class="jxr_linenumber" name="L326" href="#L326">326</a> 
+<a class="jxr_linenumber" name="L327" href="#L327">327</a>         <strong class="jxr_keyword">if</strong> (!ipV4Address) {
+<a class="jxr_linenumber" name="L328" href="#L328">328</a>             <em class="jxr_comment">// Domain is hostname name</em>
+<a class="jxr_linenumber" name="L329" href="#L329">329</a>             hostname = DOMAIN_PATTERN.matcher(hostIP).matches();
+<a class="jxr_linenumber" name="L330" href="#L330">330</a>         }
+<a class="jxr_linenumber" name="L331" href="#L331">331</a> 
+<a class="jxr_linenumber" name="L332" href="#L332">332</a>         <em class="jxr_comment">//rightmost hostname will never start with a digit.</em>
+<a class="jxr_linenumber" name="L333" href="#L333">333</a>         <strong class="jxr_keyword">if</strong> (hostname) {
+<a class="jxr_linenumber" name="L334" href="#L334">334</a>             <em class="jxr_comment">// LOW-TECH FIX FOR VALIDATOR-202</em>
+<a class="jxr_linenumber" name="L335" href="#L335">335</a>             <em class="jxr_comment">// TODO: Rewrite to use ArrayList and .add semantics: see VALIDATOR-203</em>
+<a class="jxr_linenumber" name="L336" href="#L336">336</a>             <strong class="jxr_keyword">char</strong>[] chars = hostIP.toCharArray();
+<a class="jxr_linenumber" name="L337" href="#L337">337</a>             <strong class="jxr_keyword">int</strong> size = 1;
+<a class="jxr_linenumber" name="L338" href="#L338">338</a>             <strong class="jxr_keyword">for</strong>(<strong class="jxr_keyword">int</strong> i=0; i&lt;chars.length; i++) {
+<a class="jxr_linenumber" name="L339" href="#L339">339</a>                 <strong class="jxr_keyword">if</strong>(chars[i] == '.') {
+<a class="jxr_linenumber" name="L340" href="#L340">340</a>                     size++;
+<a class="jxr_linenumber" name="L341" href="#L341">341</a>                 }
+<a class="jxr_linenumber" name="L342" href="#L342">342</a>             }
+<a class="jxr_linenumber" name="L343" href="#L343">343</a>             String[] domainSegment = <strong class="jxr_keyword">new</strong> String[size];
+<a class="jxr_linenumber" name="L344" href="#L344">344</a>             <strong class="jxr_keyword">boolean</strong> match = <strong class="jxr_keyword">true</strong>;
+<a class="jxr_linenumber" name="L345" href="#L345">345</a>             <strong class="jxr_keyword">int</strong> segmentCount = 0;
+<a class="jxr_linenumber" name="L346" href="#L346">346</a>             <strong class="jxr_keyword">int</strong> segmentLength = 0;
+<a class="jxr_linenumber" name="L347" href="#L347">347</a> 
+<a class="jxr_linenumber" name="L348" href="#L348">348</a>             <strong class="jxr_keyword">while</strong> (match) {
+<a class="jxr_linenumber" name="L349" href="#L349">349</a>                 Matcher atomMatcher = ATOM_PATTERN.matcher(hostIP);
+<a class="jxr_linenumber" name="L350" href="#L350">350</a>                 match = atomMatcher.matches();
+<a class="jxr_linenumber" name="L351" href="#L351">351</a>                 <strong class="jxr_keyword">if</strong> (match) {
+<a class="jxr_linenumber" name="L352" href="#L352">352</a>                     domainSegment[segmentCount] = atomMatcher.group(1);
+<a class="jxr_linenumber" name="L353" href="#L353">353</a>                     segmentLength = domainSegment[segmentCount].length() + 1;
+<a class="jxr_linenumber" name="L354" href="#L354">354</a>                     hostIP =
+<a class="jxr_linenumber" name="L355" href="#L355">355</a>                             (segmentLength &gt;= hostIP.length())
+<a class="jxr_linenumber" name="L356" href="#L356">356</a>                             ? <span class="jxr_string">""</span>
+<a class="jxr_linenumber" name="L357" href="#L357">357</a>                             : hostIP.substring(segmentLength);
+<a class="jxr_linenumber" name="L358" href="#L358">358</a> 
+<a class="jxr_linenumber" name="L359" href="#L359">359</a>                     segmentCount++;
+<a class="jxr_linenumber" name="L360" href="#L360">360</a>                 }
+<a class="jxr_linenumber" name="L361" href="#L361">361</a>             }
+<a class="jxr_linenumber" name="L362" href="#L362">362</a>             String topLevel = domainSegment[segmentCount - 1];
+<a class="jxr_linenumber" name="L363" href="#L363">363</a>             <strong class="jxr_keyword">if</strong> (topLevel.length() &lt; 2 || topLevel.length() &gt; 4) {
+<a class="jxr_linenumber" name="L364" href="#L364">364</a>                 <strong class="jxr_keyword">return</strong> false;
+<a class="jxr_linenumber" name="L365" href="#L365">365</a>             }
+<a class="jxr_linenumber" name="L366" href="#L366">366</a> 
+<a class="jxr_linenumber" name="L367" href="#L367">367</a>             <em class="jxr_comment">// First letter of top level must be a alpha</em>
+<a class="jxr_linenumber" name="L368" href="#L368">368</a>             <strong class="jxr_keyword">if</strong> (!ALPHA_PATTERN.matcher(topLevel.substring(0, 1)).matches()) {
+<a class="jxr_linenumber" name="L369" href="#L369">369</a>                 <strong class="jxr_keyword">return</strong> false;
+<a class="jxr_linenumber" name="L370" href="#L370">370</a>             }
+<a class="jxr_linenumber" name="L371" href="#L371">371</a> 
+<a class="jxr_linenumber" name="L372" href="#L372">372</a>             <em class="jxr_comment">// Make sure there's a host name preceding the authority.</em>
+<a class="jxr_linenumber" name="L373" href="#L373">373</a>             <strong class="jxr_keyword">if</strong> (segmentCount &lt; 2) {
+<a class="jxr_linenumber" name="L374" href="#L374">374</a>                 <strong class="jxr_keyword">return</strong> false;
+<a class="jxr_linenumber" name="L375" href="#L375">375</a>             }
+<a class="jxr_linenumber" name="L376" href="#L376">376</a>         }
+<a class="jxr_linenumber" name="L377" href="#L377">377</a> 
+<a class="jxr_linenumber" name="L378" href="#L378">378</a>         <strong class="jxr_keyword">if</strong> (!hostname &amp;&amp; !ipV4Address) {
+<a class="jxr_linenumber" name="L379" href="#L379">379</a>             <strong class="jxr_keyword">return</strong> false;
+<a class="jxr_linenumber" name="L380" href="#L380">380</a>         }
+<a class="jxr_linenumber" name="L381" href="#L381">381</a> 
+<a class="jxr_linenumber" name="L382" href="#L382">382</a>         String port = authorityMatcher.group(PARSE_AUTHORITY_PORT);
+<a class="jxr_linenumber" name="L383" href="#L383">383</a>         <strong class="jxr_keyword">if</strong> (port != <strong class="jxr_keyword">null</strong> &amp;&amp; !PORT_PATTERN.matcher(port).matches()) {
+<a class="jxr_linenumber" name="L384" href="#L384">384</a>             <strong class="jxr_keyword">return</strong> false;
+<a class="jxr_linenumber" name="L385" href="#L385">385</a>         }
+<a class="jxr_linenumber" name="L386" href="#L386">386</a> 
+<a class="jxr_linenumber" name="L387" href="#L387">387</a>         String extra = authorityMatcher.group(PARSE_AUTHORITY_EXTRA);
+<a class="jxr_linenumber" name="L388" href="#L388">388</a>         <strong class="jxr_keyword">if</strong> (!GenericValidator.isBlankOrNull(extra)) {
+<a class="jxr_linenumber" name="L389" href="#L389">389</a>             <strong class="jxr_keyword">return</strong> false;
 <a class="jxr_linenumber" name="L390" href="#L390">390</a>         }
 <a class="jxr_linenumber" name="L391" href="#L391">391</a> 
-<a class="jxr_linenumber" name="L392" href="#L392">392</a>         String extra = authorityMatcher.group(PARSE_AUTHORITY_EXTRA);
-<a class="jxr_linenumber" name="L393" href="#L393">393</a>         <strong class="jxr_keyword">if</strong> (!GenericValidator.isBlankOrNull(extra)) {
-<a class="jxr_linenumber" name="L394" href="#L394">394</a>             <strong class="jxr_keyword">return</strong> false;
-<a class="jxr_linenumber" name="L395" href="#L395">395</a>         }
-<a class="jxr_linenumber" name="L396" href="#L396">396</a> 
-<a class="jxr_linenumber" name="L397" href="#L397">397</a>         <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>;
-<a class="jxr_linenumber" name="L398" href="#L398">398</a>     }
-<a class="jxr_linenumber" name="L399" href="#L399">399</a> 
-<a class="jxr_linenumber" name="L400" href="#L400">400</a>     <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="L401" href="#L401">401</a> <em class="jxr_javadoccomment">     * Returns true if the path is valid.  A &lt;code&gt;null&lt;/code&gt; value is considered invalid.</em>
-<a class="jxr_linenumber" name="L402" href="#L402">402</a> <em class="jxr_javadoccomment">     * @param path Path value to validate.</em>
-<a class="jxr_linenumber" name="L403" href="#L403">403</a> <em class="jxr_javadoccomment">     * @return true if path is valid.</em>
-<a class="jxr_linenumber" name="L404" href="#L404">404</a> <em class="jxr_javadoccomment">     */</em>
-<a class="jxr_linenumber" name="L405" href="#L405">405</a>     <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">boolean</strong> isValidPath(String path) {
-<a class="jxr_linenumber" name="L406" href="#L406">406</a>         <strong class="jxr_keyword">if</strong> (path == <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="L407" href="#L407">407</a>             <strong class="jxr_keyword">return</strong> false;
-<a class="jxr_linenumber" name="L408" href="#L408">408</a>         }
-<a class="jxr_linenumber" name="L409" href="#L409">409</a> 
-<a class="jxr_linenumber" name="L410" href="#L410">410</a>         <strong class="jxr_keyword">if</strong> (!PATH_PATTERN.matcher(path).matches()) {
+<a class="jxr_linenumber" name="L392" href="#L392">392</a>         <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>;
+<a class="jxr_linenumber" name="L393" href="#L393">393</a>     }
+<a class="jxr_linenumber" name="L394" href="#L394">394</a> 
+<a class="jxr_linenumber" name="L395" href="#L395">395</a>     <em class="jxr_javadoccomment">/**</em>
+<a class="jxr_linenumber" name="L396" href="#L396">396</a> <em class="jxr_javadoccomment">     * Returns true if the path is valid.  A &lt;code&gt;null&lt;/code&gt; value is considered invalid.</em>
+<a class="jxr_linenumber" name="L397" href="#L397">397</a> <em class="jxr_javadoccomment">     * @param path Path value to validate.</em>
+<a class="jxr_linenumber" name="L398" href="#L398">398</a> <em class="jxr_javadoccomment">     * @return true if path is valid.</em>
+<a class="jxr_linenumber" name="L399" href="#L399">399</a> <em class="jxr_javadoccomment">     */</em>
+<a class="jxr_linenumber" name="L400" href="#L400">400</a>     <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">boolean</strong> isValidPath(String path) {
+<a class="jxr_linenumber" name="L401" href="#L401">401</a>         <strong class="jxr_keyword">if</strong> (path == <strong class="jxr_keyword">null</strong>) {
+<a class="jxr_linenumber" name="L402" href="#L402">402</a>             <strong class="jxr_keyword">return</strong> false;
+<a class="jxr_linenumber" name="L403" href="#L403">403</a>         }
+<a class="jxr_linenumber" name="L404" href="#L404">404</a> 
+<a class="jxr_linenumber" name="L405" href="#L405">405</a>         <strong class="jxr_keyword">if</strong> (!PATH_PATTERN.matcher(path).matches()) {
+<a class="jxr_linenumber" name="L406" href="#L406">406</a>             <strong class="jxr_keyword">return</strong> false;
+<a class="jxr_linenumber" name="L407" href="#L407">407</a>         }
+<a class="jxr_linenumber" name="L408" href="#L408">408</a> 
+<a class="jxr_linenumber" name="L409" href="#L409">409</a>         <strong class="jxr_keyword">int</strong> slash2Count = countToken(<span class="jxr_string">"//"</span>, path);
+<a class="jxr_linenumber" name="L410" href="#L410">410</a>         <strong class="jxr_keyword">if</strong> (options.isOff(ALLOW_2_SLASHES) &amp;&amp; (slash2Count &gt; 0)) {
 <a class="jxr_linenumber" name="L411" href="#L411">411</a>             <strong class="jxr_keyword">return</strong> false;
 <a class="jxr_linenumber" name="L412" href="#L412">412</a>         }
 <a class="jxr_linenumber" name="L413" href="#L413">413</a> 
-<a class="jxr_linenumber" name="L414" href="#L414">414</a>         <strong class="jxr_keyword">int</strong> slash2Count = countToken(<span class="jxr_string">"//"</span>, path);
-<a class="jxr_linenumber" name="L415" href="#L415">415</a>         <strong class="jxr_keyword">if</strong> (<strong class="jxr_keyword">this</strong>.options.isOff(ALLOW_2_SLASHES) &amp;&amp; (slash2Count &gt; 0)) {
-<a class="jxr_linenumber" name="L416" href="#L416">416</a>             <strong class="jxr_keyword">return</strong> false;
-<a class="jxr_linenumber" name="L417" href="#L417">417</a>         }
-<a class="jxr_linenumber" name="L418" href="#L418">418</a> 
-<a class="jxr_linenumber" name="L419" href="#L419">419</a>         <strong class="jxr_keyword">int</strong> slashCount = countToken(<span class="jxr_string">"/"</span>, path);
-<a class="jxr_linenumber" name="L420" href="#L420">420</a>         <strong class="jxr_keyword">int</strong> dot2Count = countToken(<span class="jxr_string">".."</span>, path);
-<a class="jxr_linenumber" name="L421" href="#L421">421</a>         <strong class="jxr_keyword">if</strong> (dot2Count &gt; 0) {
-<a class="jxr_linenumber" name="L422" href="#L422">422</a>             <strong class="jxr_keyword">if</strong> ((slashCount - slash2Count - 1) &lt;= dot2Count) {
-<a class="jxr_linenumber" name="L423" href="#L423">423</a>                 <strong class="jxr_keyword">return</strong> false;
-<a class="jxr_linenumber" name="L424" href="#L424">424</a>             }
-<a class="jxr_linenumber" name="L425" href="#L425">425</a>         }
-<a class="jxr_linenumber" name="L426" href="#L426">426</a> 
-<a class="jxr_linenumber" name="L427" href="#L427">427</a>         <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>;
-<a class="jxr_linenumber" name="L428" href="#L428">428</a>     }
-<a class="jxr_linenumber" name="L429" href="#L429">429</a> 
-<a class="jxr_linenumber" name="L430" href="#L430">430</a>     <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="L431" href="#L431">431</a> <em class="jxr_javadoccomment">     * Returns true if the query is null or it's a properly formatted query string.</em>
-<a class="jxr_linenumber" name="L432" href="#L432">432</a> <em class="jxr_javadoccomment">     * @param query Query value to validate.</em>
-<a class="jxr_linenumber" name="L433" href="#L433">433</a> <em class="jxr_javadoccomment">     * @return true if query is valid.</em>
-<a class="jxr_linenumber" name="L434" href="#L434">434</a> <em class="jxr_javadoccomment">     */</em>
-<a class="jxr_linenumber" name="L435" href="#L435">435</a>     <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">boolean</strong> isValidQuery(String query) {
-<a class="jxr_linenumber" name="L436" href="#L436">436</a>         <strong class="jxr_keyword">if</strong> (query == <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="L437" href="#L437">437</a>             <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>;
-<a class="jxr_linenumber" name="L438" href="#L438">438</a>         }
-<a class="jxr_linenumber" name="L439" href="#L439">439</a> 
-<a class="jxr_linenumber" name="L440" href="#L440">440</a>         <strong class="jxr_keyword">return</strong> QUERY_PATTERN.matcher(query).matches();
-<a class="jxr_linenumber" name="L441" href="#L441">441</a>     }
-<a class="jxr_linenumber" name="L442" href="#L442">442</a> 
-<a class="jxr_linenumber" name="L443" href="#L443">443</a>     <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="L444" href="#L444">444</a> <em class="jxr_javadoccomment">     * Returns true if the given fragment is null or fragments are allowed.</em>
-<a class="jxr_linenumber" name="L445" href="#L445">445</a> <em class="jxr_javadoccomment">     * @param fragment Fragment value to validate.</em>
-<a class="jxr_linenumber" name="L446" href="#L446">446</a> <em class="jxr_javadoccomment">     * @return true if fragment is valid.</em>
-<a class="jxr_linenumber" name="L447" href="#L447">447</a> <em class="jxr_javadoccomment">     */</em>
-<a class="jxr_linenumber" name="L448" href="#L448">448</a>     <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">boolean</strong> isValidFragment(String fragment) {
-<a class="jxr_linenumber" name="L449" href="#L449">449</a>         <strong class="jxr_keyword">if</strong> (fragment == <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="L450" href="#L450">450</a>             <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>;
-<a class="jxr_linenumber" name="L451" href="#L451">451</a>         }
-<a class="jxr_linenumber" name="L452" href="#L452">452</a> 
-<a class="jxr_linenumber" name="L453" href="#L453">453</a>         <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>.options.isOff(NO_FRAGMENTS);
-<a class="jxr_linenumber" name="L454" href="#L454">454</a>     }
-<a class="jxr_linenumber" name="L455" href="#L455">455</a> 
-<a class="jxr_linenumber" name="L456" href="#L456">456</a>     <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="L457" href="#L457">457</a> <em class="jxr_javadoccomment">     * Returns the number of times the token appears in the target.</em>
-<a class="jxr_linenumber" name="L458" href="#L458">458</a> <em class="jxr_javadoccomment">     * @param token Token value to be counted.</em>
-<a class="jxr_linenumber" name="L459" href="#L459">459</a> <em class="jxr_javadoccomment">     * @param target Target value to count tokens in.</em>
-<a class="jxr_linenumber" name="L460" href="#L460">460</a> <em class="jxr_javadoccomment">     * @return the number of tokens.</em>
-<a class="jxr_linenumber" name="L461" href="#L461">461</a> <em class="jxr_javadoccomment">     */</em>
-<a class="jxr_linenumber" name="L462" href="#L462">462</a>     <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">int</strong> countToken(String token, String target) {
-<a class="jxr_linenumber" name="L463" href="#L463">463</a>         <strong class="jxr_keyword">int</strong> tokenIndex = 0;
-<a class="jxr_linenumber" name="L464" href="#L464">464</a>         <strong class="jxr_keyword">int</strong> count = 0;
-<a class="jxr_linenumber" name="L465" href="#L465">465</a>         <strong class="jxr_keyword">while</strong> (tokenIndex != -1) {
-<a class="jxr_linenumber" name="L466" href="#L466">466</a>             tokenIndex = target.indexOf(token, tokenIndex);
-<a class="jxr_linenumber" name="L467" href="#L467">467</a>             <strong class="jxr_keyword">if</strong> (tokenIndex &gt; -1) {
-<a class="jxr_linenumber" name="L468" href="#L468">468</a>                 tokenIndex++;
-<a class="jxr_linenumber" name="L469" href="#L469">469</a>                 count++;
-<a class="jxr_linenumber" name="L470" href="#L470">470</a>             }
-<a class="jxr_linenumber" name="L471" href="#L471">471</a>         }
-<a class="jxr_linenumber" name="L472" href="#L472">472</a>         <strong class="jxr_keyword">return</strong> count;
-<a class="jxr_linenumber" name="L473" href="#L473">473</a>     }
-<a class="jxr_linenumber" name="L474" href="#L474">474</a> }
+<a class="jxr_linenumber" name="L414" href="#L414">414</a>         <strong class="jxr_keyword">int</strong> slashCount = countToken(<span class="jxr_string">"/"</span>, path);
+<a class="jxr_linenumber" name="L415" href="#L415">415</a>         <strong class="jxr_keyword">int</strong> dot2Count = countToken(<span class="jxr_string">".."</span>, path);
+<a class="jxr_linenumber" name="L416" href="#L416">416</a>         <strong class="jxr_keyword">if</strong> (dot2Count &gt; 0 &amp;&amp; (slashCount - slash2Count - 1) &lt;= dot2Count){
+<a class="jxr_linenumber" name="L417" href="#L417">417</a>             <strong class="jxr_keyword">return</strong> false;
+<a class="jxr_linenumber" name="L418" href="#L418">418</a>         }
+<a class="jxr_linenumber" name="L419" href="#L419">419</a> 
+<a class="jxr_linenumber" name="L420" href="#L420">420</a>         <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>;
+<a class="jxr_linenumber" name="L421" href="#L421">421</a>     }
+<a class="jxr_linenumber" name="L422" href="#L422">422</a> 
+<a class="jxr_linenumber" name="L423" href="#L423">423</a>     <em class="jxr_javadoccomment">/**</em>
+<a class="jxr_linenumber" name="L424" href="#L424">424</a> <em class="jxr_javadoccomment">     * Returns true if the query is null or it's a properly formatted query string.</em>
+<a class="jxr_linenumber" name="L425" href="#L425">425</a> <em class="jxr_javadoccomment">     * @param query Query value to validate.</em>
+<a class="jxr_linenumber" name="L426" href="#L426">426</a> <em class="jxr_javadoccomment">     * @return true if query is valid.</em>
+<a class="jxr_linenumber" name="L427" href="#L427">427</a> <em class="jxr_javadoccomment">     */</em>
+<a class="jxr_linenumber" name="L428" href="#L428">428</a>     <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">boolean</strong> isValidQuery(String query) {
+<a class="jxr_linenumber" name="L429" href="#L429">429</a>         <strong class="jxr_keyword">if</strong> (query == <strong class="jxr_keyword">null</strong>) {
+<a class="jxr_linenumber" name="L430" href="#L430">430</a>             <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>;
+<a class="jxr_linenumber" name="L431" href="#L431">431</a>         }
+<a class="jxr_linenumber" name="L432" href="#L432">432</a> 
+<a class="jxr_linenumber" name="L433" href="#L433">433</a>         <strong class="jxr_keyword">return</strong> QUERY_PATTERN.matcher(query).matches();
+<a class="jxr_linenumber" name="L434" href="#L434">434</a>     }
+<a class="jxr_linenumber" name="L435" href="#L435">435</a> 
+<a class="jxr_linenumber" name="L436" href="#L436">436</a>     <em class="jxr_javadoccomment">/**</em>
+<a class="jxr_linenumber" name="L437" href="#L437">437</a> <em class="jxr_javadoccomment">     * Returns true if the given fragment is null or fragments are allowed.</em>
+<a class="jxr_linenumber" name="L438" href="#L438">438</a> <em class="jxr_javadoccomment">     * @param fragment Fragment value to validate.</em>
+<a class="jxr_linenumber" name="L439" href="#L439">439</a> <em class="jxr_javadoccomment">     * @return true if fragment is valid.</em>
+<a class="jxr_linenumber" name="L440" href="#L440">440</a> <em class="jxr_javadoccomment">     */</em>
+<a class="jxr_linenumber" name="L441" href="#L441">441</a>     <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">boolean</strong> isValidFragment(String fragment) {
+<a class="jxr_linenumber" name="L442" href="#L442">442</a>         <strong class="jxr_keyword">if</strong> (fragment == <strong class="jxr_keyword">null</strong>) {
+<a class="jxr_linenumber" name="L443" href="#L443">443</a>             <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>;
+<a class="jxr_linenumber" name="L444" href="#L444">444</a>         }
+<a class="jxr_linenumber" name="L445" href="#L445">445</a> 
+<a class="jxr_linenumber" name="L446" href="#L446">446</a>         <strong class="jxr_keyword">return</strong> options.isOff(NO_FRAGMENTS);
+<a class="jxr_linenumber" name="L447" href="#L447">447</a>     }
+<a class="jxr_linenumber" name="L448" href="#L448">448</a> 
+<a class="jxr_linenumber" name="L449" href="#L449">449</a>     <em class="jxr_javadoccomment">/**</em>
+<a class="jxr_linenumber" name="L450" href="#L450">450</a> <em class="jxr_javadoccomment">     * Returns the number of times the token appears in the target.</em>
+<a class="jxr_linenumber" name="L451" href="#L451">451</a> <em class="jxr_javadoccomment">     * @param token Token value to be counted.</em>
+<a class="jxr_linenumber" name="L452" href="#L452">452</a> <em class="jxr_javadoccomment">     * @param target Target value to count tokens in.</em>
+<a class="jxr_linenumber" name="L453" href="#L453">453</a> <em class="jxr_javadoccomment">     * @return the number of tokens.</em>
+<a class="jxr_linenumber" name="L454" href="#L454">454</a> <em class="jxr_javadoccomment">     */</em>
+<a class="jxr_linenumber" name="L455" href="#L455">455</a>     <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">int</strong> countToken(String token, String target) {
+<a class="jxr_linenumber" name="L456" href="#L456">456</a>         <strong class="jxr_keyword">int</strong> tokenIndex = 0;
+<a class="jxr_linenumber" name="L457" href="#L457">457</a>         <strong class="jxr_keyword">int</strong> count = 0;
+<a class="jxr_linenumber" name="L458" href="#L458">458</a>         <strong class="jxr_keyword">while</strong> (tokenIndex != -1) {
+<a class="jxr_linenumber" name="L459" href="#L459">459</a>             tokenIndex = target.indexOf(token, tokenIndex);
+<a class="jxr_linenumber" name="L460" href="#L460">460</a>             <strong class="jxr_keyword">if</strong> (tokenIndex &gt; -1) {
+<a class="jxr_linenumber" name="L461" href="#L461">461</a>                 tokenIndex++;
+<a class="jxr_linenumber" name="L462" href="#L462">462</a>                 count++;
+<a class="jxr_linenumber" name="L463" href="#L463">463</a>             }
+<a class="jxr_linenumber" name="L464" href="#L464">464</a>         }
+<a class="jxr_linenumber" name="L465" href="#L465">465</a>         <strong class="jxr_keyword">return</strong> count;
+<a class="jxr_linenumber" name="L466" href="#L466">466</a>     }
+<a class="jxr_linenumber" name="L467" href="#L467">467</a> }
 </pre>
 <hr/>
 <div id="footer">Copyright &#169; 2002&#x2013;2014 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</div>



Mime
View raw message