Java Doc for Parser.java in  » EJB-Server-resin-3.1.5 » ecmascript » com » caucho » es » parser » 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 » EJB Server resin 3.1.5 » ecmascript » com.caucho.es.parser 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.caucho.es.parser.Parser

Parser
public class Parser (Code)
Parser is a factory for generating compiled Script objects.

Most applications will use the parse(String) interface to parse JavaScript. That method will try to load a precompiled script from the work directory before trying to parse it.

Applications will often set the script path a directory for script and include the classpath in the path. Applications will often override the work dir for a more appropriate work directory.

 package com.caucho.vfs.*;
 package com.caucho.es.*;
 ...
 com.caucho.es.parser.Parser parser;
 parser = new com.caucho.es.parser.Parser();
 // configure the path to search for *.js files
 MergePath scriptPath = new MergePath();
 scriptPath.addMergePath(Vfs.lookup("/home/ferg/js"));
 ClassLoader loader = Thread.currentThread().contextClassLoader();
 scriptPath.addClassPath(loader);
 parser.setScriptPath(scriptPath);
 // configure the directory storing compiled scripts
 Path workPath = Vfs.lookup("/tmp/caucho/work");
 parser.setWorkDir(workPath);
 Script script = parser.parse("test.js");
 


Field Summary
static  ESIdANONYMOUS
    
static  ESIdARRAY
    
static  ESIdBOGUS
    
static  ESIdCAUCHO
    
static  ESIdCLINIT
    
static  ESIdCOM
    
static  ESIdFINALLY
    
static  ESIdJAVA
    
static  ESIdLENGTH
    
static  ESIdOBJECT
    
static  ESIdPACKAGES
    
final static  intPREC_AND
    
final static  intPREC_ASSIGN
    
final static  intPREC_BITAND
    
final static  intPREC_BITOR
    
final static  intPREC_BITXOR
    
final static  intPREC_CMP
    
final static  intPREC_COMMA
    
final static  intPREC_COND
    
final static  intPREC_DOT
    
final static  intPREC_EQ
    
final static  intPREC_FUN
    
final static  intPREC_MAX
    
final static  intPREC_OR
    
final static  intPREC_PLUS
    
final static  intPREC_POST
    
final static  intPREC_SHIFT
    
final static  intPREC_TIMES
    
final static  intPREC_UMINUS
    
static  ESIdPROTOTYPE
    
static  ESIdREGEXP
    
 Blockblock
    
 StringclassName
    
 Functionfunction
    
 FunctionglobalFunction
    
 IntArrayhashes
    
 ArrayListimportList
    
 booleanisEval
    
 booleanisFast
    
 Lexerlexer
    
 LineMaplineMap
    
 ClassLoaderloader
    
 ClassLoaderparentLoader
    
 ParseClassparseClass
    
 PathscriptPath
    
 FunctionstaticFunction
    
 PathworkPath
    

Constructor Summary
public  Parser()
    

Method Summary
public  voidaddImport(String name)
     Adds a package/script to be automatically imported by the script.
 ESExceptionerror(String text)
     Creates an error message with the given text.
 ClassLoadergetClassLoader()
     Returns the current class loader.
public  StringgetFilename()
     Returns the current filename being parsed.
public  PathgetScriptPath()
     Returns the path to search for imported javascript.
public  PathgetWorkDir()
     Returns the directory for generated *.java and *.class files.
public  Scriptparse(String name)
     Main application parsing method.
public  Scriptparse(ReadStream is)
     Alternative parsing method when the application only has an open stream to the file.
public  Scriptparse(ReadStream is, String name, int line)
     An alternative parsing method given an open stream, a filename and a line number.
Parameters:
  is - a stream to the javascript source.
Parameters:
  name - filename to use for error messages.
Parameters:
  line - initial line number.
public  ScriptparseEval(ReadStream is, String name, int line)
     Parses a script for the JavaScript "eval" expression.
public  voidsetClassLoader(ClassLoader loader)
     Internal method to set the actual class loader.
public  voidsetClassName(String name)
     Sets the name of the generated java class.
public  voidsetFast(boolean isFast)
     Sets "fast" mode, i.e.
public  voidsetLineMap(LineMap lineMap)
     Sets a line number map.
public  voidsetParentLoader(ClassLoader parentLoader)
     Sets the parent class loader.
public  voidsetScriptPath(Path scriptPath)
     Sets the path to search for imported javascript source files. Normally, ScriptPath will be a MergePath.
public  voidsetWorkDir(Path path)
     Sets the directory for generated *.java and *.class files. The parser will check this directory for any precompiled javascript classes.

Field Detail
ANONYMOUS
static ESId ANONYMOUS(Code)



ARRAY
static ESId ARRAY(Code)



BOGUS
static ESId BOGUS(Code)



CAUCHO
static ESId CAUCHO(Code)



CLINIT
static ESId CLINIT(Code)



COM
static ESId COM(Code)



FINALLY
static ESId FINALLY(Code)



JAVA
static ESId JAVA(Code)



LENGTH
static ESId LENGTH(Code)



OBJECT
static ESId OBJECT(Code)



PACKAGES
static ESId PACKAGES(Code)



PREC_AND
final static int PREC_AND(Code)



PREC_ASSIGN
final static int PREC_ASSIGN(Code)



PREC_BITAND
final static int PREC_BITAND(Code)



PREC_BITOR
final static int PREC_BITOR(Code)



PREC_BITXOR
final static int PREC_BITXOR(Code)



