本文整理了Java中org.jdom2.Element.removeContent()
方法的一些代码示例,展示了Element.removeContent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.removeContent()
方法的具体详情如下:
包路径:org.jdom2.Element
类名称:Element
方法名:removeContent
[英]Removes all child content from this parent.
[中]从此父级中删除所有子内容。
代码示例来源:origin: geotools/geotools
public void assignTo(Element element) {
if (!element.getName().equals(GeoTiffConstants.GEOTIFF_IIO_ROOT_ELEMENT_NAME)) {
throw new IllegalArgumentException(
"root not found: " + GeoTiffConstants.GEOTIFF_IIO_ROOT_ELEMENT_NAME);
}
final Element ifd1 = element.getChild(GeoTiffConstants.GEOTIFF_IFD_TAG);
if (ifd1 == null) {
throw new IllegalArgumentException(
"Unable to find child " + GeoTiffConstants.GEOTIFF_IFD_TAG);
}
final Element ifd2 = createIFD();
ifd1.setAttribute(
GeoTiffConstants.GEOTIFF_TAGSETS_ATT_NAME,
ifd2.getAttributeValue(GeoTiffConstants.GEOTIFF_TAGSETS_ATT_NAME));
final Element[] childElems = (Element[]) ifd2.getChildren().toArray(new Element[0]);
for (int i = 0; i < childElems.length; i++) {
final Element child = childElems[i];
ifd2.removeContent(child);
ifd1.addContent(child);
}
}
代码示例来源:origin: org.codehaus.plexus/plexus-component-metadata
/**
* @see org.jdom2.Element#removeContent(org.jdom2.filter.Filter)
* @param filter {@link Filter}.
* @return list of elements.
*/
public List removeContent( Filter filter )
{
return element.removeContent( filter );
}
代码示例来源:origin: org.codehaus.plexus/plexus-component-metadata
/**
* @see org.jdom2.Element#removeContent()
* @return list of elements.
*/
public List removeContent()
{
return element.removeContent();
}
代码示例来源:origin: org.codehaus.plexus/plexus-component-metadata
/**
* @see org.jdom2.Element#removeContent(org.jdom2.Content)
* @param child {@link Content}
* @return true/false.
*/
public boolean removeContent( Content child )
{
return element.removeContent( child );
}
代码示例来源:origin: org.codehaus.plexus/plexus-component-metadata
/**
* @see org.jdom2.Element#removeContent(int)
* @param index The index.
* @return {@link Content}
*/
public Content removeContent( int index )
{
return element.removeContent( index );
}
代码示例来源:origin: crosswire/jsword
@Override
public void processContent(Book book, Key key, Element ele) {
// Replace the parent with this element
Element parent = ele.getParentElement();
parent.removeContent(ele);
parent.addContent(ele.removeContent());
}
}
代码示例来源:origin: crosswire/jsword
@Override
public void processContent(Book book, Key key, Element ele) {
// Remove this element and all it's children
Element parent = ele.getParentElement();
parent.removeContent(ele);
}
}
代码示例来源:origin: crosswire/jsword
public List<Content> toOSIS(Book book, Key key, String plain) {
Element ele = OSISUtil.factory().createDiv();
LinkedList<Content> stack = new LinkedList<Content>();
stack.addFirst(ele);
List<Tag> taglist = parseTags(book, key, plain.trim());
while (true) {
if (taglist.isEmpty()) {
break;
}
Tag tag = taglist.remove(0);
tag.updateOsisStack(book, key, stack);
}
stack.removeFirst();
return ele.removeContent();
}
代码示例来源:origin: crosswire/jsword
public List<Content> toOSIS(Book book, Key key, String plain) {
Element ele = cleanParse(book, key, plain);
if (ele == null) {
if (error instanceof SAXParseException) {
SAXParseException spe = (SAXParseException) error;
int colNumber = spe.getColumnNumber();
int start = Math.max(0, colNumber - 40);
int stop = Math.min(finalInput.length(), colNumber + 40);
int here = stop - start;
log.warn("Could not fix {}({}) by {}: Error here({},{},{}): {}",
book.getInitials(),
key.getName(),
errorMessage,
Integer.toString(colNumber),
Integer.toString(finalInput.length()),
Integer.toString(here),
finalInput.substring(start, stop));
} else {
log.warn("Could not fix {}({}) by {}: {}",
book.getInitials(),
key.getName(),
errorMessage,
error.getMessage());
}
ele = OSISUtil.factory().createP();
}
return ele.removeContent();
}
代码示例来源:origin: crosswire/jsword
public void updateOsisStack(Book book, Key key, LinkedList<Content> stack) {
if (stack.isEmpty()) {
DataPolice.report(book, key, "Ignoring end tag without corresponding start tag: " + getName());
return;
}
Object pop = stack.removeFirst();
if (!(pop instanceof Element)) {
DataPolice.report(book, key, "expected to pop a Note, but found " + ClassUtil.getShortClassName(pop.getClass()));
return;
}
Element note = (Element) pop;
if (note.getContentSize() < 1) {
Content top = stack.get(0);
if (top instanceof Element) {
Element ele = (Element) top;
ele.removeContent(note);
}
}
}
}
代码示例来源:origin: pwm-project/pwm
public void resetSetting( final PwmSetting setting, final String profileID, final UserIdentity userIdentity )
{
changeLog.updateChangeLog( setting, profileID, defaultValue( setting, this.getTemplateSet() ) );
domModifyLock.writeLock().lock();
try
{
preModifyActions();
final Element settingElement = createOrGetSettingElement( document, setting, profileID );
settingElement.removeContent();
settingElement.addContent( new Element( XML_ELEMENT_DEFAULT ) );
updateMetaData( settingElement, userIdentity );
}
finally
{
domModifyLock.writeLock().unlock();
}
}
代码示例来源:origin: org.openfuxml/ofx-util
private Element mergeRecursive(Element rootElement, XPath xpath) throws OfxInternalProcessingException
{
try
{
List<?> list = xpath.selectNodes(rootElement);
logger.debug(list.size()+" sections");
for (Iterator<?> iter = list.iterator(); iter.hasNext();)
{
Element e = (Element) iter.next();
int index = e.getParentElement().indexOf(e);
List<Element> lChilds = new ArrayList<Element>();
if (e.getName().equalsIgnoreCase(Sections.class.getSimpleName())){lChilds = processSections(e.getChildren());}
else if(e.getName().equalsIgnoreCase(Section.class.getSimpleName())){lChilds = processSection(e.getChildren());}
else {throw new OfxInternalProcessingException("Root element <"+e.getName()+"> of Wiki.Processing not expected");}
e.getParentElement().addContent(index, lChilds);
e.getParentElement().removeContent(e);
}
}
catch (JDOMException e) {logger.error("",e);}
return rootElement;
}
代码示例来源:origin: org.openfuxml/ofx-wiki
private Element exchangeParagraphByTemplate(Element rootElement, XPath xpath)
{
try
{
List<?> list = xpath.selectNodes(rootElement);
logger.debug(list.size()+" sections");
for (Iterator<?> iter = list.iterator(); iter.hasNext();)
{
Element eTemplate = (Element) iter.next();
int index = eTemplate.getParentElement().getParentElement().indexOf(eTemplate.getParentElement());
Element parent = eTemplate.getParentElement().getParentElement();
eTemplate.detach();
parent.removeContent(index);
parent.addContent(index, createExternalTemplate(eTemplate));
}
}
catch (JDOMException e) {logger.error("",e);}
return rootElement;
}
代码示例来源:origin: com.xebialabs.cloud/overcast
public static void removeFilesystemsWithTarget(Document domainXml, String targetDir) {
XPathFactory xpf = XPathFactory.instance();
XPathExpression<Element> fsExpr = xpf.compile(String.format("/domain/devices/filesystem[@type='mount']/target[@dir='%s']", targetDir), Filters.element());
List<Element> tfs = fsExpr.evaluate(domainXml);
for (Element e : tfs) {
e.getParentElement().getParentElement().removeContent(e.getParentElement());
}
}
代码示例来源:origin: org.mycore/mycore-restapi
private void filterNonEmpty(String classId, Element e) {
SolrClient solrClient = MCRSolrClientFactory.getMainSolrClient();
for (int i = 0; i < e.getChildren("category").size(); i++) {
Element cat = e.getChildren("category").get(i);
SolrQuery solrQquery = new SolrQuery();
solrQquery.setQuery(
"category:\"" + MCRSolrUtils.escapeSearchValue(classId + ":" + cat.getAttributeValue("ID")) + "\"");
solrQquery.setRows(0);
try {
QueryResponse response = solrClient.query(solrQquery);
SolrDocumentList solrResults = response.getResults();
if (solrResults.getNumFound() == 0) {
e.removeContent(cat);
i--;
}
} catch (SolrServerException | IOException exc) {
LOGGER.error(exc);
}
}
for (int i = 0; i < e.getChildren("category").size(); i++) {
filterNonEmpty(classId, e.getChildren("category").get(i));
}
}
代码示例来源:origin: com.xebialabs.cloud/overcast
public static void updateCloneMetadata(Document domainXml, String baseDomainName, Date creationTime) {
checkArgument(baseDomainName, "baseDomainName");
Preconditions.checkNotNull(creationTime, "creationTime must not be null");
Element element = getMetadataElement(domainXml);
if (element != null) {
domainXml.getRootElement().removeContent(element);
}
Element metadata = createCloningMetadata(baseDomainName, creationTime);
domainXml.getRootElement().addContent(metadata);
}
代码示例来源:origin: org.mycore/mycore-restapi
/**
* Output xml
* @param eRoot - the root element
* @param lang - the language which should be filtered or null for no filter
* @return a string representation of the XML
* @throws IOException
*/
private static String writeXML(Element eRoot, String lang) throws IOException {
StringWriter sw = new StringWriter();
if (lang != null) {
// <label xml:lang="en" text="part" />
XPathExpression<Element> xpE = XPathFactory.instance().compile("//label[@xml:lang!='" + lang + "']",
Filters.element(), null, Namespace.XML_NAMESPACE);
for (Element e : xpE.evaluate(eRoot)) {
e.getParentElement().removeContent(e);
}
}
XMLOutputter xout = new XMLOutputter(Format.getPrettyFormat());
Document docOut = new Document(eRoot.detach());
xout.output(docOut, sw);
return sw.toString();
}
代码示例来源:origin: crosswire/jsword
public List<Content> toOSIS(Book book, Key key, String plain) {
OSISUtil.OSISFactory factory = OSISUtil.factory();
Element ele = factory.createDiv();
String[] lines = StringUtil.splitAll(plain, '\n');
int lastIndex = lines.length - 1;
for (int i = 0; i < lastIndex; i++) {
// TODO(DMS): Preserve whitespace, in a smart manner.
ele.addContent(lines[i]);
ele.addContent(factory.createLB());
}
// Don't add a line break after the last line.
if (lastIndex >= 0) {
ele.addContent(lines[lastIndex]);
}
return ele.removeContent();
}
代码示例来源:origin: com.xebialabs.cloud/overcast
public static void updateProvisioningMetadata(Document domainXml, String baseDomainName, String provisionCmd, String expirationTag, Date creationTime) {
checkArgument(baseDomainName, "baseDomainName");
checkArgument(provisionCmd, "provisionCmd");
checkArgument(expirationTag, "expirationTag");
Preconditions.checkNotNull(creationTime, "creationTime must not be null");
Element element = getMetadataElement(domainXml);
if (element != null) {
domainXml.getRootElement().removeContent(element);
}
Element metadata = createProvisioningMetadata(baseDomainName, provisionCmd, expirationTag, creationTime);
domainXml.getRootElement().addContent(metadata);
}
代码示例来源:origin: dqeasycloud/easy-cloud
/** 更新id为setColumnSql的子节点 */
protected void updateSetColumnSqlChidren(Element rootElement) {
Element setColumnSqlElement = findElementById(EcMyBatisSqlTypeEnum.SET_COLUMN_SQL.getDesc(), rootElement,
EcMyBatisElementNameEnum.SQL.getDesc());
Element setElement = setColumnSqlElement.getChild(EcMyBatisElementNameEnum.SET.getDesc());
if (EcBaseUtils.isNull(setElement)) {
setElement = new Element(EcMyBatisElementNameEnum.SET.getDesc());
setColumnSqlElement.addContent(setElement);
}
List<Element> ifElements = new ArrayList<>();
for (EcGenerateXmlMybatisData data : mybatisDTO.getDatas()) {
Element ifElement = new Element(EcMyBatisElementNameEnum.IF.getDesc());
ifElement.setAttribute(EcMyBatisAttrKey.TEST, getTestAttrValue(data));
ifElement.setText(getIfElementText(data));
ifElements.add(ifElement);
}
setElement.removeContent();
setElement.setContent(ifElements);
}
内容来源于网络,如有侵权,请联系作者删除!