本文整理了Java中org.jdom2.Element.indexOf()
方法的一些代码示例,展示了Element.indexOf()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.indexOf()
方法的具体详情如下:
包路径:org.jdom2.Element
类名称:Element
方法名:indexOf
暂无
代码示例来源:origin: org.codehaus.plexus/plexus-component-metadata
/**
* @param child The child.
* @return the index.
* @see org.jdom2.Element#indexOf(org.jdom2.Content)
*/
public int indexOf( Content child )
{
return element.indexOf( child );
}
代码示例来源:origin: org.mycore/mycore-xeditor
public static MCRChangeData swap(Element parent, Element a, Element b) {
int posA = parent.indexOf(a);
int posB = parent.indexOf(b);
return swap(parent, posA, a, posB, b);
}
代码示例来源: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: org.codehaus.izpack/izpack-util
@Override
public void perform(Element originalElement, Element patchElement, Element outputParentElement)
{
if (patchElement == null && originalElement != null)
{
outputParentElement.addContent((Element) originalElement.clone());
}
else
{
List<Content> outputContent = outputParentElement.getContent();
Iterator<Content> it = outputContent.iterator();
int lastIndex = outputContent.size();
while (it.hasNext())
{
Content content = it.next();
if (content instanceof Element)
{
Element element = (Element) content;
if (element.getQualifiedName().equals(patchElement.getQualifiedName()))
{
lastIndex = outputParentElement.indexOf(element);
}
}
}
List<Content> toAdd = new ArrayList<Content>();
toAdd.add(patchElement);
outputContent.addAll(Math.min(lastIndex + 1, outputContent.size()), toAdd);
}
}
代码示例来源:origin: org.mycore/mycore-xeditor
public MCRChangeData(ProcessingInstruction pi, String prefix) {
this.pi = pi;
this.context = pi.getParentElement();
this.pos = context.indexOf(pi);
this.type = pi.getTarget().substring(prefix.length());
String xml = "<x>" + pi.getData() + "</x>";
this.text = text2element(xml).getText();
}
代码示例来源:origin: org.mycore/mycore-xeditor
public static MCRChangeData remove(Element element) {
Element parent = element.getParentElement();
MCRChangeData data = new MCRChangeData("removed-element", element, parent.indexOf(element), parent);
element.detach();
return data;
}
代码示例来源:origin: org.openfuxml/ofx-util
@Deprecated
private Element mergeRecursive(Element rootElement) throws OfxInternalProcessingException
{
try
{
List<?> list = xpath.selectNodes(rootElement);
logger.debug(list.size()+" external sources in "+rootElement.getName()+" in "+rootFile.getAbsolutePath());
for (Iterator<?> iter = list.iterator(); iter.hasNext();)
{
Element childElement = (Element) iter.next();
String source =childElement.getAttribute("source").getValue();
File childFile = new File(rootFile.getParentFile(),source);
logger.trace("Found external in "+rpf.relativate(rootFile.getParentFile(), childFile));
ExternalContentEagerLoader em = new ExternalContentEagerLoader();
Element eEx = em.getExternal(childFile);
eEx.detach();
int index = childElement.getParentElement().indexOf(childElement);
childElement.getParentElement().setContent(index, eEx);
childElement.detach();
}
}
catch (JDOMException e) {logger.error("",e);}
return rootElement;
}
}
代码示例来源: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: Vhati/Slipstream-Mod-Manager
int index = contextNode.indexOf( candidate );
orderedCandidateMap.put( new Integer( index ), candidate );
代码示例来源:origin: org.openfuxml/ofx-wiki
public void integrateWikiAsExternal(Document ofxDoc) throws OfxAuthoringException
{
org.jdom2.Document doc = JaxbUtil.toDocument(ofxDoc);
try
{
List<?> list = xpath.selectNodes(doc.getRootElement());
logger.debug(list.size()+" <wiki:content/> found");
for (Iterator<?> iter = list.iterator(); iter.hasNext();)
{
Element eChild = (Element) iter.next();
logger.trace(eChild.getName());
Content wikiContent = (Content)JDomUtil.toJaxb(eChild, Content.class);
Element eOfx = processWikiContent(wikiContent);
wikiContent.setSource(eOfx.getAttributeValue("source"));
wikiQueries.getContent().add(wikiContent);
int index = eChild.getParentElement().indexOf(eChild);
eChild.getParentElement().addContent(index,eOfx);
eChild.detach();
}
}
catch (JDOMException e) {logger.error("",e);}
ofxDocWithWikisAsExternal = (Document)JDomUtil.toJaxb(doc, Document.class);
}
代码示例来源:origin: org.mycore/mycore-xeditor
public void insert(int pos) throws JaxenException {
if ("build".equals(method)) {
Element parentElement = getParentElement();
Element precedingElement = (Element) (getBoundNodes().get(pos - 1));
int posOfPrecedingInParent = parentElement.indexOf(precedingElement);
int targetPos = posOfPrecedingInParent + 1;
String pathToBuild = getElementNameWithPredicates();
Element newElement = (Element) (new MCRNodeBuilder().buildNode(pathToBuild, null, null));
parentElement.addContent(targetPos, newElement);
boundNodes.add(pos, newElement);
track(MCRAddedElement.added(newElement));
} else {
cloneBoundElement(pos - 1);
}
}
}
代码示例来源:origin: com.atlassian.maven.plugins/maven-jgitflow-plugin
root.getChildren().add(root.indexOf(artifactId) + 1, versionElement);
modified = true;
代码示例来源:origin: org.openfuxml/ofx-wiki
int iCodeParent = eCodeGrandParent.indexOf(eCode.getParentElement());
logger.debug(iCodeParent+"");
eCode.detach();
代码示例来源:origin: org.apache.jspwiki/jspwiki-main
boolean lastListItem = base.indexOf( e ) == ( base.getContentSize() - 2 );
boolean sublistItem = m_liStack.toString().length() > 1;
if( base.indexOf( e ) != 1 )
代码示例来源:origin: org.openfuxml/ofx-util
private Element loadElement(String resourceName) throws OfxAuthoringException
{
try
{
InputStream is = mrl.searchIs(resourceName);
org.jdom2.Document doc = JDomUtil.load(is);
Element root = doc.getRootElement();
List<Element> list = build().evaluate(root);
logger.debug("Now processing childs: "+list.size());
for(Element childElement : list)
{
String source = childElement.getAttribute("include").getValue();
String resourceChild = FilenameUtils.getFullPath(resourceName)+source;
logger.debug("Found external in "+resourceChild);
ExternalContentEagerLoader em = new ExternalContentEagerLoader();
Element eExternal = em.loadElement(resourceChild);
eExternal.detach();
int index = childElement.getParentElement().indexOf(childElement);
childElement.getParentElement().setContent(index, eExternal);
childElement.detach();
}
root.detach();
return root;
}
catch (FileNotFoundException e) {throw new OfxAuthoringException(e.getMessage());}
}
代码示例来源:origin: org.apache.maven.plugins/maven-shade-plugin
int index = parent.indexOf( element );
if ( index > 0 )
代码示例来源:origin: Vhati/Slipstream-Mod-Manager
int doomedIndex = contextNode.indexOf( doomedNode );
doomedNode.detach();
contextNode.addContent( doomedIndex, newNode );
内容来源于网络,如有侵权,请联系作者删除!