Package org.apache.axiom.om
Interface OMNamedInformationItem
-
- All Superinterfaces:
OMInformationItem
- All Known Subinterfaces:
OMAttribute
,OMElement
,OMSourcedElement
,SOAPBody
,SOAPEnvelope
,SOAPFault
,SOAPFaultClassifier
,SOAPFaultCode
,SOAPFaultDetail
,SOAPFaultNode
,SOAPFaultReason
,SOAPFaultRole
,SOAPFaultSubCode
,SOAPFaultText
,SOAPFaultValue
,SOAPHeader
,SOAPHeaderBlock
public interface OMNamedInformationItem extends OMInformationItem
Represents an information item that has a name, more precisely a namespace URI, a local name and a prefix. This applies to elements and attributes.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description String
getLocalName()
Get the local name of the information item.OMNamespace
getNamespace()
Get the namespace this information item is part of.String
getNamespaceURI()
Get the namespace URI of this information item.String
getPrefix()
Get the prefix of this information item.QName
getQName()
Get the QName of this information item.boolean
hasName(QName name)
Determine if this information item has the given name.void
setLocalName(String localName)
Set the local name of this information item.void
setNamespace(OMNamespace namespace, boolean declare)
Set the namespace for this information item.-
Methods inherited from interface org.apache.axiom.om.OMInformationItem
clone, getOMFactory
-
-
-
-
Method Detail
-
getLocalName
String getLocalName()
Get the local name of the information item.- Returns:
- the local name of the information item
-
setLocalName
void setLocalName(String localName)
Set the local name of this information item.- Parameters:
localName
- the new local name of the information item
-
getNamespace
OMNamespace getNamespace()
Get the namespace this information item is part of.- Returns:
- The namespace of this information item, or
null
if the information item has no namespace. Note that this implies that the method never returns anOMNamespace
object with both prefix and namespace URI set to the empty string. In addition, the prefix of the returnedOMNamespace
object (if any) is nevernull
: if anull
prefix was specified when creating this information item, then a prefix has been automatically assigned and the assigned prefix is returned.
-
setNamespace
void setNamespace(OMNamespace namespace, boolean declare)
Set the namespace for this information item. This will change the namespace URI and the prefix of the information item. In addition, ifdeclare
istrue
this method ensures that a corresponding namespace declaration exists: if no corresponding namespace declaration is already in scope, then a new one will be added to the nearest element (i.e. the element itself if this information item is an element or the owner element if this information item is an attribute).- Parameters:
namespace
- The new namespace for this information item, ornull
to remove the namespace from this information item. If anOMNamespace
instance with anull
prefix is given, then a prefix will be generated automatically. In this case, the generated prefix can be determined usinggetNamespace()
method.declare
- Indicates whether a namespace declaration should be generated if necessary; ignored if the information item is an attribute without owner element.- Throws:
IllegalArgumentException
- if an attempt is made to change the namespace of the information item in such a way that it would make the document ill-formed with respect to namespaces (e.g. binding a prefix to the empty namespace name)
-
getQName
QName getQName()
Get the QName of this information item.Note that if you simply need to check if the information item has a given QName, then you should use
hasName(QName)
instead of this method.- Returns:
- the
QName
for the information item
-
getPrefix
String getPrefix()
Get the prefix of this information item. Note that the contract of this method is identical to DOM'sNode.getPrefix()
(when called on anElement
orAttr
).- Returns:
- the prefix of the information item or
null
if the information item has no prefix
-
getNamespaceURI
String getNamespaceURI()
Get the namespace URI of this information item. Note that the contract of this method is identical to DOM'sNode.getNamespaceURI()
(when called on anElement
orAttr
).- Returns:
- the namespace URI of the information item or
null
if the information item has no namespace
-
hasName
boolean hasName(QName name)
Determine if this information item has the given name. Note that only the namespace URI and local part will be compared, the prefix is ignored.The result of the expression
node.hasName(name)
is the same asnode.getQName().equals(name)
. However, the former expression is generally more efficient than the latter because it avoids the creation of theQName
object. In addition, for anOMSourcedElement
it avoids the expansion of the element if the prefix is unknown.- Parameters:
name
- the QName to compare with the QName of this information item- Returns:
true
if the information item has the given name,false
otherwise
-
-