private int countResults(InputStream s) throws SocketTimeoutException {
   ResultHandler handler = new ResultHandler();
   int count = 0;
   try {
     SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
     //		  ByteArrayInputStream bis = new ByteArrayInputStream(s.getBytes("UTF-8"));
     saxParser.parse(s, handler);
     count = handler.getCount();
   } catch (SocketTimeoutException e) {
     throw new SocketTimeoutException();
   } catch (Exception e) {
     System.err.println("SAX Error");
     e.printStackTrace();
     return -1;
   }
   return count;
 }
Ejemplo n.º 2
0
 public ResponderResult call() throws Exception {
   logger.debug("started responder thread");
   runResponder();
   if (null != resultHandler && !Thread.currentThread().isInterrupted()) {
     resultHandler.handleResult(success, failureReason);
   }
   return new ResponderResult(responder, failureReason, success, Thread.interrupted());
 }