Package javax.swing.text.html.parser

Examples of javax.swing.text.html.parser.ParserDelegator


       
        StringReader sourceReader = new StringReader(content);
       
        HTMLEditorKit htmlKit = new HTMLEditorKit();
        HTMLDocument htmlDoc = (HTMLDocument)htmlKit.createDefaultDocument();
        HTMLEditorKit.Parser parser = new ParserDelegator();
        final HTMLEditorKit.ParserCallback docCallback = htmlDoc.getReader(0);
       
        HTMLEditorKit.ParserCallback callback = new HTMLEditorKit.ParserCallback() {

            @Override
            public void flush() throws BadLocationException {
                docCallback.flush();
            }

            @Override
            public void handleComment(char[] data, int pos) {
                docCallback.handleComment(data, pos);
            }

            @Override
            public void handleEndOfLineString(String eol) {
                docCallback.handleEndOfLineString(eol);
            }

            @Override
            public void handleEndTag(Tag t, int pos) {
                docCallback.handleEndTag(t, pos);
            }

            @Override
            public void handleError(String errorMsg, int pos) {
                docCallback.handleError(errorMsg, pos);
                if (errorMsg.startsWith("req.att") ||
                    errorMsg.startsWith("invalid.tagatt") ||
                    errorMsg.startsWith("javascript") ||
                    errorMsg.startsWith("tag.unrecognized") ||
                    errorMsg.startsWith("end.unrecognized") ||
                    // Java 5
                    errorMsg.startsWith("tag.ignore") ||
                    // Java 6 (beta2)
                    errorMsg.startsWith("unmatched.endtag script")) {
                   
                    if (SHOW_DEBUGGING_OUTPUT) {
                        System.out.println("Spurious error: " + errorMsg);
                    }
                } else {
                    fail("Failed to parse: " + errorMsg);
                }
            }

            @Override
            public void handleSimpleTag(Tag t, MutableAttributeSet a, int pos) {
                docCallback.handleSimpleTag(t, a, pos);
            }

            @Override
            public void handleStartTag(Tag t, MutableAttributeSet a, int pos) {
                docCallback.handleStartTag(t, a, pos);
            }

            @Override
            public void handleText(char[] data, int pos) {
                docCallback.handleText(data, pos);
            }
        };
       
        try {
            parser.parse(sourceReader, callback, true);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
       
        ////
View Full Code Here


                                        }
                                    }
                                };
                        try {
                            // Call the parse method
                            new ParserDelegator().parse(readerSTR, callback, false);

                        } catch (IOException e1) {
                            e1.printStackTrace();
                        }
                        // After everything is done, you can dispose the jframe
View Full Code Here

    if (pURL.checkExistsOnly  ||  pURL.isExtern) {
      stream.close();
    } else {
      BufferedInputStream bStream = new BufferedInputStream(stream, 4096);
      ParserDelegator parser = new ParserDelegator();
      HTMLEditorKit.ParserCallback callback = new URLChecker(pURL);
      parser.parse(new InputStreamReader(bStream), callback, false);
      bStream.close();
    }
    logger.finest(mName, "<-");
  }
View Full Code Here

        writer.write();
    }

    protected Parser getParser() {
        if (parser == null) {
            parser = new ParserDelegator();
        }

        return parser;
    }
View Full Code Here

        if (source != null && TARGET_SELF.equals(target)) {
            processTarget(source, src);
        } else if (source != null && TARGET_PARENT.equals(target)) {
            final Element parent = source.getParentElement();
            if (getParser() == null) {
                setParser(new ParserDelegator());
            }
            try {
                setOuterHTML(parent, "<frame src=\"" + src + "\">");
            } catch (BadLocationException e) {
            } catch (IOException e) {
View Full Code Here

        if (source != null && TARGET_SELF.equals(target)) {
            processTarget(source, src);
        } else if (source != null && TARGET_PARENT.equals(target)) {
            final Element parent = source.getParentElement();
            if (getParser() == null) {
                setParser(new ParserDelegator());
            }
            try {
                setOuterHTML(parent, "<frame src=\"" + src + "\">");
            } catch (BadLocationException e) {
            } catch (IOException e) {
View Full Code Here

        writer.write();
    }

    protected Parser getParser() {
        if (parser == null) {
            parser = new ParserDelegator();
        }

        return parser;
    }
View Full Code Here

     * @param uri DOCUMENT ME!
     *
     * @throws IOException DOCUMENT ME!
     */
    public HTML(String uri) throws IOException {
        ParserDelegator pd = new ParserDelegator();
        htmlHandler = new HTMLHandler();
        pd.parse(getReader(uri), htmlHandler, true);
    }
View Full Code Here

    /**
     * Parses a URI.
     */
    public void parse(URI uri) throws ParseException {
        try {
            ParserDelegator delagator = new ParserDelegator();
            handler = new SwingHTMLHandler();

            Reader reader = new PreParser().parse(getReader(uri));
            delagator.parse(reader, handler, true);
        } catch (IOException e) {
            throw new ParseException(e);
        }
    }
View Full Code Here

        assertSpec(spec, ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, new char[]{' '});
    }
   
    public static void loadDocument(final HTMLDocument doc, final String content) throws Exception {
        final ParserCallback reader = doc.getReader(0);
        new ParserDelegator().parse(new StringReader(content), reader, true);
        reader.flush();
    }
View Full Code Here

TOP

Related Classes of javax.swing.text.html.parser.ParserDelegator

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.