Package com.ibm.di.connector.maximo.util
Class TemplateLoader
- java.lang.Object
-
- com.ibm.di.connector.maximo.util.TemplateLoader
-
public final class TemplateLoader extends java.lang.ObjectThis class loads a text file and replaces tokens defined inside it.Let's suppose the file
/com/ibm/di/maximo/query.xml.templatedefines the following template:<?xml version='1.0' encoding='UTF-8'?> <Query<b>{mos.name}</b> xmlns="http://www.ibm.com/maximo" creationDateTime="<b>{creation.date.time}</b>" baseLanguage="EN" transLanguage="EN" messageID="<b>{message.id}</b>" maximoVersion="<b>{maximo.version}</b>" uniqueResult="false" maxItems="<b>{max.items}</b>" rsStart="<b>{rs.start}</b>"> <<b>{mos.name}</b>Query> <b>{criteria}</b> </<b>{mos.name}</b>Query> </Query<b>{mos.name}</b>>The code bellow can be used to load and replace the tokens:
TemplateLoader tl = new TemplateLoader("/com/ibm/di/maximo/query.xml.template"); tl.setProperty("mos.name", "MXASSET"); tl.setProperty("maximo.version", "MX_VERSION"); tl.setProperty("creation.date.time", "2007-07-25T10:00:00-03:00"); tl.setProperty("message.id", 123); tl.setProperty("max.items", "10"); tl.setProperty("rs.start", "1"); tl.setProperty("criteria", "<ASSET><ASSETNUM operator=\"=\">5000</ASSETNUM></ASSET>"); System.out.println(tl.toString());The result should be something like:
<QueryMXASSET xmlns="http://www.ibm.com/maximo" creationDateTime="2007-07-25T10:00:00-03:00" baseLanguage="EN" transLanguage="EN" messageID="123" maximoVersion="MX_VERSION" uniqueResult="false" maxItems="10" rsStart="1"> <MXASSETQuery> <ASSET> <SOME CRITERIA /> </ASSET> </MXASSETQuery> </QueryMXASSET>- Since:
- 7.1
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringARG_HOLDERstatic java.lang.StringCREATION_HOLDERstatic java.lang.StringLANG_HOLDERstatic java.lang.StringMAXITEMS_HOLDERstatic java.lang.StringMBO_HOLDERstatic java.lang.StringMOS_HOLDERstatic java.lang.StringMSGID_HOLDERstatic java.lang.StringOPER_HOLDERstatic java.lang.StringQUERY_ARGSstatic java.lang.StringRSSTART_HOLDERstatic intTYPE_CREATEstatic intTYPE_DELETEstatic intTYPE_QUERYstatic intTYPE_SYNCstatic intTYPE_UPDATEstatic java.lang.StringUNIQUERES_HOLDERstatic java.lang.StringVERSION_HOLDER
-
Constructor Summary
Constructors Constructor Description TemplateLoader(int templateType, Log log)Constructs aTemplateLoaderfor the specified type.TemplateLoader(java.lang.String templateName)Constructs aTemplateLoaderwith the specified file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidsetProperty(java.lang.String token, long value)Defines the value associated with the given token.voidsetProperty(java.lang.String token, java.lang.String value)Defines the value associated with the given token.java.lang.StringtoString()Returns the template content with all tokens replaced.
-
-
-
Field Detail
-
CREATION_HOLDER
public static final java.lang.String CREATION_HOLDER
- See Also:
- Constant Field Values
-
MSGID_HOLDER
public static final java.lang.String MSGID_HOLDER
- See Also:
- Constant Field Values
-
VERSION_HOLDER
public static final java.lang.String VERSION_HOLDER
- See Also:
- Constant Field Values
-
LANG_HOLDER
public static final java.lang.String LANG_HOLDER
- See Also:
- Constant Field Values
-
UNIQUERES_HOLDER
public static final java.lang.String UNIQUERES_HOLDER
- See Also:
- Constant Field Values
-
MAXITEMS_HOLDER
public static final java.lang.String MAXITEMS_HOLDER
- See Also:
- Constant Field Values
-
RSSTART_HOLDER
public static final java.lang.String RSSTART_HOLDER
- See Also:
- Constant Field Values
-
OPER_HOLDER
public static final java.lang.String OPER_HOLDER
- See Also:
- Constant Field Values
-
ARG_HOLDER
public static final java.lang.String ARG_HOLDER
- See Also:
- Constant Field Values
-
MBO_HOLDER
public static final java.lang.String MBO_HOLDER
- See Also:
- Constant Field Values
-
MOS_HOLDER
public static final java.lang.String MOS_HOLDER
- See Also:
- Constant Field Values
-
QUERY_ARGS
public static final java.lang.String QUERY_ARGS
- See Also:
- Constant Field Values
-
TYPE_QUERY
public static final int TYPE_QUERY
- See Also:
- Constant Field Values
-
TYPE_CREATE
public static final int TYPE_CREATE
- See Also:
- Constant Field Values
-
TYPE_UPDATE
public static final int TYPE_UPDATE
- See Also:
- Constant Field Values
-
TYPE_DELETE
public static final int TYPE_DELETE
- See Also:
- Constant Field Values
-
TYPE_SYNC
public static final int TYPE_SYNC
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TemplateLoader
public TemplateLoader(java.lang.String templateName)
Constructs aTemplateLoaderwith the specified file.- Parameters:
templateName- name of the file that contains the template definition
-
TemplateLoader
public TemplateLoader(int templateType, Log log)Constructs aTemplateLoaderfor the specified type.- Parameters:
templateType- type of XML to create
-
-
Method Detail
-
setProperty
public void setProperty(java.lang.String token, long value)Defines the value associated with the given token.- Parameters:
token- token defined inside the templatevalue- value to be associated with the given token
-
setProperty
public void setProperty(java.lang.String token, java.lang.String value)Defines the value associated with the given token.- Parameters:
token- token defined inside the templatevalue- value to be associated with the given token
-
toString
public java.lang.String toString()
Returns the template content with all tokens replaced.- Overrides:
toStringin classjava.lang.Object- Returns:
- template content with all tokens replaced
-
-