jess
Class PrettyPrinter

java.lang.Object
  extended byjess.PrettyPrinter
All Implemented Interfaces:
Visitor

public class PrettyPrinter
extends java.lang.Object
implements Visitor

A PrettyPrinter knows how to format various Jess constructs for display. Used in the implementation of the "ppdefrule" command and such.

This class can produce a formatted rendering of many Jess objects, including Defrules, Deffunctions Defquerys, etc -- anything that implements the Visitable interface.

PrettyPrinter is very simple to use: you just create an instance, passing the object to be rendered as a constructor argument, and then call toString() to get the formatted result.

 Rete r = new Rete();
 r.eval("(defrule myrule (A) => (printout t \"A\" crlf))");
 Defrule dr = (Defrule) r.findDefrule("myrule");
 System.out.println(new PrettyPrinter(dr));
 
The above code produces the following output:
 (defrule MAIN::myrule
   (MAIN::A)
   =>
   (printout t "A" crlf))
 
(C) 2005 Sandia National Laboratories

See Also:
Visitable

Constructor Summary
PrettyPrinter(Visitable v)
          Construct a PrettyPrinter for the given object.
 
Method Summary
 java.lang.String toString()
          Returns the rendered version of the constructor argument.
 java.lang.Object visitAccumulate(Accumulate accumulate)
           
 java.lang.Object visitDeffacts(Deffacts facts)
           
 java.lang.Object visitDeffunction(Deffunction func)
           
 java.lang.Object visitDefglobal(Defglobal global)
           
 java.lang.Object visitDefmodule(Defmodule defmodule)
           
 java.lang.Object visitDefquery(Defquery query)
           
 java.lang.Object visitDefrule(Defrule rule)
           
 java.lang.Object visitDeftemplate(Deftemplate template)
           
 java.lang.Object visitGroup(Group g)
           
 java.lang.Object visitPattern(Pattern p)
           
 java.lang.Object visitTest1(Test1 t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PrettyPrinter

public PrettyPrinter(Visitable v)
Construct a PrettyPrinter for the given object.

Parameters:
v - the object to be rendered
Method Detail

visitDeffacts

public java.lang.Object visitDeffacts(Deffacts facts)
Specified by:
visitDeffacts in interface Visitor

visitDeftemplate

public java.lang.Object visitDeftemplate(Deftemplate template)
Specified by:
visitDeftemplate in interface Visitor

visitDefglobal

public java.lang.Object visitDefglobal(Defglobal global)
Specified by:
visitDefglobal in interface Visitor

visitDeffunction

public java.lang.Object visitDeffunction(Deffunction func)
Specified by:
visitDeffunction in interface Visitor

visitDefrule

public java.lang.Object visitDefrule(Defrule rule)
Specified by:
visitDefrule in interface Visitor

visitGroup

public java.lang.Object visitGroup(Group g)
Specified by:
visitGroup in interface Visitor

visitPattern

public java.lang.Object visitPattern(Pattern p)
Specified by:
visitPattern in interface Visitor

visitTest1

public java.lang.Object visitTest1(Test1 t)
Specified by:
visitTest1 in interface Visitor

visitAccumulate

public java.lang.Object visitAccumulate(Accumulate accumulate)
Specified by:
visitAccumulate in interface Visitor

visitDefmodule

public java.lang.Object visitDefmodule(Defmodule defmodule)
Specified by:
visitDefmodule in interface Visitor

visitDefquery

public java.lang.Object visitDefquery(Defquery query)
Specified by:
visitDefquery in interface Visitor

toString

public java.lang.String toString()
Returns the rendered version of the constructor argument.

Returns:
the formatted String

© 2006 Sandia Corporation