public abstract class TemplateProcessor extends Object
Modifier and Type | Field and Description |
---|---|
protected static String |
ESCAPE_BACK_SLASH_WITH_SIXTEEN_BACK_SLASHES |
protected static String |
ESCAPE_BACKSPACE_WITH_EIGHT_BACK_SLASHES |
protected static String |
ESCAPE_CRETURN_WITH_EIGHT_BACK_SLASHES |
protected static String |
ESCAPE_DOLLAR_WITH_SIX_BACK_SLASHES |
protected static String |
ESCAPE_DOLLAR_WITH_TEN_BACK_SLASHES |
protected static String |
ESCAPE_DOUBLE_QUOTE_WITH_FIVE_BACK_SLASHES |
protected static String |
ESCAPE_DOUBLE_QUOTE_WITH_NINE_BACK_SLASHES |
protected static String |
ESCAPE_FORMFEED_WITH_EIGHT_BACK_SLASHES |
protected static String |
ESCAPE_NEWLINE_WITH_EIGHT_BACK_SLASHES |
protected static String |
ESCAPE_TAB_WITH_EIGHT_BACK_SLASHES |
protected XMLInputFactory |
inputFactory |
protected static String |
JSON_TYPE |
protected static String |
STRING_TYPE |
protected static String |
TEXT_TYPE |
protected static String |
XML_TYPE |
Constructor and Description |
---|
TemplateProcessor() |
Modifier and Type | Method and Description |
---|---|
void |
addPathArgument(Argument arg) |
protected org.apache.axiom.om.OMElement |
convertStringToOM(String value)
Converts String to OMElement
|
protected String |
escapeSpecialCharactersOfJson(String jsonString)
Replace special characters of a JSON string.
|
protected String |
escapeSpecialCharactersOfXml(String xmlString)
Replace special characters of a XML string.
|
protected String |
escapeSpecialChars(String replaceString)
Helper method to replace required char values with escape characters.
|
protected String |
escapeXMLEnvelope(MessageContext msgCtx,
String value)
Escapes XML special characters
|
protected String |
escapeXMLSpecialChars(String replaceString)
Helper method to replace required char values with escape characters for XML.
|
protected HashMap<String,ArgumentDetails>[] |
getArgValues(String mediaType,
MessageContext synCtx)
Goes through SynapsePath argument list, evaluating each by calling stringValueOf and returns a HashMap String, String
array where each item will contain a hash map with key "evaluated expression" and value "SynapsePath type".
|
String |
getFormat() |
String |
getMediaType() |
List<Argument> |
getPathArgumentList() |
protected void |
handleException(String msg) |
protected String |
inferReplacementType(Map.Entry<String,ArgumentDetails> entry)
Helper function that takes a Map of String, ArgumentDetails where key contains the value of an evaluated
SynapsePath expression and value contains the type of SynapsePath + deepcheck status in use.
|
abstract void |
init()
Execute pre-processing steps if needed
|
protected boolean |
isEscapeXmlChars() |
protected boolean |
isJson(String value)
Helper function that returns true if value passed is of JSON type.
|
protected boolean |
isXML(String value)
Helper function that returns true if value passed is of XML Type.
|
protected String |
prepareReplacementValue(String mediaType,
MessageContext synCtx,
Map.Entry<String,ArgumentDetails> replacementEntry)
Preprocess and converty types of the given arg value.
|
abstract String |
processTemplate(String template,
String mediaType,
MessageContext synCtx)
Process the given template and return the output as String
|
void |
setEscapeXmlChars(boolean escapeXmlChars) |
void |
setFormat(String format) |
void |
setMediaType(String mediaType) |
protected static final String JSON_TYPE
protected static final String XML_TYPE
protected static final String TEXT_TYPE
protected static final String STRING_TYPE
protected static final String ESCAPE_DOUBLE_QUOTE_WITH_FIVE_BACK_SLASHES
protected static final String ESCAPE_DOUBLE_QUOTE_WITH_NINE_BACK_SLASHES
protected static final String ESCAPE_BACK_SLASH_WITH_SIXTEEN_BACK_SLASHES
protected static final String ESCAPE_DOLLAR_WITH_SIX_BACK_SLASHES
protected static final String ESCAPE_DOLLAR_WITH_TEN_BACK_SLASHES
protected static final String ESCAPE_BACKSPACE_WITH_EIGHT_BACK_SLASHES
protected static final String ESCAPE_FORMFEED_WITH_EIGHT_BACK_SLASHES
protected static final String ESCAPE_NEWLINE_WITH_EIGHT_BACK_SLASHES
protected static final String ESCAPE_CRETURN_WITH_EIGHT_BACK_SLASHES
protected static final String ESCAPE_TAB_WITH_EIGHT_BACK_SLASHES
protected final XMLInputFactory inputFactory
public abstract String processTemplate(String template, String mediaType, MessageContext synCtx)
template
- Template stringmediaType
- Output media typesynCtx
- MessageContextpublic abstract void init()
protected HashMap<String,ArgumentDetails>[] getArgValues(String mediaType, MessageContext synCtx)
synCtx
- MessageContextprotected String prepareReplacementValue(String mediaType, MessageContext synCtx, Map.Entry<String,ArgumentDetails> replacementEntry)
mediaType
- Output media typesynCtx
- Message contextreplacementEntry
- Argumentprotected String inferReplacementType(Map.Entry<String,ArgumentDetails> entry)
It returns the type of conversion required (XML | JSON | String) based on the actual returned value and the path type.
entry
- protected boolean isJson(String value)
value
- protected boolean isXML(String value)
value
- protected org.apache.axiom.om.OMElement convertStringToOM(String value) throws XMLStreamException, org.apache.axiom.om.OMException
value
- String value to convertXMLStreamException
org.apache.axiom.om.OMException
protected String escapeSpecialChars(String replaceString)
replaceString
- protected String escapeSpecialCharactersOfJson(String jsonString)
jsonString
- JSON string.protected String escapeSpecialCharactersOfXml(String xmlString)
xmlString
- XML string.protected String escapeXMLSpecialChars(String replaceString)
replaceString
- protected String escapeXMLEnvelope(MessageContext msgCtx, String value)
msgCtx
- Message Contextvalue
- XML String which needs to be escapedprotected boolean isEscapeXmlChars()
public void setEscapeXmlChars(boolean escapeXmlChars)
public void addPathArgument(Argument arg)
public String getFormat()
public void setFormat(String format)
public String getMediaType()
public void setMediaType(String mediaType)
protected void handleException(String msg)
Copyright © 2005–2024 Apache Software Foundation. All rights reserved.