proper.imp
Class Traverser

java.lang.Object
  extended by proper.core.ProperObject
      extended by proper.imp.Traverser
All Implemented Interfaces:
ProperInterface

public class Traverser
extends ProperObject

This class extracts useful information from a given structure.

Version:
$Revision: 1.2 $
Author:
FracPete

Field Summary
 
Fields inherited from interface proper.core.ProperInterface
VERSION
 
Constructor Summary
Traverser(java.util.Vector predicates)
          initializes the object
 
Method Summary
 void add(Predicate p)
          adds the specified predicate
 java.util.Vector findAll()
          returns all predicates/lists
 java.util.Vector findAll(java.lang.String name)
          returns all occurences of the specified predicate/list
 java.util.Vector findAllArgTypes(java.lang.String name)
          returns a vector with all the types of argument of the given predicate or list.
 java.util.Vector findAllLists()
          returns all lists
 java.util.Vector findAllLists(java.lang.String name)
          returns all occurences of the specified list
 java.util.Vector findAllPredicates()
          returns all predicates
 java.util.Vector findAllPredicates(java.lang.String name)
          returns all occurences of the specified predicate
 Data findFirst(java.lang.String name)
          returns the first occurence of the specified predicate/list, can be NULL
 List findFirstList(java.lang.String name)
          returns the first occurence of the specified list, can be NULL
 Predicate findFirstPredicate(java.lang.String name)
          returns the first occurence of the specified predicate, can be NULL
 java.util.Vector getAll()
          returns all distinct predicates and lists
 java.util.Vector getAllValues(java.lang.String name, int index)
          returns all the values of an argument for a given predicate/list
 java.util.Vector getLists()
          returns all distinct lists
 int getMaxLength(java.lang.String name, int index)
          returns the max.
 java.util.Vector getPredicates()
          returns all distinct predicates
 java.util.Hashtable indexPredicate(java.lang.String name, int index)
          returns a hashtable that indexes the given predicate over the argument specified by index - for faster access.
 void invalidate()
          resets the analyzed status to FALSE, i.e.
 boolean isPredicate(java.lang.String name)
          checks whether the given name is a predicate or not
 boolean keyIsUnique(java.lang.String name)
          checks whether the first argument of the specified predicate is unique
 void remove(Data d)
          removes the specified predicate/list
 void shuffleIDs()
          randomizes all the IDs of the stored items, for destroying implicit information about the creation order and therefore classes
 java.lang.String toString()
          the stored predicates in string representation
 
Methods inherited from class proper.core.ProperObject
addListener, addOutput, classInVerbose, debugprint, debugprint, debugprint, debugprint, debugprintln, debugprintln, debugprintln, debugprintln, debugprintln, getListeners, getRuntime, getVerbose, getVerboseLevel, getVerboseLevelForClass, getVerboseString, getVerboseStringForClass, notifyListener, notifyListeners, print, print, print, print, println, println, println, println, println, printMemory, removeListener, setOutput, setVerbose, setVerboseLevel, setVerboseString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Traverser

public Traverser(java.util.Vector predicates)
initializes the object

Parameters:
predicates - the Predicates to work with
Method Detail

invalidate

public void invalidate()
resets the analyzed status to FALSE, i.e. on the next retrieval the structure is analyzed again


isPredicate

public boolean isPredicate(java.lang.String name)
checks whether the given name is a predicate or not


getAll

public java.util.Vector getAll()
returns all distinct predicates and lists

Returns:
all distinct predicates and lists in the structure

getPredicates

public java.util.Vector getPredicates()
returns all distinct predicates

Returns:
all distinct predicates found in the structure

getLists

public java.util.Vector getLists()
returns all distinct lists

Returns:
all distinct lists found in the structure, i.e. the name of the parent predicate

findFirst

public Data findFirst(java.lang.String name)
returns the first occurence of the specified predicate/list, can be NULL


findFirstPredicate

public Predicate findFirstPredicate(java.lang.String name)
returns the first occurence of the specified predicate, can be NULL


findFirstList

public List findFirstList(java.lang.String name)
returns the first occurence of the specified list, can be NULL


findAll

public java.util.Vector findAll(java.lang.String name)
returns all occurences of the specified predicate/list


findAllPredicates

public java.util.Vector findAllPredicates(java.lang.String name)
returns all occurences of the specified predicate


findAll

public java.util.Vector findAll()
returns all predicates/lists


findAllPredicates

public java.util.Vector findAllPredicates()
returns all predicates


findAllLists

public java.util.Vector findAllLists(java.lang.String name)
returns all occurences of the specified list


findAllLists

public java.util.Vector findAllLists()
returns all lists


findAllArgTypes

public java.util.Vector findAllArgTypes(java.lang.String name)
returns a vector with all the types of argument of the given predicate or list. it stores actual objects, not just the names of the class. With lists it assumes that all elements are of the same type!


getMaxLength

public int getMaxLength(java.lang.String name,
                        int index)
returns the max. length of the given predicate/list, returns -1 if it fails

Parameters:
name - the name of the predicate
index - the index of the argument, starts with 0

getAllValues

public java.util.Vector getAllValues(java.lang.String name,
                                     int index)
returns all the values of an argument for a given predicate/list

Parameters:
name - the predicate to search in
index - the index of the argument, starts with 0
Returns:
the values of this argument

shuffleIDs

public void shuffleIDs()
randomizes all the IDs of the stored items, for destroying implicit information about the creation order and therefore classes


keyIsUnique

public boolean keyIsUnique(java.lang.String name)
checks whether the first argument of the specified predicate is unique

Parameters:
name - the name of the predicate to check

remove

public void remove(Data d)
removes the specified predicate/list


add

public void add(Predicate p)
adds the specified predicate


indexPredicate

public java.util.Hashtable indexPredicate(java.lang.String name,
                                          int index)
returns a hashtable that indexes the given predicate over the argument specified by index - for faster access. the index is assumed to be unique, otherwise predicates get overwritten!


toString

public java.lang.String toString()
the stored predicates in string representation

Overrides:
toString in class ProperObject