public final class BXMLItem extends BXML<org.apache.axiom.om.OMNode>
BXML
represents a single XML item in Ballerina.
XML item could be one of:
COMMENT_END, COMMENT_START, PI_END, PI_START
Constructor and Description |
---|
BXMLItem()
Create an empty XMLValue.
|
BXMLItem(InputStream inputStream)
Create a
BXMLItem from a InputStream . |
BXMLItem(org.apache.axiom.om.OMNode value)
Initialize a
BXMLItem from a OMNode object. |
BXMLItem(String xmlValue)
Initialize a
BXMLItem from a XML string. |
Modifier and Type | Method and Description |
---|---|
void |
addChildren(BXML<?> seq)
Add a XMl sequence to this XML as children.
|
void |
build()
Builds itself.
|
BXML<?> |
children()
Selects and concatenate all the children sequences of the elements in this sequence.
|
BXML<?> |
children(String qname)
Selects and concatenate all the children sequences that matches the given qualified name,
in all the element-type items in this sequence.
|
BXMLItem |
copy()
Returns a deep copy of the XML.
|
BXML<?> |
descendants(String qname)
Searches in children recursively for elements matching the name and returns a sequence containing them all.
|
BXML<?> |
elements()
Get all the elements-type items, in the given sequence.
|
BXML<?> |
elements(String qname)
Get all the elements-type items in the given sequence, that matches a given qualified name.
|
String |
getAttribute(String localName,
String namespace)
Get the value of a single attribute as a string.
|
String |
getAttribute(String localName,
String namespace,
String prefix)
Get the value of a single attribute as a string.
|
BMap<?,?> |
getAttributesMap()
Get attributes as a
BMap . |
BString |
getElementName()
Get the fully qualified name of the element as a
BString . |
BXML<?> |
getItem(long index)
Get an item from the XML sequence, at the given index.
|
BString |
getItemType()
Get the type of the XML as a
BString . |
XMLNodeType |
getNodeType()
Get the type of the XML.
|
BString |
getTextValue()
Get the text values in this XML.
|
BBoolean |
isEmpty()
Check whether the XML sequence is empty.
|
BBoolean |
isSingleton()
Check whether the XML sequence contains only a single element.
|
int |
length()
Get the length of this XML sequence.
|
BIterator |
newIterator()
Create new Iterator for this collection.
|
void |
removeAttribute(String qname)
Remove an attribute from the XML.
|
void |
serialize(OutputStream outputStream)
Default serialize implementation for
BValue . |
void |
setAttribute(String localName,
String namespaceUri,
String prefix,
String value)
Set the value of a single attribute.
|
void |
setAttributes(BMap<String,?> attributes)
Set the attributes of the XML
BMap . |
void |
setChildren(BXML<?> seq)
Set the children of this XML.
|
BXML<?> |
slice(long startIndex,
long endIndex)
Slice and return a subsequence of the given XML sequence.
|
String |
stringValue() |
BXML<?> |
strip()
Strips any text items from the XML that are all whitespace.
|
org.apache.axiom.om.OMNode |
value() |
addDescendants, getQname, getType, handleXmlException, toString
public BXMLItem()
public BXMLItem(String xmlValue)
BXMLItem
from a XML string.xmlValue
- A XML stringpublic BXMLItem(org.apache.axiom.om.OMNode value)
BXMLItem
from a OMNode
object.value
- xml objectpublic BXMLItem(InputStream inputStream)
BXMLItem
from a InputStream
.inputStream
- Input Streampublic XMLNodeType getNodeType()
getNodeType
in class BXML<org.apache.axiom.om.OMNode>
public BBoolean isEmpty()
public BBoolean isSingleton()
isSingleton
in class BXML<org.apache.axiom.om.OMNode>
public BString getItemType()
BString
. Type can be one of "element", "text", "comment" or "pi".getItemType
in class BXML<org.apache.axiom.om.OMNode>
BString
public BString getElementName()
BString
.getElementName
in class BXML<org.apache.axiom.om.OMNode>
BString
.public BString getTextValue()
getTextValue
in class BXML<org.apache.axiom.om.OMNode>
public String getAttribute(String localName, String namespace)
getAttribute
in class BXML<org.apache.axiom.om.OMNode>
localName
- Local name of the attributenamespace
- Namespace of the attributepublic String getAttribute(String localName, String namespace, String prefix)
getAttribute
in class BXML<org.apache.axiom.om.OMNode>
localName
- Local name of the attributenamespace
- Namespace of the attributeprefix
- Prefix of the namespacepublic void setAttribute(String localName, String namespaceUri, String prefix, String value)
setAttribute
in class BXML<org.apache.axiom.om.OMNode>
localName
- Local name of the attributenamespaceUri
- Namespace of the attributeprefix
- Namespace prefix of the attributevalue
- Value of the attributepublic BMap<?,?> getAttributesMap()
BMap
.getAttributesMap
in class BXML<org.apache.axiom.om.OMNode>
BMap
public void setAttributes(BMap<String,?> attributes)
BMap
.setAttributes
in class BXML<org.apache.axiom.om.OMNode>
attributes
- Attributes to be set.public BXML<?> elements()
public BXML<?> elements(String qname)
public BXML<?> children()
public BXML<?> children(String qname)
public void setChildren(BXML<?> seq)
setChildren
in class BXML<org.apache.axiom.om.OMNode>
seq
- XML Sequence to be set as the childrenpublic void addChildren(BXML<?> seq)
addChildren
in class BXML<org.apache.axiom.om.OMNode>
seq
- XML Sequence to be added as the childrenpublic BXML<?> strip()
public BXML<?> slice(long startIndex, long endIndex)
public BXML<?> descendants(String qname)
descendants
in class BXML<org.apache.axiom.om.OMNode>
qname
- Qualified name of the descendants to filterpublic void serialize(OutputStream outputStream)
BValue
.outputStream
- Represent the output stream that the data will be written to.public org.apache.axiom.om.OMNode value()
public String stringValue()
public BXMLItem copy()
public BXML<?> getItem(long index)
public int length()
public void build()
public void removeAttribute(String qname)
removeAttribute
in class BXML<org.apache.axiom.om.OMNode>
qname
- Qualified name of the attributepublic BIterator newIterator()
BCollection
Copyright © 2018 WSO2. All rights reserved.