コード例 #1
0
  @Override
  public List<String> findLanguageNames(String filter) {
    List<String> answer = new ArrayList<String>();

    List<String> names = findLanguageNames();
    for (String name : names) {
      String json = languageJSonSchema(name);
      if (json != null) {
        List<Map<String, String>> rows = JSonSchemaHelper.parseJsonSchema("language", json, false);
        for (Map<String, String> row : rows) {
          if (row.containsKey("label")) {
            String label = row.get("label");
            String[] parts = label.split(",");
            for (String part : parts) {
              try {
                if (part.equalsIgnoreCase(filter)
                    || CatalogHelper.matchWildcard(part, filter)
                    || part.matches(filter)) {
                  answer.add(name);
                }
              } catch (PatternSyntaxException e) {
                // ignore as filter is maybe not a pattern
              }
            }
          }
        }
      }
    }

    return answer;
  }
コード例 #2
0
  @Override
  public List<String> findModelNames() {
    List<String> names = new ArrayList<String>();

    InputStream is = DefaultCamelCatalog.class.getClassLoader().getResourceAsStream(MODELS_CATALOG);
    if (is != null) {
      try {
        CatalogHelper.loadLines(is, names);
      } catch (IOException e) {
        // ignore
      }
    }
    return names;
  }
コード例 #3
0
  @Override
  public String blueprintSchemaAsXml() {
    String file = SCHEMAS_XML + "/camel-blueprint.xsd";

    InputStream is = DefaultCamelCatalog.class.getClassLoader().getResourceAsStream(file);
    if (is != null) {
      try {
        return CatalogHelper.loadText(is);
      } catch (IOException e) {
        // ignore
      }
    }

    return null;
  }
コード例 #4
0
  @Override
  public String archetypeCatalogAsXml() {
    String file = ARCHETYPES_CATALOG;

    InputStream is = DefaultCamelCatalog.class.getClassLoader().getResourceAsStream(file);
    if (is != null) {
      try {
        return CatalogHelper.loadText(is);
      } catch (IOException e) {
        // ignore
      }
    }

    return null;
  }
コード例 #5
0
  @Override
  public String languageJSonSchema(String name) {
    String file = LANGUAGE_JSON + "/" + name + ".json";

    InputStream is = DefaultCamelCatalog.class.getClassLoader().getResourceAsStream(file);
    if (is != null) {
      try {
        return CatalogHelper.loadText(is);
      } catch (IOException e) {
        // ignore
      }
    }

    return null;
  }
コード例 #6
0
  @Override
  public String listModelsAsJson() {
    StringBuilder sb = new StringBuilder();
    sb.append("[");
    List<String> names = findModelNames();
    for (int i = 0; i < names.size(); i++) {
      String scheme = names.get(i);
      String json = modelJSonSchema(scheme);
      // skip first line
      json = CatalogHelper.between(json, "\"model\": {", "\"properties\": {");
      json = json.trim();
      // skip last comma if not the last
      if (i == names.size() - 1) {
        json = json.substring(0, json.length() - 1);
      }
      sb.append("\n");
      sb.append("  {\n");
      sb.append("    ");
      sb.append(json);
    }

    sb.append("\n]");
    return sb.toString();
  }