Algernon Software

org.algernon.datatype
Class Path

java.lang.Object
  extended byorg.jatha.dynatype.StandardLispValue
      extended byorg.algernon.datatype.Path
All Implemented Interfaces:
Comparable, Displayable, LispValue

public class Path
extends StandardLispValue
implements Displayable


Field Summary
private  Algernon f_algy
           
protected  LispValue m_path
           
 
Fields inherited from class org.jatha.dynatype.StandardLispValue
f_lisp
 
Constructor Summary
Path(Algernon algy)
          Creates an empty path.
Path(Algernon algy, LispValue value)
          Creates a new Path.
Path(Algernon algy, String pathString)
          Creates a new Path.
 
Method Summary
 void addClause(Clause clause)
          Adds a clause to the end of the path.
 String display(PrintStream out)
          Displayable interface
 LispValue findName(Processor processor, LispValue variable)
          Given a variable name, searches for a clause of the form ( variable string) and returns the string as a symbol.
 Clause firstClause()
          Returns the first clause in the path.
 LispValue getPath()
          Returns the LispValue containing the list of clauses in the path.
 BindingList getVariableArguments()
          Returns a BindingList of the arguments in the path that are variables.
 boolean isGround()
          Returns true if the path contains no unground clauses.
 boolean isSyntacticallyLegal()
          Returns true if the path is syntactically legal.
 Iterator iterator()
          Returns an iterator across the path.
 Clause pop(Clause clause)
          Pops a clause from the front of the path.
 void push(Clause clause)
          Pushes a clause onto the front of the path.
 int size()
          Returns the size of the Path.
 Path tail()
          Returns a path containing all of the clauses in the given path after the first.
 String toString()
          Returns a string representation of the clause.
 
Methods inherited from class org.jatha.dynatype.StandardLispValue
abs, acos, add, adjustSpecialCount, append, apply, apropos_print, asin, assoc, atan, atan2, atom, basic_atom, basic_bignump, basic_consp, basic_constantp, basic_floatp, basic_foreignp, basic_functionp, basic_integerp, basic_keywordp, basic_length, basic_listp, basic_macrop, basic_null, basic_numberp, basic_stringp, basic_symbolp, bignump, boundp, butlast, car, cdr, ceiling, characterp, clrhash, compareTo, concatenate, consp, constantp, contains, copy_list, copy, cos, cot, csc, degreesToRadians, divide, eighth, elt, elt, eq, eql, equal, equalNumeric, factorial, fboundp, fifth, first, floatp, floor, fourth, funcall, functionp, get_specialCount, gethash, gethash, getLisp, greaterThan, greaterThanOrEqual, hash_table_count, hash_table_rehash_size, hash_table_rehash_threshold, hash_table_size, hash_table_test, hashtablep, integerp, internal_getName, internal_prin1_as_cdr, internal_prin1, internal_princ_as_cdr, internal_princ, internal_print_as_cdr, internal_print, keywordp, last, length, lessThan, lessThanOrEqual, lisp_null, list, listp, max, member, min, multiply, nconc, negate, neql, ninth, nreverse, nstringCapitalize, nstringDowncase, nstringUpcase, numberp, pop, position, prin1, princ, print, push, radiansToDegrees, rassoc, reciprocal, remhash, remove, rest, reverse, rplaca, rplacd, sec, second, set_special, setf_gethash, setf_symbol_function, setf_symbol_plist, setf_symbol_value, setLisp, setPackage, setq, seventh, sin, sixth, specialP, sqrt, string, stringCapitalize, stringDowncase, stringEndsWith, stringEq, stringEqual, stringGreaterP, stringGreaterThan, stringGreaterThanOrEqual, stringLeftTrim, stringLeftTrim, stringLessP, stringLessThan, stringLessThanOrEqual, stringNeq, stringNotGreaterP, stringNotLessP, stringp, stringRightTrim, stringRightTrim, stringStartsWith, stringTrim, stringTrim, stringUpcase, subst, substring, substring, subtract, symbol_function, symbol_name, symbol_package, symbol_plist, symbol_value, symbolp, tan, tenth, third, toCollection, toJava, toJava, toString, toStringAsCdr_internal, toStringAsCdr, toStringShort, toStringShort, toStringSimple, type_of, typep, zerop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_path

protected LispValue m_path

f_algy

private Algernon f_algy
Constructor Detail

Path

public Path(Algernon algy)
Creates an empty path.


Path

public Path(Algernon algy,
            String pathString)
     throws AlgernonDataException
Creates a new Path. Send in a String or a LispValue representing the Path in LISP format.


Path

public Path(Algernon algy,
            LispValue value)
     throws AlgernonDataException
Creates a new Path. Send in a String or a LispValue representing the path in LISP format.

Method Detail

toString

public String toString()
Returns a string representation of the clause.

Specified by:
toString in interface LispValue

display

public String display(PrintStream out)
Displayable interface

Specified by:
display in interface Displayable

firstClause

public Clause firstClause()
                   throws AlgernonDataException
Returns the first clause in the path.

Throws:
AlgernonDataException

tail

public Path tail()
          throws AlgernonDataException
Returns a path containing all of the clauses in the given path after the first. Non-destructive.

Throws:
AlgernonDataException

getPath

public LispValue getPath()
Returns the LispValue containing the list of clauses in the path.


isSyntacticallyLegal

public boolean isSyntacticallyLegal()
Returns true if the path is syntactically legal. A legal path contains only clauses.


getVariableArguments

public BindingList getVariableArguments()
                                 throws AlgernonDataException
Returns a BindingList of the arguments in the path that are variables.

Throws:
AlgernonDataException

iterator

public Iterator iterator()
Returns an iterator across the path. Each element should be a Clause or coercable to a Clause.

Specified by:
iterator in interface LispValue

size

public int size()
Returns the size of the Path. The size is the number of clauses in the Path.


isGround

public boolean isGround()
Returns true if the path contains no unground clauses.


addClause

public void addClause(Clause clause)
Adds a clause to the end of the path.


findName

public LispValue findName(Processor processor,
                          LispValue variable)
Given a variable name, searches for a clause of the form ( variable string) and returns the string as a symbol. if none is found, returns NIL.


push

public void push(Clause clause)
Pushes a clause onto the front of the path.


pop

public Clause pop(Clause clause)
Pops a clause from the front of the path.

Returns:
the Clause or NIL.

Algernon Software