Java Doc for Rule.java in  » RSS-RDF » Jena-2.5.5 » com » hp » hpl » jena » reasoner » rulesys » 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 » RSS RDF » Jena 2.5.5 » com.hp.hpl.jena.reasoner.rulesys 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.hp.hpl.jena.reasoner.rulesys.Rule

Rule
public class Rule implements ClauseEntry(Code)
Representation of a generic inference rule.

This represents the rule specification but most engines will compile this specification into an abstract machine or processing graph.

The rule specification comprises a list of antecendents (body) and a list of consequents (head). If there is more than one consequent then a backchainer should regard this as a shorthand for several rules, all with the same body but with a singleton head.

Each element in the head or body can be a TriplePattern, a Functor or a Rule. A TriplePattern is just a triple of Nodes but the Nodes can represent variables, wildcards and embedded functors - as well as constant uri or literal graph nodes. A functor comprises a functor name and a list of arguments. The arguments are Nodes of any type except functor nodes (there is no functor nesting). The functor name can be mapped into a registered java class that implements its semantics. Functors play three roles - in heads they represent actions (procedural attachement); in bodies they represent builtin predicates; in TriplePatterns they represent embedded structured literals that are used to cache matched subgraphs such as restriction specifications.

The equality contract for rules is that two rules are equal if each of terms (ClauseEntry objects) are equals and they have the same name, if any.

We include a trivial, recursive descent parser but this is just there to allow rules to be embedded in code. External rule syntax based on N3 and RDF could be developed. The embedded syntax supports rules such as: [ (?C rdf:type *), guard(?C, ?P) -> (?c rb:restriction some(?P, ?D)) ].
[ (?s owl:foo ?p) -> [ (?s owl:bar ?a) -> (?s ?p ?a) ] ].
[name: (?s owl:foo ?p) -> (?s ?p ?a)].
only built in namespaces are recognized as such, * is a wildcard node, ?c is a variable, name(node ... node) is a functor, (node node node) is a triple pattern, [..] is an embedded rule, commas are ignore and can be freely used as separators. Functor names may not end in ':'.


author:
   Dave Reynolds * @version $Revision: 1.48 $ on $Date: 2008/01/02 12:07:47 $

Inner Class :public static class Parser
Inner Class :public static class ParserException extends JenaException

Field Summary
protected  ClauseEntry[]body
    
protected  ClauseEntry[]head
    
protected  booleanisBackward
    
protected  booleanisMonotonic
    
static  Loglogger
    
protected  Stringname
    
protected  intnumVars
    

Constructor Summary
public  Rule(List head, List body)
    
public  Rule(String name, List head, List body)
    
public  Rule(String name, ClauseEntry[] head, ClauseEntry[] body)
    

Method Summary
public  intbodyLength()
    
public  RulecloneRule()
     Clone a rule, cloning any embedded variables.
public  booleanequals(Object o)
    
public  ClauseEntry[]getBody()
    
public  ClauseEntrygetBodyElement(int n)
    
public  ClauseEntry[]getHead()
    
public  ClauseEntrygetHeadElement(int n)
    
public  StringgetName()
     Get the name for the rule - can be null.
public  intgetNumVars()
     Return the number of distinct variables in the rule.
public  inthashCode()
    
public  intheadLength()
    
public  Ruleinstantiate(BindingEnvironment env)
     Instantiate a rule given a variable binding environment.
public  booleanisAxiom()
     Returns true if the rule does not depend on any data, and so should be treated as an axiom.
public  booleanisBackward()
     Return true if the rule was written as a backward (as opposed to forward) rule.
public  booleanisMonotonic()
     Returns false for rules which can affect other rules non-monotonically (remove builtin or similar) or are affected non-monotonically (involve negation-as-failure).
public static  voidmain(String[] args)
    
public static  RuleparseRule(String source)
     Parse a string as a rule.
public static  ListparseRules(Parser parser)
    
public static  ListparseRules(String source)
     Parse a string as a list a rules.
public static  ListrulesFromURL(String uri)
     Answer the list of rules parsed from the given URL.
public static  ParserrulesParserFromReader(BufferedReader src)
     Processes the source reader stripping off comment lines and noting prefix definitions (@prefix) and rule inclusion commands (@include).
public static  StringrulesStringFromReader(BufferedReader src)
     Answer a String which is the concatenation (with newline glue) of all the non-comment lines readable from src.
public  booleansameAs(Object o)
     Compare clause entries, taking into account variable indices.
public  voidsetBackward(boolean flag)
     Set the rule to be run backwards.
public  voidsetNumVars(int n)
     Set the number of distinct variables for this rule.
