Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public List<String> proces(String content)
- {
- List<String> versions = new ArrayList<String>();
- try
- {
- Pattern pattern = Pattern.compile("<a\\b[^>]*href=\"[^>]*>(.*?)/</a>");
- Matcher matcher = pattern.matcher(content);
- int mIdx = 0;
- while (matcher.find())
- {
- mIdx++;
- if(mIdx == 1)
- {
- continue;
- }
- String rawVersion = matcher.group(1);
- if(include(rawVersion))
- {
- versions.add(rawVersion);
- }
- }
- }
- catch (Exception e)
- {
- throw new RuntimeException("Could not extract version numbers", e);
- }
- return versions;
- }
- private boolean include(String rawVersion)
- {
- return !rawVersion.matches(".*(SP1|SP2|SP3|OSGi).*");
- }
- HttpGet get = new HttpGet(url.toExternalForm());
- try
- {
- return client.execute(get, new ResponseHandler<T>()
- {
- @Override
- public T handleResponse(HttpResponse response) throws ClientProtocolException, IOException
- {
- StringBuilder content = new StringBuilder();
- BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
- String line;
- while( (line = in.readLine()) != null)
- {
- content.append(line);
- }
- in.close();
- return handler.proces(content.toString());
- }
- });
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement