public abstract class NodeModel extends java.lang.Object implements TemplateNodeModel, TemplateHashModel, TemplateSequenceModel, AdapterTemplateModel, WrapperTemplateModel
NOTHING
Modifier | Constructor and Description |
---|---|
protected |
NodeModel(org.w3c.dom.Node node) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object other) |
TemplateModel |
exec(java.util.List args) |
TemplateModel |
get(int i)
Retrieves the i-th template model in this sequence.
|
TemplateModel |
get(java.lang.String key)
Gets a TemplateModel from the hash.
|
java.lang.Object |
getAdaptedObject(java.lang.Class hint)
Retrieves the underlying object, or some other object semantically
equivalent to its value narrowed by the class hint.
|
TemplateSequenceModel |
getChildNodes() |
static javax.xml.parsers.DocumentBuilderFactory |
getDocumentBuilderFactory() |
static org.xml.sax.ErrorHandler |
getErrorHandler() |
org.w3c.dom.Node |
getNode() |
java.lang.String |
getNodeNamespace() |
java.lang.String |
getNodeType() |
TemplateNodeModel |
getParentNode() |
java.lang.Object |
getWrappedObject()
Retrieves the original object wrapped by this model.
|
static java.lang.Class |
getXPathSupportClass()
Get the currently used freemarker.ext.dom.XPathSupport used as the XPath engine.
|
int |
hashCode() |
static void |
mergeAdjacentText(org.w3c.dom.Node node)
Merges adjacent text/cdata nodes, so that there are no
adjacent text/cdata nodes.
|
static NodeModel |
parse(java.io.File f)
Create a NodeModel from an XML file.
|
static NodeModel |
parse(java.io.File f,
boolean removeComments,
boolean removePIs)
Create a NodeModel from an XML file.
|
static NodeModel |
parse(org.xml.sax.InputSource is)
Create a NodeModel from an XML input source.
|
static NodeModel |
parse(org.xml.sax.InputSource is,
boolean removeComments,
boolean removePIs)
Create a NodeModel from a SAX input source.
|
static void |
removeComments(org.w3c.dom.Node node)
Recursively removes all comment nodes
from the subtree.
|
static void |
removePIs(org.w3c.dom.Node node)
Recursively removes all processing instruction nodes
from the subtree.
|
static void |
setDocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory docBuilderFactory)
Sets the DOM Parser implementation to be used when building NodeModel
objects from XML files.
|
static void |
setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
sets the error handler to use when parsing the document.
|
static void |
setXPathSupportClass(java.lang.Class cl)
Set an alternative implementation of freemarker.ext.dom.XPathSupport to use
as the XPath engine.
|
static void |
simplify(org.w3c.dom.Node node)
Removes comments and processing instruction, and then unites adjacent text nodes.
|
int |
size() |
static void |
useDefaultXPathSupport()
Tells the system to use (restore) the default (initial) XPath system used by
this FreeMarker version on this system.
|
static void |
useJaxenXPathSupport()
Convenience method.
|
static void |
useSunInternalXPathSupport() |
static void |
useXalanXPathSupport()
Convenience method.
|
static NodeModel |
wrap(org.w3c.dom.Node node) |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
getNodeName
isEmpty
public static void setDocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory docBuilderFactory)
public static javax.xml.parsers.DocumentBuilderFactory getDocumentBuilderFactory()
public static void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
public static org.xml.sax.ErrorHandler getErrorHandler()
public static NodeModel parse(org.xml.sax.InputSource is, boolean removeComments, boolean removePIs) throws org.xml.sax.SAXException, java.io.IOException, javax.xml.parsers.ParserConfigurationException
removeComments
- whether to remove all comment nodes
(recursively) from the tree before processingremovePIs
- whether to remove all processing instruction nodes
(recursively from the tree before processingorg.xml.sax.SAXException
java.io.IOException
javax.xml.parsers.ParserConfigurationException
public static NodeModel parse(org.xml.sax.InputSource is) throws org.xml.sax.SAXException, java.io.IOException, javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
javax.xml.parsers.ParserConfigurationException
public static NodeModel parse(java.io.File f, boolean removeComments, boolean removePIs) throws org.xml.sax.SAXException, java.io.IOException, javax.xml.parsers.ParserConfigurationException
removeComments
- whether to remove all comment nodes
(recursively) from the tree before processingremovePIs
- whether to remove all processing instruction nodes
(recursively from the tree before processingorg.xml.sax.SAXException
java.io.IOException
javax.xml.parsers.ParserConfigurationException
public static NodeModel parse(java.io.File f) throws org.xml.sax.SAXException, java.io.IOException, javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
javax.xml.parsers.ParserConfigurationException
public org.w3c.dom.Node getNode()
public TemplateModel get(java.lang.String key) throws TemplateModelException
TemplateHashModel
get
in interface TemplateHashModel
key
- the name by which the TemplateModel
is identified in the template.TemplateModelException
public TemplateNodeModel getParentNode()
getParentNode
in interface TemplateNodeModel
public TemplateSequenceModel getChildNodes()
getChildNodes
in interface TemplateNodeModel
public final java.lang.String getNodeType() throws TemplateModelException
getNodeType
in interface TemplateNodeModel
TemplateModelException
public TemplateModel exec(java.util.List args) throws TemplateModelException
TemplateModelException
public final int size()
size
in interface TemplateSequenceModel
public final TemplateModel get(int i)
TemplateSequenceModel
get
in interface TemplateSequenceModel
null
if
the index is out of bounds. Note that a null
value is
interpreted by FreeMarker as "variable does not exist", and accessing
a missing variables is usually considered as an error in the FreeMarker
Template Language, so the usage of a bad index will not remain hidden.public java.lang.String getNodeNamespace()
getNodeNamespace
in interface TemplateNodeModel
public final int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public static NodeModel wrap(org.w3c.dom.Node node)
public static void removeComments(org.w3c.dom.Node node)
simplify(org.w3c.dom.Node)
public static void removePIs(org.w3c.dom.Node node)
simplify(org.w3c.dom.Node)
public static void mergeAdjacentText(org.w3c.dom.Node node)
simplify(org.w3c.dom.Node)
public static void simplify(org.w3c.dom.Node node)
public static void useDefaultXPathSupport()
public static void useJaxenXPathSupport() throws java.lang.Exception
java.lang.Exception
- if the Jaxen classes are not present.public static void useXalanXPathSupport() throws java.lang.Exception
java.lang.Exception
- if the Xalan XPath classes are not present.public static void useSunInternalXPathSupport() throws java.lang.Exception
java.lang.Exception
public static void setXPathSupportClass(java.lang.Class cl)
cl
- the class, or null
to disable XPath support.public static java.lang.Class getXPathSupportClass()
null
if XPath support is disabled.public java.lang.Object getAdaptedObject(java.lang.Class hint)
AdapterTemplateModel
getAdaptedObject
in interface AdapterTemplateModel
hint
- the desired class of the returned value. An implementation
should make reasonable effort to retrieve an object of the requested
class, but if that is impossible, it must at least return the underlying
object as-is. As a minimal requirement, an implementation must always
return the exact underlying object when
hint.isInstance(underlyingObject) == true holds. When called
with java.lang.Object.class, it should return a generic Java
object (i.e. if the model is wrapping a scripting language object that is
further wrapping a Java object, the deepest underlying Java object should
be returned).public java.lang.Object getWrappedObject()
WrapperTemplateModel
getWrappedObject
in interface WrapperTemplateModel