use of java.util.regex.Matcher in project jetty.project by eclipse.
the class JavaVersion method parsePreJDK9.
private static JavaVersion parsePreJDK9(String version) {
Matcher matcher = PRE_JDK9.matcher(version);
if (!matcher.matches())
throw new IllegalArgumentException("Invalid Java version " + version);
int major = 1;
int minor = Integer.parseInt(matcher.group(1));
String microGroup = matcher.group(3);
int micro = microGroup == null || microGroup.isEmpty() ? 0 : Integer.parseInt(microGroup);
String updateGroup = matcher.group(5);
int update = updateGroup == null || updateGroup.isEmpty() ? 0 : Integer.parseInt(updateGroup);
String suffix = matcher.group(6);
return new JavaVersion(version, minor, major, minor, micro, update, suffix);
}
use of java.util.regex.Matcher in project jetty.project by eclipse.
the class Module method process.
public void process(BaseHome basehome) throws FileNotFoundException, IOException {
Pattern section = Pattern.compile("\\s*\\[([^]]*)\\]\\s*");
if (!FS.canReadFile(_path)) {
StartLog.debug("Skipping read of missing file: %s", basehome.toShortForm(_path));
return;
}
try (BufferedReader buf = Files.newBufferedReader(_path, StandardCharsets.UTF_8)) {
String sectionType = "";
String line;
while ((line = buf.readLine()) != null) {
line = line.trim();
Matcher sectionMatcher = section.matcher(line);
if (sectionMatcher.matches()) {
sectionType = sectionMatcher.group(1).trim().toUpperCase(Locale.ENGLISH);
} else {
// blank lines and comments are valid for ini-template section
if ((line.length() == 0) || line.startsWith("#")) {
// for the [ini-template] section
if ("INI-TEMPLATE".equals(sectionType)) {
_iniTemplate.add(line);
}
} else {
switch(sectionType) {
case "":
// ignore (this would be entries before first section)
break;
case "DESCRIPTION":
_description.add(line);
break;
case "DEPEND":
case "DEPENDS":
_depends.add(line);
break;
case "FILE":
case "FILES":
_files.add(line);
break;
case "TAG":
case "TAGS":
_tags.add(line);
break;
// old name introduced in 9.2.x
case "DEFAULTS":
case // new name for 9.3+
"INI":
_defaultConfig.add(line);
break;
case "INI-TEMPLATE":
_iniTemplate.add(line);
break;
case "LIB":
case "LIBS":
_libs.add(line);
break;
case "LICENSE":
case "LICENSES":
case "LICENCE":
case "LICENCES":
_license.add(line);
break;
case "NAME":
StartLog.warn("Deprecated [name] used in %s", basehome.toShortForm(_path));
_provides.add(line);
break;
case "PROVIDE":
case "PROVIDES":
_provides.add(line);
break;
case "OPTIONAL":
_optional.add(line);
break;
case "EXEC":
_jvmArgs.add(line);
break;
case "VERSION":
if (version != null) {
throw new IOException("[version] already specified");
}
version = new Version(line);
break;
case "XML":
_xmls.add(line);
break;
default:
throw new IOException("Unrecognized module section: [" + sectionType + "]");
}
}
}
}
}
if (version == null) {
version = new Version(VERSION_UNSPECIFIED);
}
}
use of java.util.regex.Matcher in project jetty.project by eclipse.
the class FruitDecoder method willDecode.
@Override
public boolean willDecode(String s) {
if (s == null) {
return false;
}
Pattern pat = Pattern.compile("([^|]*)|([^|]*)");
Matcher mat = pat.matcher(s);
return (mat.find());
}
use of java.util.regex.Matcher in project jetty.project by eclipse.
the class BadDualDecoder method willDecode.
@Override
public boolean willDecode(String s) {
if (s == null) {
return false;
}
Pattern pat = Pattern.compile("([^|]*)|([^|]*)");
Matcher mat = pat.matcher(s);
return (mat.find());
}
use of java.util.regex.Matcher in project jetty.project by eclipse.
the class BadDualDecoder method decode.
@Override
public Fruit decode(String s) throws DecodeException {
Pattern pat = Pattern.compile("([^|]*)|([^|]*)");
Matcher mat = pat.matcher(s);
if (!mat.find()) {
throw new DecodeException(s, "Unable to find Fruit reference encoded in text message");
}
Fruit fruit = new Fruit();
fruit.name = mat.group(1);
fruit.color = mat.group(2);
return fruit;
}
Aggregations