Changeset 31851 in osm for applications/editors/josm/plugins/wikipedia/src
- Timestamp:
- 2015-12-22T19:02:25+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaApp.java
r31850 r31851 5 5 import java.io.InputStream; 6 6 import java.io.OutputStreamWriter; 7 import java.io.UnsupportedEncodingException;8 7 import java.net.HttpURLConnection; 9 8 import java.net.URL; 10 import java.net.URLDecoder;11 import java.net.URLEncoder;12 9 import java.util.AbstractList; 13 10 import java.util.ArrayList; … … 173 170 "?action=query" + 174 171 "&prop=langlinks" + 175 "&titles=" + U RLEncoder.encode(article, "UTF-8") +172 "&titles=" + Utils.encodeUrl(article) + 176 173 "&lllimit=500" + 177 174 "&format=xml"; … … 206 203 } 207 204 // decode URL for nicer value 208 url = decodeURL(url);205 url = Utils.decodeUrl(url); 209 206 // extract Wikipedia language and 210 207 final Matcher m = Pattern.compile("(https?:)?//(\\w*)\\.wikipedia\\.org/wiki/(.*)").matcher(url); … … 224 221 //wikipedia=[lang]:[article] 225 222 //wikipedia:[lang]=[lang]:[article] 226 final String[] item = decodeURL(value).split(":", 2);223 final String[] item = Utils.decodeUrl(value).split(":", 2); 227 224 final String article = item[1].replace("_", " "); 228 225 return new WikipediaLangArticle(item[0], article); … … 231 228 //wikipedia:[lang]=[article] 232 229 final String lang = key.split(":", 2)[1]; 233 final String[] item = decodeURL(value).split(":", 2);230 final String[] item = Utils.decodeUrl(value).split(":", 2); 234 231 final String article = item[item.length == 2 ? 1 : 0].replace("_", " "); 235 232 return new WikipediaLangArticle(lang, article); … … 341 338 } 342 339 343 public static String decodeURL(String url) {344 try {345 return URLDecoder.decode(url, "UTF-8");346 } catch (UnsupportedEncodingException ex) {347 throw new IllegalStateException(ex);348 }349 }350 351 340 public static <T> List<List<T>> partitionList(final List<T> list, final int size) { 352 341 return new AbstractList<List<T>>() {
Note:
See TracChangeset
for help on using the changeset viewer.