Lines 51-56
Link Here
|
51 |
import java.util.Map; |
51 |
import java.util.Map; |
52 |
import java.util.Set; |
52 |
import java.util.Set; |
53 |
import java.util.StringTokenizer; |
53 |
import java.util.StringTokenizer; |
|
|
54 |
import java.util.regex.Pattern; |
54 |
import org.openide.util.Utilities; |
55 |
import org.openide.util.Utilities; |
55 |
|
56 |
|
56 |
/** A dependency a module can have. Since version 7.10 this class is |
57 |
/** A dependency a module can have. Since version 7.10 this class is |
Lines 196-227
Link Here
|
196 |
} |
197 |
} |
197 |
|
198 |
|
198 |
// Now check that the rest is a valid package. |
199 |
// Now check that the rest is a valid package. |
199 |
StringTokenizer tok = new StringTokenizer(base, ".", true); // NOI18N |
200 |
if (!FQN.matcher(base).matches()) { |
200 |
|
201 |
throw new IllegalArgumentException("Malformed dot-separated identifier: " + base); |
201 |
if ((tok.countTokens() % 2) == 0) { |
|
|
202 |
throw new NumberFormatException("Even number of pieces: " + base); // NOI18N |
203 |
} |
204 |
|
205 |
boolean expectingPath = true; |
206 |
|
207 |
while (tok.hasMoreTokens()) { |
208 |
if (expectingPath) { |
209 |
expectingPath = false; |
210 |
|
211 |
String nt = tok.nextToken(); |
212 |
if (!Utilities.isJavaIdentifier(nt) && !"enum".equals (nt)) { // NOI18N |
213 |
throw new IllegalArgumentException("Bad package component in " + base); // NOI18N |
214 |
} |
215 |
} else { |
216 |
if (!".".equals(tok.nextToken())) { // NOI18N |
217 |
throw new NumberFormatException("Expected dot in code name: " + base); // NOI18N |
218 |
} |
219 |
|
220 |
expectingPath = true; |
221 |
} |
222 |
} |
202 |
} |
223 |
} |
203 |
} |
224 |
|
204 |
private static final String IDENTIFIER = "(?:\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*)"; // NOI18N |
|
|
205 |
private static final Pattern FQN = Pattern.compile(IDENTIFIER + "(?:[.]" + IDENTIFIER + ")*"); // NOI18N |
206 |
|
225 |
/** Parse dependencies from tags. |
207 |
/** Parse dependencies from tags. |
226 |
* @param type like Dependency.type |
208 |
* @param type like Dependency.type |
227 |
* @param body actual text of tag body; if <code>null</code>, returns nothing |
209 |
* @param body actual text of tag body; if <code>null</code>, returns nothing |