nesstar.api
Class PathIterator

java.lang.Object
  extended by nesstar.api.PathIterator

public class PathIterator
extends Object

An iterator on a path. A path is a, possibly empty, sequence of path steps each one representing a property traversal. For example .children[1].variables[2] is a path composed by two steps. The first represent the traversal of the children property that returns a collection of elements followed by the extraction of the first element of the returned collection. In API terms this would translate to the expression: context.getChildren().get(1). The context is the object with respect to which the path is defined. If the path derives from a query then the context would be the queried object (e.g., a catalog)

Created:
26 April 2002

Constructor Summary
PathIterator(RDFObject obj)
           
PathIterator(String path)
          Create a path iterator on the given path
 
Method Summary
static void dbg(String msg)
          Method
static int getIndex(String step)
           
 String getPath()
           
static PathIterator[] getPathIterators(String paths)
           
static String getProperty(String step)
           
 Object nextObj(Object context)
          Apply the current traversal element to the context object
 String nextStep()
           
 Object traversePath(Object context)
          Traverse the path starting from the given context and return the result object Useful for testing and as an example of path traversal
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PathIterator

public PathIterator(RDFObject obj)
             throws Exception
Parameters:
an - object with an iniatialised 'path' property
Throws:
Exception

PathIterator

public PathIterator(String path)
Create a path iterator on the given path

Parameters:
path -
Method Detail

getPathIterators

public static PathIterator[] getPathIterators(String paths)
Parameters:
paths - a ";" separate list of paths as returned by the PathsTo operations (e.g. Study2.PathsTo(nesstar.rdf.RDFObject)).
Returns:
an array of PathIterators, one per path

getProperty

public static String getProperty(String step)
Parameters:
step - the step, e.g.: children[3]
Returns:
the property part of the step, e.g.: children

getIndex

public static int getIndex(String step)
Parameters:
step - the step, e.g.: children[3]
Returns:
the index part of the step, e.g.: 3

dbg

public static void dbg(String msg)
Method

Parameters:
msg -

getPath

public String getPath()

nextStep

public String nextStep()
Returns:
the next step of the path or null if there are no more steps

nextObj

public Object nextObj(Object context)
               throws Exception
Apply the current traversal element to the context object

Parameters:
context - the object to which the traversal is to be applied
Returns:
the object that is obtained by traversing the current path property from the context
Throws:
Exception

traversePath

public Object traversePath(Object context)
                    throws Exception
Traverse the path starting from the given context and return the result object Useful for testing and as an example of path traversal

Parameters:
context -
Returns:
Throws:
Exception

Nesstar SDK

Copyright©2003 NSD - All Rights Reserved