Example usage for org.jdom2 Attribute getName

List of usage examples for org.jdom2 Attribute getName

Introduction

In this page you can find the example usage for org.jdom2 Attribute getName.

Prototype

public String getName() 

Source Link

Document

This will retrieve the local name of the Attribute.

Usage

From source file:se.miun.itm.input.model.element.Value.java

License:Open Source License

@SuppressWarnings("unchecked")
public boolean same(Object obj) {
    if (!(obj instanceof Value))
        return false;

    Value<? extends Param<?>> foreigner = (Value<?>) obj;
    Attribute forAttr;//from w  w  w .  j  a  v a  2  s  . c  om
    for (Attribute attr : getAttributes()) {
        forAttr = foreigner.getAttribute(attr.getName());
        if (forAttr == null || !forAttr.getValue().equals(attr.getValue()))
            return false;
    }

    List<Value<?>> myChildren = (List<Value<?>>) (List<?>) getChildren();
    List<Value<?>> foreignerChildren = (List<Value<?>>) (List<?>) foreigner.getChildren();
    if (myChildren.size() != foreignerChildren.size())
        return false;

    Value<?> foreignerValue;
    for (Value<?> value : myChildren) {
        foreignerValue = getSame(value, foreignerChildren);
        if (foreignerValue == null || !value.same(foreignerValue))
            return false;
    }

    return true;
}

From source file:se.miun.itm.input.model.param.Param.java

License:Open Source License

private void initFromOriginal(Element original) {
    // init attributes
    setNamespace(original.getNamespace());
    setName(original.getName());//from  w  w w  . j a v a 2  s .c o  m
    Attribute attr;
    for (Object content : original.getAttributes()) {
        attr = (Attribute) content;
        setAttribute(attr.getName(), attr.getValue());
    }

    // move children
    Element childE;
    Object[] children = original.getChildren().toArray();
    for (Object child : children) {
        childE = (Element) child;
        original.removeContent(childE);
        addContent(childE);
    }

    // attach to parent
    Element parent = original.getParentElement();
    parent.removeContent(original);
    parent.addContent(this);
}

From source file:site.util.EvXmlUtil.java

License:BSD License

/**
 * Checks if name and attributes equal, not content
 *///from w  w  w  .j  a va 2s.com
public static boolean elementsEqual(Element a, Element b) {
    if (a.getName().equals(b.getName())) {
        for (Object o : a.getAttributes()) {
            Attribute attra = (Attribute) o;
            Attribute attrb = b.getAttribute(attra.getName());
            if (attrb == null)
                return false;
            if (!attra.getValue().equals(attrb.getValue()))
                return false;
        }
        for (Object o : b.getAttributes()) {
            Attribute attrb = (Attribute) o;
            Attribute attra = a.getAttribute(attrb.getName());
            if (attra == null)
                return false;
            if (!attrb.getValue().equals(attra.getValue()))
                return false;
        }
        return true;
    } else
        return false;
}

From source file:xml.JDOMConverter.java

License:Apache License

/**.
 * Handles the case where the object in filter is an attribute
 * @param a the filtered attribute//from  www .j ava2 s.c  o m
 * @throws JSONException
 */
private void handleAttribute(final Attribute a) throws JSONException {
    tree.get(current).put(a.getName(), a.getValue());
}