本文整理了Java中org.jdom2.Element.getChildText()
方法的一些代码示例,展示了Element.getChildText()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getChildText()
方法的具体详情如下:
包路径:org.jdom2.Element
类名称:Element
方法名:getChildText
[英]Returns the textual content of the named child element, or null if there's no such child. This method is a convenience because calling getChild().getText()
can throw a NullPointerException.
[中]返回命名子元素的文本内容,如果没有这样的子元素,则返回null。此方法非常方便,因为调用getChild().getText()
会引发NullPointerException。
代码示例来源:origin: gocd/gocd
private Modification parseChangeset(Element changeset) {
Date modifiedTime = DateUtils.parseRFC822(changeset.getChildText("date"));
String author = org.apache.commons.lang3.StringEscapeUtils.unescapeXml(changeset.getChildText("author"));
String comment = org.apache.commons.lang3.StringEscapeUtils.unescapeXml(changeset.getChildText("desc"));
String revision = changeset.getChildText("node");
Modification modification = new Modification(author, comment, null, modifiedTime, revision);
Element files = changeset.getChild("files");
List<File> modifiedFiles = parseFiles(files, "modified");
List<File> addedFiles = parseFiles(files, "added");
List<File> deletedFiles = parseFiles(files, "deleted");
modifiedFiles.removeAll(addedFiles);
modifiedFiles.removeAll(deletedFiles);
addModificationFiles(modification, ModifiedAction.added, addedFiles);
addModificationFiles(modification, ModifiedAction.deleted, deletedFiles);
addModificationFiles(modification, ModifiedAction.modified, modifiedFiles);
return modification;
}
代码示例来源:origin: gocd/gocd
private Modification parseLogEntry(Element logEntry, String path) throws ParseException {
Element logEntryPaths = logEntry.getChild("paths");
if (logEntryPaths == null) {
/* Path-based access control forbids us from learning
* details of this log entry, so skip it. */
return null;
}
Date modifiedTime = convertDate(logEntry.getChildText("date"));
String author = logEntry.getChildText("author");
String comment = logEntry.getChildText("msg");
String revision = logEntry.getAttributeValue("revision");
Modification modification = new Modification(author, comment, null, modifiedTime, revision);
List paths = logEntryPaths.getChildren("path");
for (Iterator iterator = paths.iterator(); iterator.hasNext();) {
Element node = (Element) iterator.next();
if (underPath(path, node.getText())) {
ModifiedAction action = convertAction(node.getAttributeValue("action"));
modification.createModifiedFile(node.getText(), null, action);
}
}
return modification;
}
代码示例来源:origin: geotools/geotools
protected Envelope parseBounding(Element bounding) {
if (bounding == null) return new Envelope();
double minX = Double.parseDouble(bounding.getChildText("westbc"));
double maxX = Double.parseDouble(bounding.getChildText("eastbc"));
double minY = Double.parseDouble(bounding.getChildText("southbc"));
double maxY = Double.parseDouble(bounding.getChildText("northbc"));
return new Envelope(minX, maxX, minY, maxY);
}
代码示例来源:origin: org.codehaus.plexus/plexus-component-metadata
/**
* @param name The name of the child.
* @return the child text.
* @see org.jdom2.Element#getChildText(java.lang.String)
*/
public String getChildText( String name )
{
return element.getChildText( name );
}
代码示例来源:origin: org.codehaus.plexus/plexus-component-metadata
/**
* @param name The name of the child.
* @param ns {@link Namespace}
* @return the child text.
* @see org.jdom2.Element#getChildText(java.lang.String,org.jdom2.Namespace)
*/
public String getChildText( String name, Namespace ns )
{
return element.getChildText( name, ns );
}
代码示例来源:origin: fpinjava/fpinjava
private static String processElement(Element element, String format) {
return String.format(format, element.getChildText("firstname"),
element.getChildText("lastname"),
element.getChildText("email"),
element.getChildText("salary"));
}
代码示例来源:origin: org.mycore/mycore-mods
private String textOf(String childName) {
String text = element.getChildText(childName, MCRConstants.MODS_NAMESPACE);
return text == null ? "" : text.trim();
}
}
代码示例来源:origin: sc.fiji/bigdataviewer-core
@Override
public OpenConnectomeImageLoader fromXml( final Element elem, final File basePath, final AbstractSequenceDescription< ?, ?, ? > sequenceDescription )
{
final String baseUrl = elem.getChildText( "baseUrl" );
final String token = elem.getChildText( "token" );
final String mode = elem.getChildText( "mode" );
return new OpenConnectomeImageLoader( baseUrl, token, mode );
}
}
代码示例来源:origin: com.github.yamingd.argo/wx-model
@Override
public Element parseFrom(Document document){
Element root = super.parseFrom(document);
this.latitude = Float.parseFloat(root.getChildText("Latitude"));
this.longitude = Float.parseFloat(root.getChildText("Longitude"));
this.precision = Float.parseFloat(root.getChildText("Precision"));
return root;
}
}
代码示例来源:origin: jpos/jPOS
private void initWhoToSendTo() {
Element persist = getPersist();
sendMethod = persist.getChildText("send-request");
if (sendMethod==null) {
sendMethod="LAST";
}
}
代码示例来源:origin: Unidata/thredds
public static String getAltUnits(Document doc) throws IOException {
Element root = doc.getRootElement();
String altUnits = root.getChildText("AltitudeUnits");
if (altUnits == null || altUnits.length() == 0) return null;
return altUnits;
}
代码示例来源:origin: org.apache.jspwiki/jspwiki-main
protected void initializeFromXML( Element el )
{
super.initializeFromXML( el );
m_path = el.getChildText("path");
}
代码示例来源:origin: edu.ucar/cdm
public static DateUnit getTimeUnit(Document doc) throws IOException {
Element root = doc.getRootElement();
String timeUnitS = root.getChildText("TimeUnit");
if (timeUnitS == null) return null;
try {
return new DateUnit(timeUnitS);
} catch (Exception e) {
log.error("Illegal date unit {}", timeUnitS);
return null;
}
}
代码示例来源:origin: org.openfuxml/ofx-util
private Row createRow(Element cron)
{
Row row = new Row();
row.getCell().add(OfxCellFactory.createParagraphCell(cron.getChildText("url")));
row.getCell().add(OfxCellFactory.createParagraphCell(cron.getChildText("schedule")));
row.getCell().add(OfxCellFactory.createParagraphCell(cron.getChildText("description")));
return row;
}
代码示例来源:origin: jpos/jPOS
private void initIn() {
Element persist = getPersist();
inQueue = persist.getChildText("in");
if (inQueue != null) {
/*
* We have an 'in' queue to monitor for messages we will
* send out through server in our (SpaceListener)notify(Object, Object) method.
*/
sp.addListener(inQueue, this);
}
}
private void initOut() {
代码示例来源:origin: sc.fiji/bigdataviewer_fiji
public TimePoints readTimePoints()
{
final Element root = document.getRootElement();
final int nTimePoints = Integer.parseInt( root.getChild( "TimelapsCondition" ).getChildText( "Iteration" ) );
final List< TimePoint > timepoints = new ArrayList<>( nTimePoints );
for ( int i = 0; i < nTimePoints; i++ )
{
timepoints.add( new TimePoint( Integer.valueOf( i ) ) );
}
return new TimePoints( timepoints );
}
代码示例来源:origin: Unidata/thredds
/**
* Create a dataset-specific table from a jdom tree using the DSS parser
*
* @param paramTableElem the jdom tree
* @throws IOException on io error
*/
public Grib1ParamTableReader(org.jdom2.Element paramTableElem) throws IOException {
this.name = paramTableElem.getChildText("title");
DssParser p = new DssParser(Catalog.ncmlNS);
this.parameters = p.parseXml(paramTableElem);
}
代码示例来源:origin: edu.ucar/cdm
protected ThreddsMetadata.Range readGeospatialRange(Element spElem, String defUnits) {
if (spElem == null) return null;
double start = readDouble(spElem.getChild("start", defNS));
double size = readDouble(spElem.getChild("size", defNS));
double resolution = readDouble(spElem.getChild("resolution", defNS));
String units = spElem.getChildText("units", defNS);
if (units == null) units = defUnits;
return new ThreddsMetadata.Range(start, size, resolution, units);
}
代码示例来源:origin: edu.ucar/netcdf
protected ThreddsMetadata.Range readGeospatialRange( Element spElem, String defUnits) {
if (spElem == null) return null;
double start = readDouble( spElem.getChild("start", defNS));
double size = readDouble( spElem.getChild("size", defNS));
double resolution = readDouble( spElem.getChild("resolution", defNS));
String units = spElem.getChildText("units", defNS);
if (units == null) units = defUnits;
return new ThreddsMetadata.Range( start, size, resolution, units);
}
代码示例来源:origin: Unidata/thredds
protected ThreddsMetadata.Range readGeospatialRange(Element spElem, String defUnits) {
if (spElem == null) return null;
double start = readDouble(spElem.getChild("start", defNS));
double size = readDouble(spElem.getChild("size", defNS));
double resolution = readDouble(spElem.getChild("resolution", defNS));
String units = spElem.getChildText("units", defNS);
if (units == null) units = defUnits;
return new ThreddsMetadata.Range(start, size, resolution, units);
}
内容来源于网络,如有侵权,请联系作者删除!