Package com.adaptris.core.services.jdbc
Class XmlPayloadTranslatorImpl
- java.lang.Object
-
- com.adaptris.core.services.jdbc.ResultSetTranslatorBase
-
- com.adaptris.core.services.jdbc.StyledResultTranslatorImp
-
- com.adaptris.core.services.jdbc.ResultSetTranslatorImp
-
- com.adaptris.core.services.jdbc.XmlPayloadTranslatorImpl
-
- All Implemented Interfaces:
ComponentLifecycle
,ComponentLifecycleExtension
,ResultSetTranslator
- Direct Known Subclasses:
MergeResultSetIntoXmlPayload
,SplittingXmlPayloadTranslator
,XmlPayloadTranslator
public abstract class XmlPayloadTranslatorImpl extends ResultSetTranslatorImp
Base class for translating ResultSet contents into an XML Payload.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
XmlPayloadTranslatorImpl.DocumentWrapper
-
Nested classes/interfaces inherited from class com.adaptris.core.services.jdbc.StyledResultTranslatorImp
StyledResultTranslatorImp.ColumnStyle
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
ELEMENT_NAME_COLUMN
protected static java.lang.String
ELEMENT_NAME_RESULTS
protected static java.lang.String
ELEMENT_NAME_ROW
-
Fields inherited from class com.adaptris.core.services.jdbc.ResultSetTranslatorBase
log
-
-
Constructor Summary
Constructors Constructor Description XmlPayloadTranslatorImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the component.protected static org.xml.sax.InputSource
createInputSource(java.lang.String value)
protected java.util.List<org.w3c.dom.Element>
createListFromResultSet(XmlPayloadTranslatorImpl.DocumentWrapper wrapper, JdbcResultSet rs)
protected org.w3c.dom.Node
createTextNode(org.w3c.dom.Document doc, java.lang.String value, boolean isCDATA)
protected static javax.xml.transform.Transformer
createTransformer(XmlPayloadTranslatorImpl.DocumentWrapper wrapper)
protected XmlPayloadTranslatorImpl.DocumentWrapper
createWrapper(AdaptrisMessage msg)
protected static XmlUtils
createXmlUtils(AdaptrisMessage msg)
java.lang.String
getCdataColumnRegexp()
java.lang.String
getOutputMessageEncoding()
java.lang.Boolean
getStripIllegalXmlChars()
java.lang.String
getXmlColumnPrefix()
java.lang.String
getXmlColumnRegexp()
void
init()
Initialises the component.protected boolean
isCdataColumn(java.lang.String name, XmlPayloadTranslatorImpl.DocumentWrapper wrapper)
protected boolean
isXmlColumn(java.lang.String name)
void
setCdataColumnRegexp(java.lang.String s)
Set the regular expression that will be used to check if a column should be wrapped in a CDATA element.void
setOutputMessageEncoding(java.lang.String encoding)
Set the encoding for the resulting XML document.void
setStripIllegalXmlChars(java.lang.Boolean s)
Specify whether or not to strip illegal XML characters from all the data before converting to XML.void
setXmlColumnPrefix(java.lang.String s)
Sets the prefix that is used to identify columns that should be treated as XML rather than text.void
setXmlColumnRegexp(java.lang.String s)
Set a regular expression that will be used to check if a column should be treated as XML rather than text.protected boolean
stripIllegalXmlChars()
-
Methods inherited from class com.adaptris.core.services.jdbc.ResultSetTranslatorImp
addColumnTranslator, getAttemptAutoConvert, getColumnTranslators, getDisplayColumnErrors, getResultCountMetadataItem, getUpdateCountMetadataItem, isDisplayColumnErrors, logColumnErrors, setAttemptAutoConvert, setColumnTranslators, setDisplayColumnErrors, setResultCountMetadataItem, setUpdateCountMetadataItem, toString, translate, translateResult, updateMetadata, updateMetadataQueryCount, updateMetadataUpdateCount, withAttemptAutoConvert, withColumnTranslators, withColumnTranslators
-
Methods inherited from class com.adaptris.core.services.jdbc.StyledResultTranslatorImp
getColumnNameStyle, setColumnNameStyle, withColumnNameStyle
-
Methods inherited from class com.adaptris.core.services.jdbc.ResultSetTranslatorBase
prepare
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.ComponentLifecycle
start, stop
-
-
-
-
Field Detail
-
ELEMENT_NAME_COLUMN
protected static final java.lang.String ELEMENT_NAME_COLUMN
- See Also:
- Constant Field Values
-
ELEMENT_NAME_ROW
protected static final java.lang.String ELEMENT_NAME_ROW
- See Also:
- Constant Field Values
-
ELEMENT_NAME_RESULTS
protected static final java.lang.String ELEMENT_NAME_RESULTS
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public void init() throws CoreException
Description copied from interface:ComponentLifecycle
Initialises the component.Component initialisation includes config verification, creation of connections etc.
- Throws:
CoreException
- wrapping any underlyingException
s
-
close
public void close()
Description copied from interface:ComponentLifecycle
Closes the component.A closed component should release any connections it uses, etc. and clean up completely. Throwing a
RuntimeException
may cause unintended consequences
-
createListFromResultSet
protected java.util.List<org.w3c.dom.Element> createListFromResultSet(XmlPayloadTranslatorImpl.DocumentWrapper wrapper, JdbcResultSet rs) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
createXmlUtils
protected static XmlUtils createXmlUtils(AdaptrisMessage msg)
-
isXmlColumn
protected boolean isXmlColumn(java.lang.String name)
-
isCdataColumn
protected boolean isCdataColumn(java.lang.String name, XmlPayloadTranslatorImpl.DocumentWrapper wrapper)
-
createTextNode
protected org.w3c.dom.Node createTextNode(org.w3c.dom.Document doc, java.lang.String value, boolean isCDATA)
-
createInputSource
protected static org.xml.sax.InputSource createInputSource(java.lang.String value)
-
getXmlColumnPrefix
public java.lang.String getXmlColumnPrefix()
- Returns:
- the prefix used to identify columns that should be returned as XML as opposed to text
-
setXmlColumnPrefix
public void setXmlColumnPrefix(java.lang.String s)
Sets the prefix that is used to identify columns that should be treated as XML rather than text.- Parameters:
s
- the prefix; note that this will be a case sensitive match, so if the behaviour of the database / JDBC driver is to make all columns / labels uppercase, then make sure you use the right case.
-
getXmlColumnRegexp
public java.lang.String getXmlColumnRegexp()
-
setXmlColumnRegexp
public void setXmlColumnRegexp(java.lang.String s)
Set a regular expression that will be used to check if a column should be treated as XML rather than text.- Parameters:
s
- the regular expression to match that indicates the column is XML,setXmlColumnPrefix(String)
is always checked first.- See Also:
setXmlColumnPrefix(String)
-
getOutputMessageEncoding
public java.lang.String getOutputMessageEncoding()
-
setOutputMessageEncoding
public void setOutputMessageEncoding(java.lang.String encoding)
Set the encoding for the resulting XML document.If not specified the following rules will be applied:
- If the
AdaptrisMessage.getCharEncoding()
is non-null then that will be used. - UTF-8
As a result; the character encoding on the message is always set using
AdaptrisMessage.setCharEncoding(String)
.- Parameters:
encoding
- the character
- If the
-
getCdataColumnRegexp
public java.lang.String getCdataColumnRegexp()
-
setCdataColumnRegexp
public void setCdataColumnRegexp(java.lang.String s)
Set the regular expression that will be used to check if a column should be wrapped in a CDATA element.- Parameters:
s
- the regular expression to match that indicates the column should be wrapped in a CDATA element.
-
getStripIllegalXmlChars
public java.lang.Boolean getStripIllegalXmlChars()
-
setStripIllegalXmlChars
public void setStripIllegalXmlChars(java.lang.Boolean s)
Specify whether or not to strip illegal XML characters from all the data before converting to XML.The following regular expression is used to strip out all invalid XML 1.0 characters :
"[^ \r\n --�𐀀-]"
. Note that not stripping Illegal XML characters can still mean that you get output that looks like XML, but you will not be able to subsequently process it as a DOM object.- Parameters:
s
- true to enable stripping, default is null (false)
-
stripIllegalXmlChars
protected boolean stripIllegalXmlChars()
-
createTransformer
protected static javax.xml.transform.Transformer createTransformer(XmlPayloadTranslatorImpl.DocumentWrapper wrapper) throws java.lang.Exception
- Throws:
java.lang.Exception
-
createWrapper
protected XmlPayloadTranslatorImpl.DocumentWrapper createWrapper(AdaptrisMessage msg) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-