package com.yourblogz.busstop;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yourblogz.busstop.consts.Consts;

public class BusstopLocationGenerator {
    
    private final String uid;
    private int connectTimeout;
    private static final Logger log = LoggerFactory.getLogger(BusstopLocationGenerator.class);

    public BusstopLocationGenerator(String uid) {
        this.uid = uid;
    }
    
    public void generate(Busstop busstop) {
        try {
            Document doc = Jsoup.connect(String.format(Consts.BUSSTOP_LOCATION_REQUEST_URL, uid))
                                .ignoreContentType(true)
                                .timeout(connectTimeout)
                                .get();
            JSONObject result = (JSON.parseObject(doc.select("body").text().trim())).getJSONObject("content");
            if (result != null) {
                busstop.setPassBusses(result.getString("addr"));
                String[] xy = (result.getString("geo").split("\\|")[2]).split(",");
                busstop.setLng(xy[0]);
                busstop.setLat(xy[1].replaceAll(";", ""));
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }

    public int getConnectTimeout() {
        return connectTimeout;
    }

    public BusstopLocationGenerator setConnectTimeout(int connectionTimeout) {
        this.connectTimeout = connectionTimeout;
        return this;
    }
    
}

@@ -52,16 +52,18 @@
 Jsoup;%0D%0A
+%0D%0A
 import o
@@ -272,16 +272,52 @@
 sts;%0D%0A%0D%0A
+/**%0D%0A * %3Cp%3E%E6%A0%B9%E6%8D%AE%E5%85%AC%E4%BA%A4%E7%AB%99%E7%82%B9%E7%9A%84UID%E8%8E%B7%E5%8F%96%E5%9D%90%E6%A0%87%3C/p%3E%0D%0A */%0D%0A
 public c

Change class description