Java Doc for Parser.java in  » ERP-CRM-Financial » SourceTap-CRM » org » ofbiz » rules » parse » 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 » ERP CRM Financial » SourceTap CRM » org.ofbiz.rules.parse 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.ofbiz.rules.parse.Parser

All known Subclasses:   org.ofbiz.rules.parse.CollectionParser,  org.ofbiz.rules.parse.Terminal,  org.ofbiz.rules.parse.Empty,  org.ofbiz.rules.parse.Repetition,
Parser
abstract public class Parser (Code)
A Parser is an object that recognizes the elements of a language.

Each Parser object is either a Terminal or a composition of other parsers. The Terminal class is a subclass of Parser, and is itself a hierarchy of parsers that recognize specific patterns of text. For example, a Word recognizes any word, and a Literal matches a specific string.

In addition to Terminal, other subclasses of Parser provide composite parsers, describing sequences, alternations, and repetitions of other parsers. For example, the following Parser objects culminate in a good parser that recognizes a description of good coffee.

 Alternation adjective = new Alternation();
 adjective.add(new Literal("steaming"));
 adjective.add(new Literal("hot"));
 Sequence good = new Sequence();
 good.add(new Repetition(adjective));
 good.add(new Literal("coffee"));
 String s = "hot hot steaming hot coffee";
 Assembly a = new TokenAssembly(s);
 System.out.println(good.bestMatch(a));
 
This prints out:
 [hot, hot, steaming, hot, coffee]
 hot/hot/steaming/hot/coffee^
 
The parser does not match directly against a string, it matches against an Assembly. The resulting assembly shows its stack, with four words on it, along with its sequence of tokens, and the index at the end of these. In practice, parsers will do some work on an assembly, based on the text they recognize.
author:
   Steven J. Metsker
version:
   1.0


Field Summary
protected  Assemblerassembler
    
protected  Stringname
    

Constructor Summary
public  Parser()
     Constructs a nameless parser.
public  Parser(String name)
     Constructs a parser with the given name.
Parameters:
  name - A name to be known by.

Method Summary
public  voidaccept(ParserVisitor pv)
     Accepts a "visitor" which will perform some operation on a parser structure.
abstract public  voidaccept(ParserVisitor pv, List visited)
     Accepts a "visitor" along with a collection of previously visited parsers.
public static  voidadd(List v1, List v2)
     Adds the elements of one vector to another.
public  Assemblybest(List v)
     Returns the most-matched assembly in a collection.
public  AssemblybestMatch(Assembly a)
     Returns an assembly with the greatest possible number of elements consumed by matches of this parser.
public  AssemblycompleteMatch(Assembly a)
     Returns either null, or a completely matched version of the supplied assembly.
public static  ListelementClone(List v)
     Create a copy of a vector, cloning each element of the vector.
public  StringgetName()
     Returns the name of this parser.
abstract public  Listmatch(List in)
     Given a set (well, a List, really) of assemblies, this method matches this parser against all of them, and returns a new set (also really a List) of the assemblies that result from the matches.

For example, consider matching the regular expression a* against the string "aaab". The initial set of states is {^aaab}, where the ^ indicates how far along the assembly is.

public  ListmatchAndAssemble(List in)
     Match this parser against an input state, and then apply this parser's assembler against the resulting state.
abstract protected  ListrandomExpansion(int maxDepth, int depth)
     Create a random expansion for this parser, where a concatenation of the returned collection will be a language element.
public  StringrandomInput(int maxDepth, String separator)
     Return a random element of this parser's language.
public  ParsersetAssembler(Assembler assembler)
     Sets the object that will work on an assembly whenever this parser successfully matches against the assembly.
public  StringtoString()
     Returns a textual description of this parser.
protected  StringtoString(List visited)
     Returns a textual description of this parser. Parsers can be recursive, so when building a descriptive string, it is important to avoid infinite recursion by keeping track of the objects already described.
abstract protected  StringunvisitedString(List visited)
     Returns a textual description of this string.

