javax.swing.JEditorPane Java Examples

The following examples show how to use javax.swing.JEditorPane. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DrawEngineTest.java    From netbeans with Apache License 2.0 7 votes vote down vote up
@RandomlyFails
public void testModelToViewCorrectness() throws Throwable {
    for(String text : TEXTS) {
        JEditorPane jep = createJep(text);
        try {
            checkModelToViewCorrectness(jep);
        } catch (Throwable e) {
            System.err.println("testModelToViewCorrectness processing {");
            System.err.println(text);
            System.err.println("} failed with:");
            e.printStackTrace();
            throw e;
        } finally {
            JFrame frame = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, jep);
            if (frame != null) {
                frame.dispose();
            }
        }
    }
}
 
Example #2
Source File: InitializeOnBackgroundTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@RandomlyFails // NB-Core-Build #1981, #1984
public void testInitializeOnBackground() throws Exception {
    support.open();
    
    class R implements Runnable {
        JEditorPane p;
        public void run() {
            p = support.getOpenedPanes()[0];
        }
    }
    R r = new R();
    SwingUtilities.invokeAndWait(r);
    assertNotNull(r.p);
    
    if (r.p.getEditorKit() instanceof NbLikeEditorKit) {
        NbLikeEditorKit nb = (NbLikeEditorKit)r.p.getEditorKit();
        assertNotNull("call method called", nb.callThread);
        if (nb.callThread.getName().contains("AWT")) {
            fail("wrong thread: " + nb.callThread);
        }
    } else {
        fail("Should use NbLikeEditorKit: " + r.p.getEditorKit());
    }
}
 
Example #3
Source File: StyledEditorKit.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Sets the font size.
 *
 * @param e the action event
 */
public void actionPerformed(ActionEvent e) {
    JEditorPane editor = getEditor(e);
    if (editor != null) {
        int size = this.size;
        if ((e != null) && (e.getSource() == editor)) {
            String s = e.getActionCommand();
            try {
                size = Integer.parseInt(s, 10);
            } catch (NumberFormatException nfe) {
            }
        }
        if (size != 0) {
            MutableAttributeSet attr = new SimpleAttributeSet();
            StyleConstants.setFontSize(attr, size);
            setCharacterAttributes(editor, attr, false);
        } else {
            UIManager.getLookAndFeel().provideErrorFeedback(editor);
        }
    }
}
 
Example #4
Source File: HTMLPanel.java    From littleluck with Apache License 2.0 6 votes vote down vote up
public void hyperlinkUpdate(HyperlinkEvent event) {
    JEditorPane descriptionPane = (JEditorPane) event.getSource();
    HyperlinkEvent.EventType type = event.getEventType();
    if (type == HyperlinkEvent.EventType.ACTIVATED) {
        try {
            DemoUtilities.browse(event.getURL().toURI());
        } catch (Exception e) {
            e.printStackTrace();
            System.err.println(e);
        }

    } else if (type == HyperlinkEvent.EventType.ENTERED) {
        defaultCursor = descriptionPane.getCursor();
        descriptionPane.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    } else if (type == HyperlinkEvent.EventType.EXITED) {
        descriptionPane.setCursor(defaultCursor);
    }
}
 
Example #5
Source File: CompletionTestCase.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**Currently, this method is supposed to be runned inside the AWT thread.
 * If this condition is not fullfilled, an IllegalStateException is
 * thrown. Do NOT modify this behaviour, or deadlock (or even Swing
 * or NetBeans winsys data corruption) may occur.
 *
 * Currently threading model of this method is compatible with
 * editor code completion threading model. Revise if this changes
 * in future.
 */
