Here are the examples of the java api class org.jdom2.Attribute taken from open source projects.
1. SSE091Parser#parseBooleanAttr()
Project: rome
File: SSE091Parser.java
File: SSE091Parser.java
private Boolean parseBooleanAttr(final Element sharingChild, final String attrName) { final Attribute attribute = sharingChild.getAttribute(attrName); Boolean attrValue = null; if (attribute != null) { try { attrValue = Boolean.valueOf(attribute.getBooleanValue()); } catch (final DataConversionException e) { } } return attrValue; }
2. SSE091Parser#parseIntegerAttribute()
Project: rome
File: SSE091Parser.java
File: SSE091Parser.java
private Integer parseIntegerAttribute(final Element sharingChild, final String attrName) { final Attribute integerAttribute = sharingChild.getAttribute(attrName); Integer integerAttr = null; if (integerAttribute != null) { try { integerAttr = new Integer(integerAttribute.getIntValue()); } catch (final DataConversionException e) { } } return integerAttr; }
3. RSS091NetscapeParser#isMyType()
Project: rome
File: RSS091NetscapeParser.java
File: RSS091NetscapeParser.java
@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()); }
4. QThreadPoolExecutor#getAttribute()
Project: jPOS
File: QThreadPoolExecutor.java
File: QThreadPoolExecutor.java
/** * @param elt * @param attrName * @param mandatory * @param errDesc * @throws ConfigurationException */ protected Attribute getAttribute(Element elt, String attrName, boolean mandatory, String errDesc) throws ConfigurationException { Attribute attr = elt.getAttribute(attrName); if (null == attr || "".equals(attr.getValue().trim())) { if (mandatory) { throw new ConfigurationException(String.format("'%s' attribute has not been found or is empty %s", XML_CONFIG_ATTR__EXEC_SRV_TYPE, errDesc)); } else { return null; } } else { return attr; } }
5. QThreadPoolExecutor#initService()
Project: jPOS
File: QThreadPoolExecutor.java
File: QThreadPoolExecutor.java
/** * Handle specific config elements * * type := "fixed" | "scheduled" | "cached" corePoolSize := integer * (required for "fixed" and "scheduled" kinds, optional for "cached" kind) * */ @Override protected void initService() throws Exception { Element rootElt = this.getPersist(); Attribute execSrvTypeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_TYPE, true, "(thread pool executor type among {fixed|cached|scheduled|single})"); execSrvType = execSrvTypeAttr.getValue().trim(); if ("fixed".equals(execSrvType)) { Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, true, "(number of threads in the pool)"); initialCorePoolSize = corePoolSizeAttr.getIntValue(); } else if ("cached".equals(execSrvType)) { Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, false, "(number of threads in the pool)"); if (null != corePoolSizeAttr) { initialCorePoolSize = corePoolSizeAttr.getIntValue(); } } else if ("scheduled".equals(execSrvType)) { Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, true, "(number of threads in the pool)"); initialCorePoolSize = corePoolSizeAttr.getIntValue(); } else { throw new ConfigurationException("Invalid thread pool executor type '%s' (valid types={fixed|cached|scheduled} )"); } Attribute terminationTimerAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_TERMINATION_TIMER, false, "(termination timer in seconds)"); if (null != terminationTimerAttr) { terminationTimer = terminationTimerAttr.getIntValue(); } }
6. SSEParserTest#findAttribute()
Project: rome
File: SSEParserTest.java
File: SSEParserTest.java
private Attribute findAttribute(final String name, final List<Attribute> attrs) { for (final Attribute a : attrs) { if (a.getName().equalsIgnoreCase(name)) { return a; } } return null; }
7. SSE091Parser#parseDateAttribute()
Project: rome
File: SSE091Parser.java
File: SSE091Parser.java
private Date parseDateAttribute(final Element childElement, final String attrName, final Locale locale) { final Attribute dateAttribute = childElement.getAttribute(attrName); final Date date = null; if (dateAttribute != null) { // SSE spec requires the timezone to be 'GMT' // admittedly, this is a bit heavy-handed final String dateAttr = dateAttribute.getValue().trim(); return DateParser.parseRFC822(dateAttr, locale); } return date; }
8. SSE091Parser#parseStringAttribute()
Project: rome
File: SSE091Parser.java
File: SSE091Parser.java
private String parseStringAttribute(final Element syncChild, final String attrName) { final Attribute idAttribute = syncChild.getAttribute(attrName); return idAttribute != null ? idAttribute.getValue().trim() : null; }
9. AtomModuleParser#getAttributeValue()
Project: rome
File: AtomModuleParser.java
File: AtomModuleParser.java
protected String getAttributeValue(final Element e, final String attributeName) { Attribute attr = e.getAttribute(attributeName); if (attr == null) { attr = e.getAttribute(attributeName, NS); } if (attr != null) { return attr.getValue(); } else { return null; } }
10. RSS20Parser#versionMatches()
Project: rome
File: RSS20Parser.java
File: RSS20Parser.java
private boolean versionMatches(final Document document) { final Attribute version = document.getRootElement().getAttribute("version"); return (version != null) && version.getValue().trim().startsWith(getRSSVersion()); }
11. RSS091UserlandParser#isMyType()
Project: rome
File: RSS091UserlandParser.java
File: RSS091UserlandParser.java
@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()); }
12. RSS091UserlandGenerator#createRootElement()
Project: rome
File: RSS091UserlandGenerator.java
File: RSS091UserlandGenerator.java
@Override protected Element createRootElement(final Channel channel) { final Element root = new Element("rss", getFeedNamespace()); final Attribute version = new Attribute("version", getVersion()); root.setAttribute(version); root.addNamespaceDeclaration(getContentNamespace()); generateModuleNamespaceDefs(root); return root; }
13. BaseWireFeedParser#getAttributeValue()
Project: rome
File: BaseWireFeedParser.java
File: BaseWireFeedParser.java
protected String getAttributeValue(final Element e, final String attributeName) { final Attribute attr = getAttribute(e, attributeName); if (attr != null) { return attr.getValue(); } else { return null; } }
14. BaseWireFeedParser#getAttribute()
Project: rome
File: BaseWireFeedParser.java
File: BaseWireFeedParser.java
protected Attribute getAttribute(final Element e, final String attributeName) { Attribute attribute = e.getAttribute(attributeName); if (attribute == null) { attribute = e.getAttribute(attributeName, namespace); } return attribute; }
15. Atom03Generator#createRootElement()
Project: rome
File: Atom03Generator.java
File: Atom03Generator.java
protected Element createRootElement(final Feed feed) { final Element root = new Element("feed", getFeedNamespace()); root.addNamespaceDeclaration(getFeedNamespace()); final Attribute version = new Attribute("version", getVersion()); root.setAttribute(version); generateModuleNamespaceDefs(root); return root; }