Exemplo n.º 1
0
    private void writeAttributes(final cgCache cache) throws IOException {
      if (!cache.hasAttributes()) {
        return;
      }
      // TODO: Attribute conversion required: English verbose name, gpx-id
      gpx.write("<groundspeak:attributes>");

      for (String attribute : cache.getAttributes()) {
        final CacheAttribute attr =
            CacheAttribute.getByGcRawName(CacheAttribute.trimAttributeName(attribute));
        final boolean enabled = CacheAttribute.isEnabled(attribute);

        gpx.write("<groundspeak:attribute id=\"");
        gpx.write(Integer.toString(attr.id));
        gpx.write("\" inc=\"");
        if (enabled) {
          gpx.write('1');
        } else {
          gpx.write('0');
        }
        gpx.write("\">");
        gpx.write(StringEscapeUtils.escapeXml(attr.getL10n(enabled)));
        gpx.write("</groundspeak:attribute>");
      }

      gpx.write("</groundspeak:attributes>");
    }
Exemplo n.º 2
0
  private static List<String> parseAttributes(final ArrayNode nameList, final ArrayNode acodeList) {

    final List<String> result = new ArrayList<>();

    for (int i = 0; i < nameList.size(); i++) {
      try {
        final String name = nameList.get(i).asText();
        final int acode =
            acodeList != null
                ? Integer.parseInt(acodeList.get(i).asText().substring(1))
                : CacheAttribute.NO_ID;
        final CacheAttribute attr = CacheAttribute.getByOcACode(acode);

        if (attr != null) {
          result.add(attr.rawName);
        } else {
          result.add(name);
        }
      } catch (final NullPointerException e) {
        Log.e("OkapiClient.parseAttributes", e);
      }
    }

    return result;
  }
Exemplo n.º 3
0
  private static List<String> parseAttributes(final JSONArray nameList) {

    final List<String> result = new ArrayList<String>();

    for (int i = 0; i < nameList.length(); i++) {
      try {
        final String name = nameList.getString(i);
        final CacheAttribute attr = CacheAttribute.getByOcId(AttributeParser.getOcDeId(name));

        if (attr != null) {
          result.add(attr.rawName);
        }
      } catch (final JSONException e) {
        Log.e("OkapiClient.parseAttributes", e);
      }
    }

    return result;
  }