Search in sources :

Example 56 with Matcher

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;
}
Also used : HashMap(java.util.HashMap) Matcher(java.util.regex.Matcher) Map(java.util.Map) HashMap(java.util.HashMap)

Example 57 with Matcher

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);
}
Also used : Matcher(java.util.regex.Matcher) GdbParseException(org.eclipse.che.plugin.gdb.server.exception.GdbParseException)

Example 58 with Matcher

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);
}
Also used : Matcher(java.util.regex.Matcher) GdbParseException(org.eclipse.che.plugin.gdb.server.exception.GdbParseException)

Example 59 with Matcher

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);
}
Also used : Matcher(java.util.regex.Matcher) GdbParseException(org.eclipse.che.plugin.gdb.server.exception.GdbParseException)

Example 60 with Matcher

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);
}
Also used : Matcher(java.util.regex.Matcher) GdbParseException(org.eclipse.che.plugin.gdb.server.exception.GdbParseException)

Aggregations

Matcher (java.util.regex.Matcher)12473 Pattern (java.util.regex.Pattern)5010 ArrayList (java.util.ArrayList)1516 IOException (java.io.IOException)904 HashMap (java.util.HashMap)565 File (java.io.File)487 Test (org.junit.Test)442 BufferedReader (java.io.BufferedReader)428 Map (java.util.Map)363 List (java.util.List)287 InputStreamReader (java.io.InputStreamReader)266 HashSet (java.util.HashSet)236 MalformedURLException (java.net.MalformedURLException)163 URL (java.net.URL)155 Date (java.util.Date)152 InputStream (java.io.InputStream)147 Field (java.lang.reflect.Field)130 PatternSyntaxException (java.util.regex.PatternSyntaxException)128 ParseException (java.text.ParseException)127 LinkedHashMap (java.util.LinkedHashMap)120