Java Doc for JDynamiTe.java in  » Template-Engine » JDynamiTe » cb » jdynamite » 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 » Template Engine » JDynamiTe » cb.jdynamite 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   cb.jdynamite.analyser.DefaultDynamicElement
      cb.jdynamite.JDynamiTe

JDynamiTe
public class JDynamiTe extends DefaultDynamicElement implements ITemplateDocument,Serializable(Code)
JDynamiTe is the unique class you need to parse a template document. This implementation extends the DefaultDynamicElement class (from package analyser), so a JDynamiTe object is a "Dynamic Element". The use is very simple :
First define the input file or input stream (for example an HTML template document) with the "setInput" method.
Secondly fill and develop this document with a few methods such as "setVariable", and "parseDynElem".
Finally, after calling the "parse" method to finalize building your dynamic document, you simply obtain the result with the "toString" method.

See an example in the main method of this class.

JDynamiTe elements

There are (only) two elements which make a document a "template" document.

1) "Variable Element"
A "Variable Element" is defined by an identifier in the template document. Its value can be changed with the JDynamiTe.setValue method.
Example of use: titles, values of cells in tables, etc.

2) "Dynamic Element"
A "Dynamic Element" is a "block" which can be dynamically developed. It has an identifier, a template definition, and a value. Its value can be set or developed with the JDynamiTe.parseDynElem and JDynamiTe.setDynElem methods.
Example of use: list, table, enumeration, etc.


Template document syntax

There are only 3 tags to use JDynamiTe : "Variable" tag, "Begin Dynamic Element" tag, and "End Dynamic Element" tag. The tag syntax is defined by regular expressions, you can change it in the analyser.
By default JDynamiTe uses the "DefaultAnalyser" to parse the template documents. By default, this analyser uses HTML style tags.

1) "Variable" tag:
 {VARNAME} 
means you can use setVariable("VARNAME", aStringValue) in Java code.

2) "Begin Dynamic Element" tag:
 <!-- BEGIN DYNAMIC : dynElemName --> 
or
 <!-- BEGIN DYNAMIC BLOCK: dynElemName --> 
means the "dynElemName" Dynamic Element definition begins on the next line.

3) "End Dynamic Element" tag:
 <!-- END DYNAMIC : dynElemName --> 
or
 <!-- END DYNAMIC BLOCK: dynElemName --> 
means the "dynElemName" Dynamic Element definition ends on the previous line.

Identifiers syntax (for Variables and Dynamic Elements):
By default, it is a word made up of alphanumeric characters and these four characters: '.', ':', '_' and '-'


New concept : "Ignored Element"

Since JDynamiTe 1.1, this optional element can be used in template documents. An "Ignored Element" is a "block" which will be completly ignored (skipped during document analysis).
Example of use: it allows the HTML designer to build more realistic pages, with concrete data, giving a better idea of the possible dynamic page look and feel. An "Ignored Element" can be inserted anywhere in the template document, even inside "Dynamic Element".

"Ignored Element" tags
 <!-- BEGIN IGNORED : ignoredElemName --> 
means an ignored block (skipped during analysis and document output) begins on the next line.
 <!-- END IGNORED : ignoredElemName --> 
means this ignored block ends on the previous line.


JDynamiTe home page

JDynamiTe latest versions, news, examples ... at http://jdynamite.sourceforge.net



author:
   Christophe Bouleau



Constructor Summary
public  JDynamiTe()
     Constructs an empty "JDynamiTe" (Java Dynamic Template) document.
public  JDynamiTe(String name)
     Constructs an empty "JDynamiTe" (Java Dynamic Template) document.

Method Summary
public  voidclearAll()
     Reset all Variables and all Dynamic Element values.
public  voidclearAllDynElemValues()
     Reset all Dynamic Element values.
public  voidclearAllVariables()
     Reset all Variables.
public  ITemplateAnalysergetAnalyser()
     Returns the analyser that parses template documents (Note: You do not need to directly call this method to use JDynamiTe).
public  IDynamicElementgetDynElem(String key)
     Returns the "Dynamic Element" identified by a string (Note: You do not need to directly call this method to use JDynamiTe). A "JDynamiTe" document maintains a list of "Dynamic Elements".
Parameters:
  key - The "Dynamic Element" identifier.
public  StringgetTemplateDefinition()
     For debugging purposes : get the result (structure of the template document) of the analyser parsing.
public  StringgetVariable(String key)
     Returns the value of a variable that was set by setVariable. A "JDynamiTe" document maintains a list of key/value pairs, which is used when Dynamic Elements are parsed.
Parameters:
  key - The key of the variable to retrieve.
public  EnumerationgetVariableKeys()
     Returns an enumeration of the template Variable keys in this JDynamiTe document. A "JDynamiTe" document maintains a list of key/value pairs, which is used when Dynamic Elements are parsed. The setInput method build this list (with an empty string as default value) during the template document analysis.
