xmlBlaster 2.2.0 API

org.xmlBlaster.util.xbformat
Class XmlScriptParser

java.lang.Object
  extended by org.xmlBlaster.util.SaxHandlerBase
      extended by org.xmlBlaster.client.script.XmlScriptInterpreter
          extended by org.xmlBlaster.util.xbformat.XmlScriptParser
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.ErrorHandler, org.xml.sax.ext.LexicalHandler, I_MsgInfoParser

public class XmlScriptParser
extends XmlScriptInterpreter
implements I_MsgInfoParser

XmlScriptParser class for XML formated messages.
This class creates and parses xml script messages which can be used to transfer over a email or socket connection.
XmlScriptParser instances may be reused, but are NOT reentrant (there are many 'global' variables)
Please read the requirement specification The client.script requirement

Author:
xmlBlaster@marcelruff.info
See Also:
The client.script requirement, The protocol.socket requirement used with scripting protocol., Some examples of xmlScript messages., XSD For XmlScript Messages.

Field Summary
private  Global glob
           
private  boolean isNullTerminated
          If used by email, the InputStream finishes when the attaachment is read, if used over socket, we need to terminate the script with a null byte
private static java.util.logging.Logger log
           
private static java.lang.String ME
           
private  java.util.ArrayList msgInfoParsed
           
private  I_ProgressListener progressListener
          If not null somebody wants to be notified about the current bytes send over socket
private  java.lang.String schemaDecl
          xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='xmlBlasterPublish.xsd'
private  boolean sendRequestRequestId
           
private  boolean sendRequestSessionId
           
private  boolean sendResponseRequestId
           
private  boolean sendResponseSessionId
           
private  java.lang.String xmlDecl
          
static java.lang.String XMLSCRIPT_EXTENSION
           
static java.lang.String XMLSCRIPT_MIMETYPE
           
static java.lang.String XMLSCRIPT_ZLIB_EXTENSION
           
static java.lang.String XMLSCRIPT_ZLIB_MIMETYPE
           
 
Fields inherited from class org.xmlBlaster.client.script.XmlScriptInterpreter
cdata, CONTENT_TAG, contentData, ECHO_TAG, forceReadable, inhibitContentCDATAWrapping, INPUT_TAG, key, KEY_TAG, messageList, needsRootEndTag, out, qos, QOS_TAG, response, ROOT_TAG, ROOTRESPONSE_TAG, sendSimpleExceptionFormat, simpleExceptionFormatList, updateCounter, WAIT_TAG, waitMutex, waitNumUpdates
 
Fields inherited from class org.xmlBlaster.util.SaxHandlerBase
character, locator, xmlLiteral, xmlSource
 
Constructor Summary
XmlScriptParser()
           
 
Method Summary
 byte[] createRawMsg(MsgInfo msgInfo)
          Returns a XML data string.
 boolean fireMethod(MethodName methodName, java.lang.String sessionId, java.lang.String requestId, byte type)
          Called during XML parsing.
static java.lang.String getEncodingFromProcessingInstruction(java.lang.String pi)
           
 java.lang.String getExtension(boolean isCompressed)
          Get a specific extension for this format.
 java.lang.String getMimetype(boolean isCompressed)
          Get a specific extension for this format.
 void init(Global glob, I_ProgressListener progressListener, I_PluginConfig pluginConfig)
          Is guaranteed to be called by the MsgInfoParserFactory after construction.
 boolean isNullTerminated()
          If used by email, the InputStream finishes when the attaachment is read, if used over socket, we need to terminate each script with a null byte
static void main(java.lang.String[] args)
          java org.xmlBlaster.util.xbformat.XmlScriptParser
 MsgInfo[] parse(java.io.InputStream in)
          This parses the raw message from an InputStream (typically from a email or a socket).
 void setProperty(java.lang.String key, java.lang.String value)
          Called during XML parsing.
 java.lang.String toLiteral(byte[] arr)
          Get the raw messages as a string, for tests and for dumping only.
 java.lang.String toLiteral(MsgInfo msgInfo)
          Get the raw messages as a string, for tests and for dumping only
 
Methods inherited from class org.xmlBlaster.client.script.XmlScriptInterpreter
buildMsgUnit, characters, dumpToFile, endCDATA, endElement, flushResponse, initialize, parse, replaceVariable, serialize, simplifiedErrorCode, startCDATA, startElement, update, wrapForScripting, wrapForScripting, wrapForScripting, writeElementStart
 
Methods inherited from class org.xmlBlaster.util.SaxHandlerBase
comment, endDocument, endDTD, endEntity, endPrefixMapping, error, fatalError, getUseLexicalHandler, ignorableWhitespace, init, init, init, notationDecl, processingInstruction, setDocumentLocator, setUseLexicalHandler, skippedEntity, startDocument, startDTD, startEntity, startPrefixMapping, toString, toXml, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static java.util.logging.Logger log

ME

private static final java.lang.String ME
See Also:
Constant Field Values

glob

private Global glob

XMLSCRIPT_EXTENSION

