|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xmlBlaster.contrib.dbwatcher.convert.ResultSetToXmlConverter
public class ResultSetToXmlConverter
Creates a standardized XML dump from the given ResultSets.
Configurations are:I_AttributeTransformer
is loaded.
This plugin is called once for each xml dump and adds <attr> tags as returned by the plugin
Here is an example XML dump, note that all meta data settings (like isNullable) are as described in JDBC (see ResultSetMetaData.java):
<?xml version='1.0' encoding='UTF-8' ?> <sql> <desc> <command>INSERT</command> <ident>AFTN_CIRCUIT_STATE</ident> <colname type='DATE' nullable='0'>DATUM</colname> <colname type='NUMBER' precision='11' signed='false'>CPU</colname> <colname type='NUMBER' precision='10' scale='3'>OLG</colname> <colname type='VARCHAR2' precision='8' nullable='0'>FS_ST</colname> </desc> <row num='0'> <col name='DATUM'>2005-01-05 15:41:36.0</col> <col name='CPU'>238089</col> <col name='OLG'>-12.333</col> <col name='FS_ST'>GW</col> <attr name='SUBNET_ID'>TCP</attr> <attr name='CIRCUIT_STATE'>OPERATIVE</attr> </row> <row num='1'> <col name='DATUM'>2005-01-05 15:41:36.0</col> <col name='CPU'>238092</col> <col name='OLG'>1.513</col> <col name='FS_ST'>GW</col> <attr name='SUBNET_ID'>TCP</attr> <attr name='CIRCUIT_STATE'>OPERATIVE</attr> </row> </sql>
The additional <attr> tags can be created by configuring an
I_AttributeTransformer
plugin.
This class is not thread save, use separate instances if used by multiple threads.
I_DataConverter
Field Summary | |
---|---|
protected boolean |
addMeta
|
protected java.lang.String |
charSet
|
protected java.lang.String |
command
|
protected boolean |
commandIsAdded
|
protected boolean |
doneCalled
|
protected java.lang.String |
ident
|
private static java.util.logging.Logger |
log
|
private int |
maxRows
|
protected java.io.OutputStream |
out
|
protected java.lang.String |
postStatement
|
protected java.lang.String |
rootTag
|
protected int |
rowCounter
|
private long |
size
|
protected I_AttributeTransformer |
transformer
|
Fields inherited from interface org.xmlBlaster.contrib.dbwatcher.convert.I_DataConverter |
---|
ALL, BASE64, IGNORE_MESSAGE, META_ONLY, ROW_ONLY |
Constructor Summary | |
---|---|
ResultSetToXmlConverter()
Default constructor, you need to call init(info) thereafter. |
|
ResultSetToXmlConverter(I_Info info)
Create this plugin. |
Method Summary | |
---|---|
void |
addInfo(java.sql.Connection conn,
java.sql.ResultSet rs,
int what)
Add another result set to the XML string |
void |
addInfo(java.util.Map attributeMap)
Add a map with attributes to the XML string. |
int |
done()
After the last addInfo() call this method to complete the XML dump. |
long |
getCurrentMessageSize()
Returns the size of the message as it is at the current moment |
java.lang.String |
getPostStatement()
Gets the statement (if any) to be executed after processing one message.In case of the DbWatcher to be used to send/publish messages on detected changes, this can be used to delete entries in a queue. |
static byte[] |
getResultSetAsXmlLiteral(java.sql.Connection conn,
java.sql.ResultSet rs,
java.lang.String command,
java.lang.String ident,
long maxRows)
|
void |
init(I_Info info)
Needs to be called after construction. |
protected int |
protectionNeeded(java.lang.String value)
If value contains XML harmful characters it needs to be wrapped by CDATA or encoded to Base64. |
void |
setOutputStream(java.io.OutputStream out,
java.lang.String command,
java.lang.String ident,
ChangeEvent event)
This should be called before the first #addInfo(ResultSet) call. |
void |
shutdown()
Cleanup resources. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static java.util.logging.Logger log
protected I_AttributeTransformer transformer
protected java.lang.String rootTag
protected java.io.OutputStream out
protected java.lang.String command
protected java.lang.String ident
protected int rowCounter
protected boolean commandIsAdded
protected boolean doneCalled
protected boolean addMeta
protected java.lang.String postStatement
protected java.lang.String charSet
private int maxRows
private long size
Constructor Detail |
---|
public ResultSetToXmlConverter()
public ResultSetToXmlConverter(I_Info info) throws java.lang.Exception
info
- Possible configuration parameters you find in the class description
java.lang.Exception
- If transformer instantiation failsMethod Detail |
---|
public void init(I_Info info) throws java.lang.Exception
I_DataConverter
init
in interface I_DataConverter
info
- The configuration environment
java.lang.Exception
I_DataConverter.init(I_Info)
public void setOutputStream(java.io.OutputStream out, java.lang.String command, java.lang.String ident, ChangeEvent event) throws java.lang.Exception
setOutputStream
in interface I_DataConverter
event
- can be null since it is not used in this implementation.out
- The stream to dump the converted data tocommand
- An optional command string or nullident
- the identity or optionally null.
java.lang.Exception
- of any typeorg.xmlBlaster.contrib.dbwatcher.convert.I_DataConverter#setOutputStream(OutputStream, String, String)
public void addInfo(java.util.Map attributeMap) throws java.lang.Exception
addInfo
in interface I_DataConverter
attributeMap
- A map containing key/values to dump
java.lang.Exception
- of any typeI_DataConverter.addInfo(Map)
public void addInfo(java.sql.Connection conn, java.sql.ResultSet rs, int what) throws java.lang.Exception
addInfo
in interface I_DataConverter
rs
- The JDBC result setwhat
- One of I_DataConverter.ALL
, I_DataConverter.META_ONLY
or
I_DataConverter.ROW_ONLY
.
I_DataConverter.META_ONLY
is useful for an empty table where rs access fails.
java.lang.Exception
- of any typeorg.xmlBlaster.contrib.dbwatcher.convert.I_DataConverter#addInfo(ResultSet, int)
protected int protectionNeeded(java.lang.String value)
value
- The string to verify
public int done() throws java.lang.Exception
I_DataConverter
I_DataConverter.setOutputStream(java.io.OutputStream, java.lang.String, java.lang.String, org.xmlBlaster.contrib.dbwatcher.ChangeEvent)
again to reuse
this instance.
done
in interface I_DataConverter
java.lang.Exception
- typically java.io.UnsupportedEncodingException, java.io.IOExceptionI_DataConverter.done()
public void shutdown() throws java.lang.Exception
I_DataConverter
shutdown
in interface I_DataConverter
java.lang.Exception
- of any typeI_DataConverter.shutdown()
public java.lang.String getPostStatement()
I_DataConverter
getPostStatement
in interface I_DataConverter
public static byte[] getResultSetAsXmlLiteral(java.sql.Connection conn, java.sql.ResultSet rs, java.lang.String command, java.lang.String ident, long maxRows) throws java.lang.Exception
java.lang.Exception
public long getCurrentMessageSize()
I_DataConverter
getCurrentMessageSize
in interface I_DataConverter
|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |