Java Doc for ScriptUtil.java in  » Ajax » ItsNat » org » itsnat » core » script » 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 » Ajax » ItsNat » org.itsnat.core.script 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.itsnat.core.script.ScriptUtil

All known Subclasses:   org.itsnat.impl.core.js.JScriptUtilImpl,
ScriptUtil
public interface ScriptUtil (Code)
Utility interface to generate JavaScript code mainly to bridge server DOM nodes with client nodes.

When a DOM node is used a parameter this must be part of the document tree (server and client) otherwise an exception is thrown, and the generated code MUST be sent to the client normally calling org.itsnat.core.ItsNatDocument.addCodeToSend(Object) because this node may have been automatically cached at the server, the generated code contains the order and information to cache at the client too, otherwise the server and client caches are unsynchronized (if localization cache is disabled this issue does not apply).


author:
   Jose Maria Arranz Santamaria




Method Summary
public  ScriptExprcreateScriptExpr(Object value)
     Creates a new script expression object wrapping the specified object.
public  StringencodeURIComponent(String text)
     Is a Java implementation of the JavaScript encodeURIComponent function.
public  StringencodeURIComponent(char c)
     Is a Java implementation of the JavaScript encodeURIComponent function applied to a Java char.
public  StringgetCallMethodCode(Object obj, String methodName, Object[] params, boolean endSentence)
     Generates the appropriated code to call the specified object method at the client.
Parameters:
  obj - the object reference, converted to JavaScript calling ScriptUtil.toScript(Object).
Parameters:
  methodName - method name.
Parameters:
  params - the parameter list.
public  StringgetCallMethodCode(Object obj, String methodName, Object[] params)
     Generates the appropriated code to call the specified object method at the client.
Parameters:
  obj - the object reference, converted to JavaScript calling ScriptUtil.toScript(Object).
Parameters:
  methodName - method name.
Parameters:
  params - the parameter list.
public  StringgetGetPropertyCode(Object obj, String propName, boolean endSentence)
     Generates the JavaScript code to get the value of the specified property.
Parameters:
  obj - the object reference, converted to JavaScript calling ScriptUtil.toScript(Object).
public  StringgetGetPropertyCode(Object obj, String propName)
     Generates the JavaScript code to get the value of the specified property.
Parameters:
  obj - the object reference, converted to JavaScript calling ScriptUtil.toScript(Object).
public  StringgetNodeReference(Node node)
     Generates the appropriated code to locate the specified DOM node at the client.

Returned code may be considered as a JavaScript reference to the specified node.

The following example generates JavaScript to set 'City' to the "value" property of the specified DOM node:

 String code = itsNatDoc.getScriptUtil().getNodeReference(aNode) + ".value = 'City';";
 itsNatDoc.addCodeToSend(code);
 

Parameters:
  node - the node to generate a JavaScript reference.
public  StringgetSetPropertyCode(Object obj, String propName, Object value, boolean endSentence)
     Generates the JavaScript code to set a value to the specified property.
Parameters:
  obj - the object reference, converted to JavaScript calling ScriptUtil.toScript(Object).
public  StringgetSetPropertyCode(Object obj, String propName, Object value)
     Generates the JavaScript code to set a value to the specified property.
Parameters:
  obj - the object reference, converted to JavaScript calling ScriptUtil.toScript(Object).
public  StringgetTransportableCharLiteral(char c)
     Converts the specified Java String to a JavaScript string literal, this string can be send to the client.

Any special character like end of lines, tabs, " , ' , \ etc are escaped to sent to the client as a JavaScript string literal.


Parameters:
  c - the Java char to convert.
public  StringgetTransportableStringLiteral(String text)
     Converts the specified Java String to a JavaScript string literal, this string can be send to the client.

Any special character like end of lines, tabs, " , ' , \ etc are escaped to sent to the client as a JavaScript string literal.


Parameters:
  text - the String to convert.
public  StringtoScript(Object value)
     Converts the specified object value to JavaScript code.

Conversion rules if value is a:


Parameters:
  value - the object to convert to JavaScript.



Method Detail
createScriptExpr
public ScriptExpr createScriptExpr(Object value)(Code)
Creates a new script expression object wrapping the specified object. a new script expression object.



encodeURIComponent
public String encodeURIComponent(String text)(Code)
Is a Java implementation of the JavaScript encodeURIComponent function. The string encoded with this method can be unencoded using the JavaScript decodeURIComponent function.

This method is an alternative (slower and bigger) to ScriptUtil.getTransportableStringLiteral(String) to transport texts to the client.