public static final java.lang.String XMLSCRIPT_EXTENSION
See Also:
Constant Field Values

XMLSCRIPT_ZLIB_EXTENSION

public static final java.lang.String XMLSCRIPT_ZLIB_EXTENSION
See Also:
Constant Field Values

XMLSCRIPT_MIMETYPE

public static final java.lang.String XMLSCRIPT_MIMETYPE
See Also:
Constant Field Values

XMLSCRIPT_ZLIB_MIMETYPE

public static final java.lang.String XMLSCRIPT_ZLIB_MIMETYPE
See Also:
Constant Field Values

isNullTerminated

private boolean isNullTerminated
If used by email, the InputStream finishes when the attaachment is read, if used over socket, we need to terminate the script with a null byte


xmlDecl

private java.lang.String xmlDecl


sendResponseSessionId

private boolean sendResponseSessionId

sendResponseRequestId

private boolean sendResponseRequestId

sendRequestSessionId

private boolean sendRequestSessionId

sendRequestRequestId

private boolean sendRequestRequestId

schemaDecl

private java.lang.String schemaDecl
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='xmlBlasterPublish.xsd'


progressListener

private I_ProgressListener progressListener
If not null somebody wants to be notified about the current bytes send over socket


msgInfoParsed

private java.util.ArrayList msgInfoParsed
Constructor Detail

XmlScriptParser

public XmlScriptParser()
Method Detail

getEncodingFromProcessingInstruction

public static java.lang.String getEncodingFromProcessingInstruction(java.lang.String pi)

init

public void init(Global glob,
                 I_ProgressListener progressListener,
                 I_PluginConfig pluginConfig)
          throws XmlBlasterException
Description copied from interface: I_MsgInfoParser
Is guaranteed to be called by the MsgInfoParserFactory after construction.

Specified by:
init in interface I_MsgInfoParser
pluginConfig - Can be null
Throws:
XmlBlasterException

getMimetype

public java.lang.String getMimetype(boolean isCompressed)
Get a specific extension for this format.

Specified by:
getMimetype in interface I_MsgInfoParser
Returns:
For example XMLSCRIPT_MIMETYPE = "text/xmlBlasterScript" or XMLSCRIPT_MIMETYPE_ZLIB = "text/xmlBlasterScriptz"

getExtension

public final java.lang.String getExtension(boolean isCompressed)
Description copied from interface: I_MsgInfoParser
Get a specific extension for this format.

Specified by:
getExtension in interface I_MsgInfoParser
Parameters:
isCompressed - true/false
Returns:
XMLSCRIPT_EXTENSION = ".xml"; XMLSCRIPT_ZLIB_EXTENSION = ".xmlz";

parse

public final MsgInfo[] parse(java.io.InputStream in)
                      throws java.io.IOException,
                             XmlBlasterException
This parses the raw message from an InputStream (typically from a email or a socket). Use the get...() methods to access the data.

This method blocks until a message arrives

Specified by:
parse in interface I_MsgInfoParser
Parameters:
in - The raw, serialized data
Returns:
The messages read, usually only one but for XmlScript multiple could be bundled, is never null
Throws:
java.io.IOException
XmlBlasterException

setProperty

public void setProperty(java.lang.String key,
                        java.lang.String value)
                 throws XmlBlasterException
Called during XML parsing.

Specified by:
setProperty in class XmlScriptInterpreter
Throws:
XmlBlasterException

fireMethod

public boolean fireMethod(MethodName methodName,
                          java.lang.String sessionId,
                          java.lang.String requestId,
                          byte type)
                   throws XmlBlasterException
Called during XML parsing.

Specified by:
fireMethod in class XmlScriptInterpreter
type - 'I'=invoke 'R'=response 'E'=exception
Returns:
true: The methodName was known and is successfully processed false: The methodName is not known and nothing is processed
Throws:
XmlBlasterException - Will lead to stop parsing further

createRawMsg

public final byte[] createRawMsg(MsgInfo msgInfo)
                          throws XmlBlasterException
Returns a XML data string.

Specified by:
createRawMsg in interface I_MsgInfoParser
Returns:
The serializd message
Throws:
XmlBlasterException

toLiteral

public final java.lang.String toLiteral(MsgInfo msgInfo)
                                 throws XmlBlasterException
Get the raw messages as a string, for tests and for dumping only

Specified by:
toLiteral in interface I_MsgInfoParser
Returns:
The stringified message, null bytes are replaced by '*'
Throws:
XmlBlasterException

toLiteral

public final java.lang.String toLiteral(byte[] arr)
Description copied from interface: I_MsgInfoParser
Get the raw messages as a string, for tests and for dumping only.

Specified by:
toLiteral in interface I_MsgInfoParser
Parameters:
arr - The raw blob
Returns:
The stringified message, null bytes are replaced by '*'

main

public static void main(java.lang.String[] args)
java org.xmlBlaster.util.xbformat.XmlScriptParser


isNullTerminated

public boolean isNullTerminated()
If used by email, the InputStream finishes when the attaachment is read, if used over socket, we need to terminate each script with a null byte


xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.