Package org.htmlparser.util

Examples of org.htmlparser.util.ParserException


            oMtrs = oMatcher.getMatch();
            if (oMtrs!=nullsMatch = oMtrs.toString();
          }
        } // fi
        if (sMatch.length()==0)
          throw new ParserException("Match could not be retrieved for pattern " + sPattern);       
        int iDquote = sMatch.indexOf('"');
        int iSquote = sMatch.indexOf("'");
        char cQuote = (char) 0;
        if (iDquote>0 && iSquote>0)
          cQuote = iDquote<iSquote ? (char)34 : (char)39;
        else if (iDquote>0)
          cQuote = (char)34;
        else if (iSquote>0)
          cQuote = (char)39;
    if (cQuote==(char)0)
          oSrcSubs.setSubstitution(sMatch.substring(0,sAttributeName.length())+"="+sNewValue);
        else
          oSrcSubs.setSubstitution(sMatch.substring(0,sAttributeName.length())+"="+cQuote+sNewValue+cQuote);
      if (DebugFile.trace) DebugFile.writeln("Util.substitute("+sPattern+","+sMatch.substring(0,sAttributeName.length())+"="+cQuote+sNewValue+cQuote+")");
      return Util.substitute(oMatcher, oPattern, oSrcSubs, sBase);     
      } else {
        return sBase;
      } // fi (oMatcher.contains())
    } catch (MalformedPatternException mpe) {
      if (DebugFile.trace) {
        DebugFile.writeln("MalformedPatternException " + mpe.getMessage());
        try { DebugFile.writeln(StackTraceUtil.getStackTrace(mpe)); } catch (Exception ignore) { }
      }
      throw new ParserException("MalformedPatternException " + mpe.getMessage()+ " pattern " + sPattern + " substitution " + sNewValue, mpe);       
    }
    catch (ArrayIndexOutOfBoundsException aiob) {
      String sStack = "";
      try { sStack =  StackTraceUtil.getStackTrace(aiob); } catch (Exception ignore) { }
      if (DebugFile.trace) {
        DebugFile.writeln("ArrayIndexOutOfBoundsException " + aiob.getMessage());
        DebugFile.writeln(sStack);
      }
      int iAt = sStack.indexOf("at ");
      if (iAt>0) {
        int iLf = sStack.indexOf("\n",iAt);
        if (iLf>iAt)
          throw new ParserException("ArrayIndexOutOfBoundsException " + sStack.substring(iAt,iLf) + " " + aiob.getMessage()+ " attribute " + sAttributeName + " pattern " + sPattern + " match " + sMatch + " former value " + sFormerValue + " substitution " + sNewValue, aiob);
        else
          throw new ParserException("ArrayIndexOutOfBoundsException " + sStack.substring(iAt) + " " + aiob.getMessage()+ " attribute " + sAttributeName + " pattern " + sPattern + " match " + sMatch + " former value " + sFormerValue + " substitution " + sNewValue, aiob);         
      } else {
        throw new ParserException("ArrayIndexOutOfBoundsException " + aiob.getMessage()+ " attribute " + sAttributeName + " pattern " + sPattern + " match " + sMatch + " former value " + sFormerValue + " substitution " + sNewValue, aiob);
      }
    }
  } // doSubstitution
View Full Code Here


            String msg;
            if (tag != null)
                msg = tag.getText();
            else
                msg = "null";
            throw new ParserException(
                "HTMLLinkScanner.extractLink() : Error while extracting link from tag "
                    + msg
                    + ", url = "
                    + url,
                e);
View Full Code Here

        catch (IOException ioe)
        {
            String msg =
                "HTMLParser.openConnection() : Error in opening a connection to "
                    + url.toExternalForm();
            ParserException ex = new ParserException(msg, ioe);
            if (null != feedback)
                feedback.error(msg, ex);
            throw ex;
        }
View Full Code Here

            catch (MalformedURLException murle2)
            {
                String msg =
                    "HTMLParser.openConnection() : Error in opening a connection to "
                        + string;
                ParserException ex = new ParserException(msg, murle2);
                if (null != feedback)
                    feedback.error(msg, ex);
                throw ex;
            }
            catch (IOException ioe)
            {
                String msg =
                    "HTMLParser.openConnection() : Error in opening a connection to "
                        + string;
                ParserException ex = new ParserException(msg, ioe);
                if (null != feedback)
                    feedback.error(msg, ex);
                throw ex;
            }
        }
View Full Code Here

            String msg;
            if (tag != null)
                msg = tag.getText();
            else
                msg = "null";
            throw new ParserException(
                "HTMLFrameScanner.extractFrameLocn() : Error in extracting frame location from tag "
                    + msg,
                e);
        }
    }
View Full Code Here

            else
                return processor.extract(relativeLink, url);
        }
        catch (Exception e)
        {
            throw new ParserException(
                "HTMLImageScanner.extractImageLocn() : Error in extracting image location, relativeLink = "
                    + relativeLink
                    + ", url = "
                    + url,
                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

        {
            crawl(parser, crawlDepth);
        }
        catch (ParserException e)
        {
            throw new ParserException(
                "HTMLParserException at crawl(" + crawlDepth + ")",
                e);
        }
    }
View Full Code Here

        {
            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);
View Full Code Here

            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;
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.