Package javax.swing.text.html.HTMLEditorKit

Examples of javax.swing.text.html.HTMLEditorKit.ParserCallback


  private static List<String> extractText(Reader reader) throws IOException {
    final ArrayList<String> list = new ArrayList<String>();

    ParserDelegator parserDelegator = new ParserDelegator();
    ParserCallback parserCallback = new ParserCallback() {
      public void handleText(final char[] data, final int pos) {
        list.add(new String(data));
      }

      public void handleStartTag(Tag tag, MutableAttributeSet attribute, int pos) {
View Full Code Here


            return;
        }
        final String str = "<P>link</P>";
        init();
        editable = false;
        ParserCallback reader = doc.getReader(0, 2, 3, Tag.P);
        SimpleAttributeSet attr = new SimpleAttributeSet();
        attr.addAttribute(StyleConstants.NameAttribute, Tag.S.toString());
        doc.insertString(0, "0000", attr);
        assertFalse(insertMarker.isOccurred());
        parse(str, reader);
        reader.flush();
        assertTrue(insertMarker.isOccurred());
        ElementSpec[] specs = (ElementSpec[])insertMarker.getAuxiliary();
        String specsDescr = "cpeoeosnsnsnsoco";
        assertEquals(specsDescr.length()/2, specs.length);
        insertMarker.reset();
View Full Code Here

    }
   
    private void checkConstructorTagParameter(final Tag tag, final String str, final int numSpecs) throws Exception {
        init();
        editable = false;
        ParserCallback reader = doc.getReader(0, 0, 0, tag);
        SimpleAttributeSet attr = new SimpleAttributeSet();
        attr.addAttribute(StyleConstants.NameAttribute, Tag.B.toString());
        doc.insertString(0, "0000", attr);
        assertFalse("no inserts", insertMarker.isOccurred());
        parse(str, reader);
        reader.flush();
        if (numSpecs == 0 && isHarmony()) {
            assertFalse("inserted", insertMarker.isOccurred());
        } else {
            assertTrue("inserted", insertMarker.isOccurred());
            ElementSpec[] specs = (ElementSpec[])insertMarker.getAuxiliary();
View Full Code Here

            protected void insert(int offset, ElementSpec[] data) throws BadLocationException {
                insertMarker.setOccurred();
                insertMarker.setAuxiliary(new Integer(offset));
            }
        };
        ParserCallback reader = doc.getReader(offset, 0, 0, tag);
        parse(str, reader);
        reader.flush();
        assertTrue(insertMarker.isOccurred());
        assertEquals(new Integer(offset), insertMarker.getAuxiliary());
    }
View Full Code Here

    }
   
    private void checkConstructorPopPushParameter(final Tag tag, final String str, final int pop, final int push, final String specsDescr) throws Exception {
        init();
        editable = false;
        ParserCallback reader = doc.getReader(0, pop, push, tag);
        SimpleAttributeSet attr = new SimpleAttributeSet();
        attr.addAttribute(StyleConstants.NameAttribute, Tag.S.toString());
        doc.insertString(0, "0000", attr);
        assertFalse(insertMarker.isOccurred());
        parse(str, reader);
        reader.flush();
        assertTrue(insertMarker.isOccurred());
        ElementSpec[] specs = (ElementSpec[])insertMarker.getAuxiliary();
        assertEquals(specsDescr.length()/2, specs.length);
        insertMarker.reset();
        for (int i = 0; i < specs.length; i++) {
View Full Code Here

        }
    }

    private void checkConstructorOffsetPopPushParameter(final Tag tag, final String str, final int offset, final int pop, final int push, final String specsDescr) throws Exception {
        init();
        ParserCallback reader = doc.getReader(offset, pop, push, tag);
        SimpleAttributeSet attr = new SimpleAttributeSet();
        attr.addAttribute(StyleConstants.NameAttribute, Tag.S.toString());
        editable = false;
        insertMarker.reset();
        parse(str, reader);
        reader.flush();
        assertTrue(insertMarker.isOccurred());
        ElementSpec[] specs = (ElementSpec[])insertMarker.getAuxiliary();
        assertEquals(specsDescr.length()/2, specs.length);
        insertMarker.reset();
        for (int i = 0; i < specs.length; i++) {
View Full Code Here

    public static void checkImplicitContentSpec(ElementSpec spec) {
        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

            return;
        }
        final String str = "<P>link</P>";
        init();
        editable = false;
        ParserCallback reader = doc.getReader(0, 2, 3, Tag.P);
        SimpleAttributeSet attr = new SimpleAttributeSet();
        attr.addAttribute(StyleConstants.NameAttribute, Tag.S.toString());
        doc.insertString(0, "0000", attr);
        assertFalse(insertMarker.isOccurred());
        parse(str, reader);
        reader.flush();
        assertTrue(insertMarker.isOccurred());
        ElementSpec[] specs = (ElementSpec[])insertMarker.getAuxiliary();
        String specsDescr = "cpeoeosnsnsnsoco";
        assertEquals(specsDescr.length()/2, specs.length);
        insertMarker.reset();
View Full Code Here

    }
   
    private void checkConstructorTagParameter(final Tag tag, final String str, final int numSpecs) throws Exception {
        init();
        editable = false;
        ParserCallback reader = doc.getReader(0, 0, 0, tag);
        SimpleAttributeSet attr = new SimpleAttributeSet();
        attr.addAttribute(StyleConstants.NameAttribute, Tag.B.toString());
        doc.insertString(0, "0000", attr);
        assertFalse("no inserts", insertMarker.isOccurred());
        parse(str, reader);
        reader.flush();
        if (numSpecs == 0 && isHarmony()) {
            assertFalse("inserted", insertMarker.isOccurred());
        } else {
            assertTrue("inserted", insertMarker.isOccurred());
            ElementSpec[] specs = (ElementSpec[])insertMarker.getAuxiliary();
View Full Code Here

            protected void insert(int offset, ElementSpec[] data) throws BadLocationException {
                insertMarker.setOccurred();
                insertMarker.setAuxiliary(new Integer(offset));
            }
        };
        ParserCallback reader = doc.getReader(offset, 0, 0, tag);
        parse(str, reader);
        reader.flush();
        assertTrue(insertMarker.isOccurred());
        assertEquals(new Integer(offset), insertMarker.getAuxiliary());
    }
View Full Code Here

TOP

Related Classes of javax.swing.text.html.HTMLEditorKit.ParserCallback

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.