public static Settlement parse(String text) {

    Map<String, String> map = InfoboxMap.asMap(text);

    Settlement settlement = new Settlement();
    Coordinate coordinate = new Coordinate();

    for (String key : map.keySet()) {

      switch (key) {
        case NAME:
          settlement.setName(InfoboxParserUtil.removeAllParenthesis(map.get(key)));
          break;
        case STYLE:
          settlement.setType(InfoboxTypeParserUtil.getType(map.get(key)));
          break;
        case OFFICIAL_NAME:
          settlement.setOfficialName(InfoboxParserUtil.removeAllParenthesis(map.get(key)));
          break;
        case NATIVE_NAME:
          settlement.setNativeName(InfoboxParserUtil.removeAllParenthesis(map.get(key)));
          break;
        case NATIVE_NAME_LANG:
          settlement.setNativeNameLang(InfoboxParserUtil.removeAllParenthesis(map.get(key)));
          break;
        case OTHER_NAME:
          settlement.setOtherName(InfoboxParserUtil.removeAllParenthesis(map.get(key)));
          break;
        case SETTLEMENT_TYPE:
          settlement.setSettlementType(InfoboxParserUtil.removeAllParenthesis(map.get(key)));
          break;
        case LATITUDE:
          coordinate.setLatD(map.get(key));
          settlement.setCoordinate(coordinate);

          break;
        case LONGITUDE:
          coordinate.setLongD(map.get(key));
          settlement.setCoordinate(coordinate);
          break;
        case LATD:
          coordinate.setLatD(map.get(key));
          settlement.setCoordinate(coordinate);

          break;
        case LATM:
          coordinate.setLatM(map.get(key));
          settlement.setCoordinate(coordinate);
          break;
        case LATS:
          coordinate.setLatS(map.get(key));
          settlement.setCoordinate(coordinate);
          break;
        case LATDEG:
          coordinate.setLatD(map.get(key));
          settlement.setCoordinate(coordinate);

          break;
        case LATMIN:
          coordinate.setLatM(map.get(key));
          settlement.setCoordinate(coordinate);
          break;
        case LATSEC:
          coordinate.setLatS(map.get(key));
          settlement.setCoordinate(coordinate);
          break;
        case LATNS:
          coordinate.setLatNS(map.get(key));
          settlement.setCoordinate(coordinate);
          break;
        case LONGD:
          coordinate.setLongD(map.get(key));
          settlement.setCoordinate(coordinate);
          break;
        case LONGM:
          coordinate.setLongM(map.get(key));
          settlement.setCoordinate(coordinate);
          break;
        case LONGS:
          coordinate.setLongS(map.get(key));
          settlement.setCoordinate(coordinate);
          break;
        case LONGDEG:
          coordinate.setLongD(map.get(key));
          settlement.setCoordinate(coordinate);
          break;
        case LONGMIN:
          coordinate.setLongM(map.get(key));
          settlement.setCoordinate(coordinate);
          break;
        case LONGSEC:
          coordinate.setLongS(map.get(key));
          settlement.setCoordinate(coordinate);
          break;
        case LONGEW:
          coordinate.setLongEW(map.get(key));
          settlement.setCoordinate(coordinate);
          break;
        case WEB:
          settlement.setWebsite(InfoboxWebsiteParserUtil.getWebsite(map.get(key)));
          break;
        case WEBSITE:
          settlement.setWebsite(InfoboxWebsiteParserUtil.getWebsite(map.get(key)));
          break;
      }
    }

    return settlement;
  }
コード例 #2
0
  public static HistoricSite parse(String text) {
    HistoricSite historicSite = new HistoricSite();
    Coordinate coordinate = new Coordinate();

    Map<String, String> map = InfoboxMap.asMap(text);

    for (String key : map.keySet()) {
      switch (key) {
        case NAME:
          historicSite.setName(InfoboxParserUtil.removeAllParenthesis(map.get(key)));
          break;
        case STYLE:
          historicSite.setType(map.get(key));
          break;
        case CAPTION:
          historicSite.setCaption(map.get(key));
          break;
        case IMAGE:
          historicSite.setImage(InfoboxUrlParser.infoboxUrl(map.get(key)));
          break;
        case LATD:
          coordinate.setLatD(map.get(key));
          break;
        case LATM:
          coordinate.setLatM(map.get(key));
          break;
        case LATS:
          coordinate.setLatS(map.get(key));
          break;
        case LATNS:
          coordinate.setLatNS(map.get(key));
          break;
        case LONGD:
          coordinate.setLongD(map.get(key));
          break;
        case LONGM:
          coordinate.setLongM(map.get(key));
          break;
        case LONGS:
          coordinate.setLongS(map.get(key));
          break;
        case LONGEW:
          coordinate.setLongEW(map.get(key));
          break;
        case LATDL:
          coordinate.setLatD(map.get(key));
          break;
        case LATML:
          coordinate.setLatM(map.get(key));
          break;
        case LATSL:
          coordinate.setLatS(map.get(key));
          break;
        case LATNSL:
          coordinate.setLatNS(map.get(key));
          break;
        case LONGDL:
          coordinate.setLongD(map.get(key));
          break;
        case LONGML:
          coordinate.setLongM(map.get(key));
          break;
        case LONGSL:
          coordinate.setLongS(map.get(key));
          break;
        case LONGEWL:
          coordinate.setLongEW(map.get(key));
          break;
      }

      historicSite.setCoordinate(coordinate);
    }

    return historicSite;
  }