| java.lang.Object org.ofbiz.rules.engine.Structure org.ofbiz.rules.engine.Fact
All known Subclasses: org.ofbiz.rules.engine.Atom, org.ofbiz.rules.engine.EmptyList,
Fact | public class Fact extends Structure implements Axiom,DynamicAxiom(Code) | | Title: Fact
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 Fact is a Structure that contains only other Facts.
For example,
Fact s = new Fact(
"starred",
new Fact[]{
new Fact("James Cagney"),
new Fact("Yankee Doodle Dandy")});
The Fact class offers several convenience constructors. For
example, you can create an identical fact with:
Fact s = new Fact(
"starred", "James Cagney", "Yankee Doodle Dandy");
or with:
Fact s = new Fact(
"starred",
new Object[]{
"James Cagney", "Yankee Doodle Dandy"});
Since they do not contain variables, Facts do not need to
copy themselves when they provide a "copy" for a proof.
They also avoid copying when then provide a dynamic
axiom.
author: Steven J. Metsker version: 1.0 |
Field Summary | |
final protected static DynamicRule | resolvent With facts, there is nothing beyond the fact itself to
prove; there is nothing to resolve. |
Constructor Summary | |
public | Fact(Object functor) Contructs a fact from the specified object. | public | Fact(Object functor, Object[] objects) Constructs a fact with the specified functor, and with
terms that are atoms wrapped around the supplied
objects. | public | Fact(Object functor, Fact[] terms) Constructs a fact with the specified functor and facts. | public | Fact(Object functor, Term[] objects) Although "public", this method is not for public use.
Without this constructor, or if this constructor were
private,
new Fact(
"starred",
new Term[]{new Fact("Cagney", "Yankee Doodle Dandy")})
would match the signature on Fact(Object, Object[])
, which is not what we want. | public | Fact(Object functor, Object o) A convenience, equivalent to new Fact(functor, new
Object[]{o}) . | public | Fact(Object functor, Object o1, Object o2) A convenience, equivalent to new Fact(functor, new
Object[]{o1, o2}) . |
resolvent | final protected static DynamicRule resolvent(Code) | | With facts, there is nothing beyond the fact itself to
prove; there is nothing to resolve.
|
Fact | public Fact(Object functor)(Code) | | Contructs a fact from the specified object.
Parameters: Object - the functor for this fact |
Fact | public Fact(Object functor, Object[] objects)(Code) | | Constructs a fact with the specified functor, and with
terms that are atoms wrapped around the supplied
objects.
Parameters: Object - the functor of the structure Object[] the objects to convert into atomsand use as the terms of this fact |
Fact | public Fact(Object functor, Fact[] terms)(Code) | | Constructs a fact with the specified functor and facts.
Parameters: Object - the functor of the structure Term[] the terms of this fact, which can onlybe other facts |
Fact | public Fact(Object functor, Term[] objects)(Code) | | Although "public", this method is not for public use.
Without this constructor, or if this constructor were
private,
new Fact(
"starred",
new Term[]{new Fact("Cagney", "Yankee Doodle Dandy")})
would match the signature on Fact(Object, Object[])
, which is not what we want. This would wrap each
fact in another fact.
Allowing this constructor gives the appearance of allowing
Facts with any kind of terms, including variables, which
are verboten.
exception: RuntimeException - Cannot construct a fact fromgeneric terms;Use new Fact(functor, new Fact[]{...}) |
Fact | public Fact(Object functor, Object o)(Code) | | A convenience, equivalent to new Fact(functor, new
Object[]{o}) .
Parameters: Object - the functor of the structure Parameters: Object - the object to convert to an atomand use as the term of this fact |
Fact | public Fact(Object functor, Object o1, Object o2)(Code) | | A convenience, equivalent to new Fact(functor, new
Object[]{o1, o2}) .
Parameters: Object - the functor of the structure Parameters: Object - an object to convert to an atomand use as the first term of this fact Parameters: Object - an object to convert to an atomand use as the second term of this fact |
resolvent | public DynamicRule resolvent()(Code) | | Returns an empty resolvent
a dynamic rule with nothing in it |
unify | public Unification unify(Fact f)(Code) | | A speedier version of unify(Structure s) .
either an empty Unification, indicating success,or null, indicating failure |
|
|