equal
deleted
inserted
replaced
29 * However, the following notice accompanied the original version of this |
29 * However, the following notice accompanied the original version of this |
30 * file: |
30 * file: |
31 * |
31 * |
32 * The MIT License |
32 * The MIT License |
33 * |
33 * |
34 * Copyright (c) 2004-2014 Paul R. Holser, Jr. |
34 * Copyright (c) 2004-2015 Paul R. Holser, Jr. |
35 * |
35 * |
36 * Permission is hereby granted, free of charge, to any person obtaining |
36 * Permission is hereby granted, free of charge, to any person obtaining |
37 * a copy of this software and associated documentation files (the |
37 * a copy of this software and associated documentation files (the |
38 * "Software"), to deal in the Software without restriction, including |
38 * "Software"), to deal in the Software without restriction, including |
39 * without limitation the rights to use, copy, modify, merge, publish, |
39 * without limitation the rights to use, copy, modify, merge, publish, |
53 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
53 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
54 */ |
54 */ |
55 |
55 |
56 package jdk.internal.joptsimple; |
56 package jdk.internal.joptsimple; |
57 |
57 |
58 import java.util.Collection; |
58 import java.util.List; |
59 |
59 |
60 import static java.lang.Character.*; |
60 import static java.lang.Character.*; |
61 |
61 |
62 /** |
62 /** |
63 * Can tell whether or not options are well-formed. |
63 * Can tell whether or not options are well-formed. |
95 |
95 |
96 for ( int i = 0; i < option.length(); ++i ) |
96 for ( int i = 0; i < option.length(); ++i ) |
97 ensureLegalOptionCharacter( option.charAt( i ) ); |
97 ensureLegalOptionCharacter( option.charAt( i ) ); |
98 } |
98 } |
99 |
99 |
100 static void ensureLegalOptions( Collection<String> options ) { |
100 static void ensureLegalOptions( List<String> options ) { |
101 for ( String each : options ) |
101 for ( String each : options ) |
102 ensureLegalOption( each ); |
102 ensureLegalOption( each ); |
103 } |
103 } |
104 |
104 |
105 private static void ensureLegalOptionCharacter( char option ) { |
105 private static void ensureLegalOptionCharacter( char option ) { |
106 if ( !( isLetterOrDigit( option ) || isAllowedPunctuation( option ) ) ) |
106 if ( !( isLetterOrDigit( option ) || isAllowedPunctuation( option ) ) ) |
107 throw new IllegalOptionSpecificationException( String.valueOf( option ) ); |
107 throw new IllegalOptionSpecificationException( String.valueOf( option ) ); |
108 } |
108 } |
109 |
109 |
110 private static boolean isAllowedPunctuation( char option ) { |
110 private static boolean isAllowedPunctuation( char option ) { |
111 String allowedPunctuation = "?." + HYPHEN_CHAR; |
111 String allowedPunctuation = "?._" + HYPHEN_CHAR; |
112 return allowedPunctuation.indexOf( option ) != -1; |
112 return allowedPunctuation.indexOf( option ) != -1; |
113 } |
113 } |
114 } |
114 } |