Field Detail
assembler
protected Assembler assembler(Code)
an object that will work on an assembly whenever this parser successfully matches against the assembly



name
protected String name(Code)
a name to identify this parser




Constructor Detail
Parser
public Parser()(Code)
Constructs a nameless parser.



Parser
public Parser(String name)(Code)
Constructs a parser with the given name.
Parameters:
  name - A name to be known by. For parsersthat are deep composites, a simple nameidentifying its purpose is useful.




Method Detail
accept
public void accept(ParserVisitor pv)(Code)
Accepts a "visitor" which will perform some operation on a parser structure. The book, "Design Patterns", explains the visitor pattern.
Parameters:
  pv - the visitor to accept



accept
abstract public void accept(ParserVisitor pv, List visited)(Code)
Accepts a "visitor" along with a collection of previously visited parsers.
Parameters:
  pv - the visitor to accept
Parameters:
  visited - a collection of previously visitedparsers.



add
public static void add(List v1, List v2)(Code)
Adds the elements of one vector to another.
Parameters:
  v1 - the vector to add to
Parameters:
  v2 - the vector with elements to add



best
public Assembly best(List v)(Code)
Returns the most-matched assembly in a collection. the most-matched assembly in a collection.
Parameters:
  v - the collection to look through



bestMatch
public Assembly bestMatch(Assembly a)(Code)
Returns an assembly with the greatest possible number of elements consumed by matches of this parser. an assembly with the greatest possible number ofelements consumed by this parser
Parameters:
  a - an assembly to match against



completeMatch
public Assembly completeMatch(Assembly a)(Code)
Returns either null, or a completely matched version of the supplied assembly. either null, or a completely matched version of thesupplied assembly
Parameters:
  a - an assembly to match against



elementClone
public static List elementClone(List v)(Code)
Create a copy of a vector, cloning each element of the vector.
Parameters:
  in - the vector to copy a copy of the input vector, cloning eachelement of the vector



getName
public String getName()(Code)
Returns the name of this parser. the name of this parser



match
abstract public List match(List in)(Code)
Given a set (well, a List, really) of assemblies, this method matches this parser against all of them, and returns a new set (also really a List) of the assemblies that result from the matches.

For example, consider matching the regular expression a* against the string "aaab". The initial set of states is {^aaab}, where the ^ indicates how far along the assembly is. When a* matches against this initial state, it creates a new set {^aaab, a^aab, aa^ab, aaa^b}. a List of assemblies that result frommatching against a beginning set of assemblies
Parameters:
  in - a vector of assemblies to match against




matchAndAssemble
public List matchAndAssemble(List in)(Code)
Match this parser against an input state, and then apply this parser's assembler against the resulting state. a List of assemblies that result from matchingagainst a beginning set of assemblies
Parameters:
  in - a vector of assemblies to match against



randomExpansion
abstract protected List randomExpansion(int maxDepth, int depth)(Code)
Create a random expansion for this parser, where a concatenation of the returned collection will be a language element.



randomInput
public String randomInput(int maxDepth, String separator)(Code)
Return a random element of this parser's language. a random element of this parser's language



setAssembler
public Parser setAssembler(Assembler assembler)(Code)
Sets the object that will work on an assembly whenever this parser successfully matches against the assembly.
Parameters:
  Assembler - the assembler to apply Parser this



toString
public String toString()(Code)
Returns a textual description of this parser. String a textual description of thisparser, taking care to avoidinfinite recursion



toString
protected String toString(List visited)(Code)
Returns a textual description of this parser. Parsers can be recursive, so when building a descriptive string, it is important to avoid infinite recursion by keeping track of the objects already described. This method keeps an object from printing twice, and uses unvisitedString which subclasses must implement.
Parameters:
  visited - a list of objects already printed a textual version of this parser,avoiding recursion



unvisitedString
abstract protected String unvisitedString(List visited)(Code)
Returns a textual description of this string.



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.