Java Doc for BSLTemplate.java in  » Web-Server » Brazil » sunlabs » brazil » template » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Server » Brazil » sunlabs.brazil.template 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   sunlabs.brazil.template.Template
      sunlabs.brazil.template.BSLTemplate

BSLTemplate
public class BSLTemplate extends Template implements Serializable(Code)
The BSLTemplate takes an HTML document with embedded "BSL" markup tags in it and evaluates those special tags to produce a standard HTML document.

BSL stands for Brazil Scripting Language. BSL can be used to substitute data from the request properties into the resultant document. However, rather than simple property substitution as is provided by the PropsTemplate, this class provides the ability to iterate over and choose amongst the values substituted with a set of simple flow-control constructs.

BSL uses the following special tags as its language constructs:

  • <foreach>
  • <if>

This template recursively evalutes the bodies/clauses of the BSL commands, meaning that they may contain nested BSL and/or other tags defined by other templates.

The following configuration parameter is used to initialize this template.

debug
If this configuration parameter is present, this class replaces the BSL tags with comments, so the user can keep track of where the dynamically generated content is coming from by examining the comments in the resultant HTML document. By default, the BSL tags are completely eliminated from the HTML document rather than changed into comments.

<foreach> TAG

The <foreach> tag repeatedly evaluates its body a selected number of times. Each time the body is evaluated, the provided named property is set to the next word in the provided list of words. The body is terminated by the </foreach> tag. This tag is especially useful for dynamically producing lists and tables.
  •  <foreach name=var list="value1 value2 ..." [delim=x]>
     <property var>
     </foreach>
    Iterate over the set of values "value1 value2 ...". The named property var is assigned each value in turn. If the optional parameter delim is specified, its value is used as the list delimeter. By default, whitespace is used.

  •  <foreach name=var property=property [delim=x]>
     <property var>
     </foreach> 
    Iterate over the values in the other property. The value of the other property is broken up using the StringTokenizer and each piece is assigned to the named property var in turn. If the optional parameter delim is specified, its value is used as the list delimeter. By default, whitespace is used.

  •  <foreach name=var property=property [delim=x]>
     <property var>
     </foreach> 
    Iterate over the values in the other property. The value of the other property is broken up using the StringTokenizer and each piece is assigned to the named property var in turn.

  •  <foreach name=var glob=pattern>
     <property var.name>
     <property var.value>
     <property var.name.1>
     <property var.name.2>
     </foreach> 
    Iterate over all the properties whose name matches the sunlabs.brazil.util.Glob glob pattern. In turn, the following properties are set:
    var.name is the name of the property.
    var.value is the value of the property.
    var.name.1, var.name.2, ... are the substrings matching the wildcard characters in the pattern, if any.

  •  <foreach name=var glob=pattern>
     <property var.name>
     <property var.value>
     <property var.name.1>
     <property var.name.2>
     </foreach> 
    Iterate over all the properties whose name matches the sunlabs.brazil.util.Glob glob pattern. In turn, the following properties are set:
    var.name is the name of the property.
    var.value is the value of the property.
    var.name.1, var.name.2, ... are the substrings matching the wildcard characters in the pattern, if any.

  •  <foreach name=var match=pattern>
     <property var.name>
     <property var.value>
     <property var.name.0>
     <property var.name.1>
     <property var.name.2>
     </foreach> 
    Iterate over all the properties whose name matches the sunlabs.brazil.util.regexp.Regexp regular expression pattern. In turn, the following properties are set:
    var.name is the name of the property.
    var.value is the value of the property.
    var.name.0 is the substring that matched the whole pattern.
    var.name.1, var.name.2, ... are the substrings matching the parenthesized subexpressions, if any.

Sorting using foreach

The <foreach> tag contains an (experimantal) feature to change the order of iteration. This facility is intended for common sorting operations. For general purpose manipulation of the iteration order, the order should be defined either in another handler, or by using the sunlabs.brazil.tcl.TclServerTemplate <server> directive.

The three additional parameters used to control sorting are:

reverse
The list of items is iterated in the reverse order.
numeric
When used in conjunction with the sort parameter, it causes the sort keys to be interpreted as numbers (or zero if the key is an invalid number).
sort[=key]
The items to be iterated over are sorted. If no key is supplied, the items are sorted by the property name. If a key is supplied, its value is used as the sort key for the iteration. For this to be meaningful, the key should contain one or more variable substitutions (e.g. ${...}, see * sunlabs.brazil.util.Format.getPropertygetProperty ). Before iteration commences, the value for the key is computed for each item to be iterated over, by performing all of the '${...}' substitutions in key for each value, then sorting the items by the result.

<if> TAG

The <if> tag evaluates one of its clauses dependant upon the value of the provided named property(ies). The other clauses are not evaluated and do not appear in the resultant HTML document. The general format of the <if> tag is as follows:
 <if ...condition...>
 ...clause...
 <elseif ...condition...>
 ...clause...
 <else>
 ...clause...
 </if> 
The <elseif> and <else> tags are optional, and multiple <elseif> tags may be present.

Following are the formats of the "...condition...":

<if var>
Test if the value of property var is set and is not "", "false", "no", "off", or the number 0.

<if name=var>
Same as above.

<if name=var value=string>
Test if the value of property var is equal to the given string.

<if name=var glob=pattern>
Test if the value of property var matches the given sunlabs.brazil.util.Glob glob pattern.

<if name=var match=pattern>
Test if the value of property var matches the given sunlabs.brazil.util.regexp.Regexp regular expression pattern.

Anytime a variable name is specified, variable substitution as described in sunlabs.brazil.util.Format.getProperty may be used.
See Also:    a sample HTML page that contains some BSL
See Also:   markup



Field Summary
transient  booleandebug
    


Method Summary
public  booleaninit(RewriteContext hr)
     Called at the beginning of each HTML document that this BSLTemplate is asked to process.
public  voidtag_extract(RewriteContext hr)
     Handle the [experimental] "extract" tag. This permits parts of a property's value to be extracted into additional properties, based on either glob or regular expression patterns.
<extract name= prepend= glob= match=>
name
The name of the property to extract
prepend
The base name for all extracted properties (defaults to "name").
public  voidtag_foreach(RewriteContext hr)
     Handles the "foreach" tag.
public  voidtag_if(RewriteContext hr)
     Handles the "if" tag.

Field Detail
debug
transient boolean debug(Code)





Method Detail
init
public boolean init(RewriteContext hr)(Code)
Called at the beginning of each HTML document that this BSLTemplate is asked to process.

Checks the "debug" configuation parameter.
Parameters:
  hr - The request and associated HTML document that will beprocessed.




tag_extract
public void tag_extract(RewriteContext hr)(Code)
Handle the [experimental] "extract" tag. This permits parts of a property's value to be extracted into additional properties, based on either glob or regular expression patterns.
<extract name= prepend= glob= match=>
name
The name of the property to extract
prepend
The base name for all extracted properties (defaults to "name"). If it doesn't end with a ".", one is added.
glob
The glob pattern to use for extraction. The text matching each wildcard in the pattern is extracted.
match
The regular expression pattern to use for extraction. The text matching each sub-expression is extracted. If "glob" is specified, then "match" is ignored.



tag_foreach
public void tag_foreach(RewriteContext hr)(Code)
Handles the "foreach" tag.



tag_if
public void tag_if(RewriteContext hr)(Code)
Handles the "if" tag.



Methods inherited from sunlabs.brazil.template.Template
public boolean done(RewriteContext hr)(Code)(Java Doc)
public boolean init(RewriteContext hr)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.