Package org.htmlparser.util

Examples of org.htmlparser.util.ParserException


          } while (node instanceof StringNode);

        }

        catch (Exception e) {
          throw new ParserException("HTMLTagScanner.extractXMLData() : error while trying to find xml tag", e);
        }
      }
      if (xmlTagFound) {
        if (node != null) {
          if (node instanceof org.htmlparser.tags.EndTag) {
            org.htmlparser.tags.EndTag endTag = (org.htmlparser.tags.EndTag) node;
            if (!endTag.getText().equals(tagName))
              xmlTagFound = false;
          }

        }

      }
      if (xmlTagFound)
        return xmlData;
      else
        return null;
    } catch (Exception e) {
      throw new ParserException(
          "HTMLTagScanner.extractXMLData() : Error occurred while trying to extract xml tag", e);
    }
  }
View Full Code Here


      if (relativeLink == null)
        return "";
      else
        return processor.extract(relativeLink, url);
    } catch (Exception e) {
      throw new ParserException(
          "HTMLbgsoundScanner.extractbgsoundLocn() : Error in extracting image location, relativeLink = "
              + relativeLink + ", url = " + url, e);
    }
  }
View Full Code Here

        character_set = getCharacterSet(url_conn);
        createReader();
      } catch (IOException ioe) {
        String msg = "setConnection() : Error in opening a connection to "
            + connection.getURL().toExternalForm();
        ParserException ex = new ParserException(msg, ioe);
        feedback.error(msg, ex);
        resourceLocn = res;
        url_conn = con;
        character_set = chs;
        reader = rd;
View Full Code Here

          character_set = encoding;
          recreateReader();
        } catch (IOException ioe) {
          String msg = "setEncoding() : Error in opening a connection to "
              + getConnection().getURL().toExternalForm();
          ParserException ex = new ParserException(msg, ioe);
          feedback.error(msg, ex);
          character_set = chs;
          reader = rd;
          input = in;
          throw ex;
View Full Code Here

          }
        }
      } catch (UnsupportedEncodingException uee) {
        String msg = "elements() : The content of " + url_conn.getURL().toExternalForm()
            + " has an encoding which is not supported";
        ParserException ex = new ParserException(msg, uee);
        feedback.error(msg, ex);
        throw ex;
      } catch (IOException ioe) {
        String msg = "elements() : Error in opening a connection to " + url_conn.getURL().toExternalForm();
        ParserException ex = new ParserException(msg, ioe);
        feedback.error(msg, ex);
        throw ex;
      } finally {
        if (remove_scanner)
          scanners.remove("-m");
View Full Code Here

          } catch (Exception e) {
            StringBuffer msgBuffer = new StringBuffer();
            msgBuffer.append(DECIPHER_ERROR + "\n" + "    Tag being processed : " + tag.getTagName() + "\n"
                + "    Current Tag Line : " + tag.getTagLine());
            appendLineDetails(msgBuffer);
            ParserException ex = new ParserException(msgBuffer.toString(), e);

            parser.getFeedback().error(msgBuffer.toString(), ex);
            throw ex;
          }
        }

        node = EndTag.find(line, posInLine);
        if (node != null)
          return node;
      } else {
        node = stringParser.find(this, line, posInLine, balance_quotes);
        if (node != null)
          return node;
      }

      return null;
    } catch (ParserException pe) {
      throw pe;
    } catch (Exception e) {
      StringBuffer msgBuffer = new StringBuffer(
          "NodeReader.readElement() : Error occurred while trying to read the next element,");
      StringWriter sw = new StringWriter();
      e.printStackTrace(new PrintWriter(sw));
      appendLineDetails(msgBuffer);
      msgBuffer.append("\n Caused by:\n").append(sw.getBuffer().toString());
      ParserException ex = new ParserException(msgBuffer.toString(), e);
      parser.getFeedback().error(msgBuffer.toString(), ex);
      throw ex;
    }
  }
View Full Code Here

  public void testElementsFromWeb() throws Exception {
    Parser parser;
    try {
      parser = new Parser("http://www.google.com");
    } catch (Exception e) {
      throw new ParserException("You must be offline! This test needs you to be connected to the internet.", e);
    }
    parser.getReader().mark(5000);

    Node[] node = new Node[500];
    int i = 0;
View Full Code Here

      out = new PrintWriter(connection.getOutputStream());
      out.print(buffer);
      out.close();
      parser = new Parser(connection);
    } catch (Exception e) {
      throw new ParserException("You must be offline! This test needs you to be connected to the internet.", e);
    }

    pass = false;
    for (enumeration = parser.elements(); enumeration.hasMoreNodes();) {
      node = enumeration.nextNode();
View Full Code Here

    imgTagCount = findImageTagCount();
    try {
      int parserImgTagCount = countImageTagsWithHTMLParser();
      assertEquals("Image Tag Count", imgTagCount, parserImgTagCount);
    } catch (ParserException e) {
      throw new ParserException("Error thrown in call to countImageTagsWithHTMLParser()", e);
    }

  }
View Full Code Here

      String msg;
      if (tag != null)
        msg = tag.getText();
      else
        msg = "";
      throw new ParserException("HTMLFormScanner.extractFormLocn() : Error in extracting form location, tag = "
          + msg + ", url = " + url, e);
    }
  }
View Full Code Here

TOP

Related Classes of org.htmlparser.util.ParserException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.