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


java.lang.Object
   org.ofbiz.rules.engine.Structure

All known Subclasses:   org.ofbiz.rules.engine.ConsultingStructure,  org.ofbiz.rules.engine.Gateway,  org.ofbiz.rules.engine.ArithmeticOperator,  org.ofbiz.rules.engine.Fact,  org.ofbiz.rules.engine.Not,
Structure
public class Structure implements Term(Code)

Title: Structure

Description: None

Copyright (c) 1999 Steven J. Metsker.

Copyright (c) 2001 The Open For Business Project - www.ofbiz.org

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

A Structure is a functor associated with a number of terms; a functor can be any object. A term is an object that implements the Term interface, including structures and variables.

An example of a structure is:

 starred(jamesCagney, "Yankee Doodle Dandy", Year)
 
This structure has the String "starred" as its functor. This structure's first term is another structure that has "jamesCagney" as its functor and no terms of its own. Similarly, the second term is a structure with the functor "Yankee Doodle Dandy" and no terms of its own. The third term is a variable, Year.

This particular example has two elements that favor a parser: the quotes around the film title and the capitalization of the variable. When using Structure and Variable directly, you do not need the kinds of clues a parser needs. So, Yankee Doodle Dandy is just another string, whose internal blanks are not at all confusing. Further, a variable can have any string as its name, not necessarily capitalized.

You can create the starred example with

 Structure s = new Structure(
 "starred",
 new Term[]{
 new Structure("jamesCagney"),
 new Structure("Yankee Doodle Dandy"),
 new Variable("Year")});
 
To be able to prove itself against a program, a structure must appear in a Rule. Rules associate like-named variables in a "scope", which is essentially a dictionary. A rule makes an executable copy of itself by creating a new variable dictionary, and by making "consulting" copies of its structures.
author:
   Steven J. Metsker
version:
   1.0


Field Summary
final public static  EmptyListemptyList
    
protected  Objectfunctor
    
protected  Term[]terms
    

Constructor Summary
public  Structure(Object functor)
     Contructs a structure from the specified object.
public  Structure(Object functor, Term[] terms)
     Constructs a structure with the specified functor and terms.

Method Summary
public  intarity()
     Return the number of terms in this structure.
public  booleancanFindNextProof()
     Returns false.

Objects of this class, the superclass of all structures, should not appear in dynamic rules.

public  TermcopyForProof(AxiomSource as, Scope scope)
     Create a ConsultingStructure counterpart that can unify with other structures.
public  booleanequals(Object o)
     Returns true if the supplied object is an equivalent structure.
public  Objecteval()
     Return this structure, if it is nonatomic, or just the functor, if this is an atom.
public  booleanfunctorAndArityEquals(Structure s)
     Returns true if this structure's functor and number of terms match the supplied structure.
protected static  Term[]headAndTail(Term[] terms, Term tail)
     This method helps the static list factories. A list is a structure whose functor is "." and that has two terms.
public  booleanisList()
     Return true, if this structure is a list, which means it has an functor of ".", and has two terms, the second of which must be a list.
public static  Structurelist(Object[] objects)
     Constructs a list that contains the supplied object, wrapped as Facts.
public static  Structurelist(Term[] terms)
     Constructs a list from the given terms.

This constructor creates a list of two terms, regardless of the number of terms supplied here.

public static  Structurelist(Term[] terms, Term tail)
     Constructs a list that terminates with a known list, or a variable.

This allows construction of a list such as:

 Variable head = new Variable("Head");
 Variable tail = new Variable("Tail");
 Structure ht = Structure.list(new Term[] {head}, tail);
 
Term[] the leading terms of the list.
public  StringlistTailString()
     Returns a representation of this list as the inner part of some other list.
protected  StringlistTermsToString()
     Return a textual represenation of this list's terms, with a normal representation of the first term, and with the second term as the tail of a list.
public  Term[]terms()
     Return the terms of this structure.
public  StringtoString()
     Returns a string representation of this structure.
public  Unificationunify(Structure s)
     Unifies the terms in this structure with the terms in the given structure, and returns the variable bindings that result.

If two structures have equal functors and the same number of terms, they can unify if all of their terms unify.

public  Unificationunify(Term t)
     Unifies this structure with the supplied term.

This method dispatches the unify request to either a structure or a variable.

public  Unificationunify(Variable v)
     Unifies this structure with the supplied variable.

This method dispatches the unify request to the variable. Note that the variable may be instantiated to a structure that contains variables.

public  Unificationvariables()
     Returns the variables of the terms of this structure.

Note that a structure may contain variables or other structures as terms.


Field Detail
emptyList
final public static EmptyList emptyList(Code)
the empty list singleton



functor
protected Object functor(Code)



terms
protected Term[] terms(Code)




Constructor Detail
Structure
public Structure(Object functor)(Code)
Contructs a structure from the specified object.
Parameters:
  Object - the functor for this structure



Structure
public Structure(Object functor, Term[] terms)(Code)
Constructs a structure with the specified functor and terms.
Parameters:
  Object - the functor of the structure Term[] the terms of the structure, which may beeither variables or other structures




