Java Doc for Pnuts.java in  » Scripting » Pnuts » pnuts » lang » 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 » Scripting » Pnuts » pnuts.lang 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   pnuts.lang.Pnuts

All known Subclasses:   pnuts.compiler.CompiledScript,  pnuts.ext.CachedScript,
Pnuts
public class Pnuts implements Executable,Serializable(Code)
This class provides a set of static methods to parse/execute scripts.

This object also represents a parsed script.

This class is serializable. When a Pnuts object is serialized, the syntax tree is written to the object stream, along with the attributes such as line, column, and script source.

When the object is deserialized, the parsed script is restored using the information read from the object stream. If the script had been compiled, the script should be recompiled.

Serialized objects of this class will not be compatible with future releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing.



Field Summary
static  StringcompiledClassPrefix
    
static  PropertiesdefaultSettings
    
final public static  Stringpnuts_version
    
public static  Stringprompt
    
protected  ObjectscriptSource
     The script source, from where the script came.
final static  longserialVersionUID
    
protected  SimpleNodestartNodes
    

Constructor Summary
protected  Pnuts()
    

Method Summary
public  Objectaccept(Visitor visitor, Context context)
    
protected  Objectaccept(Context context)
    
public static  ClassLoadercreateClassLoader(Context context)
    
public static  ClassLoadercreateClassLoader(Context context, ClassLoader parent)
    
static  intenter(Context context)
     all public entry points must go through this to ensure the correct behavior of evalDepth method.
Parameters:
  context - the context in which the execution is taken place.
public static  Objecteval(String expr, Context context)
    
public static  intevalDepth(Context context)
     Get the depth of evaluation.
public static  Stringformat(Object obj)
     Returns the string representation of an object.
public static  Objectget(String str)
    
public static  Objectget(String str, String pkg)
     Gets a global variable.
static  StringgetCompiledClassPrefix()
    
public static  PropertiesgetDefaults()
     Gets the properties previously set by setDefaults() method.
static  PnutsParsergetParser(Reader reader)
    
final public static  URLgetResource(String s, Context context)
     Get the resource URL.
public  ObjectgetScriptSource()
    
final public static  booleanisJava2()
     Checks if the runtime environment supports J2SE.
public static  booleanisVerbose()
    
public static  Objectload(String name, Context context)
    
public static  Objectload(URL url, Context context)
     Loads a script specifed as a URL.
public static  Objectload(InputStream in, Context context)
    
public static  Objectload(InputStream in, boolean interactive, Context context)
     Load a script from an InputStream in the specified Context.
Parameters:
  in - an InputStream from which the interpreter reads an input
Parameters:
  interactive -
  • When "interactive" is true, the greeting message, theprompt, and the results of evaluations are displayed.
public static  Objectload(Reader reader, Context context)
    
public static  Objectload(Reader reader, boolean interactive, Context context)
    
final public static  ClassloadClass(String name, Context context)
     Loads the class by the following order.
  1. A class loader associated with Pnuts context.
  2. The class loader associated with the current Thread (J2SE).
  3. The class loader by which Pnuts classes are loaded.

Parameters:
  name - the class name to be loaded
Parameters:
  context - the context in which the class is loaded the loaded class.
public static  ObjectloadFile(String file, Context context)
    
public static  Pnutsparse(InputStream in)
    
public static  Pnutsparse(Reader reader)
    
public static  Pnutsparse(Reader reader, ParseEnvironment env)
    
public static  Pnutsparse(Reader reader, Object scriptSource, Context context)
    
public static  Pnutsparse(Reader reader, Object scriptSource, Context context, ParseEnvironment env)
    
public static  Pnutsparse(String expr)
    
static  voidrecycleParser(PnutsParser parser)
    
public static  voidrequire(String file, Context context)
     Loads a script "file" only if the script has not been read.
public static  voidrequire(String file, Context context, boolean checkForUpdate)
    
public  Objectrun(Context context)
    
static  Objectsession(Reader r, Context context)
    
public static  voidset(String str, Object val)
    
public static  voidset(String str, Object val, String pkg)
    
public static  voidsetDefaults(Properties properties)
     Sets properties that affect the behavior of Pnuts interpreter/compiler.
public static  voidsetPrompt(String str)
    
public  voidsetScriptSource(Object src)
     Associates a script source with this parsed (compiled) expression.
public static  voidsetVerbose(boolean b)
    
public  Stringunparse()
    
public  voidunparse(Writer writer)
     Obtain the script code from a parsed object and write it to the specified Writer.

Field Detail
compiledClassPrefix
static String compiledClassPrefix(Code)



defaultSettings
static Properties defaultSettings(Code)



