Example usage for org.jdom2 Attribute getValue

List of usage examples for org.jdom2 Attribute getValue

Introduction

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

Prototype

public String getValue() 

Source Link

Document

This will return the actual textual value of this Attribute.

Usage

From source file:com.rometools.rome.io.impl.RSS091NetscapeParser.java

License:Open Source License

@Override
public boolean isMyType(final Document document) {

    final Element rssRoot = document.getRootElement();
    final String name = rssRoot.getName();
    final Attribute version = rssRoot.getAttribute("version");
    final DocType docType = document.getDocType();

    return name.equals(ELEMENT_NAME) && version != null && version.getValue().equals(getRSSVersion())
            && docType != null && ELEMENT_NAME.equals(docType.getElementName())
            && PUBLIC_ID.equals(docType.getPublicID()) && SYSTEM_ID.equals(docType.getSystemID());

}

From source file:com.rometools.rome.io.impl.RSS091UserlandParser.java

License:Open Source License

@Override
public boolean isMyType(final Document document) {
    final Element rssRoot = document.getRootElement();
    final Attribute version = rssRoot.getAttribute("version");
    return rssRoot.getName().equals("rss") && version != null && version.getValue().equals(getRSSVersion());
}

From source file:com.rometools.rome.io.impl.RSS20Parser.java

License:Open Source License

@Override
public boolean isMyType(final Document document) {
    final Element rssRoot = document.getRootElement();
    final Attribute version = rssRoot.getAttribute("version");
    // as far ROME is concerned RSS 2.0, 2.00 and 2.0.X are all the same, so let's use
    // startsWith for leniency.
    return rssRoot.getName().equals("rss") && version != null && version.getValue().startsWith(getRSSVersion());
}

From source file:com.sangupta.jerry.util.DomUtils.java

License:Apache License

/**
 * Returns the value of the attribute from the element.
 * //from   w  w w .  ja va 2 s.c  om
 * @param element
 * @param attributeName
 */
public static String getAttributeValue(Element element, String attributeName) {
    Attribute attribute = element.getAttribute(attributeName);
    if (attribute != null) {
        return attribute.getValue();
    }

    return null;
}

From source file:com.sangupta.jerry.util.DomUtils.java

License:Apache License

/**
 * Returns the value of a given attribute for the given tagName amongst the
 * supplied foreign markup values.//from   ww  w. j a va  2s .  c om
 * 
 * @param tagName
 *            the tag name to find
 * 
 * @param attributeName
 *            the attribute name to extract
 * 
 * @param elements
 *            list of elements to search in
 * 
 * @return the value of the attribute if found, <code>null</code> otherwise
 */
public static String getTagAttribute(String tagName, String attributeName, List<Element> elements) {
    for (Element element : elements) {
        if (tagName.equals(element.getName())) {
            Attribute attribute = element.getAttribute(attributeName);
            if (attribute != null) {
                return attribute.getValue();
            }
        }
    }

    return null;
}

From source file:com.speedment.codgen.example.uml.TransformDelegator.java

License:Open Source License

static <M> void ifType(Attribute a, Object obj, Class<M> type, Consumer<M> doer) {
    if (a.getValue().equals(type.getSimpleName().replace("_", ""))) {
        Optional.ofNullable(obj).filter(o -> type.isAssignableFrom(o.getClass())).map(o -> type.cast(o))
                .ifPresent(doer);//from w  w w . j  av  a  2  s.  c o m
    }
}

From source file:com.sun.syndication.io.impl.Atom10Parser.java

License:Open Source License

/** 
 * Return URL string of Atom link element under parent element.
 * Link with no rel attribute is considered to be rel="alternate"
 * @param parent Consider only children of this parent element
 * @param rel    Consider only links with this relationship
 *//*  ww w  .j a v  a 2s .  c  o m*/
private String findAtomLink(Element parent, String rel) {
    String ret = null;
    List linksList = parent.getChildren("link", ATOM_10_NS);
    if (linksList != null) {
        for (Iterator links = linksList.iterator(); links.hasNext();) {
            Element link = (Element) links.next();
            Attribute relAtt = getAttribute(link, "rel");
            Attribute hrefAtt = getAttribute(link, "href");
            if ((relAtt == null && "alternate".equals(rel))
                    || (relAtt != null && relAtt.getValue().equals(rel))) {
                ret = hrefAtt.getValue();
                break;
            }
        }
    }
    return ret;
}

From source file:com.sun.syndication.io.impl.DCModuleParser.java

License:Open Source License

/**
 * Utility method to parse a taxonomy from an element.
 * <p>//w w w  .  j a v a 2  s. co m
 * @param desc the taxonomy description element.
 * @return the string contained in the resource of the element.
 */
protected final String getTaxonomy(Element desc) {
    String d = null;
    Element taxo = desc.getChild("topic", getTaxonomyNamespace());
    if (taxo != null) {
        Attribute a = taxo.getAttribute("resource", getRDFNamespace());
        if (a != null) {
            d = a.getValue();
        }
    }
    return d;
}

From source file:com.sun.syndication.io.impl.RSS091NetscapeParser.java

License:Open Source License

public boolean isMyType(Document document) {
    boolean ok = false;
    Element rssRoot = document.getRootElement();
    ok = rssRoot.getName().equals("rss");
    if (ok) {//from w  w  w .j a va2s.  c  o m
        ok = false;
        Attribute version = rssRoot.getAttribute("version");
        if (version != null) {
            ok = version.getValue().equals(getRSSVersion());
            if (ok) {
                ok = false;
                DocType docType = document.getDocType();

                if (docType != null) {
                    ok = ELEMENT_NAME.equals(docType.getElementName());
                    ok = ok && PUBLIC_ID.equals(docType.getPublicID());
                    ok = ok && SYSTEM_ID.equals(docType.getSystemID());
                }
            }
        }
    }
    return ok;
}

From source file:com.sun.syndication.io.impl.RSS091UserlandParser.java

License:Open Source License

public boolean isMyType(Document document) {
    boolean ok;//from   w w w.j  ava 2 s .c  o  m
    Element rssRoot = document.getRootElement();
    ok = rssRoot.getName().equals("rss");
    if (ok) {
        ok = false;
        Attribute version = rssRoot.getAttribute("version");
        if (version != null) {
            ok = version.getValue().equals(getRSSVersion());
        }
    }
    return ok;
}