public  StringtoShortString()
     Print a short description of the rule, just its name if it has one, otherwise the whole rule description.
public  StringtoString()
    

Field Detail
body
protected ClauseEntry[] body(Code)
Rule body



head
protected ClauseEntry[] head(Code)
Rule head or set of heads



isBackward
protected boolean isBackward(Code)
Flags whether the rule was written as a forward or backward rule



isMonotonic
protected boolean isMonotonic(Code)
Flags whether the rule is monotonic



logger
static Log logger(Code)



name
protected String name(Code)
Optional name for the rule



numVars
protected int numVars(Code)
The number of distinct variables used in the rule




Constructor Detail
Rule
public Rule(List head, List body)(Code)
Constructor
Parameters:
  body - a list of TriplePatterns or Functors.
Parameters:
  head - a list of TriplePatterns, Functors or rules



Rule
public Rule(String name, List head, List body)(Code)
Constructor
Parameters:
  name - a label for rule
Parameters:
  body - a list of TriplePatterns or Functors.
Parameters:
  head - a list of TriplePatterns, Functors or rules



Rule
public Rule(String name, ClauseEntry[] head, ClauseEntry[] body)(Code)
Constructor
Parameters:
  name - a label for rule
Parameters:
  body - an array of TriplePatterns or Functors.
Parameters:
  head - an array of TriplePatterns, Functors or rules




Method Detail
bodyLength
public int bodyLength()(Code)
Return the number of body elements



cloneRule
public Rule cloneRule()(Code)
Clone a rule, cloning any embedded variables.



equals
public boolean equals(Object o)(Code)
Equality override



getBody
public ClauseEntry[] getBody()(Code)
return the entire rule body as an array of objects



getBodyElement
public ClauseEntry getBodyElement(int n)(Code)
Return the n'th body element



getHead
public ClauseEntry[] getHead()(Code)
return the entire rule head as an array of objects



getHeadElement
public ClauseEntry getHeadElement(int n)(Code)
Return the n'th head element



getName
public String getName()(Code)
Get the name for the rule - can be null.



getNumVars
public int getNumVars()(Code)
Return the number of distinct variables in the rule. Or more precisely, the size of a binding environment needed to represent the rule.



hashCode
public int hashCode()(Code)
hash function override



headLength
public int headLength()(Code)
Return the number of head elements



instantiate
public Rule instantiate(BindingEnvironment env)(Code)
Instantiate a rule given a variable binding environment. This will clone any non-bound variables though that is only needed for trail implementations.



isAxiom
public boolean isAxiom()(Code)
Returns true if the rule does not depend on any data, and so should be treated as an axiom.



isBackward
public boolean isBackward()(Code)
Return true if the rule was written as a backward (as opposed to forward) rule.



isMonotonic
public boolean isMonotonic()(Code)
Returns false for rules which can affect other rules non-monotonically (remove builtin or similar) or are affected non-monotonically (involve negation-as-failure).



main
public static void main(String[] args)(Code)



parseRule
public static Rule parseRule(String source) throws ParserException(Code)
Parse a string as a rule.
throws:
  ParserException - if there is a problem



parseRules
public static List parseRules(Parser parser) throws ParserException(Code)
Run a pre-bound rule parser to extract it's rules a list of rules
throws:
  ParserException - if there is a problem



parseRules
public static List parseRules(String source) throws ParserException(Code)
Parse a string as a list a rules. a list of rules
throws:
  ParserException - if there is a problem



rulesFromURL
public static List rulesFromURL(String uri)(Code)
Answer the list of rules parsed from the given URL.
throws:
  RulesetNotFoundException -



rulesParserFromReader
public static Parser rulesParserFromReader(BufferedReader src)(Code)
Processes the source reader stripping off comment lines and noting prefix definitions (@prefix) and rule inclusion commands (@include). Returns a parser which is bound to the stripped source text with associated prefix and rule inclusion definitions.



rulesStringFromReader
public static String rulesStringFromReader(BufferedReader src)(Code)
Answer a String which is the concatenation (with newline glue) of all the non-comment lines readable from src. A comment line is one starting "#" or "//".



sameAs
public boolean sameAs(Object o)(Code)
Compare clause entries, taking into account variable indices. The equality function ignores differences between variables.



setBackward
public void setBackward(boolean flag)(Code)
Set the rule to be run backwards.
Parameters:
  flag - if true the rule should run backwards.



setNumVars
public void setNumVars(int n)(Code)
Set the number of distinct variables for this rule. Used internally when cloing rules, not normally required.



toShortString
public String toShortString()(Code)
Print a short description of the rule, just its name if it has one, otherwise the whole rule description.



toString
public String toString()(Code)
Printable string describing the rule



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.