The encoded Java String is not a string literal. The following example encloses the String as a literal:

String code = "\"" + encodeURIComponent(someText) + "\"";


Parameters:
  text - the Java String to encode. the encoded text.



encodeURIComponent
public String encodeURIComponent(char c)(Code)
Is a Java implementation of the JavaScript encodeURIComponent function applied to a Java char.

This method is an alternative (slower and bigger) to ScriptUtil.getTransportableCharLiteral(char) to transport characters to the client.

The encoded Java char is not a char literal. The following example encloses the char as a literal:

String code = "'" + encodeURIComponent(someChar) + "'";


Parameters:
  c - the Java char to encode. the encoded char.



getCallMethodCode
public String getCallMethodCode(Object obj, String methodName, Object[] params, boolean endSentence)(Code)
Generates the appropriated code to call the specified object method at the client.
Parameters:
  obj - the object reference, converted to JavaScript calling ScriptUtil.toScript(Object).
Parameters:
  methodName - method name.
Parameters:
  params - the parameter list. Are converted to JavaScript calling ScriptUtil.toScript(Object).
Parameters:
  endSentence - if true adds a ; at the end. the JavaScript code.



getCallMethodCode
public String getCallMethodCode(Object obj, String methodName, Object[] params)(Code)
Generates the appropriated code to call the specified object method at the client.
Parameters:
  obj - the object reference, converted to JavaScript calling ScriptUtil.toScript(Object).
Parameters:
  methodName - method name.
Parameters:
  params - the parameter list. Are converted to JavaScript calling ScriptUtil.toScript(Object). the JavaScript code.



getGetPropertyCode
public String getGetPropertyCode(Object obj, String propName, boolean endSentence)(Code)
Generates the JavaScript code to get the value of the specified property.
Parameters:
  obj - the object reference, converted to JavaScript calling ScriptUtil.toScript(Object).
Parameters:
  propName - property name.
Parameters:
  endSentence - if true adds a ; at the end. the JavaScript code.



getGetPropertyCode
public String getGetPropertyCode(Object obj, String propName)(Code)
Generates the JavaScript code to get the value of the specified property.
Parameters:
  obj - the object reference, converted to JavaScript calling ScriptUtil.toScript(Object).
Parameters:
  propName - property name. the JavaScript code.



getNodeReference
public String getNodeReference(Node node)(Code)
Generates the appropriated code to locate the specified DOM node at the client.

Returned code may be considered as a JavaScript reference to the specified node.

The following example generates JavaScript to set 'City' to the "value" property of the specified DOM node:

 String code = itsNatDoc.getScriptUtil().getNodeReference(aNode) + ".value = 'City';";
 itsNatDoc.addCodeToSend(code);
 

Parameters:
  node - the node to generate a JavaScript reference. the JavaScript reference to send to the client.



getSetPropertyCode
public String getSetPropertyCode(Object obj, String propName, Object value, boolean endSentence)(Code)
Generates the JavaScript code to set a value to the specified property.
Parameters:
  obj - the object reference, converted to JavaScript calling ScriptUtil.toScript(Object).
Parameters:
  propName - property name.
Parameters:
  value - the value to set. Is converted to JavaScript calling ScriptUtil.toScript(Object).
Parameters:
  endSentence - if true adds a ; at the end. the JavaScript code.



getSetPropertyCode
public String getSetPropertyCode(Object obj, String propName, Object value)(Code)
Generates the JavaScript code to set a value to the specified property.
Parameters:
  obj - the object reference, converted to JavaScript calling ScriptUtil.toScript(Object).
Parameters:
  propName - property name.
Parameters:
  value - the value to set. Is converted to JavaScript calling ScriptUtil.toScript(Object). the JavaScript code.



getTransportableCharLiteral
public String getTransportableCharLiteral(char c)(Code)
Converts the specified Java String to a JavaScript string literal, this string can be send to the client.

Any special character like end of lines, tabs, " , ' , \ etc are escaped to sent to the client as a JavaScript string literal.


Parameters:
  c - the Java char to convert. the resulting JavaScript string literal.



getTransportableStringLiteral
public String getTransportableStringLiteral(String text)(Code)
Converts the specified Java String to a JavaScript string literal, this string can be send to the client.

Any special character like end of lines, tabs, " , ' , \ etc are escaped to sent to the client as a JavaScript string literal.


Parameters:
  text - the String to convert. the resulting JavaScript string literal.



toScript
public String toScript(Object value)(Code)
Converts the specified object value to JavaScript code.

Conversion rules if value is a:


Parameters:
  value - the object to convert to JavaScript. the JavaScript code.



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