本文整理了Java中org.jdom2.Element.getTextTrim()
方法的一些代码示例,展示了Element.getTextTrim()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getTextTrim()
方法的具体详情如下:
包路径:org.jdom2.Element
类名称:Element
方法名:getTextTrim
[英]Returns the textual content of this element with all surrounding whitespace removed. If no textual value exists for the element, or if only whitespace exists, the empty string is returned.
[中]返回此元素的文本内容,并删除所有周围的空白。如果元素不存在文本值,或者只有空格,则返回空字符串。
代码示例来源:origin: org.jdom/jdom
/**
* 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();
}
代码示例来源:origin: org.jdom/jdom
/**
* 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();
}
代码示例来源:origin: org.codehaus.plexus/plexus-component-metadata
/**
* @return the trimmed text.
* @see org.jdom2.Element#getTextTrim()
*/
public String getTextTrim()
{
return element.getTextTrim();
}
代码示例来源:origin: sc.fiji/bigdataviewer-core
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;
}
}
代码示例来源:origin: sc.fiji/bigdataviewer-core
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;
}
代码示例来源:origin: org.mycore/mycore-xeditor
public static String getValue(Object node) {
if (node instanceof Element) {
return ((Element) node).getTextTrim();
} else {
return ((Attribute) node).getValue();
}
}
代码示例来源:origin: sc.fiji/TrackMate_
/**
* @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 "";
}
代码示例来源:origin: sc.fiji/TrackMate_
/**
* 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 "";
}
代码示例来源:origin: fiji/TrackMate
/**
* @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 "";
}
代码示例来源:origin: fiji/TrackMate
/**
* 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 "";
}
代码示例来源:origin: org.mycore/mycore-mods
public String getElementValue(String xPath) {
Element element = getElement(xPath);
return (element == null ? null : element.getTextTrim());
}
代码示例来源:origin: org.mycore/mycore-mods
/** 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());
}
代码示例来源:origin: org.openfuxml/ofx-wiki
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;
}
}
代码示例来源:origin: org.opencadc/cadc-uws
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();
}
代码示例来源:origin: org.mycore/mycore-mods
/**
* 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);
}
代码示例来源:origin: Vhati/Slipstream-Mod-Manager
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;
}
代码示例来源:origin: org.mycore/mycore-pi
@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);
}
代码示例来源:origin: rometools/rome
/**
* @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);
}
}
代码示例来源:origin: org.mycore/mycore-mods
/**
* 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);
}
代码示例来源:origin: jpos/jPOS
@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);
}
内容来源于网络,如有侵权,请联系作者删除!