Example usage for javax.swing.text.html HTML getAllTags

List of usage examples for javax.swing.text.html HTML getAllTags

Introduction

In this page you can find the example usage for javax.swing.text.html HTML getAllTags.

Prototype

public static Tag[] getAllTags() 

Source Link

Document

Returns the set of actual HTML tags that are recognized by the default HTML reader.

Usage

From source file:MainClass.java

public static void main(String[] args) {

    HTML.Tag[] list = HTML.getAllTags();
    for (int i = 0; i < list.length; i++) {
        System.out.println((i + 1) + ": " + list[i]);
    }/*from ww w  . j  a  va 2 s.co  m*/

}

From source file:Main.java

public static void main(String[] args) {

    HTML.Tag[] tags = HTML.getAllTags();
    HTML.Attribute[] attrs = HTML.getAllAttributeKeys();

    System.out.println("HTML Tags:");
    for (int i = 0; i < tags.length - 1; i++) {
        System.out.print(tags[i] + ", ");
        if ((i % 8) == 7) {
            System.out.println("");
        }//from  www . j  av a 2s.  co  m
    }
    System.out.println(tags[tags.length - 1]);

    System.out.println("\n\nHTML Attributes:");
    for (int i = 0; i < attrs.length - 1; i++) {
        System.out.print(attrs[i] + ", ");
        if ((i % 8) == 7) {
            System.out.println("");
        }
    }
    System.out.println(attrs[attrs.length - 1]);
}

From source file:com.hexidec.ekit.component.HTMLUtilities.java

public HTMLUtilities(EkitCore newParent) {
    parent = newParent;//from  w  w w .ja  v  a2 s.  co m
    HTML.Tag[] tagList = HTML.getAllTags();
    for (int i = 0; i < tagList.length; i++) {
        tags.put(tagList[i].toString(), tagList[i]);
    }
}

From source file:fr.aliasource.webmail.formatting.htmlcleaner.AbstractHTMLCleaner.java

private String convert(String html, AttachmentManager am, Map<String, String> attachments) {

    String cleanHtml = html;//ww  w  .j  a v a2 s .  c o  m

    ElementRemover er = new ElementRemover();

    Attribute[] attr = HTML.getAllAttributeKeys();
    Set<String> allowedAttributes = new HashSet<String>();
    for (int i = 0; i < attr.length; i++) {
        if (!removedAttributes.contains(attr[i].toString().toLowerCase())) {
            allowedAttributes.add(attr[i].toString());
        }
    }

    Tag[] tags = HTML.getAllTags();
    for (int i = 0; i < tags.length; i++) {
        if (!removedElements.contains(tags[i].toString())) {
            er.acceptElement(tags[i].toString(),
                    allowedAttributes.toArray(new String[allowedAttributes.size()]));
        }
    }

    for (String s : removedElements) {
        er.removeElement(s);
    }

    StringWriter sw = new StringWriter();

    XMLDocumentFilter[] filters = { er, new Writer(sw, "UTF-8") };

    XMLParserConfiguration xpc = new HTMLConfiguration();
    xpc.setProperty("http://cyberneko.org/html/properties/filters", filters);
    xpc.setProperty("http://cyberneko.org/html/properties/names/elems", "lower");

    XMLInputSource xis = new XMLInputSource(null, null, null, new StringReader(html), null);

    try {
        xpc.parse(xis);
        cleanHtml = sw.toString();
    } catch (Exception e) {
        logger.error(e.getMessage());
    }

    // all links open in other tab
    cleanHtml = cleanHtml.replace("<a ", "<a target=\"_blank\" ");

    // Replace cid:images by attachment url
    if (attachments != null) {
        for (String aId : attachments.keySet()) {
            Map<String, String> meta = am.getMetadata(aId);
            if (meta.get("content-id") != null) {
                String cid = "cid:" + meta.get("content-id").substring(1, meta.get("content-id").length() - 1);
                cleanHtml = cleanHtml.replace(cid, "download/" + aId + "/" + meta.get("filename"));
            }
        }
    }

    return cleanHtml;
}