Package org.htmlparser.util

Examples of org.htmlparser.util.ParserException


            String errorMsg;
            if (tagContents != null)
                errorMsg = tagContents.toString();
            else
                errorMsg = "null";
            throw new ParserException(
                "Tag.scan() : Error while scanning tag, tag contents = "
                    + errorMsg
                    + ", tagLine = "
                    + tagLine,
                e);
View Full Code Here


                }

                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

            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 errorMsg;
            if (tagContents != null)
                errorMsg = tagContents.toString();
            else
                errorMsg = "null";
            throw new ParserException(
                "Tag.scan() : Error while scanning tag, tag contents = "
                    + errorMsg
                    + ", tagLine = "
                    + tagLine,
                e);
View Full Code Here

            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

                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

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

                                + 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

                    mMark = -1;
                    if (0 != offset)
                    {
                        new_chars = new char[offset];
                        if (offset != read (new_chars))
                            throw new ParserException ("reset stream failed");
                        for (int i = 0; i < offset; i++)
                            if (new_chars[i] != buffer[i])
                                throw new EncodingChangeException ("character mismatch (new: "
                                + new_chars[i]
                                + " [0x"
                                + Integer.toString (new_chars[i], 16)
                                + "] != old: "
                                + " [0x"
                                + Integer.toString (buffer[i], 16)
                                + buffer[i]
                                + "]) for encoding change from "
                                + encoding
                                + " to "
                                + character_set
                                + " at character offset "
                                + i);
                    }
                }
                catch (IOException ioe)
                {
                    throw new ParserException (ioe.getMessage (), ioe);
                }
            }
            catch (IOException ioe)
            {   // bug #1044707 mark()/reset() issues
                throw new ParserException ("Stream reset failed ("
                    + ioe.getMessage ()
                    + "), try wrapping it with a org.htmlparser.lexer.Stream",
                    ioe);
            }
        }
View Full Code Here

        {
            getConnection ().connect ();
        }
        catch (UnknownHostException uhe)
        {
            throw new ParserException ("Connect to "
                + mConnection.getURL ().toExternalForm () + " failed.", uhe);
        }
        catch (IOException ioe)
        {
            throw new ParserException ("Exception connecting to "
                + mConnection.getURL ().toExternalForm ()
                + " (" + ioe.getMessage () + ").", ioe);
        }
        type = getContentType ();
        charset = getCharset (type);
        try
        {
            contentEncoding = connection.getContentEncoding();
            if ((null != contentEncoding)
                && (-1 != contentEncoding.indexOf ("gzip")))
            {
                stream = new Stream (new GZIPInputStream (
                    getConnection ().getInputStream ()));
            }
            else if ((null != contentEncoding)
                && (-1 != contentEncoding.indexOf ("deflate")))
            {
                stream = new Stream (new InflaterInputStream (
                    getConnection ().getInputStream (), new Inflater (true)));
            }
            else
            {
                stream = new Stream (getConnection ().getInputStream ());
            }

            try
            {
                mSource = new InputStreamSource (stream, charset);
            }
            catch (UnsupportedEncodingException uee)
            {
//                StringBuffer msg;
//
//                msg = new StringBuffer (1024);
//                msg.append (getConnection ().getURL ().toExternalForm ());
//                msg.append (" has an encoding (");
//                msg.append (charset);
//                msg.append (") which is not supported, using ");
//                msg.append (DEFAULT_CHARSET);
//                System.out.println (msg.toString ());
                charset = DEFAULT_CHARSET;
                mSource = new InputStreamSource (stream, charset);
            }
        }
        catch (IOException ioe)
        {
            throw new ParserException ("Exception getting input stream from "
                + mConnection.getURL ().toExternalForm ()
                + " (" + ioe.getMessage () + ").", ioe);
        }
        mUrl = connection.getURL ().toExternalForm ();
        mIndex = new PageIndex (this);
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.