private void testPerform(PrintWriter out, PrintWriter log,
        JEditorPane editor,
        boolean unsorted,
        String assign,
        int lineIndex,
        int queryType) throws BadLocationException, IOException {
    if (!SwingUtilities.isEventDispatchThread())
        throw new IllegalStateException("The testPerform method may be called only inside AWT event dispatch thread.");
    
    BaseDocument doc        = Utilities.getDocument(editor);
    int          lineOffset = Utilities.getRowStartFromLineOffset(doc, lineIndex -1);
    
    editor.grabFocus();
    editor.getCaret().setDot(lineOffset);
    doc.insertString(lineOffset, assign, null);
    reparseDocument((DataObject) doc.getProperty(doc.StreamDescriptionProperty));
    completionQuery(out, log, editor, unsorted, queryType);
}
 
Example #6
Source File: ScriptEditor.java    From ramus with GNU General Public License v3.0 6 votes vote down vote up
@Override
public JComponent createComponent() {
    JScrollPane pane = new JScrollPane();
    editorPane = new JEditorPane();
    pane.setViewportView(editorPane);
    if (scriptPath.endsWith(".js"))
        editorPane.setContentType("text/javascript");
    byte[] bs = framework.getEngine().getStream(scriptPath);
    if (bs == null)
        bs = new byte[]{};
    try {
        editorPane.setText(new String(bs, "UTF-8"));
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    if (!saveScriptAction.isEnabled())
        editorPane.setEditable(false);
    return pane;
}
 
Example #7
Source File: ResourceSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private boolean isExcludedProperty1(FormProperty prop) {
    if (!Boolean.TRUE.equals(prop.getValue(EXCLUSION_DETERMINED))) {
        prop.setValue(EXCLUSION_DETERMINED, true);
        Object propOwner = prop.getPropertyContext().getOwner();
        Class type = null;
        if (propOwner instanceof RADComponent) {
            type = ((RADComponent)propOwner).getBeanClass();
        } else if (propOwner instanceof FormProperty) {
            type = ((FormProperty)propOwner).getValueType();
        }
        String propName = prop.getName();
        boolean excl = (Component.class.isAssignableFrom(type) && "name".equals(propName)) // NOI18N
                || (JEditorPane.class.isAssignableFrom(type) && "contentType".equals(propName)); // NOI18N
        prop.setValue(EXCLUDE_FROM_RESOURCING, excl);
        return excl;
    }
    return false;
}
 
Example #8
Source File: StyledEditorKit.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the font family.
 *
 * @param e the event
 */
public void actionPerformed(ActionEvent e) {
    JEditorPane editor = getEditor(e);
    if (editor != null) {
        String family = this.family;
        if ((e != null) && (e.getSource() == editor)) {
            String s = e.getActionCommand();
            if (s != null) {
                family = s;
            }
        }
        if (family != null) {
            MutableAttributeSet attr = new SimpleAttributeSet();
            StyleConstants.setFontFamily(attr, family);
            setCharacterAttributes(editor, attr, false);
        } else {
            UIManager.getLookAndFeel().provideErrorFeedback(editor);
        }
    }
}
 
Example #9
Source File: EditorContextImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Returns identifier currently selected in editor or <code>null</code>.
 *
 * @return identifier currently selected in editor or <code>null</code>
 */
@Override
public String getSelectedIdentifier () {
    JEditorPane ep = contextDispatcher.getCurrentEditor ();
    if (ep == null) {
        return null;
    }
    Caret caret = ep.getCaret();
    if (caret == null) {
        // No caret => no selected text
        return null;
    }
    String s = ep.getSelectedText ();
    if (s == null) {
        return null;
    }
    if (Utilities.isJavaIdentifier (s)) {
        return s;
    }
    return null;
}
 
Example #10
Source File: HintsPanelLogic.java    From netbeans with Apache License 2.0 6 votes vote down vote up
void connect( JTree errorTree, JComboBox severityComboBox, 
              JCheckBox tasklistCheckBox, JPanel customizerPanel,
              JEditorPane descriptionTextArea) {
    
    this.errorTree = errorTree;
    this.severityComboBox = severityComboBox;
    this.tasklistCheckBox = tasklistCheckBox;
    this.customizerPanel = customizerPanel;
    this.descriptionTextArea = descriptionTextArea;        
    
    valueChanged( null );
    
    errorTree.addKeyListener(this);
    errorTree.addMouseListener(this);
    errorTree.getSelectionModel().addTreeSelectionListener(this);
        
    severityComboBox.addActionListener(this);
    tasklistCheckBox.addChangeListener(this);
    
}
 
Example #11
Source File: bug7189299.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void setup() {
    /**
     * Note the input type is not restricted to "submit". Types "image",
     * "checkbox", "radio" have the same problem.
     */
    html = new JEditorPane("text/html",
            "<html><body><form action=\"http://localhost.cgi\">"
                    + "<input type=submit name=submit value=\"submit\"/>"
                    + "</form></body></html>");
    frame = new JFrame();
    frame.setLayout(new BorderLayout());
    frame.add(html, BorderLayout.CENTER);
    frame.setSize(200, 100);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}
 
Example #12
Source File: RenameWithTimestampChangeTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testRenameTheDocumentWhilechangingTheTimestamp() throws Exception {
    Document doc = edit.openDocument();
    
    assertFalse("Not Modified", edit.isModified());

    doc.insertString(0, "Base change\n", null);
    assertTrue("Is Modified", edit.isModified());
    
    edit.open();
    waitEQ();

    JEditorPane[] arr = getPanes();
    assertNotNull("There is one opened pane", arr);
    
    obj.getFolder().rename("newName");

    assertEquals("Last modified incremented by 10000", lastM + 10000, obj.getPrimaryFile().lastModified().getTime());
    assertTrue("Name contains newName: " + obj.getPrimaryFile(), obj.getPrimaryFile().getPath().contains("newName/"));
    
    waitEQ();
    edit.saveDocument();
    
    if (DD.error != null) {
        fail("Error in dialog:\n" + DD.error);
    }
}
 
Example #13
Source File: JSONMinifyClipboard.java    From minifierbeans with Apache License 2.0 6 votes vote down vote up
protected final void jsonMinify(final Node[] activatedNodes) {
    final EditorCookie editorCookie
            = Utilities.actionsGlobalContext().lookup(EditorCookie.class);

    for (final JEditorPane pane : editorCookie.getOpenedPanes()) {
        if (pane.isShowing()
                && pane.getSelectionEnd() > pane.getSelectionStart()) {
            try {
                StringSelection content = new StringSelection(selectedSourceAsMinify(pane));
                Toolkit.getDefaultToolkit().getSystemClipboard().
                        setContents(content, content);
                return;
            } catch (final HeadlessException e) {
                org.openide.ErrorManager.getDefault().notify(e);
            }
        }
    }
}
 
Example #14
Source File: StyledEditorKit.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the foreground color.
 *
 * @param e the action event
 */
public void actionPerformed(ActionEvent e) {
    JEditorPane editor = getEditor(e);
    if (editor != null) {
        Color fg = this.fg;
        if ((e != null) && (e.getSource() == editor)) {
            String s = e.getActionCommand();
            try {
                fg = Color.decode(s);
            } catch (NumberFormatException nfe) {
            }
        }
        if (fg != null) {
            MutableAttributeSet attr = new SimpleAttributeSet();
            StyleConstants.setForeground(attr, fg);
            setCharacterAttributes(editor, attr, false);
        } else {
            UIManager.getLookAndFeel().provideErrorFeedback(editor);
        }
    }
}
 
Example #15
Source File: JavaViewHierarchyRandomTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testSelectionAndInsertTab() throws Exception {
        loggingOn();
        RandomTestContainer container = createContainer();
        JEditorPane pane = container.getInstance(JEditorPane.class);
        Document doc = pane.getDocument();
        doc.putProperty("mimeType", "text/plain");
        ViewHierarchyRandomTesting.initRandomText(container);
        RandomTestContainer.Context context = container.context();
        DocumentTesting.insert(context, 0,
" osen   \n\n\n  esl\t\ta \t\t \n\n\nabcd\td  m\t\tabcdef\te\t\tab\tcdef\tef\tkojd p\t\t \n\n\n        t\t vpjm\ta\ngooywzmj           q\tugos\tdefy\t   i  xs    us tg z"
        );
        EditorPaneTesting.setCaretOffset(context, 64);
        EditorPaneTesting.moveOrSelect(context, SwingConstants.NORTH, false);
        EditorPaneTesting.moveOrSelect(context, SwingConstants.SOUTH, true);
        DocumentTesting.insert(context, 19, "g");
        EditorPaneTesting.moveOrSelect(context, SwingConstants.EAST, true);
        EditorPaneTesting.moveOrSelect(context, SwingConstants.NORTH, true);
        EditorPaneTesting.moveOrSelect(context, SwingConstants.WEST, true);
        EditorPaneTesting.performAction(context, pane, DefaultEditorKit.deletePrevCharAction);
        EditorPaneTesting.performAction(context, pane, DefaultEditorKit.insertTabAction);
        EditorPaneTesting.moveOrSelect(context, SwingConstants.EAST, false);
        EditorPaneTesting.typeChar(context, 'f');
    }
 
Example #16
Source File: TestSingleMethodSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static boolean canHandle(Node activatedNode) {
    FileObject fileObject = CommandUtils.getFileObject(activatedNode);
    if (fileObject == null) {
        return false;
    }
    PhpProject project = PhpProjectUtils.getPhpProject(fileObject);
    if (project == null) {
        return false;
    }
    final EditorCookie editorCookie = activatedNode.getLookup().lookup(EditorCookie.class);
    if (editorCookie == null) {
        return false;
    }
    JEditorPane pane = Mutex.EVENT.readAccess(new Mutex.Action<JEditorPane>() {
        @Override
        public JEditorPane run() {
            return NbDocument.findRecentEditorPane(editorCookie);
        }

    });
    if (pane == null) {
        return false;
    }
    return getTestMethod(pane.getDocument(), pane.getCaret().getDot()) != null;
}
 
Example #17
Source File: HTMLPrintable.java    From ramus with GNU General Public License v3.0 6 votes vote down vote up
public void loadPage(String url, final ActionListener listener)
        throws IOException {
    this.url = url;
    pane = new JEditorPane();
    pane.setContentType("text/html");
    pane.addPropertyChangeListener("page", new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            generate(0);
            if (listener != null)
                listener.actionPerformed(new ActionEvent(
                        HTMLPrintable.this, 0, "PageLoaded"));
        }
    });
    pane.setPage(url);
}
 
