Java 8 AttributeSet - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 AttributeSet class.

This code example shows how to use the following methods:containsAttribute, getAttribute
		this.stylesheetHrefs = stylesheetHrefs;
	} 
	 
	private boolean isStylesheetLink(Tag tag, MutableAttributeSet attributes) {
		return ((tag == Tag.LINK)
				&& (attributes.containsAttribute(HTML.Attribute.REL, "stylesheet"))
				&& (attributes.containsAttribute(HTML.Attribute.TYPE, "text/css")));
	} 
	 
	 
	private void handleStylesheet(Tag tag, MutableAttributeSet attributes) {
		if (isStylesheetLink(tag, attributes)) {
			stylesheetHrefs.add(attributes.getAttribute(HTML.Attribute.HREF).toString());
		} 
	} 
	 
	public int hashCode() { 
		return parserCallback.hashCode();
	} 
 
6
CodeRank
This code example shows how to use the following methods:getLength, getText, putProperty
        try { 
            final EditorKit kit = new HTMLEditorKit();
            final Document doc = kit.createDefaultDocument();
 
            // The Document class does not yet handle charset's properly. 
            doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);
 
            // Create a reader on the HTML content. 
            final Reader rd = new StringReader(html);
 
            // Parse the HTML. 
            kit.read(rd, doc, 0);
 
            // The HTML text is now stored in the document 
            return doc.getText(0, doc.getLength());
        } catch (final Exception e) {
        } 
        return ""; 
    } 
 
7
CodeRank
This code example shows how to use the following methods:getEndPosition, getStartPosition, getText
    private boolean isValid(char c) {
        return characterSet.isValid(c);
    } 
 
    private void updateSegment() throws BadLocationException {
        document.getText(document.getStartPosition().getOffset(), document.getEndPosition().getOffset(), segment);
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:getLength, getText, putProperty
        // try and read the document - set to ignore character set directive, 
        // assuming that the input stream is already set properly (I hope) 
        HTMLEditorKit kit = new HTMLEditorKit();
        Document doc = kit.createDefaultDocument();
 
        doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);
 
        kit.read(source, doc, 0);
 
        String extractedText = doc.getText(0, doc.getLength());
 
        // generate an input stream with the extracted text 
        byte[] textBytes = extractedText.getBytes();
        ByteArrayInputStream bais = new ByteArrayInputStream(textBytes);
 
        return bais; // will this work? or will the byte array be out of scope?
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getLength, insertString
This code example shows how to use the following methods:getLength, insertString, remove
        notifyContentsChanged(); 
    } 
 
    private void setEditorTextTo(String enteredValue) {
        try { 
            textFieldDocument.remove(0, textFieldDocument.getLength());
            textFieldDocument.insertString(0, enteredValue, null);
        } catch (BadLocationException ignore) {
 
        } 
    } 
 
    private String getEnteredEndpointValue() {
        try { 
            return textFieldDocument.getText(0, textFieldDocument.getLength());
        } catch (BadLocationException ignore) {
            return ""; 
        } 
    } 
 
6
CodeRank
This code example shows how to use the following methods:getLength, getText
    { 
        final Document doc = e.getDocument ();
        String txt;
        try 
        { 
            txt = doc.getText ( 0, doc.getLength () );
        } 
        catch ( final BadLocationException ex )
        { 
            txt = null;
        } 
        return txt;
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getLength, insertString, getStyle
This code example shows how to use the following methods:getLength, getText, putProperty
        // try and read the document - set to ignore character set directive, 
        // assuming that the input stream is already set properly (I hope) 
        HTMLEditorKit kit = new HTMLEditorKit();
        Document doc = kit.createDefaultDocument();
 
        doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);
 
        kit.read(source, doc, 0);
 
        String extractedText = doc.getText(0, doc.getLength());
 
        // generate an input stream with the extracted text 
        byte[] textBytes = extractedText.getBytes();
        ByteArrayInputStream bais = new ByteArrayInputStream(textBytes);
 
        return bais; // will this work? or will the byte array be out of scope?
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getLength, getText
    public void changedUpdate(DocumentEvent e) {
    } 
 
    public String getText(Document document) {
        try { 
            return document.getText(0, document.getLength());
        } catch (BadLocationException e) {
            e.printStackTrace();
            return ""; 
        } 
    } 
} 
5
CodeRank
See Code Examples for Java 8 AttributeSet Methods: