Difference between revisions of "Placeholders"

From GreenVulcano Wiki
Jump to: navigation, search
(Created page with "This section contains the placeholders used by {{GVESB}}. # fixed : a text string; # <nowiki>${{propname}} </nowiki> : a System property name; # <nowiki>sp{{propname}} </nowiki...")
 
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This section contains the placeholders used by {{GVESB}}.
+
{{GVESB}} provides some placeholders and metadata. Their numerous applications range from the property definitions and attribute settings to more concrete applications as the evaluations of JavaScript scripts and database queries. Placeholders can be nested.
  
# fixed : a text string;
+
Next comes a table with all the metadata used by {{GVESB}} and their description. It is also available for each item a link for deepening into, with concrete examples.
# <nowiki>${{propname}} </nowiki> : a System property name;
+
 
# <nowiki>sp{{propname}} </nowiki> : a System property name;
+
{|class="gvtable"
# <nowiki>@{{propname}} </nowiki> : a inProperties property name;
+
! Placeholders / Metadata !! Brief description
# <nowiki>timestamp{{pattern}} </nowiki>: return the current timestamp formatted as ''pattern''
+
|-
# <nowiki>dateformat{{date::source-pattern::dest-pattern}} </nowiki>: reformat ''date'' from 'source-pattern'' to ''dest-pattern''
+
| [[Placeholders Example|<nowiki>xmlp{{propname}}</nowiki>]] || Used by XML configuration reading framework. Replaces in file ''filename.xml'' the occurrences of <nowiki>xmlp{{prop}}</nowiki> with the prop value defined in the ''filename.properties'' file, before parsing the XML document.
# <nowiki>decode{{field[::cond1::val1][::cond2::val2][cond...n::val...n]::default}} </nowiki>: evaluate as if-then-else; if ''field'' is equal to cond1...n, return the value of val1...n, otherwise ''default''
+
|-
# <nowiki>decodeL{{sep::field[::cond1::val1][::cond2::val2][cond...n::val...n]::default}}</nowiki> : is equivalent to ''decode'', with the difference that ''condX''  can be a list of values separated by ''sep''
+
| [[Placeholders Example|fixed]] || You can use a text string
# <nowiki>js{{scope::script}}</nowiki> : evaluate a JavaScript script, using the scope ''scope''
+
|-
# <nowiki>sql{{[conn::]statement}}</nowiki> : execute a select sql statement sql and return the value of the first field of the first selected record.<br/> The ''conn'' parameter is the JNDI name of a DataSource, if not defined is used the current connection
+
| [[Placeholders Example|<nowiki>%{{class}}</nowiki>]] || Represents the object class name
# <nowiki>sqllist{{[conn::]statement}}</nowiki>: execute a select sql statement sql and return the value of the first field of all selected records as a comma separated list. <br/> The ''conn'' parameter is the JNDI name of a DataSource, if not defined is used the current connection
+
|-
# <nowiki>sqltable{{conn::statement}}</nowiki>: executes a select sql statement and returns all values of returned cursor as an XML. <br/> The ''conn'' parameter is the JNDI name of a DataSource
+
| [[Placeholders Example|<nowiki>%{{fqclass}}</nowiki>]] || Represents the object fully qualified class name
# <nowiki>ognl{{script}}</nowiki> : evaluate a OGNL script
+
|-
 +
| [[Placeholders Example|<nowiki>%{{package}}</nowiki>]] || Represents the object package name
 +
|-
 +
| [[Placeholders Example|<nowiki>${{propname}} </nowiki>]] || Returns the value of the ''propname'' system property
 +
|-
 +
| [[Placeholders Example|<nowiki>sp{{propname}} </nowiki>]] || Returns the value of the ''propname'' system property
 +
|-
 +
| [[Placeholders Example|<nowiki>@{{propname}} </nowiki>]] || Use this if you want a property passed as input. <br/> ''propname'' represents the inProperties property name
 +
|-
 +
| [[Placeholders Example|<nowiki>timestamp{{pattern}} </nowiki>]] || Returns the current timestamp formatted as ''pattern''. The pattern syntax is like the ''SimpleDateFormat'' class
 +
|-
 +
| [[Placeholders Example|<nowiki>dateformat{{date::source-pattern::dest-pattern}} </nowiki>]] || Use this if you want to change the ''date'' format from ''source-pattern'' to ''dest-pattern''. the pattern syntax is like the ''SimpleDateFormat'' class
 +
|-
 +
| [[Placeholders Example|<nowiki>decode{{field[::cond1::val1][::cond2::val2][cond...n::val...n]::default}} </nowiki>]] || Works as the if-then-else construct: if ''field'' is equal to cond1, return the value of val1, ...; if ''field'' is equal to condn, return the value of valn; otherwise ''default''
 +
|-
 +
| [[Placeholders Example|<nowiki>decodeL{{sep::field[::cond1::val1][::cond2::val2][cond...n::val...n]::default}}</nowiki>]] || It is equivalent to ''decode'', with the difference that ''condX''  can be a list of values separated by ''sep''
 +
|-
 +
| [[Placeholders Example|<nowiki>xpath{{field::path}}</nowiki>]] || Parses the inProperties ''field'' value (must contain a XML string), then applies the xpath and returns the found value
 +
|-
 +
| [[Placeholders Example|<nowiki>xpath{{field://name::path}}</nowiki>]] || If ''field'' begin with ''file://'' the following string must be a name of a file in the classpath on which apply the xpath. Then is read by XMLConfig class
 +
|-
 +
| [[Placeholders Example|<nowiki>js{{scope::script}}</nowiki>]] || Evaluates a JavaScript script, using the scope ''scope''. The [[GVBuffer]] is added to the scope as ''object'' variable
 +
|-
 +
| [[Placeholders Example|<nowiki>sql{{[conn::]statement}}</nowiki>]] || Executes a select sql statement and returns the value of the first field of the first selected record.<br/> The ''conn'' parameter is the name of a connection defined in GVAdapter.xml/[[GVJDBCConnectionBuilder]]] or the JNDI name of a DataSource
 +
|-
 +
| [[Placeholders Example|<nowiki>sqllist{{[conn::[::sep]]statement}}</nowiki>]] || Executes a select sql statement and returns the value of the first field of all selected records as  as a 'sep' (default to comma) separated list. <br/> The ''conn'' parameter is the name of a connection defined in GVAdapter.xml/[[GVJDBCConnectionBuilder]] or the JNDI name of a DataSource
 +
|-
 +
| [[Placeholders Example|<nowiki>sqltable{{conn::statement}}</nowiki>]] || Executes a select sql statement and returns all values of returned cursor as a XML. <br/> For instance, if the cursor has 3 fields, the returned XML will have following fields:
 +
<syntaxhighlight lang="XML">
 +
<RowSet>
 +
  <data>
 +
      <row>
 +
        <col>value1</col>
 +
        <col>value2</col>
 +
        <col>value3</col>
 +
      </row>
 +
      ...
 +
      <row>
 +
        <col>valuex</col>
 +
        <col>valuey</col>
 +
        <col>valuez</col>
 +
      </row>
 +
  </data>
 +
</RowSet>
 +
</syntaxhighlight>
 +
The ''conn'' parameter is the name of a connection defined in GVAdapter.xml/[[GVJDBCConnectionBuilder]] or the JNDI name of a DataSource
 +
|-
 +
| [[Placeholders Example|<nowiki>ognl{{script}}</nowiki>]] || Evaluates a OGNL script. The [[GVBuffer]] is added to the context as ''<nowiki>#object</nowiki>'' variable (and is also the context object on which executes the script)
 +
|-
 +
| [[Placeholders Example|<nowiki>escJS{{string}}</nowiki>]] || escapes invalid JavaScript characters from 'string' (ex. ' -> \')
 +
|-
 +
| [[Placeholders Example|<nowiki>escSQL{{string}}</nowiki>]] || escapes invalid SQL characters from 'string' (ex. ' -> <nowiki>''</nowiki>)
 +
|-
 +
| [[Placeholders Example|<nowiki>escXML{{string}}</nowiki>]] || escapes invalid XML characters from 'string' (ex. ' -> <nowiki>&apos;</nowiki>)
 +
|-
 +
| [[Placeholders Example|<nowiki>replace{{string::search::subst}}</nowiki>]] || replaces in ''string'' all occurrences of ''search'' with ''replace''
 +
|}
 +
 
 +
 
 +
<div class="version_ge3.3.2">
 +
{|class="gvtable"
 +
! Placeholders / Metadata !! Brief description
 +
|-
 +
| [[Placeholders Example|<nowiki>env{{propname}} </nowiki>]] || Returns the value of the ''propname'' environment variable
 +
|}
 +
</div>
 +
 
 +
<div class="version_ge3.3.3">
 +
{|class="gvtable"
 +
! Placeholders / Metadata !! Brief description
 +
|-
 +
| [[Placeholders Example|<nowiki>urlEnc{{string}} </nowiki>]] || URL encode invalid characters from 'string'
 +
|-
 +
| [[Placeholders Example|<nowiki>urlDec{{string}} </nowiki>]] || decode URL encoded characters from 'string'
 +
|}
 +
</div>

Latest revision as of 14:37, 31 October 2013

GreenVulcano® ESB provides some placeholders and metadata. Their numerous applications range from the property definitions and attribute settings to more concrete applications as the evaluations of JavaScript scripts and database queries. Placeholders can be nested.

Next comes a table with all the metadata used by GreenVulcano® ESB and their description. It is also available for each item a link for deepening into, with concrete examples.

Placeholders / Metadata Brief description
xmlp{{propname}} Used by XML configuration reading framework. Replaces in file filename.xml the occurrences of xmlp{{prop}} with the prop value defined in the filename.properties file, before parsing the XML document.
fixed You can use a text string
%{{class}} Represents the object class name
%{{fqclass}} Represents the object fully qualified class name
%{{package}} Represents the object package name
${{propname}} Returns the value of the propname system property
sp{{propname}} Returns the value of the propname system property
@{{propname}} Use this if you want a property passed as input.
propname represents the inProperties property name
timestamp{{pattern}} Returns the current timestamp formatted as pattern. The pattern syntax is like the SimpleDateFormat class
dateformat{{date::source-pattern::dest-pattern}} Use this if you want to change the date format from source-pattern to dest-pattern. the pattern syntax is like the SimpleDateFormat class
decode{{field[::cond1::val1][::cond2::val2][cond...n::val...n]::default}} Works as the if-then-else construct: if field is equal to cond1, return the value of val1, ...; if field is equal to condn, return the value of valn; otherwise default
decodeL{{sep::field[::cond1::val1][::cond2::val2][cond...n::val...n]::default}} It is equivalent to decode, with the difference that condX can be a list of values separated by sep
xpath{{field::path}} Parses the inProperties field value (must contain a XML string), then applies the xpath and returns the found value
xpath{{field://name::path}} If field begin with file:// the following string must be a name of a file in the classpath on which apply the xpath. Then is read by XMLConfig class
js{{scope::script}} Evaluates a JavaScript script, using the scope scope. The GVBuffer is added to the scope as object variable
sql{{[conn::]statement}} Executes a select sql statement and returns the value of the first field of the first selected record.
The conn parameter is the name of a connection defined in GVAdapter.xml/GVJDBCConnectionBuilder] or the JNDI name of a DataSource
sqllist{{[conn::[::sep]]statement}} Executes a select sql statement and returns the value of the first field of all selected records as as a 'sep' (default to comma) separated list.
The conn parameter is the name of a connection defined in GVAdapter.xml/GVJDBCConnectionBuilder or the JNDI name of a DataSource
sqltable{{conn::statement}} Executes a select sql statement and returns all values of returned cursor as a XML.
For instance, if the cursor has 3 fields, the returned XML will have following fields:
<RowSet>
   <data>
      <row>
         <col>value1</col>
         <col>value2</col>
         <col>value3</col>
      </row>
      ...
      <row>
         <col>valuex</col>
         <col>valuey</col>
         <col>valuez</col>
      </row>
   </data>
</RowSet>

The conn parameter is the name of a connection defined in GVAdapter.xml/GVJDBCConnectionBuilder or the JNDI name of a DataSource

ognl{{script}} Evaluates a OGNL script. The GVBuffer is added to the context as #object variable (and is also the context object on which executes the script)
escJS{{string}} escapes invalid JavaScript characters from 'string' (ex. ' -> \')
escSQL{{string}} escapes invalid SQL characters from 'string' (ex. ' -> '')
escXML{{string}} escapes invalid XML characters from 'string' (ex. ' -> ')
replace{{string::search::subst}} replaces in string all occurrences of search with replace


Placeholders / Metadata Brief description
env{{propname}} Returns the value of the propname environment variable
Placeholders / Metadata Brief description
urlEnc{{string}} URL encode invalid characters from 'string'
urlDec{{string}} decode URL encoded characters from 'string'