Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/**
 * Kuebiko - SwingHtmlUtil.java
 * Copyright 2011 Dave Huffman (dave dot huffman at me dot com).
 * Open source under the BSD 3-Clause License.
 */

import javax.swing.text.Element;

import javax.swing.text.html.CSS;

public class Main {
    public static boolean isBold(Element element) {
        return containsAttribute(element, CSS.Attribute.FONT_WEIGHT, "bold");
    }

    public static boolean containsAttribute(Element element, Object name, Object value) {
        if (element == null) {
            return false;
        }

        Object attribute = element.getAttributes().getAttribute(name);

        if (attribute == null) {
            return containsAttribute(element.getParentElement(), name, value);
        }
        return value.equals(attribute.toString());
    }
}