java.util.regex.Pattern
has a method Map<String, Integer> namedGroups()
. For some reason they decided to make it private, and so there is no way to obtain this very useful information! :(
I've tried accessing this information (read-only) with this helper class:
package java.util.regex;
import java.util.Collections;
import java.util.Map;
public class PatternHelper {
public static Map<String, Integer> getNamedGroups(Pattern pattern) {
return Collections.unmodifiableMap(pattern.namedGroups());
}
}
But Java8 complains with java.lang.SecurityException: Prohibited package name: java.util.regex
.
How can I access this information (read-only)? maybe by reflection?
Aucun commentaire:
Enregistrer un commentaire