Example #18
Source File: HighlightingManagerTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@RandomlyFails
public void testSimple() {
    JEditorPane pane = new JEditorPane();
    pane.putClientProperty("HighlightsLayerExcludes", "^org\\.netbeans\\.modules\\.editor\\.lib2\\.highlighting\\..*$");
    HighlightingManager hm = HighlightingManager.getInstance(pane);
    assertNotNull("Can't get instance of HighlightingManager", hm);
    HighlightsContainer hc = hm.getHighlights(HighlightsLayerFilter.IDENTITY);
    assertNotNull("Can't get fixed HighlightsContainer", hc);
    assertEquals(0, pane.getDocument().getLength());
    assertFalse("There should be no fixed highlights", hc.getHighlights(0, Integer.MAX_VALUE).moveNext());
}
 
Example #19
Source File: SeaGlassEditorPaneUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * @inheritDoc
 */
@Override
protected void installDefaults() {
    // Installs the text cursor on the component
    super.installDefaults();
    JComponent c = getComponent();
    Object clientProperty =
        c.getClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES);
    if (clientProperty == null) {
        c.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, localTrue);
    }
    updateStyle(getComponent());
}
 
Example #20
Source File: HtmlSpecificRefactoringsProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public boolean canExtractInlineStyle(Lookup lookup) {
    //the editor cookie is in the lookup only if the file is opened in the editor and is active
    EditorCookie ec = lookup.lookup(EditorCookie.class);
    if(ec == null) {
        return false;
    }

    //non-blocking call, return null if no document pane initialized yet
    JEditorPane pane = NbDocument.findRecentEditorPane(ec);
    if(pane == null) {
        return false;
    }
    return canExtractInlineStyle(ec.getDocument(), new OffsetRange(pane.getSelectionStart(), pane.getSelectionEnd()));
}
 