public static  voidmain(String args)
     Provides a simple (but sufficient) example of use.
public  voidparse()
     Calls the parse method inherited from DefaultDynamicElement.
public  voidparseDynElem(String elementName)
     This is a "key" method you call to append elements to the current value of a Dynamic Element. These elements are built from the template definition of this Dynamic Element and the current value of variables (and possibly nested Dynamic Elements).
public  voidrecordDynElem(String key, IDynamicElement value)
     Records a "Dynamic Element" in this "JDynamiTe" Document (Note: You do not need to directly call this method to use JDynamiTe).
public  voidsetAnalyser(ITemplateAnalyser templateAnalyser)
     Set the analyser that parses template documents (Note: You do not need to directly call this method to use JDynamiTe).
public  voidsetDynElemValue(String elementName, String value)
     Set an arbitrary value to a Dynamic Element.
public  voidsetInput(BufferedReader reader)
     Starts the analysis of the input template document.
public  voidsetInput(InputStream istream)
     Starts the analysis of the input template document.
public  voidsetInput(String fileName)
     Starts the analysis of the input template document.
public  voidsetVariable(String key, String value)
     Set the value of a variable.
public  StringtoString()
     Returns the value (after parsing) of this JDynamiTe document.


Constructor Detail
JDynamiTe
public JDynamiTe()(Code)
Constructs an empty "JDynamiTe" (Java Dynamic Template) document.



JDynamiTe
public JDynamiTe(String name)(Code)
Constructs an empty "JDynamiTe" (Java Dynamic Template) document.
Parameters:
  name - The name of this "JDynamiTe" document, used for debugging purposes by the"getTemplateDefinition" method.




Method Detail
clearAll
public void clearAll()(Code)
Reset all Variables and all Dynamic Element values.



clearAllDynElemValues
public void clearAllDynElemValues()(Code)
Reset all Dynamic Element values.



clearAllVariables
public void clearAllVariables()(Code)
Reset all Variables.



getAnalyser
public ITemplateAnalyser getAnalyser()(Code)
Returns the analyser that parses template documents (Note: You do not need to directly call this method to use JDynamiTe). The current analyser.
See Also:    setAnalyser(cb.jdynamite.analyser.ITemplateAnalyser)



getDynElem
public IDynamicElement getDynElem(String key)(Code)
Returns the "Dynamic Element" identified by a string (Note: You do not need to directly call this method to use JDynamiTe). A "JDynamiTe" document maintains a list of "Dynamic Elements".
Parameters:
  key - The "Dynamic Element" identifier. This is the string defined in thetemplate document in the "BEGIN DYNAMIC" tag. For example:
<-- BEGIN DYNAMIC : myList -->
Here "myList" identifies the Dynamic Element which begins. The interface of the Dynamic Element.



getTemplateDefinition
public String getTemplateDefinition()(Code)
For debugging purposes : get the result (structure of the template document) of the analyser parsing. Result (structure of the template document) of the analyser parsing.



getVariable
public String getVariable(String key)(Code)
Returns the value of a variable that was set by setVariable. A "JDynamiTe" document maintains a list of key/value pairs, which is used when Dynamic Elements are parsed.
Parameters:
  key - The key of the variable to retrieve. The value of the variable.
See Also:    setVariable(java.lang.String, java.lang.String)



getVariableKeys
public Enumeration getVariableKeys()(Code)
Returns an enumeration of the template Variable keys in this JDynamiTe document. A "JDynamiTe" document maintains a list of key/value pairs, which is used when Dynamic Elements are parsed. The setInput method build this list (with an empty string as default value) during the template document analysis. After this step, the setVariable method is used to set a value to a Variable. Example of use :
 Enumeration keys = myJDynamiTeDoc.getVariableKeys();
 while (keys.hasMoreElements()) {
 String key = keys.nextElement();
 System.err.println(keys);
 String value = myDatabase.selectValue(key); // get the current value somewhere...
 myJDynamiTeDoc.setVariable(key, value); // set the template Variable.
 }
 
The value of the variable.
See Also:    setVariable(java.lang.String, java.lang.String)
See Also:    setInput(InputStream istream)
See Also:    setInput(String fileName)
since:
   JDynamiTe 1.2



main
public static void main(String args)(Code)
Provides a simple (but sufficient) example of use. Needs "testTemplate.html" in current directory as a template file. Writes the result on standard output.



parse
public void parse()(Code)
Calls the parse method inherited from DefaultDynamicElement. As this object is the "top level" dynamic element, this method enables obtaining the "final" value of this document. You can use the "toString" method to get this value.
See Also:    toString()



