Difference between revisions of "Placeholders"

From GreenVulcano Wiki
Jump to: navigation, search
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{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.
+
{{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.
  
 
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.
 
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.
  
{| class="gvtable"
+
{|class="gvtable"
 
! Placeholders / Metadata !! Brief description  
 
! Placeholders / Metadata !! Brief description  
 
|-
 
|-
| [[More about Placeholders|fixed]] || You can use a text string
+
| [[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.
 +
|-
 +
| [[Placeholders Example|fixed]] || You can use a text string
 
|-
 
|-
| [[More about Placeholders|<nowiki>${{propname}} </nowiki>]] || Use if you want a property previously defined by System. <br/> ''propname'' represents the System property name
+
| [[Placeholders Example|<nowiki>%{{class}}</nowiki>]] || Represents the object class name
 +
|-
 +
| [[Placeholders Example|<nowiki>%{{fqclass}}</nowiki>]] || Represents the object fully qualified class name
 +
|-
 +
| [[Placeholders Example|<nowiki>%{{package}}</nowiki>]] || Represents the object package name
 
|-
 
|-
| [[More about Placeholders|<nowiki>sp{{propname}} </nowiki>]] || Use if you want a property previously defined by System. <br/> ''propname'' represents the System property name
+
| [[Placeholders Example|<nowiki>${{propname}} </nowiki>]] || Returns the value of the ''propname'' system property
 
|-
 
|-
| [[More about Placeholders|<nowiki>@{{propname}} </nowiki>]] || Use this if you want a property passed as input. <br/> ''propname'' represents the inProperties property name
+
| [[Placeholders Example|<nowiki>sp{{propname}} </nowiki>]] || Returns the value of the ''propname'' system property
 
|-
 
|-
| [[More about Placeholders|<nowiki>timestamp{{pattern}} </nowiki>]] || Returns the current timestamp formatted as ''pattern''
+
| [[Placeholders Example|<nowiki>@{{propname}} </nowiki>]] || Use this if you want a property passed as input. <br/> ''propname'' represents the inProperties property name
 
|-
 
|-
| [[More about Placeholders|<nowiki>dateformat{{date::source-pattern::dest-pattern}} </nowiki>]] || Use this if you want t change the ''date'' format from ''source-pattern'' to ''dest-pattern''
+
| [[Placeholders Example|<nowiki>timestamp{{pattern}} </nowiki>]] || Returns the current timestamp formatted as ''pattern''. The pattern syntax is like the ''SimpleDateFormat'' class
 
|-
 
|-
| [[More about Placeholders|<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>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
 
|-
 
|-
| [[More about Placeholders|<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>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''
 
|-
 
|-
| [[More about Placeholders|<nowiki>js{{scope::script}}</nowiki>]] || Evaluates a JavaScript script, using the scope ''scope''
+
| [[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''
 
|-
 
|-
| [[More about Placeholders|<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 JNDI name of a DataSource, if it is not defined  the current connection is used
+
| [[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
 
|-
 
|-
| [[More about Placeholders|<nowiki>sqllist{{[conn::]statement}}</nowiki>]] || Executes a select sql statement and returns 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 it is not defined the current connection is used
+
| [[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
 
|-
 
|-
| [[More about Placeholders|<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>js{{scope::script}}</nowiki>]] || Evaluates a JavaScript script, using the scope ''scope''. The [[GVBuffer]] is added to the scope as ''object'' variable
 
|-
 
|-
| [[More about Placeholders|<nowiki>ognl{{script}}</nowiki>]] || Evaluates a OGNL script
+
| [[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'