use of java.util.regex.Matcher in project che by eclipse.
the class KubernetesLabelConverter method namesToLabels.
/**
* Undoes the label conversion done by {@link KubernetesLabelConverter#labelsToNames(Map)}
*
* @param labels Map of DNS names
* @return Map of unconverted labels
*/
public static Map<String, String> namesToLabels(Map<String, String> names) {
Map<String, String> labels = new HashMap<>();
for (Map.Entry<String, String> entry : names.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
// Remove padding
Matcher keyMatcher = CHE_SERVER_LABEL_KEY.matcher(key);
Matcher valueMatcher = CHE_SERVER_LABEL_KEY.matcher(value);
if (!keyMatcher.matches() || !valueMatcher.matches()) {
continue;
}
key = keyMatcher.group(1);
value = valueMatcher.group(1);
// Convert key: e.g. "che.server.4401_tcp.ref" -> "che:server:4401/tcp:ref"
key = key.replaceAll("\\.", ":").replaceAll("_", "/");
// Convert value: e.g. Convert values: e.g. "_api" -> "/api"
value = value.replaceAll("_", "/");
labels.put(key, value);
}
return labels;
}
use of java.util.regex.Matcher in project che by eclipse.
the class GdbPType method parse.
/**
* Factory method.
*/
public static GdbPType parse(GdbOutput gdbOutput) throws GdbParseException {
String output = gdbOutput.getOutput();
Matcher matcher = GDB_ARGS.matcher(output);
if (matcher.find()) {
String type = matcher.group(1);
return new GdbPType(type);
}
throw new GdbParseException(GdbPrint.class, output);
}
use of java.util.regex.Matcher in project che by eclipse.
the class GdbPrint method parse.
/**
* Factory method.
*/
public static GdbPrint parse(GdbOutput gdbOutput) throws GdbParseException {
String output = gdbOutput.getOutput();
Matcher matcher = GDB_PRINT.matcher(output);
if (matcher.find()) {
String value = matcher.group(2);
return new GdbPrint(value);
}
throw new GdbParseException(GdbPrint.class, output);
}
use of java.util.regex.Matcher in project che by eclipse.
the class ProcessInfo method parse.
/**
* Factory method.
*/
public static ProcessInfo parse(String output) throws GdbParseException {
final Matcher matcher = PROCESS_INFO.matcher(output);
if (matcher.find()) {
try {
final int processId = Integer.parseInt(matcher.group(1));
final String processName = matcher.group(2).replaceAll("\\s+", "");
return new ProcessInfo(processName, processId);
} catch (NumberFormatException e) {
throw new GdbParseException(ProcessInfo.class, output);
}
}
throw new GdbParseException(ProcessInfo.class, output);
}
use of java.util.regex.Matcher in project che by eclipse.
the class GdbDelete method parse.
/**
* Factory method.
*/
public static GdbDelete parse(GdbOutput gdbOutput) throws GdbParseException {
String output = gdbOutput.getOutput();
Matcher matcher = GDB_DELETE.matcher(output);
if (matcher.find()) {
return new GdbDelete();
}
throw new GdbParseException(GdbDelete.class, output);
}
Aggregations