List of usage examples for org.jdom2 Attribute getValue
public String getValue()
Attribute
. From source file:org.helm.notation2.MonomerFactory.java
License:Open Source License
private static Map<String, Map<String, Monomer>> buildMonomerDB(Element polymerList) throws MonomerException, IOException, JDOMException, CTKException, ChemistryException { Map<String, Map<String, Monomer>> map = new HashMap<String, Map<String, Monomer>>(); List poplymers = polymerList.getChildren(); Iterator i = poplymers.iterator(); while (i.hasNext()) { Element polymer = (Element) i.next(); Attribute polymerType = polymer.getAttribute(POLYMER_TYPE_ATTRIBUTE); Map idMonomerMap = new HashMap<String, Monomer>(); List monomers = polymer.getChildren(); Iterator it = monomers.iterator(); while (it.hasNext()) { Element monomer = (Element) it.next(); Monomer m = MonomerParser.getMonomer(monomer); if (MonomerParser.validateMonomer(m)) { idMonomerMap.put(m.getAlternateId(), m); }//from w ww . ja v a2s .co m } map.put(polymerType.getValue(), idMonomerMap); } return map; }
From source file:org.isisaddons.module.docx.dom.util.Jdom2.java
License:Apache License
public static String attrOf(Element input, String attname) { Attribute attribute = input.getAttribute(attname); if (attribute == null) { return null; }//from w w w .j av a 2s . c o m return attribute.getValue(); }
From source file:org.jahia.utils.osgi.parsers.JpdlXmlFileParser.java
License:Open Source License
@Override public void parse(String fileName, Element rootElement, String fileParent, boolean externalDependency, boolean optionalDependency, String version, ParsingContext parsingContext) throws JDOMException { getLogger()//from w w w.ja v a 2 s.c o m .debug("Processing workflow definition file (JBPM JPDL) " + fileParent + " / " + fileName + "..."); List<Attribute> classAttributes = getAttributes(rootElement, "//@class"); for (Attribute classAttribute : classAttributes) { getLogger().debug(fileName + " Found class " + classAttribute.getValue() + " package=" + PackageUtils.getPackagesFromClass(classAttribute.getValue(), optionalDependency, version, fileName, parsingContext).toString()); parsingContext.addAllPackageImports(PackageUtils.getPackagesFromClass(classAttribute.getValue(), optionalDependency, version, fileParent + "/" + fileName, parsingContext)); } }
From source file:org.jpos.q2.qbean.QThreadPoolExecutor.java
License:Open Source License
/** * Handle specific config elements//from ww w.j ava 2 s . co m * * 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(); } }
From source file:org.jpos.q2.qbean.QThreadPoolExecutor.java
License:Open Source License
/** * @param elt/*w w w.java 2 s.co m*/ * @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; } }
From source file:org.kdp.word.transformer.AttributeTransformer.java
License:Apache License
private void transformInternal(Parser parser, Element el, Set<Replace> replace) { String elname = el.getName(); for (Attribute att : new ArrayList<Attribute>(el.getAttributes())) { String attname = att.getName(); String attvalue = att.getValue(); String attid = elname + "." + attname; for (Replace rep : replace) { if (attid.equals(rep.attid)) { if (rep.substr == null || attvalue.contains(rep.substr)) { if (rep.newval == null || rep.newval.length() == 0) { log.debug("Remote attribute: {}", att); el.getAttributes().remove(att); } else { log.debug("Replace attribute: {}", att); att.setValue(rep.newval); }// w w w . j a v a2 s . com break; } } } } for (Element ch : el.getChildren()) { transformInternal(parser, ch, replace); } }
From source file:org.kdp.word.transformer.FootnodeTransformer.java
License:Apache License
private String isFootnodeRef(Element el) { String result = null;/*w ww. jav a2 s . com*/ if (JDOMUtils.isElement(el, "a", null, null)) { Attribute att = el.getAttribute("href"); if (att != null) { String value = att.getValue(); if (value.startsWith("#_ftn")) { result = value.substring(1); } } } return result; }
From source file:org.kdp.word.transformer.MetadataTransformer.java
License:Apache License
@Override public void transform(Context context) { Element root = context.getSourceRoot(); Element el = JDOMUtils.findElement(root, "meta", "name", "Generator"); if (el != null) { Attribute att = el.getAttribute("content"); String attval = att.getValue(); att.setValue(attval + " - word2mobi"); }/* w w w . ja v a 2 s.c o m*/ }
From source file:org.kdp.word.transformer.SectionTransformer.java
License:Apache License
private String getSectionName(Element el) { if (!JDOMUtils.isElement(el, "div", null, null)) { return null; }// ww w . j ava 2 s .c om Attribute att = el.getAttribute("class"); if (att == null) { return null; } String name = att.getValue(); return name.startsWith("WordSection") ? name : null; }
From source file:org.kdp.word.transformer.StyleTransformer.java
License:Apache License
private void classStyleReplace(Context context, Element element, Attribute attClass) { String value = null;//from w w w . ja v a2 s. c om String attname = attClass.getName(); String attvalue = attClass.getValue(); for (Replacement rep : replacements) { if (attname.equals(rep.attname)) { if (isWhitelisted(attvalue)) { value = attvalue; } else if (rep.pattern.matcher(attvalue).matches()) { value = rep.value; break; } } } if (value != null) { attClass.setValue(value); } else { element.removeAttribute(attClass); } }