com.hp.hpl.jena.reasoner.rulesys
Class Functor

java.lang.Object
  extended by com.hp.hpl.jena.reasoner.rulesys.Functor
All Implemented Interfaces:
ClauseEntry

public class Functor
extends java.lang.Object
implements ClauseEntry

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). Functors play three roles in rules - 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.

Version:
$Revision: 1.1 $ on $Date: 2009/06/29 08:55:38 $
Author:
Dave Reynolds

Nested Class Summary
static class Functor.FunctorDatatype
          Inner class.
 
Field Summary
static com.hp.hpl.jena.util.iterator.Filter<Triple> acceptFilter
          A static Filter instance that detects triples with Functor objects
 
Constructor Summary
Functor(java.lang.String name, java.util.List<Node> args)
          Constructor.
Functor(java.lang.String name, java.util.List<Node> args, BuiltinRegistry registry)
          Constructor
Functor(java.lang.String name, Node[] args)
          Constructor.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Equality is based on structural comparison
 boolean evalAsBodyClause(RuleContext context)
          Execute the given built in as a body clause.
 int getArgLength()
          Return the length of the functor argument array.
 Node[] getArgs()
          Return the functor aguments as an array of nodes
 Node[] getBoundArgs(BindingEnvironment env)
          Return a new Node array containing the bound versions of this Functor's arguments
 Builtin getImplementor()
          Return the Builtin that implements this functor
 java.lang.String getName()
          Return the functor name
 int hashCode()
          hash function override
static boolean isFunctor(Node n)
          tests that a given Node represents a functor
 boolean isGround()
          Returns true if the functor is fully ground, no variables
 boolean isGround(BindingEnvironment env)
          Returns true if the functor is fully ground in the given environment
static Node makeFunctorNode(Functor f)
          Wrap a functor as a Literal node
static Node makeFunctorNode(java.lang.String name, Node[] args)
          Create a functor and wrap it up as a Literal node
 boolean safeEvalAsBodyClause(RuleContext context)
          Execute the given built in as a body clause, only if it is side-effect-free.
 boolean sameAs(java.lang.Object o)
          Compare Functors, taking into account variable indices.
 void setImplementor(Builtin implementor)
          Set the Builtin that implements this functor.
 java.lang.String toString()
          Printable string describing the functor
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

acceptFilter

public static final com.hp.hpl.jena.util.iterator.Filter<Triple> acceptFilter
A static Filter instance that detects triples with Functor objects

Constructor Detail

Functor

public Functor(java.lang.String name,
               java.util.List<Node> args)
Constructor.

Parameters:
name - the name of the functor
args - a list of nodes defining the arguments

Functor

public Functor(java.lang.String name,
               Node[] args)
Constructor.

Parameters:
name - the name of the functor
args - an array of nodes defining the arguments, this will not be copied so beware of accidental structure sharing

Functor

public Functor(java.lang.String name,
               java.util.List<Node> args,
               BuiltinRegistry registry)
Constructor

Parameters:
name - the name of the functor
args - a list of nodes defining the arguments
registry - a table of builtins to consult to check for implementations of this functor when used as a rule clause
Method Detail

getName

public java.lang.String getName()
Return the functor name


getArgs

public Node[] getArgs()
Return the functor aguments as an array of nodes


getArgLength

public int getArgLength()
Return the length of the functor argument array.


isGround

public boolean isGround()
Returns true if the functor is fully ground, no variables


isGround

public boolean isGround(BindingEnvironment env)
Returns true if the functor is fully ground in the given environment


evalAsBodyClause

public boolean evalAsBodyClause(RuleContext context)
Execute the given built in as a body clause.

Parameters:
context - an execution context giving access to other relevant data
Returns:
true if the functor has an implementation and that implementation returns true when evaluated

safeEvalAsBodyClause

public boolean safeEvalAsBodyClause(RuleContext context)
Execute the given built in as a body clause, only if it is side-effect-free.

Parameters:
context - an execution context giving access to other relevant data
Returns:
true if the functor has an implementation and that implementation returns true when evaluated

getBoundArgs

public Node[] getBoundArgs(BindingEnvironment env)
Return a new Node array containing the bound versions of this Functor's arguments


getImplementor

public Builtin getImplementor()
Return the Builtin that implements this functor

Returns:
the Builtin or null if there isn't one

setImplementor

public void setImplementor(Builtin implementor)
Set the Builtin that implements this functor.


toString

public java.lang.String toString()
Printable string describing the functor

Overrides:
toString in class java.lang.Object

isFunctor

public static boolean isFunctor(Node n)
tests that a given Node represents a functor


equals

public boolean equals(java.lang.Object obj)
Equality is based on structural comparison

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
hash function override

Overrides:
hashCode in class java.lang.Object

sameAs

public boolean sameAs(java.lang.Object o)
Compare Functors, taking into account variable indices. The equality function ignores differences between variables.

Specified by:
sameAs in interface ClauseEntry

makeFunctorNode

public static Node makeFunctorNode(java.lang.String name,
                                   Node[] args)
Create a functor and wrap it up as a Literal node

Parameters:
name - the name of the functor
args - an array of nodes defining the arguments, this will not be copied so beware of accidental structure sharing

makeFunctorNode

public static Node makeFunctorNode(Functor f)
Wrap a functor as a Literal node

Parameters:
f - the functor data structure to be wrapped in a node.


Copyright © 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Hewlett-Packard Development Company, LP