/**
   * @param stop
   * @param format {0} - ref, {1} - type, {2} - name, {3} - name_en
   * @return null if something goes wrong
   */
  @Override
  public List<String> getRouteDescriptionsForStop(TransportStop stop, String format) {
    assert acceptTransportStop(stop);
    long now = System.currentTimeMillis();

    MessageFormat f = new MessageFormat(format);
    List<String> res = new ArrayList<String>();
    try {
      List<TransportRoute> routes = file.getTransportRouteDescriptions(stop);
      if (routes != null) {
        for (TransportRoute route : routes) {
          res.add(
              f.format(
                  new String[] {
                    route.getRef() + "",
                    route.getType() + "",
                    route.getName() + "",
                    route.getEnName() + ""
                  })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        }
      }
    } catch (IOException e) {
      log.error("Disk error ", e); // $NON-NLS-1$
    }

    if (log.isDebugEnabled()) {
      log.debug(
          String.format(
              "Search for stop %s done in %s ms found %s.", //$NON-NLS-1$
              stop.getId() + "", System.currentTimeMillis() - now, res.size())); // $NON-NLS-1$
    }
    return res;
  }
コード例 #2
0
  private void insertTransportIntoIndex(TransportRoute route) throws SQLException {
    transRouteStat.setLong(1, route.getId());
    transRouteStat.setString(2, route.getType());
    transRouteStat.setString(3, route.getOperator());
    transRouteStat.setString(4, route.getRef());
    transRouteStat.setString(5, route.getName());
    transRouteStat.setString(6, route.getEnName());
    transRouteStat.setInt(7, route.getAvgBothDistance());
    addBatch(transRouteStat);

    writeRouteStops(route, route.getForwardStops(), true);
    writeRouteStops(route, route.getBackwardStops(), false);
  }