/** * Returns the trimmed textual content of the named child element, or null * if there's no such child. See <code>{@link #getTextTrim()}</code> for * details of text trimming. * * @param cname the name of the child * @return trimmed text content for the named child, or * null if no such child */ public String getChildTextTrim(final String cname) { final Element child = getChild(cname); if (child == null) { return null; } return child.getTextTrim(); }
/** * Returns the trimmed textual content of the named child element, or null * if there's no such child. * * @param cname * the name of the child * @param ns * the namespace of the child. A null implies Namespace.NO_NAMESPACE. * @return trimmed text content for the named child, or null if no such * child */ public String getChildTextTrim(final String cname, final Namespace ns) { final Element child = getChild(cname, ns); if (child == null) { return null; } return child.getTextTrim(); }
/** * @return the trimmed text. * @see org.jdom2.Element#getTextTrim() */ public String getTextTrim() { return element.getTextTrim(); }
protected Interpolation interpolationModeFromXml( final Element elem ) { final String t = elem.getTextTrim(); if ( VIEWERSTATE_INTERPOLATION_VALUE_NLINEAR.equals( t ) ) return NLINEAR; else // if ( VIEWERSTATE_INTERPOLATION_VALUE_NEARESTNEIGHBOR.equals( t ) ) return NEARESTNEIGHBOR; } }
protected DisplayMode displayModeFromXml( final Element elem ) { final String t = elem.getTextTrim(); if ( VIEWERSTATE_DISPLAYMODE_VALUE_GROUP.equals( t ) ) return GROUP; else if ( VIEWERSTATE_DISPLAYMODE_VALUE_FUSED.equals( t ) ) return FUSED; else if ( VIEWERSTATE_DISPLAYMODE_VALUE_FUSEDGROUP.equals( t ) ) return FUSEDGROUP; else // if ( VIEWERSTATE_DISPLAYMODE_VALUE_SINGLE.equals( t ) ) return SINGLE; }
public static String getValue(Object node) { if (node instanceof Element) { return ((Element) node).getTextTrim(); } else { return ((Attribute) node).getValue(); } }
/** * @return the log text saved in the specified file, or <code>null</code> if * log text was not saved. */ public String getLogText() { final Element logElement = root.getChild( LOG_ELEMENT_KEY ); if ( null != logElement ) return logElement.getTextTrim(); return ""; }
/** * Returns the log text saved in the file, or <code>null</code> if log text * was not saved. */ public String getLog() { final Element logElement = root.getChild( LOG_ELEMENT_KEY ); if ( null != logElement ) return logElement.getTextTrim(); return ""; }
/** * @return the log text saved in the specified file, or <code>null</code> if * log text was not saved. */ public String getLogText() { final Element logElement = root.getChild( LOG_ELEMENT_KEY ); if ( null != logElement ) return logElement.getTextTrim(); return ""; }
/** * Returns the log text saved in the file, or <code>null</code> if log text * was not saved. */ public String getLog() { final Element logElement = root.getChild( LOG_ELEMENT_KEY ); if ( null != logElement ) return logElement.getTextTrim(); return ""; }
public String getElementValue(String xPath) { Element element = getElement(xPath); return (element == null ? null : element.getTextTrim()); }
/** Returns all identifiers of this type found in the given MODS element. */ List<MCRIdentifier> getIdentifiers(Element mods) { return xPathExpr.evaluate(mods).stream() .map(e -> new MCRIdentifier(this, e.getTextTrim())) .collect(Collectors.toList()); }
protected double getChartValue(String xp, String type, Document doc) { double value=0; try { XPath xPath = XPath.newInstance(xp+"[@type='"+type+"']"); Element element = (Element)xPath.selectSingleNode(doc); value = new Double(element.getTextTrim()); } catch (JDOMException e) {logger.error("",e);} return value; } }
private String parseStringContent(Element e) throws DataConversionException { if (e == null) return null; Attribute nil = e.getAttribute("nil", UWS.XSI_NS); if (nil != null && nil.getBooleanValue()) return null; return e.getTextTrim(); }
/** * If the given element is mods:typeOfResource, returns the MCRTypeOfResource mapping. */ public static MCRTypeOfResource getAuthorityInfo(org.jdom2.Element modsElement) { if (modsElement == null) { return null; } String name = modsElement.getName(); String code = modsElement.getTextTrim(); return getTypeOfResource(name, code); }
public LikeFilter( String type, Element selectorNode ) { this.type = type; if ( selectorNode.hasAttributes() ) { this.attrMap = new HashMap<String,String>(); for ( Attribute attr : selectorNode.getAttributes() ) { attrMap.put( attr.getName(), attr.getValue() ); } } this.value = selectorNode.getTextTrim(); if ( this.value.length() == 0 ) this.value = null; }
@Override public void removeIdentifier(MCRPersistentIdentifier identifier, MCRBase obj, String additional) { String xpath = getProperties().get("Xpath"); Document xml = obj.createXML(); XPathFactory xPathFactory = XPathFactory.instance(); XPathExpression<Element> xp = xPathFactory.compile(xpath, Filters.element()); List<Element> elements = xp.evaluate(xml); elements.stream() .filter(element -> element.getTextTrim().equals(identifier.asString())) .forEach(Element::detach); }
/** * @param e element to parse * @param md metadata to fill in */ private void parseComments(final Element e, final Metadata md) { final Element commentsElement = e.getChild("comments", getNS()); if (commentsElement != null) { final List<Element> commentElements = commentsElement.getChildren("comment", getNS()); final String[] comments = new String[commentElements.size()]; for (int i = 0; i < commentElements.size(); i++) { comments[i] = commentElements.get(i).getTextTrim(); } md.setComments(comments); } }
/** * Inspects the attributes in the given MODS XML element and returns the AuthorityInfo given there. */ public static MCRAuthorityAndCode getAuthorityInfo(org.jdom2.Element modsElement) { String authority = modsElement.getAttributeValue("authority"); String type = modsElement.getAttributeValue("type"); String code = modsElement.getTextTrim(); return getAuthorityInfo(authority, type, code); }
@Test public void testCreateBshMethod2() throws Throwable { when(e.getTextTrim()).thenReturn("testStringtestStringtestStringIll(gal Surrogate Pair"); when(e.getAttributeValue("file")).thenReturn(null); BSHMethod result = BSHMethod.createBshMethod(e); assertNotNull("result", result); }