List of usage examples for org.jdom2 Element getAttribute
public Attribute getAttribute(final String attname)
This returns the attribute for this element with the given name and within no namespace, or null if no such attribute exists.
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 a v a2 s. c o m return attribute.getValue(); }
From source file:org.janusproject.acl.encoding.xml.XMLACLCodecHelper.java
License:Open Source License
/** * Retrieves the Performative//from w ww . j av a2 s .co m * * @param element a JDOM Element which represents the root tag (<fipa-message>) * @return the decoded Performative * * @see Performative */ public static Performative decodePerformative(Element element) { if (element == null || element.getAttribute(Locale.getString(XMLACLCodec.class, "FIPAMESSAGEATTR")) == null) { //$NON-NLS-1$ return Performative.NONE; } return Performative .valueOfByName(element.getAttributeValue(Locale.getString(XMLACLCodec.class, "FIPAMESSAGEATTR"))); //$NON-NLS-1$ }
From source file:org.janusproject.acl.encoding.xml.XMLACLCodecHelper.java
License:Open Source License
/** * Retrieves the reply by date/* w ww . ja v a 2 s. c o m*/ * @param element a JDOM Element which represents a reply-by tag * @return the reply by data String value */ public static Date decodeReplyByDate(Element element) { if (element == null || element.getAttribute(Locale.getString(XMLACLCodec.class, "REPLYBYATTR")) == null) { //$NON-NLS-1$ return null; } return ACLDateUtil.toDate(element.getAttributeValue(Locale.getString(XMLACLCodec.class, "REPLYBYATTR"))); //$NON-NLS-1$ }
From source file:org.jpos.q2.qbean.QThreadPoolExecutor.java
License:Open Source License
/** * @param elt// www .ja v a2 s .c o 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.jpos.qi.ViewConfig.java
License:Open Source License
public void setXmlElement(Element e) throws DataConversionException { xmlElement = e;//from w w w. java 2 s. com for (Element f : e.getChildren("attribute")) { String name = f.getAttributeValue("name"); String perm = f.getAttributeValue("perm"); String regex = f.getAttributeValue("regex"); String width = f.getAttributeValue("width"); String optionsStr = f.getAttributeValue("options"); int length = f.getAttribute("length") != null ? f.getAttribute("length").getIntValue() : 0; boolean addField = f.getAttribute("field") == null || f.getAttribute("field").getBooleanValue(); boolean addColumn = f.getAttribute("column") == null || f.getAttribute("column").getBooleanValue(); boolean isReadOnly = f.getAttribute("read-only") != null && f.getAttribute("read-only").getBooleanValue(); boolean isRequired = f.getAttribute("required") != null && f.getAttribute("required").getBooleanValue(); int expandRatio = f.getAttribute("expand-ratio") != null ? f.getAttribute("expand-ratio").getIntValue() : -1; if (addField) { if (optionsStr != null) { String[] options = optionsStr.split(","); addField(name, perm, options, length, isRequired); } addField(name, perm, regex, length, isRequired, width); } if (addColumn) { addColumn(name, perm); if (expandRatio != -1 && fields.get(name) != null) fields.get(name).setExpandRatio(expandRatio); } if (isReadOnly) { addReadOnly(name); } } }
From source file:org.kdp.word.transformer.FootnodeTransformer.java
License:Apache License
private String isFootnodeRef(Element el) { String result = null;//from w ww . j av a 2 s .c om 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 va 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; }/*from w w w .ja v a 2s. com*/ 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 transformStyles(Context context, Element element) { Attribute attClass = element.getAttribute("class"); if (attClass != null) { classStyleReplace(context, element, attClass); }// www . j av a 2 s. co m for (Element ch : element.getChildren()) { transformStyles(context, ch); } }
From source file:org.kdp.word.transformer.TOCTransformer.java
License:Apache License
private String getAnchorName(Element el) { String result = null;//from w ww . java2 s .c o m Attribute att = el.getAttribute("name"); if ("a".equals(el.getName()) && att != null) { result = att.getValue(); } else { for (Element ch : el.getChildren()) { result = getAnchorName(ch); if (result != null) { break; } } } return result; }