public final class SnuggleSession extends java.lang.Object implements SessionContext
SnuggleEngine.createSession(), optionally passing
configuration details for this session.
parseInput(SnuggleInput) on one or more input documents to tokenise and
fix-up the LaTeX contained therein.
getErrors() to get at the errors that have arisen during this session.
createSnapshot() at any time to make a "snapshot" of the current state for
later reuse.
| 限定符和类型 | 类和说明 |
|---|---|
static class |
SnuggleSession.EndOutputAction
Trivial enumeration which specifies the possible actions to perform once we
finish writing with the various
writeWebPage(WebPageOutputOptions, OutputStream)
methods. |
| 限定符和类型 | 方法和说明 |
|---|---|
org.w3c.dom.NodeList |
buildDOMSubtree()
Convenience method to build a DOM
NodeList representing the converted Tokens. |
org.w3c.dom.NodeList |
buildDOMSubtree(DOMOutputOptions options)
Convenience method to build a DOM
NodeList representing the converted Tokens. |
boolean |
buildDOMSubtree(org.w3c.dom.Element targetRoot)
Builds a DOM sub-tree based on the currently parsed tokens, appending the results as
children of the given target root Element.
|
boolean |
buildDOMSubtree(org.w3c.dom.Element targetRoot,
DOMOutputOptions options)
Builds a DOM sub-tree based on the currently parsed tokens, appending the results as
children of the given target root Element.
|
org.w3c.dom.Document |
buildWebPage(WebPageOutputOptions options)
Builds a complete web page based on the currently parsed tokens, returning a DOM
Document Object. |
java.lang.String |
buildWebPageString(WebPageOutputOptions options)
Builds a complete web page based on the currently parsed tokens, returning a String
containing the resulting content.
|
java.lang.String |
buildXMLString()
Creates a well-formed external general parsed entity out of the currently parsed tokens.
|
java.lang.String |
buildXMLString(boolean indent)
已过时。
Use
buildXMLString(XMLStringOutputOptions) instead |
java.lang.String |
buildXMLString(DOMOutputOptions options)
已过时。
Use
buildXMLString(XMLStringOutputOptions) instead. |
java.lang.String |
buildXMLString(DOMOutputOptions options,
boolean indent)
已过时。
Use
buildXMLString(XMLStringOutputOptions) instead. |
java.lang.String |
buildXMLString(XMLStringOutputOptions options)
Creates a well-formed external general parsed entity out of the currently parsed tokens.
|
SnuggleSnapshot |
createSnapshot()
Creates a
SnuggleSnapshot Object holding the current state of this session that can
be later used to recreate a session having exactly the same state. |
org.w3c.dom.Document |
createWebPage(WebPageOutputOptions options)
已过时。
|
BuiltinCommand |
getBuiltinCommandByTeXName(java.lang.String texName)
Returns the
BuiltinCommand corresponding to LaTeX command called
\texName, or null if this command is not defined. |
BuiltinEnvironment |
getBuiltinEnvironmentByTeXName(java.lang.String texName)
Returns the
BuiltinEnvironment corresponding to LaTeX environment
called texName, or null if this environment is not defined. |
SessionConfiguration |
getConfiguration() |
java.util.List<InputError> |
getErrors() |
MathCharacter |
getMathCharacter(int codePoint) |
java.util.List<FlowToken> |
getParsedTokens() |
StylesheetManager |
getStylesheetManager()
Gets the
StylesheetManager being used by the underlying SnuggleEngine |
java.util.Map<java.lang.String,UserDefinedCommand> |
getUserCommandMap()
Gets the
Map of all user-defined commands created in this session. |
java.util.Map<java.lang.String,UserDefinedEnvironment> |
getUserEnvironmentMap()
Gets the
Map of all user-defined environments created in this session. |
boolean |
parseInput(SnuggleInput snuggleInput)
Parses the data contained within the given
SnuggleInput, and performs fixing
on the resulting tokens. |
void |
registerError(InputError inputError)
Records a new error, throwing a
SnuggleParseException if
the current SessionConfiguration deems that we should
fail on the first error. |
void |
reset()
Resets this
SnuggleSession back to an initial blank state |
void |
setWebPageContentType(WebPageOutputOptions options,
java.lang.Object contentTypeSettable)
Calls the
setContentType of the given Object to something appropriate for the
given WebPageOutputOptions. |
boolean |
writeWebPage(WebPageOutputOptions options,
java.lang.Object contentTypeSettable,
java.io.OutputStream outputStream)
Builds a complete web page based on the currently parsed tokens, sending the results
to the given
OutputStream, which is closed afterwards. |
boolean |
writeWebPage(WebPageOutputOptions options,
java.lang.Object contentTypeSettable,
java.io.OutputStream outputStream,
SnuggleSession.EndOutputAction endOutputAction)
Builds a complete web page based on the currently parsed tokens, sending the results
to the given
OutputStream and performing the given SnuggleSession.EndOutputAction to
it afterwards (i.e. close, flush or do nothing). |
boolean |
writeWebPage(WebPageOutputOptions options,
java.io.OutputStream outputStream)
Builds a complete web page based on the currently parsed tokens, sending the results
to the given
OutputStream, which is closed afterwards. |
boolean |
writeWebPage(WebPageOutputOptions options,
java.io.OutputStream outputStream,
SnuggleSession.EndOutputAction endOutputAction)
Builds a complete web page based on the currently parsed tokens, sending the results
to the given
OutputStream and performing the given SnuggleSession.EndOutputAction to
it afterwards (i.e. close, flush or do nothing). |
public SessionConfiguration getConfiguration()
getConfiguration 在接口中 SessionContextpublic java.util.List<InputError> getErrors()
getErrors 在接口中 SessionContextpublic java.util.List<FlowToken> getParsedTokens()
public boolean parseInput(SnuggleInput snuggleInput) throws java.io.IOException
SnuggleInput, and performs fixing
on the resulting tokens.snuggleInput - input to parse, which must not be nulljava.io.IOExceptionpublic SnuggleSnapshot createSnapshot()
SnuggleSnapshot Object holding the current state of this session that can
be later used to recreate a session having exactly the same state.public void reset()
SnuggleSession back to an initial blank statepublic boolean buildDOMSubtree(org.w3c.dom.Element targetRoot,
DOMOutputOptions options)
DOMOutputOptions Object
is used to configure the process.
If the DOMOutputOptions specifies that MathML should be down-converted to
XHTML where possible, then this will also happen.
public boolean buildDOMSubtree(org.w3c.dom.Element targetRoot)
DOMOutputOptions
associated with this engine.public org.w3c.dom.NodeList buildDOMSubtree()
NodeList representing the converted Tokens.
These Nodes will belong to a "fake root" element in the
SnuggleConstants.SNUGGLETEX_NAMESPACE namespace called "root".
The default DOMOutputOptions specified in the SnuggleEngine will be
used.
NodeList if the process completed successfully, null if the process was
terminated by an error in the input LaTeX and if the session was configured to fail on
the first error.public org.w3c.dom.NodeList buildDOMSubtree(DOMOutputOptions options)
NodeList representing the converted Tokens.
These Nodes will belong to a "fake root" element in the
SnuggleConstants.SNUGGLETEX_NAMESPACE namespace called "root".
The given DOMOutputOptions Object is used to configure the process, which must
not be null.
options - DOMOutputOptions to use, which must not be nullNodeList if the process completed successfully, null if the process was
terminated by an error in the input LaTeX and if the session was configured to fail on
the first error.public java.lang.String buildXMLString()
The default XMLStringOutputOptions specified in the SnuggleEngine will be
used.
public java.lang.String buildXMLString(XMLStringOutputOptions options)
The given XMLStringOutputOptions Object is used to configure the process.
options - XMLStringOutputOptions to use, which must not be null.@Deprecated public java.lang.String buildXMLString(boolean indent)
buildXMLString(XMLStringOutputOptions) instead
The default DOMOutputOptions specified in the SnuggleEngine will be
used.
indent - whether to indent the resulting XML or not@Deprecated public java.lang.String buildXMLString(DOMOutputOptions options)
buildXMLString(XMLStringOutputOptions) instead.
The given DOMOutputOptions Object is used to configure the process.
@Deprecated public java.lang.String buildXMLString(DOMOutputOptions options, boolean indent)
buildXMLString(XMLStringOutputOptions) instead.
The given DOMOutputOptions Object is used to configure the process.
indent - whether to indent the resulting XML or notpublic org.w3c.dom.Document buildWebPage(WebPageOutputOptions options)
Document Object.
The provided WebPageOutputOptions Object is
used to determine which type of web page to generate and how it should be configured.
Any XSLT stylesheet specified by WebPageOutputOptions.getStylesheets()
will have been applied to the result before it is returned. On the other hand, serialisation
options in the WebPageOutputOptions (such as Content Type and encoding)
will not have been applied when this method returns.
@Deprecated public org.w3c.dom.Document createWebPage(WebPageOutputOptions options)
buildWebPage(WebPageOutputOptions) instead.public java.lang.String buildWebPageString(WebPageOutputOptions options)
writeWebPage(WebPageOutputOptions, OutputStream) might be more efficient.
The provided WebPageOutputOptions Object is
used to determine which type of web page to generate and how it should be configured.
Any XSLT stylesheet specified by WebPageOutputOptions.getStylesheets()
will have been applied to the result before it is returned. On the other hand, serialisation
options in the WebPageOutputOptions (such as Content Type and encoding)
will not have been applied when this method returns.
public boolean writeWebPage(WebPageOutputOptions options, java.io.OutputStream outputStream) throws java.io.IOException
OutputStream, which is closed afterwards.
The provided WebPageOutputOptions Object is
used to determine which type of web page to generate and how it should be configured.
java.io.IOExceptionpublic boolean writeWebPage(WebPageOutputOptions options, java.io.OutputStream outputStream, SnuggleSession.EndOutputAction endOutputAction) throws java.io.IOException
OutputStream and performing the given SnuggleSession.EndOutputAction to
it afterwards (i.e. close, flush or do nothing).
The provided WebPageOutputOptions Object is
used to determine which type of web page to generate and how it should be configured.
java.io.IOExceptionpublic boolean writeWebPage(WebPageOutputOptions options, java.lang.Object contentTypeSettable, java.io.OutputStream outputStream) throws java.io.IOException
OutputStream, which is closed afterwards.
The provided WebPageOutputOptions Object is
used to determine which type of web page to generate and how it should be configured.
If the contentTypeSettable Object has a
property called contentType, then it is set in advance to the appropriate HTTP
Content-Type header for the resulting page before the web page data is written.
java.io.IOException - if an I/O problem arose whilst writing out the web page data.SnuggleRuntimeException - if calling setContentType() on the contentTypeSettable
Object failed, with the underlying Exception wrapped up.public boolean writeWebPage(WebPageOutputOptions options, java.lang.Object contentTypeSettable, java.io.OutputStream outputStream, SnuggleSession.EndOutputAction endOutputAction) throws java.io.IOException
OutputStream and performing the given SnuggleSession.EndOutputAction to
it afterwards (i.e. close, flush or do nothing).
The provided WebPageOutputOptions Object is
used to determine which type of web page to generate and how it should be configured.
If the contentTypeSettable Object has a
property called contentType, then it is set in advance to the appropriate HTTP
Content-Type header for the resulting page before the web page data is written.
java.io.IOException - if an I/O problem arose whilst writing out the web page data.SnuggleRuntimeException - if calling setContentType() on the contentTypeSettable
Object failed, with the underlying Exception wrapped up.public void setWebPageContentType(WebPageOutputOptions options, java.lang.Object contentTypeSettable)
setContentType of the given Object to something appropriate for the
given WebPageOutputOptions. This may be useful in some cases.
The main example for this would be passing a javax.servlet.http.HttpResponse
Object, which I want to avoid a compile-time dependency on.
public MathCharacter getMathCharacter(int codePoint)
getMathCharacter 在接口中 SessionContextpublic BuiltinCommand getBuiltinCommandByTeXName(java.lang.String texName)
BuiltinCommand corresponding to LaTeX command called
\texName, or null if this command is not defined.getBuiltinCommandByTeXName 在接口中 SessionContextpublic BuiltinEnvironment getBuiltinEnvironmentByTeXName(java.lang.String texName)
BuiltinEnvironment corresponding to LaTeX environment
called texName, or null if this environment is not defined.getBuiltinEnvironmentByTeXName 在接口中 SessionContextpublic java.util.Map<java.lang.String,UserDefinedCommand> getUserCommandMap()
Map of all user-defined commands created in this session.getUserCommandMap 在接口中 SessionContextpublic java.util.Map<java.lang.String,UserDefinedEnvironment> getUserEnvironmentMap()
Map of all user-defined environments created in this session.getUserEnvironmentMap 在接口中 SessionContextpublic StylesheetManager getStylesheetManager()
StylesheetManager being used by the underlying SnuggleEnginegetStylesheetManager 在接口中 SessionContextpublic void registerError(InputError inputError) throws SnuggleParseException
SnuggleParseException if
the current SessionConfiguration deems that we should
fail on the first error.registerError 在接口中 SessionContextinputError - InputError to register, which must not be null.SnuggleParseException - if this session is configured to fail fast