parseDynElem
public void parseDynElem(String elementName)(Code)
This is a "key" method you call to append elements to the current value of a Dynamic Element. These elements are built from the template definition of this Dynamic Element and the current value of variables (and possibly nested Dynamic Elements). See examples.
Parameters:
  elementName - The "Dynamic Element" identifier. This is the string definedin the template document in the "BEGIN DYNAMIC" tag. For example:
<-- BEGIN DYNAMIC : myList -->
Here "myList" identifies the Dynamic Element that begins.



recordDynElem
public void recordDynElem(String key, IDynamicElement value)(Code)
Records a "Dynamic Element" in this "JDynamiTe" Document (Note: You do not need to directly call this method to use JDynamiTe). A "JDynamiTe" document maintains a list of "Dynamic Elements". It is called by the analyser.
Parameters:
  key - The "Dynamic Element" identifier.
Parameters:
  value - An object that implements the IDynamicElement interface.



setAnalyser
public void setAnalyser(ITemplateAnalyser templateAnalyser)(Code)
Set the analyser that parses template documents (Note: You do not need to directly call this method to use JDynamiTe).
Parameters:
  templateAnalyser - The new analyser.
See Also:    getAnalyser()



setDynElemValue
public void setDynElemValue(String elementName, String value)(Code)
Set an arbitrary value to a Dynamic Element. For example, enables emptying a Dynamic Element if you give an empty string as argument.
Parameters:
  elementName - The Dynamic Element identifier.
Parameters:
  value - New value for The Dynamic Element



setInput
public void setInput(BufferedReader reader) throws IOException(Code)
Starts the analysis of the input template document. If no custom "ITemplateAnalyser" was defined, JDynamiTe uses the "DefaultAnalyser". After this step, all the Variables and Dynamic Elements are identified, so this JDynamiTe is ready to be developed. By default all Variables are set to an empty string value. In addition, Variable identifiers (keys) can be retreived by getVariablesKeys.
Parameters:
  reader - A BufferedReader to read the input template document.
exception:
  java.io.IOException - If an I/O error occurs.
See Also:    setInput(java.io.InputStream)
See Also:    setInput(java.lang.String)
See Also:   cb.jdynamite.analyser.DefaultAnalyser
See Also:    setAnalyser(ITemplateAnalyser templateAnalyser)
since:
   JDynamyTe 1.2



setInput
public void setInput(InputStream istream) throws IOException(Code)
Starts the analysis of the input template document. If no custom "ITemplateAnalyser" was defined, JDynamiTe uses the "DefaultAnalyser". After this step, all the Variables and Dynamic Elements are identified, so this JDynamiTe is ready to be developed. By default all Variables are set to an empty string value. In addition, Variable identifiers (keys) can be retreived by getVariablesKeys.
Parameters:
  istream - A stream to read the input template document.
exception:
  java.io.IOException - If an I/O error occurs.
See Also:    setInput(java.io.BufferedReader)
See Also:    setInput(java.lang.String)
See Also:   cb.jdynamite.analyser.DefaultAnalyser
See Also:    setAnalyser(ITemplateAnalyser templateAnalyser)



setInput
public void setInput(String fileName) throws IOException, FileNotFoundException(Code)
Starts the analysis of the input template document. If no custom "ITemplateAnalyser" was defined, JDynamiTe uses the "DefaultAnalyser". After this step, all the Variables and Dynamic Elements are identified, so this JDynamiTe is ready to be developed. By default all Variables are set to an empty string value. In addition, Variable identifiers (keys) can be retreived by getVariablesKeys.
Parameters:
  fileName - The name of the file which contains the input template document.
exception:
  java.io.IOException - If an I/O error occurs.
exception:
  java.io.FileNotFoundException - Bad filename.
See Also:    setInput(java.io.BufferedReader)
See Also:    setInput(java.io.InputStream)
See Also:   cb.jdynamite.analyser.DefaultAnalyser
See Also:    setAnalyser(ITemplateAnalyser templateAnalyser)



setVariable
public void setVariable(String key, String value)(Code)
Set the value of a variable. Overrides its previous value if any. A "JDynamiTe" document maintains a list of key/value pairs, which is used when Dynamic Elements are parsed.
Parameters:
  key - The key of the variable to set.
Parameters:
  value - The new value of this variable.
See Also:    getVariable(java.lang.String)



toString
public String toString()(Code)
Returns the value (after parsing) of this JDynamiTe document. Value (after parsing) of this JDynamiTe document



Methods inherited from cb.jdynamite.analyser.DefaultDynamicElement
public void addElement(ITemplateElement templateElement)(Code)(Java Doc)
public String getDefinition(int depth)(Code)(Java Doc)
public String getValue(ITemplateDocument rootDocument)(Code)(Java Doc)
public void parse(ITemplateDocument rootDocument)(Code)(Java Doc)
public void setValue(String arbitraryValue)(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.