|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dk.brics.xact.Node dk.brics.xact.XML
public abstract class XML
XML template content node.
This class contains the main functionality of the XACT runtime system. See also the general documentation for the packagedk.brics.xact
.
Method Summary | ||
---|---|---|
XML |
analyze(String type)
Instruction for the program analyzer; no operation at runtime. |
|
XML |
append(Object v)
Inserts the given value after this template. |
|
XML |
appendContent(Object v)
Inserts the given value after the content of this element. |
|
XML |
appendContent(String xpath,
Object v)
Inserts the given value after the content of each selected element node. |
|
int |
byteLength(String encoding)
Computes the number of bytes written if invoking toDocument(OutputStream, String) . |
|
XML |
close()
Removes all gaps in this template. |
|
static XML |
concat(Iterable<?> vs)
Concatenates the given list of XML templates or strings into one template. |
|
static XML |
concat(Object... xs)
Concatenates the given list of XML templates or strings. |
|
XML |
gapify(String xpath,
String gap)
Converts all nodes selected by the given XPath expression into gaps of the given name. |
|
XML |
gapify(String xpath,
String gap,
String type)
Converts all nodes selected by the given XPath expression into gaps of the given name and schema type. |
|
NodeList<Node> |
get(String xpath)
Returns the nodes specified by the given XPath expression. |
|
String |
getAttribute(String localname)
Returns the value of the attribute of the given name in the first element in this template, or null if not present. |
|
String |
getAttribute(String namespace,
String localname)
Returns the value of the attribute of the given name in the first element in this template, or null if not present. |
|
Element |
getElement(String xpath)
Returns the first element specified by the given XPath expression. |
|
Element |
getElementByID(String id)
Returns the element with the given ID. |
|
NodeList<Element> |
getElements(String xpath)
Returns the elements specified by the given XPath expression. |
|
Element |
getFirstElement()
Returns the first element in this template. |
|
static Map<String,String> |
getNamespaceMap()
Returns the global namespace map (from prefix to URI). |
|
XML |
getNextSibling()
Returns the next sibling node, or null if none. |
|
Number |
getNumber()
Returns the number value of the first element or text node in this template. |
|
Number |
getNumber(String xpath)
Returns the number specified by the given XPath expression. |
|
String |
getString()
Returns the string value of the first element or text node in this template. |
|
String |
getString(String xpath)
Returns the text specified by the given XPath expression. |
|
List<String> |
getStrings(String xpath)
Returns the text or attribute values specified by the given XPath expression. |
|
static Map<String,String> |
getThreadNamespaceMap()
Returns the thread local namespace map (from prefix to URI). |
|
boolean |
has(String xpath)
Returns the boolean specified by the given XPath expression. |
|
XML |
insertAfter(String xpath,
Object v)
Inserts the given value after each selected content node. |
|
XML |
insertBefore(String xpath,
Object v)
Inserts the given value before each selected content node. |
|
static void |
loadXMLSchema(String url)
Loads an XML schema. |
|
static void |
loadXMLSchema(URL url)
Loads an XML schema. |
|
static XML |
parseDocument(InputStream in)
Constructs an XML document from its string representation from an input stream. |
|
static XML |
parseDocument(InputStream in,
String encoding,
Origin origin)
Constructs an XML document from its string representation from an input stream using the given encoding. |
|
static XML |
parseDocument(String doc)
Constructs an XML document from its string representation. |
|
static XML |
parseDocument(URL url)
Constructs an XML document from its string representation from a URL. |
|
static XML |
parseTemplate(InputStream in)
Constructs an XML template from its string representation from an input stream. |
|
static XML |
parseTemplate(InputStream in,
Origin origin)
Constructs an XML template from its string representation from an input stream. |
|
static XML |
parseTemplate(String template)
Constructs an XML template from its string representation. |
|
static XML |
parseTemplate(String template,
Origin origin)
Constructs an XML template from its string representation. |
|
static XML |
parseTemplateResource(Class<?> base,
String name)
Constructs an XML template from its string representation located in a resource. |
|
static XML |
parseTemplateResource(String name)
Constructs an XML template from its string representation located in a resource. |
|
XML |
plug(String gap,
Object v)
Constructs a new XML template by plugging the given value into each template gap of the given name in this template. |
|
XML |
plugList(String gap,
Iterable<?> vs)
Constructs a new XML template by plugging the given list of values into the list of template gaps of the given name in this template. |
|
XML |
plugWrap(String gap,
Iterable<?> vs)
Constructs a template by wrapping each value from the given list into the gaps of the given name in this template and concatenating the results. |
|
XML |
prepend(Object v)
Inserts the given value in front of this template. |
|
XML |
prependContent(Object v)
Inserts the given value before the content of this element. |
|
XML |
prependContent(String xpath,
Object v)
Inserts the given value before the content of each selected element node. |
|
XML |
remove(String xpath)
Removes the nodes selected by the given XPath expression. |
|
XML |
set(AttrNode a)
Sets an attribute at this element. |
|
XML |
set(NamespaceDecl d)
Sets a namespace declaration at this element. |
|
XML |
set(String xpath,
AttrNode a)
Sets an attribute at each selected element node. |
|
XML |
set(String xpath,
Object v)
Replaces each selected content node by the given value. |
|
XML |
setContent(Object v)
Sets the content of this element to the given value. |
|
XML |
setContent(String xpath,
Object v)
Sets the content of each selected element node to the given value. |
|
String |
toDocument()
Converts this XML template to its string representation with all gaps removed. |
|
void |
toDocument(OutputStream out,
String encoding)
Converts this XML template to its string representation with all gaps removed and prints the result to an output stream. |
|
String |
toDocument(String encoding)
Converts this XML template to its string representation with all gaps removed, using the given encoding. |
|
String |
toDocument(dk.brics.xact.operations.XMLIndentation indentation)
Converts this XML template to its string representation with all gaps removed, using the given encoding. |
|
String |
toTemplate()
Converts this template to its string representation. |
|
String |
toTemplate(String encoding)
Converts this template to its string representation, using the given encoding. |
|
String |
toTemplate(dk.brics.xact.operations.XMLIndentation indentation)
Converts this template to its string representation, using the specified indentation strategy. |
|
XML |
toXML()
Returns this object. |
|
static XML |
toXML(Object v)
Converts the given value to an XML template using ToXMLable.toXML() or Node.toString() . |
|
XML |
validate(String type)
Checks that this template is valid according to the given schema type. |
|
void |
visitBy(NodeVisitor v)
Visits this node by the given visitor. |
|
|
visitBy(NodeVisitorParameterized<R,A> v,
A arg)
Visits this node by the given visitor. |
Methods inherited from class dk.brics.xact.Node |
---|
asAttribute, asComment, asElement, asNamespaceDecl, asProcessingInstruction, asText, getOrigin, isAttribute, isComment, isElement, isNamespaceDecl, isProcessingInstruction, isText, toString |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public XML analyze(String type)
validate(String)
public XML append(Object v)
insertAfter(String, Object)
,
prepend(Object)
public XML appendContent(Object v)
ClassCastException
- if this is not an element nodeappendContent(String, Object)
,
prependContent(Object)
public XML appendContent(String xpath, Object v)
appendContent(Object)
,
prependContent(String, Object)
public int byteLength(String encoding) throws UnsupportedEncodingException
toDocument(OutputStream, String)
.
XMLWellformednessException
- if the result is not a wellformed XML document
UnsupportedEncodingException
- if the encoding is not supportedpublic final XML close()
plug(String, Object)
,
plugList(String, Iterable)
,
plugWrap(String, Iterable)
public static XML concat(Iterable<?> vs)
concat(Object...)
public static XML concat(Object... xs)
concat(Iterable)
public XML gapify(String xpath, String gap)
gapify(String, String, String)
public XML gapify(String xpath, String gap, String type)
gapify(String, String)
public final NodeList<Node> get(String xpath)
getElements(String)
,
getElement(String)
,
getString(String)
,
has(String)
public String getAttribute(String localname)
get(String)
,
getAttribute(String, String)
public String getAttribute(String namespace, String localname)
get(String)
,
getAttribute(String)
public final Element getElement(String xpath)
get(String)
,
getFirstElement()
public final Element getElementByID(String id)
getElement(String)
public final NodeList<Element> getElements(String xpath)
get(String)
,
getElement(String)
,
getStrings(String)
,
getString(String)
,
has(String)
public Element getFirstElement()
getElement(String)
public static Map<String,String> getNamespaceMap()
getThreadNamespaceMap()
public XML getNextSibling()
public Number getNumber()
get(String)
,
getNumber(String)
,
getString()
public Number getNumber(String xpath)
number(..)
core function as defined in the XPath 1.0 specification.
get(String)
,
getNumber()
public String getString()
getString(String)
public String getString(String xpath)
string(..)
core function as defined in the XPath 1.0 specification.
getString()
,
get(String)
,
getElement(String)
public List<String> getStrings(String xpath)
string(..)
core function as defined in the XPath 1.0 specification.
The strings are returned in document order. The returned list is unmodifiable.
get(String)
,
getElements(String)
,
getString(String)
public static Map<String,String> getThreadNamespaceMap()
getNamespaceMap()
public boolean has(String xpath)
boolean(..)
core function as defined in the XPath 1.0 specification.
get(String)
public XML insertAfter(String xpath, Object v)
insertBefore(String, Object)
,
append(Object)
,
appendContent(String, Object)
public XML insertBefore(String xpath, Object v)
insertAfter(String, Object)
,
prepend(Object)
,
prependContent(String, Object)
public static void loadXMLSchema(String url)
public static void loadXMLSchema(URL url)
public static XML parseDocument(InputStream in)
XMLTemplateException
- if the string is not a syntactically wellformed XML documentparseDocument(InputStream, String, Origin)
,
parseDocument(String)
,
toDocument(OutputStream, String)
public static XML parseDocument(InputStream in, String encoding, Origin origin)
XMLTemplateException
- if the string is not a syntactically wellformed XML documentparseDocument(InputStream)
,
parseDocument(String)
,
toDocument(OutputStream, String)
public static XML parseDocument(String doc)
XMLTemplateException
- if the string is not a syntactically wellformed XML documentparseDocument(InputStream)
public static XML parseDocument(URL url)
XMLTemplateException
- if the string is not a syntactically wellformed XML documentparseDocument(InputStream, String, Origin)
,
parseDocument(String)
,
toDocument(OutputStream, String)
public static XML parseTemplate(InputStream in)
XMLTemplateException
- if the string is not a syntactically wellformed XML templateparseDocument(String)
public static XML parseTemplate(InputStream in, Origin origin)
XMLTemplateException
- if the string is not a syntactically wellformed XML templateparseDocument(String)
public static XML parseTemplate(String template)
XMLTemplateException
- if the string is not a syntactically wellformed XML templateparseDocument(String)
,
parseTemplate(String, Origin)
public static XML parseTemplate(String template, Origin origin)
XMLTemplateException
- if the string is not a syntactically wellformed XML templateparseDocument(String)
,
parseTemplate(InputStream, Origin)
public static XML parseTemplateResource(Class<?> base, String name)
base.getResourceAsStream
to load the string.
Results are cached in memory.
XMLTemplateException
- if the string is not a syntactically wellformed XML template
or the resource is not foundparseDocument(String)
public static XML parseTemplateResource(String name)
XML.class.getResourceAsStream
to load the string.
Results are cached in memory.
XMLTemplateException
- if the string is not a syntactically wellformed XML template
or the resource is not foundparseDocument(String)
public final XML plug(String gap, Object v)
NullPointerException
- if the value is nullplugList(String, Iterable)
,
plugWrap(String, Iterable)
,
close()
public final XML plugList(String gap, Iterable<?> vs)
NullPointerException
- if one of the values is nullplug(String, Object)
,
plugWrap(String, Iterable)
,
close()
public final XML plugWrap(String gap, Iterable<?> vs)
NullPointerException
- if one of the values is nullplug(String, Object)
,
plugList(String, Iterable)
,
close()
public XML prepend(Object v)
insertBefore(String, Object)
,
append(Object)
public XML prependContent(Object v)
ClassCastException
- if this is not an element nodeprependContent(String, Object)
,
appendContent(Object)
public XML prependContent(String xpath, Object v)
prependContent(Object)
,
appendContent(String, Object)
public XML remove(String xpath)
gapify(String, String)
public XML set(AttrNode a)
ClassCastException
- if this is not an element nodeset(String, AttrNode)
public XML set(NamespaceDecl d)
ClassCastException
- if this is not an element nodepublic XML set(String xpath, AttrNode a)
set(AttrNode)
public XML set(String xpath, Object v)
appendContent(Object)
,
prependContent(String, Object)
,
setContent(String, Object)
,
set(String, AttrNode)
public XML setContent(Object v)
ClassCastException
- if this is not an element nodeappendContent(String, Object)
,
prependContent(Object)
public XML setContent(String xpath, Object v)
appendContent(Object)
,
prependContent(String, Object)
,
set(String, Object)
public String toDocument()
toTemplate()
,
toDocument(String)
public void toDocument(OutputStream out, String encoding) throws UnsupportedEncodingException
XMLWellformednessException
- if the result is not a wellformed XML document
UnsupportedEncodingException
- if the encoding is not supportedparseDocument(InputStream)
public String toDocument(String encoding) throws UnsupportedEncodingException
XMLWellformednessException
- if the result is not a wellformed XML document
UnsupportedEncodingException
- if the encoding is not supportedtoDocument()
,
toTemplate(String)
public String toDocument(dk.brics.xact.operations.XMLIndentation indentation)
XMLWellformednessException
- if the result is not a wellformed XML documenttoDocument()
,
toTemplate(XMLIndentation)
public String toTemplate()
Node.toString()
, gaps are preserved in the output.
Node.toString()
,
toTemplate(String)
public String toTemplate(String encoding) throws UnsupportedEncodingException
toDocument()
, gaps are preserved in the output.
UnsupportedEncodingException
toDocument(String)
,
toTemplate()
public String toTemplate(dk.brics.xact.operations.XMLIndentation indentation)
toDocument()
, gaps are preserved in the output.
Node.toString()
,
toTemplate(String)
public XML toXML()
toXML
in interface ToXMLable
public static XML toXML(Object v)
ToXMLable.toXML()
or Node.toString()
.
public XML validate(String type) throws XMLValidationException
XMLValidationException
- if the template is invalidanalyze(String)
public final void visitBy(NodeVisitor v)
Node
visitBy
in class Node
public final <R,A> R visitBy(NodeVisitorParameterized<R,A> v, A arg)
Node
visitBy
in class Node
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |