View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.vfs2.util;
18  
19  import java.util.BitSet;
20  
21  import org.apache.commons.vfs2.provider.GenericURLFileName;
22  
23  /**
24   * Internal URI encoding {@link BitSet} definitions.
25   * <P>
26   * This was forked from the {@link BitSet}s in {@code org.apache.commons.httpclient.URI},
27   * in order to not be dependent on HttpClient v3 API, when generating and handling {@link GenericURLFileName}s,
28   * but it should work with any different HTTP backend provider implementations.
29   * </p>
30   */
31  class URIBitSets {
32  
33      // ---------------------- Generous characters for each component validation
34  
35      /**
36       * The percent "%" character always has the reserved purpose of being the
37       * escape indicator, it must be escaped as "%25" in order to be used as
38       * data within a URI.
39       */
40      protected static final BitSet percent = new BitSet(256);
41      // Static initializer for percent
42      static {
43          percent.set('%');
44      }
45  
46  
47      /**
48       * BitSet for digit.
49       * <p><blockquote><pre>
50       * digit    = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" |
51       *            "8" | "9"
52       * </pre></blockquote></p>
53       */
54      protected static final BitSet digit = new BitSet(256);
55      // Static initializer for digit
56      static {
57          for (int i = '0'; i <= '9'; i++) {
58              digit.set(i);
59          }
60      }
61  
62  
63      /**
64       * BitSet for alpha.
65       * <p><blockquote><pre>
66       * alpha         = lowalpha | upalpha
67       * </pre></blockquote></p>
68       */
69      protected static final BitSet alpha = new BitSet(256);
70      // Static initializer for alpha
71      static {
72          for (int i = 'a'; i <= 'z'; i++) {
73              alpha.set(i);
74          }
75          for (int i = 'A'; i <= 'Z'; i++) {
76              alpha.set(i);
77          }
78      }
79  
80  
81      /**
82       * BitSet for alphanum (join of alpha &amp; digit).
83       * <p><blockquote><pre>
84       *  alphanum      = alpha | digit
85       * </pre></blockquote></p>
86       */
87      protected static final BitSet alphanum = new BitSet(256);
88      // Static initializer for alphanum
89      static {
90          alphanum.or(alpha);
91          alphanum.or(digit);
92      }
93  
94  
95      /**
96       * BitSet for hex.
97       * <p><blockquote><pre>
98       * hex           = digit | "A" | "B" | "C" | "D" | "E" | "F" |
99       *                         "a" | "b" | "c" | "d" | "e" | "f"
100      * </pre></blockquote></p>
101      */
102     protected static final BitSet hex = new BitSet(256);
103     // Static initializer for hex
104     static {
105         hex.or(digit);
106         for (int i = 'a'; i <= 'f'; i++) {
107             hex.set(i);
108         }
109         for (int i = 'A'; i <= 'F'; i++) {
110             hex.set(i);
111         }
112     }
113 
114 
115     /**
116      * BitSet for escaped.
117      * <p><blockquote><pre>
118      * escaped       = "%" hex hex
119      * </pre></blockquote></p>
120      */
121     protected static final BitSet escaped = new BitSet(256);
122     // Static initializer for escaped
123     static {
124         escaped.or(percent);
125         escaped.or(hex);
126     }
127 
128 
129     /**
130      * BitSet for mark.
131      * <p><blockquote><pre>
132      * mark          = "-" | "_" | "." | "!" | "~" | "*" | "'" |
133      *                 "(" | ")"
134      * </pre></blockquote></p>
135      */
136     protected static final BitSet mark = new BitSet(256);
137     // Static initializer for mark
138     static {
139         mark.set('-');
140         mark.set('_');
141         mark.set('.');
142         mark.set('!');
143         mark.set('~');
144         mark.set('*');
145         mark.set('\'');
146         mark.set('(');
147         mark.set(')');
148     }
149 
150 
151     /**
152      * Data characters that are allowed in a URI but do not have a reserved
153      * purpose are called unreserved.
154      * <p><blockquote><pre>
155      * unreserved    = alphanum | mark
156      * </pre></blockquote></p>
157      */
158     protected static final BitSet unreserved = new BitSet(256);
159     // Static initializer for unreserved
160     static {
161         unreserved.or(alphanum);
162         unreserved.or(mark);
163     }
164 
165 
166     /**
167      * BitSet for reserved.
168      * <p><blockquote><pre>
169      * reserved      = ";" | "/" | "?" | ":" | "@" | "&amp;" | "=" | "+" |
170      *                 "$" | ","
171      * </pre></blockquote></p>
172      */
173     protected static final BitSet reserved = new BitSet(256);
174     // Static initializer for reserved
175     static {
176         reserved.set(';');
177         reserved.set('/');
178         reserved.set('?');
179         reserved.set(':');
180         reserved.set('@');
181         reserved.set('&');
182         reserved.set('=');
183         reserved.set('+');
184         reserved.set('$');
185         reserved.set(',');
186     }
187 
188 
189     /**
190      * BitSet for uric.
191      * <p><blockquote><pre>
192      * uric          = reserved | unreserved | escaped
193      * </pre></blockquote></p>
194      */
195     protected static final BitSet uric = new BitSet(256);
196     // Static initializer for uric
197     static {
198         uric.or(reserved);
199         uric.or(unreserved);
200         uric.or(escaped);
201     }
202 
203 
204     /**
205      * BitSet for fragment (alias for uric).
206      * <p><blockquote><pre>
207      * fragment      = *uric
208      * </pre></blockquote></p>
209      */
210     protected static final BitSet fragment = uric;
211 
212 
213     /**
214      * BitSet for query (alias for uric).
215      * <p><blockquote><pre>
216      * query         = *uric
217      * </pre></blockquote></p>
218      */
219     protected static final BitSet query = uric;
220 
221 
222     /**
223      * BitSet for pchar.
224      * <p><blockquote><pre>
225      * pchar         = unreserved | escaped |
226      *                 ":" | "@" | "&amp;" | "=" | "+" | "$" | ","
227      * </pre></blockquote></p>
228      */
229     protected static final BitSet pchar = new BitSet(256);
230     // Static initializer for pchar
231     static {
232         pchar.or(unreserved);
233         pchar.or(escaped);
234         pchar.set(':');
235         pchar.set('@');
236         pchar.set('&');
237         pchar.set('=');
238         pchar.set('+');
239         pchar.set('$');
240         pchar.set(',');
241     }
242 
243 
244     /**
245      * BitSet for param (alias for pchar).
246      * <p><blockquote><pre>
247      * param         = *pchar
248      * </pre></blockquote></p>
249      */
250     protected static final BitSet param = pchar;
251 
252 
253     /**
254      * BitSet for segment.
255      * <p><blockquote><pre>
256      * segment       = *pchar *( ";" param )
257      * </pre></blockquote></p>
258      */
259     protected static final BitSet segment = new BitSet(256);
260     // Static initializer for segment
261     static {
262         segment.or(pchar);
263         segment.set(';');
264         segment.or(param);
265     }
266 
267 
268     /**
269      * BitSet for path segments.
270      * <p><blockquote><pre>
271      * path_segments = segment *( "/" segment )
272      * </pre></blockquote></p>
273      */
274     protected static final BitSet path_segments = new BitSet(256);
275     // Static initializer for path_segments
276     static {
277         path_segments.set('/');
278         path_segments.or(segment);
279     }
280 
281 
282     /**
283      * URI absolute path.
284      * <p><blockquote><pre>
285      * abs_path      = "/"  path_segments
286      * </pre></blockquote></p>
287      */
288     protected static final BitSet abs_path = new BitSet(256);
289     // Static initializer for abs_path
290     static {
291         abs_path.set('/');
292         abs_path.or(path_segments);
293     }
294 
295 
296     /**
297      * URI bitset for encoding typical non-slash characters.
298      * <p><blockquote><pre>
299      * uric_no_slash = unreserved | escaped | ";" | "?" | ":" | "@" |
300      *                 "&amp;" | "=" | "+" | "$" | ","
301      * </pre></blockquote></p>
302      */
303     protected static final BitSet uric_no_slash = new BitSet(256);
304     // Static initializer for uric_no_slash
305     static {
306         uric_no_slash.or(unreserved);
307         uric_no_slash.or(escaped);
308         uric_no_slash.set(';');
309         uric_no_slash.set('?');
310         uric_no_slash.set(';');
311         uric_no_slash.set('@');
312         uric_no_slash.set('&');
313         uric_no_slash.set('=');
314         uric_no_slash.set('+');
315         uric_no_slash.set('$');
316         uric_no_slash.set(',');
317     }
318 
319 
320     /**
321      * URI bitset that combines uric_no_slash and uric.
322      * <p><blockquote><pre>
323      * opaque_part   = uric_no_slash *uric
324      * </pre></blockquote></p>
325      */
326     protected static final BitSet opaque_part = new BitSet(256);
327     // Static initializer for opaque_part
328     static {
329         // it's generous. because first character must not include a slash
330         opaque_part.or(uric_no_slash);
331         opaque_part.or(uric);
332     }
333 
334 
335     /**
336      * URI bitset that combines absolute path and opaque part.
337      * <p><blockquote><pre>
338      * path          = [ abs_path | opaque_part ]
339      * </pre></blockquote></p>
340      */
341     protected static final BitSet path = new BitSet(256);
342     // Static initializer for path
343     static {
344         path.or(abs_path);
345         path.or(opaque_part);
346     }
347 
348 
349     /**
350      * Port, a logical alias for digit.
351      */
352     protected static final BitSet port = digit;
353 
354 
355     /**
356      * Bitset that combines digit and dot fo IPv$address.
357      * <p><blockquote><pre>
358      * IPv4address   = 1*digit "." 1*digit "." 1*digit "." 1*digit
359      * </pre></blockquote></p>
360      */
361     protected static final BitSet IPv4address = new BitSet(256);
362     // Static initializer for IPv4address
363     static {
364         IPv4address.or(digit);
365         IPv4address.set('.');
366     }
367 
368 
369     /**
370      * RFC 2373.
371      * <p><blockquote><pre>
372      * IPv6address = hexpart [ ":" IPv4address ]
373      * </pre></blockquote></p>
374      */
375     protected static final BitSet IPv6address = new BitSet(256);
376     // Static initializer for IPv6address reference
377     static {
378         IPv6address.or(hex); // hexpart
379         IPv6address.set(':');
380         IPv6address.or(IPv4address);
381     }
382 
383 
384     /**
385      * RFC 2732, 2373.
386      * <p><blockquote><pre>
387      * IPv6reference   = "[" IPv6address "]"
388      * </pre></blockquote></p>
389      */
390     protected static final BitSet IPv6reference = new BitSet(256);
391     // Static initializer for IPv6reference
392     static {
393         IPv6reference.set('[');
394         IPv6reference.or(IPv6address);
395         IPv6reference.set(']');
396     }
397 
398 
399     /**
400      * BitSet for toplabel.
401      * <p><blockquote><pre>
402      * toplabel      = alpha | alpha *( alphanum | "-" ) alphanum
403      * </pre></blockquote></p>
404      */
405     protected static final BitSet toplabel = new BitSet(256);
406     // Static initializer for toplabel
407     static {
408         toplabel.or(alphanum);
409         toplabel.set('-');
410     }
411 
412 
413     /**
414      * BitSet for domainlabel.
415      * <p><blockquote><pre>
416      * domainlabel   = alphanum | alphanum *( alphanum | "-" ) alphanum
417      * </pre></blockquote></p>
418      */
419     protected static final BitSet domainlabel = toplabel;
420 
421 
422     /**
423      * BitSet for hostname.
424      * <p><blockquote><pre>
425      * hostname      = *( domainlabel "." ) toplabel [ "." ]
426      * </pre></blockquote></p>
427      */
428     protected static final BitSet hostname = new BitSet(256);
429     // Static initializer for hostname
430     static {
431         hostname.or(toplabel);
432         // hostname.or(domainlabel);
433         hostname.set('.');
434     }
435 
436 
437     /**
438      * BitSet for host.
439      * <p><blockquote><pre>
440      * host          = hostname | IPv4address | IPv6reference
441      * </pre></blockquote></p>
442      */
443     protected static final BitSet host = new BitSet(256);
444     // Static initializer for host
445     static {
446         host.or(hostname);
447         // host.or(IPv4address);
448         host.or(IPv6reference); // IPv4address
449     }
450 
451 
452     /**
453      * BitSet for hostport.
454      * <p><blockquote><pre>
455      * hostport      = host [ ":" port ]
456      * </pre></blockquote></p>
457      */
458     protected static final BitSet hostport = new BitSet(256);
459     // Static initializer for hostport
460     static {
461         hostport.or(host);
462         hostport.set(':');
463         hostport.or(port);
464     }
465 
466 
467     /**
468      * Bitset for userinfo.
469      * <p><blockquote><pre>
470      * userinfo      = *( unreserved | escaped |
471      *                    ";" | ":" | "&amp;" | "=" | "+" | "$" | "," )
472      * </pre></blockquote></p>
473      */
474     protected static final BitSet userinfo = new BitSet(256);
475     // Static initializer for userinfo
476     static {
477         userinfo.or(unreserved);
478         userinfo.or(escaped);
479         userinfo.set(';');
480         userinfo.set(':');
481         userinfo.set('&');
482         userinfo.set('=');
483         userinfo.set('+');
484         userinfo.set('$');
485         userinfo.set(',');
486     }
487 
488 
489     /**
490      * BitSet for within the userinfo component like user and password.
491      */
492     public static final BitSet within_userinfo = new BitSet(256);
493     // Static initializer for within_userinfo
494     static {
495         within_userinfo.or(userinfo);
496         within_userinfo.clear(';'); // reserved within authority
497         within_userinfo.clear(':');
498         within_userinfo.clear('@');
499         within_userinfo.clear('?');
500         within_userinfo.clear('/');
501     }
502 
503 
504     /**
505      * Bitset for server.
506      * <p><blockquote><pre>
507      * server        = [ [ userinfo "@" ] hostport ]
508      * </pre></blockquote></p>
509      */
510     protected static final BitSet server = new BitSet(256);
511     // Static initializer for server
512     static {
513         server.or(userinfo);
514         server.set('@');
515         server.or(hostport);
516     }
517 
518 
519     /**
520      * BitSet for reg_name.
521      * <p><blockquote><pre>
522      * reg_name      = 1*( unreserved | escaped | "$" | "," |
523      *                     ";" | ":" | "@" | "&amp;" | "=" | "+" )
524      * </pre></blockquote></p>
525      */
526     protected static final BitSet reg_name = new BitSet(256);
527     // Static initializer for reg_name
528     static {
529         reg_name.or(unreserved);
530         reg_name.or(escaped);
531         reg_name.set('$');
532         reg_name.set(',');
533         reg_name.set(';');
534         reg_name.set(':');
535         reg_name.set('@');
536         reg_name.set('&');
537         reg_name.set('=');
538         reg_name.set('+');
539     }
540 
541 
542     /**
543      * BitSet for authority.
544      * <p><blockquote><pre>
545      * authority     = server | reg_name
546      * </pre></blockquote></p>
547      */
548     protected static final BitSet authority = new BitSet(256);
549     // Static initializer for authority
550     static {
551         authority.or(server);
552         authority.or(reg_name);
553     }
554 
555 
556     /**
557      * BitSet for scheme.
558      * <p><blockquote><pre>
559      * scheme        = alpha *( alpha | digit | "+" | "-" | "." )
560      * </pre></blockquote></p>
561      */
562     protected static final BitSet scheme = new BitSet(256);
563     // Static initializer for scheme
564     static {
565         scheme.or(alpha);
566         scheme.or(digit);
567         scheme.set('+');
568         scheme.set('-');
569         scheme.set('.');
570     }
571 
572 
573     /**
574      * BitSet for rel_segment.
575      * <p><blockquote><pre>
576      * rel_segment   = 1*( unreserved | escaped |
577      *                     ";" | "@" | "&amp;" | "=" | "+" | "$" | "," )
578      * </pre></blockquote></p>
579      */
580     protected static final BitSet rel_segment = new BitSet(256);
581     // Static initializer for rel_segment
582     static {
583         rel_segment.or(unreserved);
584         rel_segment.or(escaped);
585         rel_segment.set(';');
586         rel_segment.set('@');
587         rel_segment.set('&');
588         rel_segment.set('=');
589         rel_segment.set('+');
590         rel_segment.set('$');
591         rel_segment.set(',');
592     }
593 
594 
595     /**
596      * BitSet for rel_path.
597      * <p><blockquote><pre>
598      * rel_path      = rel_segment [ abs_path ]
599      * </pre></blockquote></p>
600      */
601     protected static final BitSet rel_path = new BitSet(256);
602     // Static initializer for rel_path
603     static {
604         rel_path.or(rel_segment);
605         rel_path.or(abs_path);
606     }
607 
608 
609     /**
610      * BitSet for net_path.
611      * <p><blockquote><pre>
612      * net_path      = "//" authority [ abs_path ]
613      * </pre></blockquote></p>
614      */
615     protected static final BitSet net_path = new BitSet(256);
616     // Static initializer for net_path
617     static {
618         net_path.set('/');
619         net_path.or(authority);
620         net_path.or(abs_path);
621     }
622 
623 
624     /**
625      * BitSet for hier_part.
626      * <p><blockquote><pre>
627      * hier_part     = ( net_path | abs_path ) [ "?" query ]
628      * </pre></blockquote></p>
629      */
630     protected static final BitSet hier_part = new BitSet(256);
631     // Static initializer for hier_part
632     static {
633         hier_part.or(net_path);
634         hier_part.or(abs_path);
635         // hier_part.set('?'); aleady included
636         hier_part.or(query);
637     }
638 
639 
640     /**
641      * BitSet for relativeURI.
642      * <p><blockquote><pre>
643      * relativeURI   = ( net_path | abs_path | rel_path ) [ "?" query ]
644      * </pre></blockquote></p>
645      */
646     protected static final BitSet relativeURI = new BitSet(256);
647     // Static initializer for relativeURI
648     static {
649         relativeURI.or(net_path);
650         relativeURI.or(abs_path);
651         relativeURI.or(rel_path);
652         // relativeURI.set('?'); aleady included
653         relativeURI.or(query);
654     }
655 
656 
657     /**
658      * BitSet for absoluteURI.
659      * <p><blockquote><pre>
660      * absoluteURI   = scheme ":" ( hier_part | opaque_part )
661      * </pre></blockquote></p>
662      */
663     protected static final BitSet absoluteURI = new BitSet(256);
664     // Static initializer for absoluteURI
665     static {
666         absoluteURI.or(scheme);
667         absoluteURI.set(':');
668         absoluteURI.or(hier_part);
669         absoluteURI.or(opaque_part);
670     }
671 
672 
673     /**
674      * BitSet for URI-reference.
675      * <p><blockquote><pre>
676      * URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
677      * </pre></blockquote></p>
678      */
679     protected static final BitSet URI_reference = new BitSet(256);
680     // Static initializer for URI_reference
681     static {
682         URI_reference.or(absoluteURI);
683         URI_reference.or(relativeURI);
684         URI_reference.set('#');
685         URI_reference.or(fragment);
686     }
687 
688     // ---------------------------- Characters disallowed within the URI syntax
689     // Excluded US-ASCII Characters are like control, space, delims and unwise
690 
691     /**
692      * BitSet for control.
693      */
694     public static final BitSet control = new BitSet(256);
695     // Static initializer for control
696     static {
697         for (int i = 0; i <= 0x1F; i++) {
698             control.set(i);
699         }
700         control.set(0x7F);
701     }
702 
703     /**
704      * BitSet for space.
705      */
706     public static final BitSet space = new BitSet(256);
707     // Static initializer for space
708     static {
709         space.set(0x20);
710     }
711 
712 
713     /**
714      * BitSet for delims.
715      */
716     public static final BitSet delims = new BitSet(256);
717     // Static initializer for delims
718     static {
719         delims.set('<');
720         delims.set('>');
721         delims.set('#');
722         delims.set('%');
723         delims.set('"');
724     }
725 
726 
727     /**
728      * BitSet for unwise.
729      */
730     public static final BitSet unwise = new BitSet(256);
731     // Static initializer for unwise
732     static {
733         unwise.set('{');
734         unwise.set('}');
735         unwise.set('|');
736         unwise.set('\\');
737         unwise.set('^');
738         unwise.set('[');
739         unwise.set(']');
740         unwise.set('`');
741     }
742 
743 
744     /**
745      * Disallowed rel_path before escaping.
746      */
747     public static final BitSet disallowed_rel_path = new BitSet(256);
748     // Static initializer for disallowed_rel_path
749     static {
750         disallowed_rel_path.or(uric);
751         disallowed_rel_path.andNot(rel_path);
752     }
753 
754 
755     /**
756      * Disallowed opaque_part before escaping.
757      */
758     public static final BitSet disallowed_opaque_part = new BitSet(256);
759     // Static initializer for disallowed_opaque_part
760     static {
761         disallowed_opaque_part.or(uric);
762         disallowed_opaque_part.andNot(opaque_part);
763     }
764 
765     // ----------------------- Characters allowed within and for each component
766 
767     /**
768      * Those characters that are allowed for the authority component.
769      */
770     public static final BitSet allowed_authority = new BitSet(256);
771     // Static initializer for allowed_authority
772     static {
773         allowed_authority.or(authority);
774         allowed_authority.clear('%');
775     }
776 
777 
778     /**
779      * Those characters that are allowed for the opaque_part.
780      */
781     public static final BitSet allowed_opaque_part = new BitSet(256);
782     // Static initializer for allowed_opaque_part
783     static {
784         allowed_opaque_part.or(opaque_part);
785         allowed_opaque_part.clear('%');
786     }
787 
788 
789     /**
790      * Those characters that are allowed for the reg_name.
791      */
792     public static final BitSet allowed_reg_name = new BitSet(256);
793     // Static initializer for allowed_reg_name
794     static {
795         allowed_reg_name.or(reg_name);
796         // allowed_reg_name.andNot(percent);
797         allowed_reg_name.clear('%');
798     }
799 
800 
801     /**
802      * Those characters that are allowed for the userinfo component.
803      */
804     public static final BitSet allowed_userinfo = new BitSet(256);
805     // Static initializer for allowed_userinfo
806     static {
807         allowed_userinfo.or(userinfo);
808         // allowed_userinfo.andNot(percent);
809         allowed_userinfo.clear('%');
810     }
811 
812 
813     /**
814      * Those characters that are allowed for within the userinfo component.
815      */
816     public static final BitSet allowed_within_userinfo = new BitSet(256);
817     // Static initializer for allowed_within_userinfo
818     static {
819         allowed_within_userinfo.or(within_userinfo);
820         allowed_within_userinfo.clear('%');
821     }
822 
823 
824     /**
825      * Those characters that are allowed for the IPv6reference component.
826      * The characters '[', ']' in IPv6reference should be excluded.
827      */
828     public static final BitSet allowed_IPv6reference = new BitSet(256);
829     // Static initializer for allowed_IPv6reference
830     static {
831         allowed_IPv6reference.or(IPv6reference);
832         // allowed_IPv6reference.andNot(unwise);
833         allowed_IPv6reference.clear('[');
834         allowed_IPv6reference.clear(']');
835     }
836 
837 
838     /**
839      * Those characters that are allowed for the host component.
840      * The characters '[', ']' in IPv6reference should be excluded.
841      */
842     public static final BitSet allowed_host = new BitSet(256);
843     // Static initializer for allowed_host
844     static {
845         allowed_host.or(hostname);
846         allowed_host.or(allowed_IPv6reference);
847     }
848 
849 
850     /**
851      * Those characters that are allowed for the authority component.
852      */
853     public static final BitSet allowed_within_authority = new BitSet(256);
854     // Static initializer for allowed_within_authority
855     static {
856         allowed_within_authority.or(server);
857         allowed_within_authority.or(reg_name);
858         allowed_within_authority.clear(';');
859         allowed_within_authority.clear(':');
860         allowed_within_authority.clear('@');
861         allowed_within_authority.clear('?');
862         allowed_within_authority.clear('/');
863     }
864 
865 
866     /**
867      * Those characters that are allowed for the abs_path.
868      */
869     public static final BitSet allowed_abs_path = new BitSet(256);
870     // Static initializer for allowed_abs_path
871     static {
872         allowed_abs_path.or(abs_path);
873         // allowed_abs_path.set('/');  // aleady included
874         allowed_abs_path.andNot(percent);
875         allowed_abs_path.clear('+');
876     }
877 
878 
879     /**
880      * Those characters that are allowed for the rel_path.
881      */
882     public static final BitSet allowed_rel_path = new BitSet(256);
883     // Static initializer for allowed_rel_path
884     static {
885         allowed_rel_path.or(rel_path);
886         allowed_rel_path.clear('%');
887         allowed_rel_path.clear('+');
888     }
889 
890 
891     /**
892      * Those characters that are allowed within the path.
893      */
894     public static final BitSet allowed_within_path = new BitSet(256);
895     // Static initializer for allowed_within_path
896     static {
897         allowed_within_path.or(abs_path);
898         allowed_within_path.clear('/');
899         allowed_within_path.clear(';');
900         allowed_within_path.clear('=');
901         allowed_within_path.clear('?');
902     }
903 
904 
905     /**
906      * Those characters that are allowed for the query component.
907      */
908     public static final BitSet allowed_query = new BitSet(256);
909     // Static initializer for allowed_query
910     static {
911         allowed_query.or(uric);
912         allowed_query.clear('%');
913     }
914 
915 
916     /**
917      * Those characters that are allowed within the query component.
918      */
919     public static final BitSet allowed_within_query = new BitSet(256);
920     // Static initializer for allowed_within_query
921     static {
922         allowed_within_query.or(allowed_query);
923         allowed_within_query.andNot(reserved); // excluded 'reserved'
924     }
925 
926 
927     /**
928      * Those characters that are allowed for the fragment component.
929      */
930     public static final BitSet allowed_fragment = new BitSet(256);
931     // Static initializer for allowed_fragment
932     static {
933         allowed_fragment.or(uric);
934         allowed_fragment.clear('%');
935     }
936 
937     private URIBitSets() {
938     }
939 
940 }