pnuts_version
final public static String pnuts_version(Code)
The version number



prompt
public static String prompt(Code)
"prompt" string for the command shell



scriptSource
protected Object scriptSource(Code)
The script source, from where the script came. It is usually a URL object, but not limitted to. If this variable is not null, error message would include the positional information such as the line number and the file name.



serialVersionUID
final static long serialVersionUID(Code)



startNodes
protected SimpleNode startNodes(Code)
Parsed scripts




Constructor Detail
Pnuts
protected Pnuts()(Code)




Method Detail
accept
public Object accept(Visitor visitor, Context context)(Code)
traverse the parsed tree with the specified Visitor and Context
Parameters:
  context - the Context the result
since:
   Pnuts 1.0beta3



accept
protected Object accept(Context context)(Code)
Executes the parsed script
Parameters:
  context - the context in which the script is executed the result



createClassLoader
public static ClassLoader createClassLoader(Context context)(Code)
Create a classloader that can compile scripted classes with the current thread's context classloader as its parent classloader
Parameters:
  context - the context in which scripts are compiled the classloader



createClassLoader
public static ClassLoader createClassLoader(Context context, ClassLoader parent)(Code)
Create a classloader that can compile scripted classes
Parameters:
  context - the context in which scripts are compiled
Parameters:
  parent - the parent classloader the classloader



enter
static int enter(Context context)(Code)
all public entry points must go through this to ensure the correct behavior of evalDepth method.
Parameters:
  context - the context in which the execution is taken place. the last value of context.depth.



eval
public static Object eval(String expr, Context context)(Code)
Evaluates "str" in "context"
Parameters:
  expr - the expression to be evaluated
Parameters:
  context - the context in which the expression is evaluated the result of the evaluation



evalDepth
public static int evalDepth(Context context)(Code)
Get the depth of evaluation. This value increases when load(), loadFile(), or eval() is called.
Parameters:
  context - the context of the evaluation.



format
public static String format(Object obj)(Code)
Returns the string representation of an object. When the object is a number, a character, a boolean, or a string, it can be reconstructed by eval() function.
Parameters:
  obj - the object. the string representation of the object



get
public static Object get(String str)(Code)
Get the value of a global variable
Parameters:
  str - the name of the global variable the value of the global variable str



get
public static Object get(String str, String pkg)(Code)
Gets a global variable.
Parameters:
  str - the name of the variable
Parameters:
  pkg - the package where the variable is defined the value of a variable "str" in the package "pkg"



getCompiledClassPrefix
static String getCompiledClassPrefix()(Code)



getDefaults
public static Properties getDefaults()(Code)
Gets the properties previously set by setDefaults() method. the default setting that affects the behavior of Pnutsinterpreter/compiler.



getParser
static PnutsParser getParser(Reader reader)(Code)



getResource
final public static URL getResource(String s, Context context)(Code)
Get the resource URL.
Parameters:
  s - the resource name
Parameters:
  context - the context in which the resource is read



getScriptSource
public Object getScriptSource()(Code)
Gets the script source associated with this parsed (compiled) expression the script source to be associated with.



isJava2
final public static boolean isJava2()(Code)
Checks if the runtime environment supports J2SE. true if the runtime environment supports J2SE



isVerbose
public static boolean isVerbose()(Code)
Check the current verbose mode the current verbose mode



load
public static Object load(String name, Context context) throws FileNotFoundException(Code)
Loads a script "file" in "context"
Parameters:
  name - the name of the script to be loaded
Parameters:
  context - the context in which the script is loaded.



load
public static Object load(URL url, Context context)(Code)
Loads a script specifed as a URL.
Parameters:
  url - the URL
Parameters:
  context - the context in which the script is loaded.



load
public static Object load(InputStream in, Context context)(Code)
Loads a script from InputStream "in" in "context"
Parameters:
  in - the input stream from which the script can be read.
Parameters:
  context - the context in which the script is loaded.



load
public static Object load(InputStream in, boolean interactive, Context context)(Code)
Load a script from an InputStream in the specified Context.
Parameters:
  in - an InputStream from which the interpreter reads an input
Parameters:
  interactive -
  • When "interactive" is true, the greeting message, theprompt, and the results of evaluations are displayed. When anexception is thrown and not caught by any exception handler,it is caught at the top level of the interpreter, display anerror message, and resume the interactive session. If theexception is caught by a handler that is registered at the toplevel, the result of the handler becomes the return value ofthe last expression.
  • When "interactive" is false, exceptions are caught at the top levelof the interpreter and exits this function. If the exception thrown iscaught by a handler that is registered at the top level, the result ofthe handler becomes the return value of this method.