Method Detail
arity
public int arity()(Code)
Return the number of terms in this structure. the number of terms in this structure



canFindNextProof
public boolean canFindNextProof()(Code)
Returns false.

Objects of this class, the superclass of all structures, should not appear in dynamic rules. When a nondynamic rule creates its dynamic counterpart, it populates it with provable versions of its structures. A general Structure object will construct a ConsultingStructure when it participates in building a dynamic rule.

This particular method is almost never called. Subclasses implement more interesting behavior. false




copyForProof
public Term copyForProof(AxiomSource as, Scope scope)(Code)
Create a ConsultingStructure counterpart that can unify with other structures.
Parameters:
  AxiomSource - where to find axioms to proveagainst
Parameters:
  Scope - the scope to use for variables in theConsultingStructure a ConsultingStructure counterpart thatcan unify with other structures.



equals
public boolean equals(Object o)(Code)
Returns true if the supplied object is an equivalent structure.
Parameters:
  object - the object to compare true, if the supplied object's functor equalsthis structure's functor, and both structures'terms are all equal



eval
public Object eval()(Code)
Return this structure, if it is nonatomic, or just the functor, if this is an atom.



functorAndArityEquals
public boolean functorAndArityEquals(Structure s)(Code)
Returns true if this structure's functor and number of terms match the supplied structure.
Parameters:
  Structure - the structure to compare this one against true if this structure's functor andnumber of terms match the supplied structure



headAndTail
protected static Term[] headAndTail(Term[] terms, Term tail)(Code)
This method helps the static list factories. A list is a structure whose functor is "." and that has two terms. The first term of a list can be any term; the second term of a list is another list, an empty list, or a variable.

This method accepts an array of terms and a tail, which must be a list structure or a variable. This method composes and returns a two-element array.

The first element of the returned array will always be the first element of the supplied terms array.

The second element of the returned array will be a list. This list will be a concatenation of the remainder of the given array with the supplied tail.




isList
public boolean isList()(Code)
Return true, if this structure is a list, which means it has an functor of ".", and has two terms, the second of which must be a list. true if this structure is a list



list
public static Structure list(Object[] objects)(Code)
Constructs a list that contains the supplied object, wrapped as Facts. Object[] the contents of the list



list
public static Structure list(Term[] terms)(Code)
Constructs a list from the given terms.

This constructor creates a list of two terms, regardless of the number of terms supplied here. The new list's first term is the first term of the supplied array. Its second term is a list of the remaining terms. Term[] the terms of the list




list
public static Structure list(Term[] terms, Term tail)(Code)
Constructs a list that terminates with a known list, or a variable.

This allows construction of a list such as:

 Variable head = new Variable("Head");
 Variable tail = new Variable("Tail");
 Structure ht = Structure.list(new Term[] {head}, tail);
 
Term[] the leading terms of the list. In practice,this array usually contains a single term.
Parameters:
  Term - a list, or a variable that represents the tailof the list



listTailString
public String listTailString()(Code)
Returns a representation of this list as the inner part of some other list. This method is used by toString() .



listTermsToString
protected String listTermsToString()(Code)
Return a textual represenation of this list's terms, with a normal representation of the first term, and with the second term as the tail of a list.



terms
public Term[] terms()(Code)
Return the terms of this structure. the terms of this structure



toString
public String toString()(Code)
Returns a string representation of this structure. a string representation of this structure



unify
public Unification unify(Structure s)(Code)
Unifies the terms in this structure with the terms in the given structure, and returns the variable bindings that result.

If two structures have equal functors and the same number of terms, they can unify if all of their terms unify. For example, the following structures can unify:

 address(Detail, city(City), state(State))
 address(mall(fayette), city(lexington), state(ky))
 
The unification of these structures is:
 Detail = mall(fayette),
 City = lexington,
 State = ky
 

Parameters:
  Structure - a structure to unify with the sum of the variables that bind to values to makethe unification work.



unify
public Unification unify(Term t)(Code)
Unifies this structure with the supplied term.

This method dispatches the unify request to either a structure or a variable. The receiver will get a signature match from this object as a Structure, not just a Term.
Parameters:
  Term - a term to unify with the sum of the variables that bind to values to makethe unification work. Returns null if theunification fails.




unify
public Unification unify(Variable v)(Code)
Unifies this structure with the supplied variable.

This method dispatches the unify request to the variable. Note that the variable may be instantiated to a structure that contains variables. An uninstantiated variable will bind to this structure, but an instantiated variable will forward the unification request to its instantiation.
Parameters:
  Term - a term to unify with the sum of the variables that bind to values to makethe unification work. Returns null if theunification fails.




variables
public Unification variables()(Code)
Returns the variables of the terms of this structure.

Note that a structure may contain variables or other structures as terms. This method adds this structure's variables directly to the returned unification. In addition, this method adds in all the variables from the structures among this structure's terms.

For example, the variables of:

 address(street(StreetName), city(CityName), State)
 
are StreetName, CityName, and State. unification all the variables of the terms of thisstructure



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.