Example #21
Source File: StyledEditorKit.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Toggles the bold attribute.
 *
 * @param e the action event
 */
public void actionPerformed(ActionEvent e) {
    JEditorPane editor = getEditor(e);
    if (editor != null) {
        StyledEditorKit kit = getStyledEditorKit(editor);
        MutableAttributeSet attr = kit.getInputAttributes();
        boolean bold = (StyleConstants.isBold(attr)) ? false : true;
        SimpleAttributeSet sas = new SimpleAttributeSet();
        StyleConstants.setBold(sas, bold);
        setCharacterAttributes(editor, sas, false);
    }
}
 
Example #22
Source File: StyledEditorKit.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void actionPerformed(ActionEvent e) {
    JEditorPane target = getEditor(e);

    if (target != null) {
        if ((!target.isEditable()) || (!target.isEnabled())) {
            UIManager.getLookAndFeel().provideErrorFeedback(target);
            return;
        }
        StyledEditorKit sek = getStyledEditorKit(target);

        if (tempSet != null) {
            tempSet.removeAttributes(tempSet);
        }
        else {
            tempSet = new SimpleAttributeSet();
        }
        tempSet.addAttributes(sek.getInputAttributes());
        target.replaceSelection("\n");

        MutableAttributeSet ia = sek.getInputAttributes();

        ia.removeAttributes(ia);
        ia.addAttributes(tempSet);
        tempSet.removeAttributes(tempSet);
    }
    else {
        // See if we are in a JTextComponent.
        JTextComponent text = getTextComponent(e);

        if (text != null) {
            if ((!text.isEditable()) || (!text.isEnabled())) {
                UIManager.getLookAndFeel().provideErrorFeedback(target);
                return;
            }
            text.replaceSelection("\n");
        }
    }
}
 