Parameters:
  context - a Context in which the interpretation is taken place. the result of the last expression



load
public static Object load(Reader reader, Context context)(Code)
This method loads a script
Parameters:
  reader - the Reader from which the script is loaded
Parameters:
  context - the context in which the script is loaded the result of the last expression



load
public static Object load(Reader reader, boolean interactive, Context context)(Code)
This method loads a script
Parameters:
  reader - the Reader from which the script is loaded
Parameters:
  interactive - specifies if the execution is in interactive mode.
Parameters:
  context - the context in which the script is loaded the result of the last expression



loadClass
final public static Class loadClass(String name, Context context) throws ClassNotFoundException(Code)
Loads the class by the following order.
  1. A class loader associated with Pnuts context.
  2. The class loader associated with the current Thread (J2SE).
  3. The class loader by which Pnuts classes are loaded.

Parameters:
  name - the class name to be loaded
Parameters:
  context - the context in which the class is loaded the loaded class. Note that it is not initialized.



loadFile
public static Object loadFile(String file, Context context) throws FileNotFoundException(Code)
Loads a local script "file" in "context"
Parameters:
  file - the script file to be loaded.
Parameters:
  context - the context in which the file is loaded.



parse
public static Pnuts parse(InputStream in) throws ParseException, IOException(Code)
Parses a script from InputStream and return a Pnuts object the Pnuts object including a parsed syntax tree
Parameters:
  in - the InputStream



parse
public static Pnuts parse(Reader reader) throws ParseException, IOException(Code)
parse a script from Reader and return a Pnuts object the Pnuts object including a parsed syntax tree
Parameters:
  reader - the Reader
since:
   Pnuts 1.0beta3



parse
public static Pnuts parse(Reader reader, ParseEnvironment env) throws ParseException, IOException(Code)
parse a script from Reader and return a Pnuts object



parse
public static Pnuts parse(Reader reader, Object scriptSource, Context context) throws IOException(Code)
parse a script from Reader and return a Pnuts object the Pnuts object including a parsed syntax tree
Parameters:
  reader - the Reader
Parameters:
  scriptSource - the script source



parse
public static Pnuts parse(Reader reader, Object scriptSource, Context context, ParseEnvironment env) throws IOException(Code)
parse a script from Reader and return a Pnuts object the Pnuts object including a parsed syntax tree
Parameters:
  reader - the Reader
Parameters:
  scriptSource - the script source
Parameters:
  env -



parse
public static Pnuts parse(String expr) throws ParseException(Code)
Parses a script and return a Pnuts object the Pnuts object including a parsed syntax tree
Parameters:
  expr - the script



recycleParser
static void recycleParser(PnutsParser parser)(Code)



require
public static void require(String file, Context context) throws FileNotFoundException(Code)
Loads a script "file" only if the script has not been read. It is guaranteed that the script runs at most once in this context.
Parameters:
  file - the script file, which must be an intern'ed String.
Parameters:
  context - the context in which the script is loaded



require
public static void require(String file, Context context, boolean checkForUpdate) throws FileNotFoundException(Code)



run
public Object run(Context context)(Code)
Executes a Pnuts object with the specified Context
Parameters:
  context - the Context the result



session
static Object session(Reader r, Context context)(Code)



set
public static void set(String str, Object val)(Code)
set a value "val" to a global variable "str"



set
public static void set(String str, Object val, String pkg)(Code)
Set a value "val" to a variable "str" in package "pkg"
Parameters:
  str -
Parameters:
  val -
Parameters:
  pkg -



setDefaults
public static void setDefaults(Properties properties)(Code)
Sets properties that affect the behavior of Pnuts interpreter/compiler. This method should be called before the classes that read the default settings, such as pnuts.lang.Configuration and pnuts.lang.PnutsImpl. Once those classes are loaded, this method call has no effect.
 Pnuts.setDefaults(properties);
 Context c = new Context(); // this line should not precede setDefaults() call.
 

Parameters:
  properties - the properties that override the system properties.



setPrompt
public static void setPrompt(String str)(Code)
Sets a "prompt" string for the command shell



setScriptSource
public void setScriptSource(Object src)(Code)
Associates a script source with this parsed (compiled) expression.
Parameters:
  src - the script source to be associated with.



setVerbose
public static void setVerbose(boolean b)(Code)
Sets the verbose mode



unparse
public String unparse()(Code)
Obtain the script code from a parsed object the script code



unparse
public void unparse(Writer writer) throws IOException(Code)
Obtain the script code from a parsed object and write it to the specified Writer.
Parameters:
  writer - the Writer to which the script code is written



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.