PREC_CMP
final static int PREC_CMP(Code)



PREC_COMMA
final static int PREC_COMMA(Code)



PREC_COND
final static int PREC_COND(Code)



PREC_DOT
final static int PREC_DOT(Code)



PREC_EQ
final static int PREC_EQ(Code)



PREC_FUN
final static int PREC_FUN(Code)



PREC_MAX
final static int PREC_MAX(Code)



PREC_OR
final static int PREC_OR(Code)



PREC_PLUS
final static int PREC_PLUS(Code)



PREC_POST
final static int PREC_POST(Code)



PREC_SHIFT
final static int PREC_SHIFT(Code)



PREC_TIMES
final static int PREC_TIMES(Code)



PREC_UMINUS
final static int PREC_UMINUS(Code)



PROTOTYPE
static ESId PROTOTYPE(Code)



REGEXP
static ESId REGEXP(Code)



block
Block block(Code)



className
String className(Code)



function
Function function(Code)



globalFunction
Function globalFunction(Code)



hashes
IntArray hashes(Code)



importList
ArrayList importList(Code)



isEval
boolean isEval(Code)



isFast
boolean isFast(Code)



lexer
Lexer lexer(Code)



lineMap
LineMap lineMap(Code)



loader
ClassLoader loader(Code)



parentLoader
ClassLoader parentLoader(Code)



parseClass
ParseClass parseClass(Code)



scriptPath
Path scriptPath(Code)



staticFunction
Function staticFunction(Code)



workPath
Path workPath(Code)




Constructor Detail
Parser
public Parser()(Code)




Method Detail
addImport
public void addImport(String name)(Code)
Adds a package/script to be automatically imported by the script. Each import is the equivalent of adding the following javascript:
 package name;
 

Parameters:
  name - package or script name to be automatically imported.



error
ESException error(String text)(Code)
Creates an error message with the given text.



getClassLoader
ClassLoader getClassLoader()(Code)
Returns the current class loader. If null, creates from the parent loader and the work-dir.



getFilename
public String getFilename()(Code)
Returns the current filename being parsed.



getScriptPath
public Path getScriptPath()(Code)
Returns the path to search for imported javascript. Normally, scriptPath will be a MergePath.
Parameters:
  scriptPath - path to search for imported scripts.



getWorkDir
public Path getWorkDir()(Code)
Returns the directory for generated *.java and *.class files.



parse
public Script parse(String name) throws ESException, IOException(Code)
Main application parsing method. The parser will try to load the compiled script. If the compiled script exists and the source file has not changed, parse will return the old script. Otherwise, it will parse and compile the javascript.
Parameters:
  name - the name of the javascript source. the parsed script



parse
public Script parse(ReadStream is) throws ESException, IOException(Code)
Alternative parsing method when the application only has an open stream to the file. Since this method will always compile a new script, it can be significantly slower than the parse(String) method.
Parameters:
  is - a read stream to the javascript source. the parsed script.



parse
public Script parse(ReadStream is, String name, int line) throws ESException, IOException(Code)
An alternative parsing method given an open stream, a filename and a line number.
Parameters:
  is - a stream to the javascript source.
Parameters:
  name - filename to use for error messages.
Parameters:
  line - initial line number. the compiled script



parseEval
public Script parseEval(ReadStream is, String name, int line) throws ESException, IOException(Code)
Parses a script for the JavaScript "eval" expression. The semantics for "eval" are slightly different from standard scripts.
Parameters:
  is - stream to the eval source.
Parameters:
  name - filename to use for error messages
Parameters:
  line - initial line number to use for error messages. the compiled script.



setClassLoader
public void setClassLoader(ClassLoader loader)(Code)
Internal method to set the actual class loader. Normally, this should only be called from com.caucho.es functions.



setClassName
public void setClassName(String name)(Code)
Sets the name of the generated java class. If unset, the parser will mangle the input name.



setFast
public void setFast(boolean isFast)(Code)
Sets "fast" mode, i.e. JavaScript 2.0. Fast mode lets the compiler make assumptions about types and classes, e.g. that class methods won't change dynamically. This lets the compiler generate more code that directly translates to Java calls.



setLineMap
public void setLineMap(LineMap lineMap)(Code)
Sets a line number map. For generated files like JSP or XTP, the error messages need an extra translation to get to the original line numbers.



setParentLoader
public void setParentLoader(ClassLoader parentLoader)(Code)
Sets the parent class loader. If unspecified, defaults to the context classloader. Most applications will just use the default.
Parameters:
  parentLoader - the classloader to be used for the script's parent.



setScriptPath
public void setScriptPath(Path scriptPath)(Code)
Sets the path to search for imported javascript source files. Normally, ScriptPath will be a MergePath. If the MergePath adds the classpath, then JavaScript files can be put in the normal Java classpath.

If the ScriptPath is not specified, it will use the current directory and the classpath from the context class loader.

 MergePath scriptPath = new MergePath();
 scriptPath.addMergePath(Vfs.lookup("/home/ferg/js"));
 ClassLoader loader = Thread.currentThread().contextClassLoader();
 scriptPath.addClassPath(loader);
 parser.setScriptPath(scriptPath);
 

Parameters:
  scriptPath - path to search for imported scripts.



setWorkDir
public void setWorkDir(Path path)(Code)
Sets the directory for generated *.java and *.class files. The parser will check this directory for any precompiled javascript classes. The default work-dir is /tmp/caucho on unix and c:\temp\caucho on windows.
Parameters:
  path - the work directory.



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.