public class GramarContext extends Object implements IGramarContext
Constructor and Description |
---|
GramarContext(GramarContext parentContext) |
GramarContext(IGramarPlatform platform,
Document model) |
Modifier and Type | Method and Description |
---|---|
void |
addModel(String name,
Document model)
Adds a secondary DOM to the context and associates the Document object at the root of that model
with the given variable name.
|
void |
debug(String message)
Log a debug-level message
|
void |
declareTemplatingExtension(String namespace,
String extensionId)
Associates a platform extension (ID) with a namespace.
|
void |
error(Exception e)
Log an error
|
void |
error(String message)
Log an error message
|
String |
extensionIdForNamespace(String namespace)
Return the extension ID that has been associated with this namespace.
|
void |
free()
Frees up any cached resources
|
IFileStore |
getFileStore()
Answers the current file store
|
IGramar |
getGramar()
Answer the gramar being applied
|
int |
getMaxStatus() |
int |
getModelAccessCount() |
IGramar |
getPattern() |
IGramarPlatform |
getPlatform()
Answers the PatternPlatform from which all extensions can be eventually located
|
Document |
getPrimaryModel()
Answer the model specified when the context was originally constructed
|
DefinedTag |
getTagDef(String namespace,
String tagName)
Answers the tag definition with the given name from the extension associated with the given namespace
|
ITagHandler |
getTagHandler(String namespace,
String tagName)
Answers the tag handler with the given name from the extension associated with the given namespace.
|
Object |
getVariable(String name)
Answers the value associated with the variable name
|
XPath |
getXPath() |
XPathFunction |
getXPathFunction(String namespace,
String name,
int arity)
Answers the xpath function that best matches the given name and arity from the extension associated
with the given namespace
|
void |
info(String message)
Log an informational message
|
boolean |
isExtensionDefined(String extensionId) |
void |
log(String message,
int severity) |
String |
resolveExpressions(String pattern)
Replace substrings delimited by curly brackets with the results of evaluating those
substrings as xpath expressions.
|
boolean |
resolveToBoolean(String expression)
Resolve the given XPath expression to a boolean value
|
boolean |
resolveToBoolean(String expression,
Node sourceNode)
Resolve the given XPath expression from the sourceNode to a boolean value
|
Node |
resolveToNode(String expression)
Resolve the given XPath expression to a single node
|
Node |
resolveToNode(String expression,
Node sourceNode)
Resolve the given XPath expression from the sourceNode to a single node
|
Node[] |
resolveToNodes(String expression)
Resolve the given XPath expression to an array of nodes
|
Node[] |
resolveToNodes(String expression,
Node sourceNode)
Resolve the given XPath expression from the sourceNode to an array of nodes
|
double |
resolveToNumber(String expression)
Resolve the given XPath expression to a numeric (double) value
|
double |
resolveToNumber(String expression,
Node sourceNode)
Resolve the given XPath expression from the sourceNode to a numeric (double) value
|
Object |
resolveToObject(String expression)
Resolve the given XPath expression to a value and return the correct type of result.
|
Object |
resolveToObject(String expression,
Node sourceNode)
Resolve the given XPath expression from the source node to a value and return the correct type of result.
|
String |
resolveToString(String expression)
Resolve the given XPath expression to a single string
|
String |
resolveToString(String expression,
Node sourceNode)
Resolve the given XPath expression from the sourceNode to a single string
|
void |
setAttribute(String nodeExpression,
String attrName,
String value)
Sets the attribute on the node (obtained by resolving the nodeExpression) to
the specified value
|
void |
setFileStore(IFileStore fileStore)
Sets the current file store
|
void |
setGramar(IGramar pattern) |
void |
setPrimaryModel(Document primaryModel) |
void |
setVariable(String variableName,
Object value)
Sets associates the value with the variable name.
|
void |
unsetVariable(String variableName)
Removes the association between the variable name and its value.
|
void |
warning(Exception e)
Log a warning
|
void |
warning(String message)
Log a warning message
|
public GramarContext(IGramarPlatform platform, Document model)
public GramarContext(GramarContext parentContext)
public Document getPrimaryModel()
IGramarContext
getPrimaryModel
in interface IGramarContext
public void setPrimaryModel(Document primaryModel)
public Object getVariable(String name)
IGramarContext
getVariable
in interface IGramarContext
public void setVariable(String variableName, Object value)
IGramarContext
setVariable
in interface IGramarContext
public void unsetVariable(String variableName)
IGramarContext
unsetVariable
in interface IGramarContext
public void setAttribute(String nodeExpression, String attrName, String value) throws XPathExpressionException
IGramarContext
setAttribute
in interface IGramarContext
XPathExpressionException
public String resolveExpressions(String pattern) throws XPathExpressionException
IGramarContext
resolveExpressions
in interface IGramarContext
XPathExpressionException
public String resolveToString(String expression) throws XPathExpressionException
IGramarContext
resolveToString
in interface IGramarContext
XPathExpressionException
public String resolveToString(String expression, Node sourceNode) throws XPathExpressionException
IGramarContext
resolveToString
in interface IGramarContext
XPathExpressionException
public Node resolveToNode(String expression) throws XPathExpressionException
IGramarContext
resolveToNode
in interface IGramarContext
XPathExpressionException
public Node resolveToNode(String expression, Node sourceNode) throws XPathExpressionException
IGramarContext
resolveToNode
in interface IGramarContext
XPathExpressionException
public Node[] resolveToNodes(String expression) throws XPathExpressionException
IGramarContext
resolveToNodes
in interface IGramarContext
XPathExpressionException
public Node[] resolveToNodes(String expression, Node sourceNode) throws XPathExpressionException
IGramarContext
resolveToNodes
in interface IGramarContext
XPathExpressionException
public boolean resolveToBoolean(String expression) throws XPathExpressionException
IGramarContext
resolveToBoolean
in interface IGramarContext
XPathExpressionException
public boolean resolveToBoolean(String expression, Node sourceNode) throws XPathExpressionException
IGramarContext
resolveToBoolean
in interface IGramarContext
XPathExpressionException
public double resolveToNumber(String expression) throws XPathExpressionException
IGramarContext
resolveToNumber
in interface IGramarContext
XPathExpressionException
public double resolveToNumber(String expression, Node sourceNode) throws XPathExpressionException
IGramarContext
resolveToNumber
in interface IGramarContext
XPathExpressionException
public Object resolveToObject(String expression) throws XPathExpressionException
IGramarContext
resolveToObject
in interface IGramarContext
XPathExpressionException
public Object resolveToObject(String expression, Node sourceNode) throws XPathExpressionException
IGramarContext
resolveToObject
in interface IGramarContext
XPathExpressionException
public void addModel(String name, Document model)
IGramarContext
addModel
in interface IGramarContext
public void setFileStore(IFileStore fileStore)
IGramarContext
setFileStore
in interface IGramarContext
public IFileStore getFileStore()
IGramarContext
getFileStore
in interface IGramarContext
public DefinedTag getTagDef(String namespace, String tagName) throws GramarException
IGramarContext
getTagDef
in interface IGramarContext
GramarException
public ITagHandler getTagHandler(String namespace, String tagName) throws GramarException
IGramarContext
getTagHandler
in interface IGramarContext
GramarException
public XPathFunction getXPathFunction(String namespace, String name, int arity) throws GramarException
IGramarContext
getXPathFunction
in interface IGramarContext
GramarException
public String extensionIdForNamespace(String namespace) throws NamespaceNotDefinedException
IGramarContext
extensionIdForNamespace
in interface IGramarContext
NamespaceNotDefinedException
public IGramarPlatform getPlatform()
IGramarContext
getPlatform
in interface IGramarContext
public void declareTemplatingExtension(String namespace, String extensionId)
IGramarContext
declareTemplatingExtension
in interface IGramarContext
public boolean isExtensionDefined(String extensionId)
isExtensionDefined
in interface IGramarContext
public void setGramar(IGramar pattern)
setGramar
in interface IGramarContext
public IGramar getPattern()
getPattern
in interface IGramarContext
public void warning(Exception e)
IGramarContext
warning
in interface IGramarContext
public void error(Exception e)
IGramarContext
error
in interface IGramarContext
public void error(String message)
IGramarContext
error
in interface IGramarContext
message
- - the text to be writtenpublic void info(String message)
IGramarContext
info
in interface IGramarContext
message
- - the text to be writtenpublic void debug(String message)
IGramarContext
debug
in interface IGramarContext
message
- - the text to be writtenpublic void warning(String message)
IGramarContext
warning
in interface IGramarContext
message
- - the text to be writtenpublic void log(String message, int severity)
public XPath getXPath()
getXPath
in interface IGramarContext
public int getModelAccessCount()
getModelAccessCount
in interface IGramarContext
public void free()
IGramarContext
free
in interface IGramarContext
public int getMaxStatus()
getMaxStatus
in interface IGramarContext
public IGramar getGramar()
IGramarContext
getGramar
in interface IGramarContext
Copyright © 2015. All rights reserved.