本文整理了Java中org.jdom.Attribute.getParent()
方法的一些代码示例,展示了Attribute.getParent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Attribute.getParent()
方法的具体详情如下:
包路径:org.jdom.Attribute
类名称:Attribute
方法名:getParent
[英]This will return the parent of this Attribute
. If there is no parent, then this returns null
.
[中]这将返回此Attribute
的父项。如果没有父项,则返回null
。
代码示例来源:origin: org.freemarker/freemarker
private static final Element getParent(Object node) {
if (node instanceof Element)
return((Element) node).getParent();
else if (node instanceof Attribute)
return((Attribute) node).getParent();
else if (node instanceof Text)
return((Text) node).getParent();
else if (node instanceof ProcessingInstruction)
return((ProcessingInstruction) node).getParent();
else if (node instanceof Comment)
return((Comment) node).getParent();
else if (node instanceof EntityRef)
return((EntityRef) node).getParent();
else
// With 2.1 semantics it makes more sense to just return a null and let the core
// throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR)
return null;
// throw new TemplateModelException("_parent can not be applied on " + node.getClass());
}
代码示例来源:origin: org.freemarker/freemarker
@Override
Object getParent(Object node) {
if (node instanceof Element) {
return((Element) node).getParent();
}
if (node instanceof Attribute) {
return((Attribute) node).getParent();
}
if (node instanceof Text) {
return((Text) node).getParent();
}
if (node instanceof ProcessingInstruction) {
return((ProcessingInstruction) node).getParent();
}
if (node instanceof Comment) {
return((Comment) node).getParent();
}
if (node instanceof EntityRef) {
return((EntityRef) node).getParent();
}
return null;
}
代码示例来源:origin: org.freemarker/freemarker
public List operate(Object node) {
Document doc = null;
if (node instanceof Element)
doc = ((Element) node).getDocument();
else if (node instanceof Attribute) {
Element parent = ((Attribute) node).getParent();
doc = parent == null ? null : parent.getDocument();
} else if (node instanceof Text) {
Element parent = ((Text) node).getParent();
doc = parent == null ? null : parent.getDocument();
} else if (node instanceof Document)
doc = (Document) node;
else if (node instanceof ProcessingInstruction)
doc = ((ProcessingInstruction) node).getDocument();
else if (node instanceof EntityRef)
doc = ((EntityRef) node).getDocument();
else if (node instanceof Comment)
doc = ((Comment) node).getDocument();
else
// With 2.1 semantics it makes more sense to just return a null and let the core
// throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR)
return null;
// throw new TemplateModelException("_document can not be applied on " + node.getClass());
return doc == null ? Collections.EMPTY_LIST : Collections.singletonList(doc);
}
}
代码示例来源:origin: org.freemarker/freemarker
@Override
Object getDocument(Object node) {
if (node instanceof Element) {
return ((Element) node).getDocument();
} else if (node instanceof Attribute) {
Element parent = ((Attribute) node).getParent();
return parent == null ? null : parent.getDocument();
} else if (node instanceof Text) {
Element parent = ((Text) node).getParent();
return parent == null ? null : parent.getDocument();
} else if (node instanceof Document)
return node;
else if (node instanceof ProcessingInstruction) {
return ((ProcessingInstruction) node).getDocument();
} else if (node instanceof EntityRef) {
return ((EntityRef) node).getDocument();
} else if (node instanceof Comment) {
return ((Comment) node).getDocument();
}
return null;
}
代码示例来源:origin: jaxen/jaxen
element = ((Attribute)context).getParent();
代码示例来源:origin: jaxen/jaxen
parent = ((Attribute)contextNode).getParent();
代码示例来源:origin: commons-jxpath/commons-jxpath
public void remove() {
attr.getParent().removeAttribute(attr);
}
代码示例来源:origin: org.jdom/jdom-legacy
/**
* This retrieves the owning <code>{@link Document}</code> for
* this Attribute, or null if not a currently a member of a
* <code>{@link Document}</code>.
*
* @return <code>Document</code> owning this Attribute, or null.
*/
public Document getDocument() {
final Element parentElement = getParent();
if (parentElement != null) {
return parentElement.getDocument();
}
return null;
}
代码示例来源:origin: org.jdom/jdom-legacy
/**
* This detaches the <code>Attribute</code> from its parent, or does
* nothing if the <code>Attribute</code> has no parent.
*
* @return <code>Attribute</code> - this <code>Attribute</code> modified.
*/
public Attribute detach() {
final Element parentElement = getParent();
if (parentElement != null) {
parentElement.removeAttribute(getName(),getNamespace());
}
return this;
}
代码示例来源:origin: org.jdom/jdom-legacy
/**
* Set the object at the specified location to the supplied
* object. Note: does not check for duplicate attributes.
*
* @param index The location to set the value to.
* @param attribute The attribute to set.
* @return The object which was replaced.
* throws IndexOutOfBoundsException if index < 0 || index >= size()
*/
Object set(int index, Attribute attribute) {
if (index < 0 || index >= size)
throw new IndexOutOfBoundsException("Index: " + index +
" Size: " + size());
if (attribute.getParent() != null) {
throw new IllegalAddException(
"The attribute already has an existing parent \"" +
attribute.getParent().getQualifiedName() + "\"");
}
String reason = Verifier.checkNamespaceCollision(attribute, parent);
if (reason != null) {
throw new IllegalAddException(parent, attribute, reason);
}
Attribute old = (Attribute) elementData[index];
old.setParent(null);
elementData[index] = attribute;
attribute.setParent(parent);
return old;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker
private static final Element getParent(Object node) {
if (node instanceof Element)
return((Element) node).getParent();
else if (node instanceof Attribute)
return((Attribute) node).getParent();
else if (node instanceof Text)
return((Text) node).getParent();
else if (node instanceof ProcessingInstruction)
return((ProcessingInstruction) node).getParent();
else if (node instanceof Comment)
return((Comment) node).getParent();
else if (node instanceof EntityRef)
return((EntityRef) node).getParent();
else
// With 2.1 semantics it makes more sense to just return a null and let the core
// throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR)
return null;
// throw new TemplateModelException("_parent can not be applied on " + node.getClass());
}
代码示例来源:origin: org.freemarker/freemarker-gae
private static final Element getParent(Object node) {
if (node instanceof Element)
return((Element) node).getParent();
else if (node instanceof Attribute)
return((Attribute) node).getParent();
else if (node instanceof Text)
return((Text) node).getParent();
else if (node instanceof ProcessingInstruction)
return((ProcessingInstruction) node).getParent();
else if (node instanceof Comment)
return((Comment) node).getParent();
else if (node instanceof EntityRef)
return((EntityRef) node).getParent();
else
// With 2.1 semantics it makes more sense to just return a null and let the core
// throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR)
return null;
// throw new TemplateModelException("_parent can not be applied on " + node.getClass());
}
代码示例来源:origin: org.freemarker/com.springsource.freemarker
private static final Element getParent(Object node)
{
if (node instanceof Element)
return((Element)node).getParent();
else if (node instanceof Attribute)
return((Attribute)node).getParent();
else if (node instanceof Text)
return((Text)node).getParent();
else if (node instanceof ProcessingInstruction)
return((ProcessingInstruction)node).getParent();
else if (node instanceof Comment)
return((Comment)node).getParent();
else if (node instanceof EntityRef)
return((EntityRef)node).getParent();
else
// With 2.1 semantics it makes more sense to just return a null and let the core
// throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR)
return null;
// throw new TemplateModelException("_parent can not be applied on " + node.getClass());
}
代码示例来源:origin: org.freemarker/com.springsource.freemarker
Object getParent(Object node) {
if (node instanceof Element) {
return((Element)node).getParent();
}
if (node instanceof Attribute) {
return((Attribute)node).getParent();
}
if (node instanceof Text) {
return((Text)node).getParent();
}
if (node instanceof ProcessingInstruction) {
return((ProcessingInstruction)node).getParent();
}
if (node instanceof Comment) {
return((Comment)node).getParent();
}
if (node instanceof EntityRef) {
return((EntityRef)node).getParent();
}
return null;
}
代码示例来源:origin: org.freemarker/freemarker-gae
@Override
Object getParent(Object node) {
if (node instanceof Element) {
return((Element) node).getParent();
}
if (node instanceof Attribute) {
return((Attribute) node).getParent();
}
if (node instanceof Text) {
return((Text) node).getParent();
}
if (node instanceof ProcessingInstruction) {
return((ProcessingInstruction) node).getParent();
}
if (node instanceof Comment) {
return((Comment) node).getParent();
}
if (node instanceof EntityRef) {
return((EntityRef) node).getParent();
}
return null;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker
@Override
Object getParent(Object node) {
if (node instanceof Element) {
return((Element) node).getParent();
}
if (node instanceof Attribute) {
return((Attribute) node).getParent();
}
if (node instanceof Text) {
return((Text) node).getParent();
}
if (node instanceof ProcessingInstruction) {
return((ProcessingInstruction) node).getParent();
}
if (node instanceof Comment) {
return((Comment) node).getParent();
}
if (node instanceof EntityRef) {
return((EntityRef) node).getParent();
}
return null;
}
代码示例来源:origin: org.freemarker/freemarker-gae
public List operate(Object node) {
Document doc = null;
if (node instanceof Element)
doc = ((Element) node).getDocument();
else if (node instanceof Attribute) {
Element parent = ((Attribute) node).getParent();
doc = parent == null ? null : parent.getDocument();
} else if (node instanceof Text) {
Element parent = ((Text) node).getParent();
doc = parent == null ? null : parent.getDocument();
} else if (node instanceof Document)
doc = (Document) node;
else if (node instanceof ProcessingInstruction)
doc = ((ProcessingInstruction) node).getDocument();
else if (node instanceof EntityRef)
doc = ((EntityRef) node).getDocument();
else if (node instanceof Comment)
doc = ((Comment) node).getDocument();
else
// With 2.1 semantics it makes more sense to just return a null and let the core
// throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR)
return null;
// throw new TemplateModelException("_document can not be applied on " + node.getClass());
return doc == null ? Collections.EMPTY_LIST : Collections.singletonList(doc);
}
}
代码示例来源:origin: org.freemarker/freemarker-gae
@Override
Object getDocument(Object node) {
if (node instanceof Element) {
return ((Element) node).getDocument();
} else if (node instanceof Attribute) {
Element parent = ((Attribute) node).getParent();
return parent == null ? null : parent.getDocument();
} else if (node instanceof Text) {
Element parent = ((Text) node).getParent();
return parent == null ? null : parent.getDocument();
} else if (node instanceof Document)
return node;
else if (node instanceof ProcessingInstruction) {
return ((ProcessingInstruction) node).getDocument();
} else if (node instanceof EntityRef) {
return ((EntityRef) node).getDocument();
} else if (node instanceof Comment) {
return ((Comment) node).getDocument();
}
return null;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker
@Override
Object getDocument(Object node) {
if (node instanceof Element) {
return ((Element) node).getDocument();
} else if (node instanceof Attribute) {
Element parent = ((Attribute) node).getParent();
return parent == null ? null : parent.getDocument();
} else if (node instanceof Text) {
Element parent = ((Text) node).getParent();
return parent == null ? null : parent.getDocument();
} else if (node instanceof Document)
return node;
else if (node instanceof ProcessingInstruction) {
return ((ProcessingInstruction) node).getDocument();
} else if (node instanceof EntityRef) {
return ((EntityRef) node).getDocument();
} else if (node instanceof Comment) {
return ((Comment) node).getDocument();
}
return null;
}
代码示例来源:origin: org.freemarker/com.springsource.freemarker
Object getDocument(Object node) {
if (node instanceof Element) {
return ((Element)node).getDocument();
}
else if (node instanceof Attribute) {
Element parent = ((Attribute)node).getParent();
return parent == null ? null : parent.getDocument();
}
else if (node instanceof Text) {
Element parent = ((Text)node).getParent();
return parent == null ? null : parent.getDocument();
}
else if (node instanceof Document)
return node;
else if (node instanceof ProcessingInstruction) {
return ((ProcessingInstruction)node).getDocument();
}
else if (node instanceof EntityRef) {
return ((EntityRef)node).getDocument();
}
else if (node instanceof Comment) {
return ((Comment)node).getDocument();
}
return null;
}
内容来源于网络,如有侵权,请联系作者删除!