本文整理了Java中org.jdom2.Element.cloneContent()
方法的一些代码示例,展示了Element.cloneContent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.cloneContent()
方法的具体详情如下:
包路径:org.jdom2.Element
类名称:Element
方法名:cloneContent
暂无
代码示例来源:origin: org.codehaus.plexus/plexus-component-metadata
public List cloneContent()
{
return element.cloneContent();
}
代码示例来源:origin: io.wcm/io.wcm.handler.richtext
/**
* Parses XHTML text string, and adds to parsed content to the given parent element.
* @param parent Parent element to add parsed content to
* @param text XHTML text string (root element not needed)
* @param xhtmlEntities If set to true, Resolving of XHtml entities in XHtml fragment is supported.
* @throws JDOMException Is thrown if the text could not be parsed as XHTML
*/
public static void addParsedText(@NotNull Element parent, @NotNull String text, boolean xhtmlEntities) throws JDOMException {
Element root = parseText(text, xhtmlEntities);
parent.addContent(root.cloneContent());
}
代码示例来源:origin: org.mycore/mycore-mods
public void mergeFrom(MCRMerger other) {
mergeAttributes(other);
MCRTitleInfoMerger otherTitle = (MCRTitleInfoMerger) other;
boolean otherHasSubTitleAndWeNot = textOf("subTitle").isEmpty() && !otherTitle.textOf("subTitle").isEmpty();
boolean otherTitleIsLonger = otherTitle.text.length() > this.text.length();
if (otherHasSubTitleAndWeNot || otherTitleIsLonger) {
this.element.setContent(other.element.cloneContent());
}
}
代码示例来源:origin: org.mycore/mycore-xeditor
public void undo(MCRChangeData data) {
data.getContext().setContent(data.getElement().cloneContent());
}
}
代码示例来源:origin: io.wcm/io.wcm.handler.richtext
private List<Content> processRichText(String text, UrlMode urlMode, MediaArgs mediaArgs) {
if (isEmpty(text)) {
return ImmutableList.of();
}
// Parse text
try {
Element contentParent = RichTextUtil.parseText(text, true);
// Rewrite content (e.g. anchor tags)
List<RewriteContentHandler> rewriters = getRewriterContentHandlers();
for (RewriteContentHandler rewriter : rewriters) {
RichTextUtil.rewriteContent(contentParent, rewriter);
}
// return xhtml elements
return ImmutableList.copyOf(contentParent.cloneContent());
}
catch (JDOMException ex) {
log.debug("Unable to parse XHTML text."
+ (currentPage != null ? " Current page is " + currentPage.getPath() + "." : ""), ex);
return ImmutableList.of();
}
}
代码示例来源:origin: io.wcm/io.wcm.handler.richtext
/**
* Checks if the given anchor element has to be rewritten.
* @param element Element to check
* @return null if nothing is to do with this element.
* Return empty list to remove this element.
* Return list with other content to replace element with new content.
*/
private List<Content> rewriteAnchor(Element element) {
// detect empty anchor elements and insert at least an empty string to avoid "self-closing" elements
// that are not handled correctly by most browsers
if (element.getContent().isEmpty()) {
element.setText("");
}
// resolve link metadata from DOM element
Link link = getAnchorLink(element);
// build anchor for link metadata
Element anchorElement = buildAnchorElement(link, element);
// Replace anchor tag or remove anchor tag if invalid - add any sub-content in every case
List<Content> content = new ArrayList<Content>();
if (anchorElement != null) {
anchorElement.addContent(element.cloneContent());
content.add(anchorElement);
}
else {
content.addAll(element.getContent());
}
return content;
}
代码示例来源:origin: crosswire/jsword
return div.cloneContent();
代码示例来源:origin: org.mycore/mycore-mods
@Override
public void mergeFrom(MCRMerger other) {
if (element.getParentElement().getName().equals("physicalDescription")) {
super.mergeFrom(other);
} else { // parent is "mods:part"
if ((!this.hasStartPage()) && ((MCRExtentMerger) other).hasStartPage()) {
mergeAttributes(other);
this.element.setContent(other.element.cloneContent());
}
}
}
}
代码示例来源:origin: org.mycore/mycore-mods
private void inheritToChild(MCRMODSWrapper parentWrapper, MCRMODSWrapper childWrapper) {
LOGGER.info("Inserting inherited Metadata.");
Element hostContainer = childWrapper.getElement(HOST_SECTION_XPATH);
if (hostContainer == null) {
LOGGER.info("Adding new relatedItem[@type='host'])");
hostContainer = new Element("relatedItem", MCRConstants.MODS_NAMESPACE)
.setAttribute("href", parentWrapper.getMCRObject().getId().toString(), MCRConstants.XLINK_NAMESPACE)
.setAttribute("type", "host");
childWrapper.addElement(hostContainer);
}
hostContainer.addContent(parentWrapper.getMODS().cloneContent());
}
代码示例来源:origin: org.mycore/mycore-mods
@Override
public void receiveMetadata(MCRObject child) {
MCRMODSWrapper childWrapper = new MCRMODSWrapper(child);
MCRObjectID parentID = child.getStructure().getParentID();
LOGGER.debug("Removing old inherited Metadata.");
childWrapper.removeInheritedMetadata();
if (parentID != null && MCRMODSWrapper.isSupported(parentID)) {
MCRObject parent = MCRMetadataManager.retrieveMCRObject(parentID);
MCRMODSWrapper parentWrapper = new MCRMODSWrapper(parent);
inheritToChild(parentWrapper, childWrapper);
}
for (Element relatedItem : childWrapper.getLinkedRelatedItems()) {
String type = relatedItem.getAttributeValue("type");
String holderId = relatedItem.getAttributeValue("href", MCRConstants.XLINK_NAMESPACE);
LOGGER.info("receive metadata from {} document {}", type, holderId);
if ((holderId == null || parentID != null && parentID.toString().equals(holderId))
&& MCRMODSRelationshipType.host.name().equals(type)) {
//already received metadata from parent;
continue;
}
MCRObjectID holderObjectID = MCRObjectID.getInstance(holderId);
if (MCRMODSWrapper.isSupported(holderObjectID)) {
MCRObject targetObject = MCRMetadataManager.retrieveMCRObject(holderObjectID);
MCRMODSWrapper targetWrapper = new MCRMODSWrapper(targetObject);
relatedItem.addContent(targetWrapper.getMODS().cloneContent());
}
}
}
代码示例来源:origin: org.mycore/mycore-mods
MCRConstants.MODS_NAMESPACE).negate();
relatedItem.removeContent(sharedMetadata);
relatedItem.addContent(holderWrapper.getMODS().cloneContent());
LOGGER.info("Saving: {}", recipientId);
try {
代码示例来源:origin: crosswire/jsword
/**
* Convert a Difference list into a pretty HTML report.
*
* @param diffs
* List of Difference objects
* @return HTML representation
*/
public static List<Content> diffToOsis(List<Difference> diffs) {
Element div = factory().createDiv();
for (int x = 0; x < diffs.size(); x++) {
Difference diff = diffs.get(x);
EditType editType = diff.getEditType(); // Mode (delete, equal,
// insert)
Text text = factory.createText(diff.getText()); // Text of change.
if (EditType.DELETE.equals(editType)) {
Element hi = factory().createHI();
hi.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.HI_LINETHROUGH);
hi.addContent(text);
div.addContent(hi);
} else if (EditType.INSERT.equals(editType)) {
Element hi = factory().createHI();
hi.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.HI_UNDERLINE);
hi.addContent(text);
div.addContent(hi);
} else {
div.addContent(text);
}
}
return div.cloneContent();
}
内容来源于网络,如有侵权,请联系作者删除!