本文整理了Java中org.apache.axiom.om.OMNode.getType()
方法的一些代码示例,展示了OMNode.getType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OMNode.getType()
方法的具体详情如下:
包路径:org.apache.axiom.om.OMNode
类名称:OMNode
方法名:getType
[英]Returns the type of node.
[中]返回节点的类型。
代码示例来源:origin: org.ballerinalang/ballerina-core
private void setXMLNodeType() {
switch (omNode.getType()) {
case OMNode.ELEMENT_NODE:
nodeType = XMLNodeType.ELEMENT;
break;
case OMNode.TEXT_NODE:
nodeType = XMLNodeType.TEXT;
break;
case OMNode.COMMENT_NODE:
nodeType = XMLNodeType.COMMENT;
break;
case OMNode.PI_NODE:
nodeType = XMLNodeType.PI;
break;
default:
nodeType = XMLNodeType.SEQUENCE;
break;
}
}
代码示例来源:origin: org.apache.ws.commons.axiom/axiom-impl
public List getAllSoapTexts() {
List faultTexts = new ArrayList(1);
Iterator childrenIter = this.getChildren();
while (childrenIter.hasNext()) {
OMNode node = (OMNode) childrenIter.next();
if (node.getType() == OMNode.ELEMENT_NODE && (node instanceof SOAPFaultText)) {
faultTexts.add(((SOAPFaultText) node));
}
}
return faultTexts;
}
代码示例来源:origin: org.apache.ws.commons.axiom/axiom-api
/**
* Gets the valid element collection of an OMDocument. OMElement and OMProcessingInstruction
* only
*
* @param document
* @return Returns a collection of OMProcessingInstructions and OMElements
*/
public Collection getValidElements(OMDocument document) {
ArrayList list = new ArrayList();
Iterator itr = document.getChildren();
while (itr.hasNext()) {
OMNode node = (OMNode) itr.next();
if (node.getType() == OMNode.ELEMENT_NODE || node.getType() == OMNode.PI_NODE)
list.add(node);
}
return list;
}
代码示例来源:origin: org.apache.ws.commons.axiom/axiom-impl
public SOAPFaultText getSOAPFaultText(String language) {
Iterator childrenIter = this.getChildren();
while (childrenIter.hasNext()) {
OMNode node = (OMNode) childrenIter.next();
if (node.getType() == OMNode.ELEMENT_NODE && (node instanceof SOAPFaultText) &&
(language == null || language.equals(((SOAPFaultText) node).getLang()))) {
return (SOAPFaultText) node;
}
}
return null;
}
}
代码示例来源:origin: org.bluestemsoftware.open.eoa.ext/open-eoa-aspect-axiom
public List getAllSoapTexts() {
//TODO Ruchith check
List faultTexts = new ArrayList();
Iterator childrenIter = this.getChildren();
while (childrenIter.hasNext()) {
OMNode node = (OMNode) childrenIter.next();
if (node.getType() == OMNode.ELEMENT_NODE && (node instanceof SOAPFaultTextImpl)) {
faultTexts.add(((SOAPFaultTextImpl) node));
}
}
return faultTexts;
}
代码示例来源:origin: org.apache.ws.commons.axiom/axiom-api
/**
* This method is an overloaded method for the digest generation for OMNode
*
* @param node
* @param digestAlgorithm
* @return Returns a byte array representing the calculated digest value
*/
public byte[] getDigest(OMNode node, String digestAlgorithm) {
if (node.getType() == OMNode.ELEMENT_NODE)
return getDigest((OMElement) node, digestAlgorithm);
else if (
node.getType() == OMNode.TEXT_NODE)
return getDigest((OMText) node, digestAlgorithm);
else if (node.getType() == OMNode.PI_NODE)
return getDigest((OMProcessingInstruction) node, digestAlgorithm);
else return new byte[0];
}
代码示例来源:origin: org.paxml/PaxmlCore
private String getInnerXml(OMElement ele) {
StringBuilder sb = new StringBuilder();
for (Iterator<OMNode> it = ele.getChildren(); it.hasNext();) {
OMNode node = it.next();
if (node.getType() == OMNode.TEXT_NODE) {
sb.append(((OMText) node).getText());
} else if (node.getType() == OMNode.COMMENT_NODE) {
sb.append("<!--").append(((OMComment) node).getValue()).append("-->");
} else {
sb.append(node.toString());
}
}
return sb.toString();
}
}
代码示例来源:origin: org.apache.abdera/abdera-parser
public String[] getProcessingInstruction(String target) {
List<String> values = new ArrayList<String>();
for (Iterator i = getChildren(); i.hasNext();) {
OMNode node = (OMNode)i.next();
if (node.getType() == OMNode.PI_NODE) {
OMProcessingInstruction pi = (OMProcessingInstruction)node;
if (pi.getTarget().equalsIgnoreCase(target))
values.add(pi.getValue());
}
}
return values.toArray(new String[values.size()]);
}
代码示例来源:origin: org.apache.synapse/synapse-core
public static String getTextPayload(SOAPEnvelope envelope) {
OMElement el = getXMLPayload(envelope);
if (el == null)
return null;
if (!el.getQName().equals(TEXTELT)) {
log.error("Wrong QName " + el.getQName());
return null;
}
OMNode textNode = el.getFirstOMChild();
if (textNode.getType() != OMNode.TEXT_NODE) {
log.error("Text Node not found");
return null;
}
return el.getText();
}
代码示例来源:origin: org.paxml/paxml-core
private String getInnerXml(OMElement ele) {
StringBuilder sb = new StringBuilder();
for (Iterator<OMNode> it = ele.getChildren(); it.hasNext();) {
OMNode node = it.next();
if (node.getType() == OMNode.TEXT_NODE) {
sb.append(((OMText) node).getText());
} else if (node.getType() == OMNode.COMMENT_NODE) {
sb.append("<!--").append(((OMComment) node).getValue()).append("-->");
} else {
sb.append(node.toString());
}
}
return sb.toString();
}
}
代码示例来源:origin: org.apache.ws.commons.axiom/axiom-api
/**
* @deprecated please use OMElement.getFirstChildWithName(qname) instead!
*/
public static OMElement getChildWithName(OMElement parent,
String childName) {
Iterator childrenIter = parent.getChildren();
while (childrenIter.hasNext()) {
OMNode node = (OMNode) childrenIter.next();
if (node.getType() == OMNode.ELEMENT_NODE &&
childName.equals(((OMElement) node).getLocalName())) {
return (OMElement) node;
}
}
return null;
}
代码示例来源:origin: org.apache.ws.commons.axiom/axiom-truth
@Override
public String getText() {
switch (node.getType()) {
case OMNode.TEXT_NODE:
case OMNode.SPACE_NODE:
case OMNode.CDATA_SECTION_NODE:
return ((OMText)node).getText();
case OMNode.COMMENT_NODE:
return ((OMComment)node).getValue();
default:
throw new IllegalStateException();
}
}
代码示例来源:origin: org.apache.synapse/synapse-core
public static DataHandler getBinaryPayload(SOAPEnvelope envelope) {
OMElement el = getXMLPayload(envelope);
if (el == null)
return null;
if (!el.getQName().equals(BINARYELT)) {
log.error("Wrong QName" + el.getQName());
return null;
}
OMNode textNode = el.getFirstOMChild();
if (textNode.getType() != OMNode.TEXT_NODE) {
log.error("Text Node not found");
return null;
}
OMText text = (OMText) textNode;
try {
return (DataHandler) text.getDataHandler();
} catch (ClassCastException ce) {
log.error("cannot get DataHandler" + ce.getMessage());
return null;
}
}
代码示例来源:origin: wso2/wso2-synapse
public static String getTextPayload(SOAPEnvelope envelope) {
OMElement el = getXMLPayload(envelope);
if (el == null)
return null;
if (!el.getQName().equals(TEXTELT)) {
log.error("Wrong QName " + el.getQName());
return null;
}
OMNode textNode = el.getFirstOMChild();
if (textNode.getType() != OMNode.TEXT_NODE) {
log.error("Text Node not found");
return null;
}
OMText text = (OMText) textNode;
return text.getText();
}
代码示例来源:origin: org.bluestemsoftware.open.eoa.ext/open-eoa-aspect-axiom
public String getTrimmedText() {
String childText = null;
OMNode child = this.getFirstOMChild();
OMText textNode;
while (child != null) {
if (child.getType() == OMNode.TEXT_NODE) {
textNode = (OMText) child;
String textValue = textNode.getText();
if (textValue != null &&
!"".equals(textValue.trim())) {
if (childText == null) childText = "";
childText += textValue.trim();
}
}
child = child.getNextOMSibling();
}
return childText;
}
代码示例来源:origin: org.bluestemsoftware.open.eoa.ext/open-eoa-aspect-axiom
/**
* Returns the first Element node.
*
* @see org.apache.axiom.om.OMElement#getFirstElement()
*/
public OMElement getFirstElement() {
OMNode node = getFirstOMChild();
while (node != null) {
if (node.getType() == Node.ELEMENT_NODE) {
return (OMElement) node;
} else {
node = node.getNextOMSibling();
}
}
return null;
}
代码示例来源:origin: org.paxml/paxml-core
static void processExpressions(ITag tag, IParserContext context) {
if (!(tag instanceof ExpressionTag)) {
// make sure all text nodes are converted to <expression> tags
OMElement ele = context.getElement();
for (OMNode child : AxiomUtils.getNodes(ele)) {
if (child.getType() == OMNode.TEXT_NODE) {
OMText textNode = (OMText) child;
String text = textNode.getText();
if (StringUtils.isNotBlank(text)) {
OMElement expTag = createExpressionTag(text, ele.getLineNumber());
child.insertSiblingAfter(expTag);
child.detach();
}
}
}
}
}
代码示例来源:origin: org.apache.abdera/abdera-parser
public void setText(String text) {
complete();
if (text != null) {
OMNode child = this.getFirstOMChild();
while (child != null) {
if (child.getType() == OMNode.TEXT_NODE) {
child.detach();
}
child = child.getNextOMSibling();
}
getOMFactory().createOMText(this, text);
} else
_removeAllChildren();
// return (T)this;
}
代码示例来源:origin: org.apache.abdera/abdera-parser
public <T extends Element> T setText(Text.Type type, String value) {
complete();
init(type);
if (value != null) {
OMNode child = this.getFirstOMChild();
while (child != null) {
if (child.getType() == OMNode.TEXT_NODE) {
child.detach();
}
child = child.getNextOMSibling();
}
getOMFactory().createOMText(this, value);
} else
_removeAllChildren();
return (T)this;
}
代码示例来源:origin: org.apache.abdera/abdera-parser
public <T extends Element> T setText(Content.Type type, String value) {
complete();
init(type);
if (value != null) {
OMNode child = this.getFirstOMChild();
while (child != null) {
if (child.getType() == OMNode.TEXT_NODE) {
child.detach();
}
child = child.getNextOMSibling();
}
getOMFactory().createOMText(this, value);
} else
_removeAllChildren();
return (T)this;
}
内容来源于网络,如有侵权,请联系作者删除!