Example usage for org.jsoup.parser Tag isInline

List of usage examples for org.jsoup.parser Tag isInline

Introduction

In this page you can find the example usage for org.jsoup.parser Tag isInline.

Prototype

public boolean isInline() 

Source Link

Document

Gets if this tag is an inline tag.

Usage

From source file:org.structr.web.common.microformat.MicroformatParser.java

private void recurse(final Element element, final Map<String, Object> values, final int depth) {

    final Tag tag = element.tag();
    final Set<String> classes = element.classNames();
    final String link = element.attr("href");
    final Object content = extractChildContent(element);

    if (!classes.isEmpty()) {

        removeEmpty(classes);/*from  w  w  w  .  j  a v a2 s  .com*/

        // toplevel classes define type
        if (tag.isBlock()) {

            if (depth == 0) {

                // store type attribute
                values.put("type", classes);

                for (final Element child : element.children()) {
                    recurse(child, values, depth + 1);
                }

            } else {

                final Map<String, Object> childMap = new LinkedHashMap<>();
                values.put(classes.iterator().next(), childMap);

                if (content != null) {
                    childMap.put("name", content);
                }

                for (final Element child : element.children()) {
                    recurse(child, childMap, depth + 1);
                }
            }

        } else if (tag.isInline()) {

            // extract href and store as URL
            if (classes.contains("url") && StringUtils.isNotBlank(link)) {

                values.put("url", link);
                classes.remove("url");
            }

            if (content != null) {

                for (final String type : classes) {
                    values.put(type, content);
                }
            }

        }
    }
}