Example #23
Source File: UserAnnotationPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void initSourceEditor() {
    sourceEditorPane.setEditorKit(CloneableEditorSupport.getEditorKit(HTML_CONTENT_TYPE));
    // ui
    Font font = new JLabel().getFont();
    sourceEditorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
    sourceEditorPane.setFont(font);
    previewTextPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
    previewTextPane.setFont(font);
}
 
Example #24
Source File: TransferHandlerAnnotationPlaintext.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new plain text transfer handler for the annotation editor.
 *
 * @param editor
 *            the editor instance
 */
public TransferHandlerAnnotationPlaintext(final JEditorPane editor) {
	if (editor == null) {
		throw new IllegalArgumentException("editor must not be null!");
	}
	this.editor = editor;
	this.original = editor.getTransferHandler();
}
 
Example #25
Source File: MultiViewPeer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
JEditorPane getEditorPane() {
    if (model != null) {
        MultiViewElement el = model.getActiveElement();
        if (el != null && el.getVisualRepresentation() instanceof Pane) {
            Pane pane = (Pane)el.getVisualRepresentation();
            return pane.getEditorPane();
        }
    }
    return null;
}
 
Example #26
Source File: TokenMarker.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void install(JEditorPane editor) {
    this.pane = editor;
    pane.addCaretListener(this);
    markTokenAt(editor.getCaretPosition());
    status = Status.INSTALLING;
}
 
