本文整理了Java中org.jdom2.Element.clone()
方法的一些代码示例,展示了Element.clone()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.clone()
方法的具体详情如下:
包路径:org.jdom2.Element
类名称:Element
方法名:clone
[英]This returns a deep clone of this element. The new element is detached from its parent, and getParent() on the clone will return null.
[中]这将返回此元素的深层克隆。新元素将与其父元素分离,克隆上的getParent()将返回null。
代码示例来源:origin: org.codehaus.izpack/izpack-util
@Override
public Element map(Element patchElement)
{
if (patchElement == null) { return null; }
return (Element) patchElement.clone();
}
代码示例来源:origin: org.codehaus.plexus/plexus-component-metadata
public Object clone()
{
return element.clone();
}
代码示例来源:origin: org.jdom/jdom
Object obj = content.get(i);
if (obj instanceof Element) {
Element element = ((Element)obj).clone();
doc.content.add(element);
代码示例来源:origin: org.codehaus.izpack/izpack-util
@Override
public void perform(Element originalElement, Element patchElement, Element outputParentElement)
{
if (originalElement != null && patchElement == null)
{
outputParentElement.addContent((Element) originalElement.clone());
}
}
代码示例来源:origin: org.codehaus.izpack/izpack-util
@Override
public void perform(Element originalElement, Element patchElement, Element outputParentElement)
{
if (originalElement != null && patchElement != null)
{
outputParentElement.addContent((Element) patchElement.clone());
}
else if (originalElement != null)
{
outputParentElement.addContent((Element) originalElement.clone());
}
}
代码示例来源:origin: org.codehaus.izpack/izpack-util
@Override
public void perform(Element originalElement, Element patchElement, Element outputParentElement)
{
if (originalElement != null && patchElement != null)
{
outputParentElement.addContent((Element) patchElement.clone());
}
}
代码示例来源:origin: org.codehaus.izpack/izpack-util
@Override
public void perform(Element originalElement, Element patchElement, Element outputParentElement)
{
if (originalElement != null)
{
outputParentElement.addContent((Element) originalElement.clone());
}
}
代码示例来源:origin: org.codehaus.izpack/izpack-util
@Override
public void perform(Element originalElement, Element patchElement, Element outputParentElement)
{
if (patchElement != null)
{
outputParentElement.addContent((Element) patchElement.clone());
}
else
{
outputParentElement.addContent((Element) originalElement.clone());
}
}
代码示例来源:origin: org.mycore/mycore-oai
@Override
public Element toXML() {
return description.getChildren().get(0).clone();
}
代码示例来源:origin: org.mycore/mycore-xeditor
public static MCRChangeData setText(Element element, String text) {
Element clone = element.clone();
for (Iterator<Attribute> attributes = clone.getAttributes().iterator(); attributes.hasNext();) {
attributes.next();
attributes.remove();
}
MCRChangeData data = new MCRChangeData("set-text", clone, 0, element);
element.setText(text);
return data;
}
代码示例来源:origin: org.mycore/mycore-orcid
/**
* Returns a single mods:mods representation of the publication represented by this group.
* The MODS from each is merged together.
*/
public Element buildMergedMODS() {
Element mods = works.get(0).getMODS().clone();
for (int i = 1; i < works.size(); i++) {
MCRMergeTool.merge(mods, works.get(i).getMODS());
}
return mods;
}
}
代码示例来源:origin: org.mycore/mycore-xeditor
public Element cloneBoundElement(int index) {
Element template = (Element) (boundNodes.get(index));
Element newElement = template.clone();
Element parent = template.getParentElement();
int indexInParent = parent.indexOf(template) + 1;
parent.addContent(indexInParent, newElement);
boundNodes.add(index + 1, newElement);
trackNodeCreated(newElement);
return newElement;
}
代码示例来源:origin: edu.ucar/netcdf
void add(Element elem, Element parent) {
if (elem.getName().equals("object"))
parent.addContent( (Element) elem.clone());
for (Object child : elem.getChildren()) {
add((Element) child, parent);
}
}
代码示例来源:origin: Unidata/thredds
private void add(Element elem, Element parent) {
if (elem.getName().equals("object")) {
parent.addContent( elem.clone());
return;
}
for (Object child : elem.getChildren()) {
add((Element) child, parent);
}
}
代码示例来源:origin: edu.ucar/netcdf
private void add(Element elem, Element parent) {
if (elem.getName().equals("object")) {
parent.addContent( (Element) elem.clone());
return;
}
for (Object child : elem.getChildren()) {
add((Element) child, parent);
}
}
代码示例来源:origin: LendingClub/mercator
public void logDebug(String message, Element element) {
if (logger.isDebugEnabled()) {
XMLOutputter out = new XMLOutputter();
out.setFormat(Format.getPrettyFormat());
element = element.clone();
if (!Strings.isNullOrEmpty(element.getAttributeValue("outCookie"))) {
element.setAttribute("outCookie", "**********");
}
if (!Strings.isNullOrEmpty(element.getAttributeValue("cookie"))) {
element.setAttribute("cookie", "**********");
}
logger.debug(message + "\n{}", out.outputString(element));
}
}
代码示例来源:origin: rometools/rome
protected List<Element> extractForeignMarkup(final Element e, final Extendable ext, final Namespace namespace) {
final ArrayList<Element> foreignElements = new ArrayList<Element>();
for (final Element element : e.getChildren()) {
if (!namespace.equals(element.getNamespace()) && ext.getModule(element.getNamespaceURI()) == null) {
// if element not in the RSS namespace and elem was not handled by a module save it
// as foreign markup but we can't detach it while we're iterating
foreignElements.add(element.clone());
}
}
// now we can detach the foreign markup elements
for (final Element foreignElement : foreignElements) {
foreignElement.detach();
}
return foreignElements;
}
代码示例来源:origin: LendingClub/mercator
public void logInfo(String message, Element element) {
XMLOutputter out = new XMLOutputter();
out.setFormat(Format.getPrettyFormat());
element = element.clone();
if (!Strings.isNullOrEmpty(element.getAttributeValue("outCookie"))) {
element.setAttribute("outCookie", "**********");
}
if (!Strings.isNullOrEmpty(element.getAttributeValue("cookie"))) {
element.setAttribute("cookie", "**********");
}
logger.info(message + "\n{}", out.outputString(element));
}
代码示例来源:origin: org.mycore/mycore-mods
private Element cloneRelatedItem(Element relatedItem) {
Element mods = relatedItem.clone();
mods.setName("mods");
mods.removeAttribute("type");
mods.removeAttribute("href", MCRConstants.XLINK_NAMESPACE);
mods.removeAttribute("type", MCRConstants.XLINK_NAMESPACE);
mods.removeChildren("part", MCRConstants.MODS_NAMESPACE);
return mods;
}
代码示例来源:origin: org.mycore/mycore-xeditor
public MCRJDOMContent transform(MCRContent source) throws IOException {
try {
Element root = source.asXML().getRootElement().clone();
for (Text text : root.getDescendants(Filters.text())) {
text.setText(MCRXMLFunctions.normalizeUnicode(text.getText()));
}
return new MCRJDOMContent(root);
} catch (JDOMException | SAXException ex) {
throw new IOException(ex);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!