Example #27
Source File: MasterMatcherTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testAreas() throws Exception {
    MockServices.setServices(MockMimeLookup.class);
    MockMimeLookup.setInstances(MimePath.EMPTY, new TestMatcher());
    
    AttributeSet EAS = SimpleAttributeSet.EMPTY;
    JEditorPane c = new JEditorPane();
    Document d = c.getDocument();
    OffsetsBag bag = new OffsetsBag(d);
    d.insertString(0, "text text { text } text", null);

    c.putClientProperty(MasterMatcher.PROP_MAX_BACKWARD_LOOKAHEAD, 256);
    c.putClientProperty(MasterMatcher.PROP_MAX_FORWARD_LOOKAHEAD, 256);
    
    TestMatcher.origin = new int [] { 2, 3 };
    TestMatcher.matches = new int [] { 10, 11 };
    
    MasterMatcher.get(c).highlight(d, 7, bag, EAS, EAS, EAS, EAS);
    TestMatcher.waitUntilCreated(1000);
    {
    TestMatcher tm = TestMatcher.lastMatcher;
    assertNotNull("No matcher created", tm);
    
    HighlightsSequence hs = bag.getHighlights(0, Integer.MAX_VALUE);
    assertTrue("Wrong number of highlighted areas", hs.moveNext());
    assertEquals("Wrong origin startOfset", 2, hs.getStartOffset());
    assertEquals("Wrong origin endOfset", 3, hs.getEndOffset());
    
    assertTrue("Wrong number of highlighted areas", hs.moveNext());
    assertEquals("Wrong match startOfset", 10, hs.getStartOffset());
    assertEquals("Wrong match endOfset", 11, hs.getEndOffset());
    }        
}
 
Example #28
Source File: StyledEditorKit.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Toggles the Underline attribute.
 *
 * @param e the action event
 */
public void actionPerformed(ActionEvent e) {
    JEditorPane editor = getEditor(e);
    if (editor != null) {
        StyledEditorKit kit = getStyledEditorKit(editor);
        MutableAttributeSet attr = kit.getInputAttributes();
        boolean underline = (StyleConstants.isUnderline(attr)) ? false : true;
        SimpleAttributeSet sas = new SimpleAttributeSet();
        StyleConstants.setUnderline(sas, underline);
        setCharacterAttributes(editor, sas, false);
    }
}
 
Example #29
Source File: EditorSanityTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testApplicationRtfEditorKits() {
    JEditorPane pane = new JEditorPane();
    setContentTypeInAwt(pane, "application/rtf");
    
    // Test JDK kit
    EditorKit kitFromJdk = pane.getEditorKit();
    assertNotNull("Can't find JDK kit for application/rtf", kitFromJdk);
    assertTrue("Wrong JDK kit for application/rtf", kitFromJdk instanceof RTFEditorKit);
}
 
Example #30
Source File: JEditorPaneTagJavaElement.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public int getHRefIndex() {
    return EventQueueWait.exec(new Callable<Integer>() {
        @Override
        public Integer call() throws Exception {
            String href = getAttribute("href");
            int hRefIndex = 0;
            int current = 0;
            JEditorPane editor = (JEditorPane) parent.getComponent();
            HTMLDocument document = (HTMLDocument) editor.getDocument();
            Iterator iterator = document.getIterator(Tag.A);
            while (iterator.isValid()) {
                if (current++ >= index) {
                    return hRefIndex;
                }
                AttributeSet attributes = iterator.getAttributes();
                if (attributes != null) {
                    Object attributeObject = attributes.getAttribute(HTML.Attribute.HREF);
                    if (attributeObject != null) {
                        String attribute = attributeObject.toString();
                        if (attribute.equals(href)) {
                            hRefIndex++;
                        }
                    }
                }
                iterator.next();
            }
            return -1;
        }
    });
}