org.w3c.IsaViz.fresnel
Class FSLJenaEvaluator

java.lang.Object
  extended byorg.w3c.IsaViz.fresnel.FSLEvaluator
      extended byorg.w3c.IsaViz.fresnel.FSLJenaEvaluator
All Implemented Interfaces:
com.hp.hpl.jena.rdf.model.RDFErrorHandler

public class FSLJenaEvaluator
extends FSLEvaluator
implements com.hp.hpl.jena.rdf.model.RDFErrorHandler

Main class for evaluating an FSL expression on a Jena model (requires Jena 2.3)


Field Summary
static boolean DEBUG
           
 
Constructor Summary
FSLJenaEvaluator(FSLNSResolver nsr, FSLHierarchyStore fhs)
          Construct an FSL Path evaluator for expression path
 
Method Summary
 void error(java.lang.Exception ex)
           
 java.util.Vector evaluate(java.lang.String path, short firstStepType, java.lang.String file, boolean printPaths)
          Evaluate this FSL expression on an RDF/XML file
 java.util.Vector evaluatePath(FSLPath p)
          Evaluate a path expression on the repository set by setRepository(Repository r).
The initial set of nodes/arcs (i.e., the set of nodes or arcs that are going to be considered as potential starting points for matching paths) is:
1) all resource nodes in the graph if firstStepType = NODE_STEP and the first location step does not test for a literal node (i.e.
 java.util.Vector evaluatePath(FSLPath p, java.util.Vector startSet)
          Evaluate a path expression on the repository set by setRepository(Repository r), only considering specific nodes/arcs in the graph as potential starting points for paths.
 java.util.Vector evaluatePathExpr(FSLPath expr, java.lang.Object nodeOrArc)
           
 void fatalError(java.lang.Exception ex)
           
 java.lang.String fcLiteralDT(FSLPath expr, java.lang.Object nodeOrArc)
           
 java.lang.String fcLiteralValue(FSLPath expr, java.lang.Object nodeOrArc)
           
 java.lang.String fcLocalName(FSLPath expr, java.lang.Object nodeOrArc)
           
 java.lang.String fcNamespaceURI(FSLPath expr, java.lang.Object nodeOrArc)
           
 java.lang.String fcURI(FSLPath expr, java.lang.Object nodeOrArc)
           
 float getFirstLiteralAsNumber(FSLPath expr, java.lang.Object nodeOrArc)
           
 java.lang.String getFirstLiteralAsString(FSLPath expr, java.lang.Object nodeOrArc)
           
 float[] getLiteralsAsNumbers(FSLPath expr, java.lang.Object nodeOrArc)
           
 java.lang.String[] getLiteralsAsStrings(FSLPath expr, java.lang.Object nodeOrArc)
           
 com.hp.hpl.jena.rdf.model.Model getModel()
          Get the Jena model on which the path expression is evaluated
static void main(java.lang.String[] args)
           
 void printPath(java.util.Vector v)
           
 void setModel(com.hp.hpl.jena.rdf.model.Model m)
          Set the Jena model on which the path expression will be evaluated
This method should be used when the model is created, initialized and populated somewhere else.
When just evaluating the path expression on a file or URL, it is simpler to use methods evaluate(...)
 void warning(java.lang.Exception ex)
           
 
Methods inherited from class org.w3c.IsaViz.fresnel.FSLEvaluator
callBooleanFunction, callNumberFunction, callStringFunction, evaluateBooleanExpr, evaluateNumberExpr, evaluateStringExpr, fcBoolean, fcConcat, fcContains, fcContains, fcContains, fcContains, fcCount, fcExpand, fcFalse, fcNormalizeSpace, fcNot, fcNumber, fcNumber, fcStartsWith, fcStartsWith, fcStartsWith, fcStartsWith, fcStringLength, fcStringLength, fcSubstring, fcSubstring, fcSubstringAfter, fcSubstringBefore, fcTrue, printFunctionCallError, printUnknownFunctionError, testDIFFExpr, testEQExpr, testINFEQExpr, testINFExpr, testSUPEQExpr, testSUPExpr
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static boolean DEBUG
Constructor Detail

FSLJenaEvaluator

public FSLJenaEvaluator(FSLNSResolver nsr,
                        FSLHierarchyStore fhs)
Construct an FSL Path evaluator for expression path

Parameters:
nsr - namespace prefix bindings used in the FSL expression (this has to be instantiated by the client)
fhs - class / type hierarchy store for RDFS/OWL awareness (this has to be instantiated by the client)
Method Detail

evaluate

public java.util.Vector evaluate(java.lang.String path,
                                 short firstStepType,
                                 java.lang.String file,
                                 boolean printPaths)
Evaluate this FSL expression on an RDF/XML file

Parameters:
path - the FSL path expression as a String
firstStepType - one of {FSLPath.NODE_STEP, FSLPath.ARC_STEP} - specifies how the first location step should be interpreted (as a node step or arc step)
file - the file's URL
printPaths - should the result paths be printed on System.out or not
Returns:
the set of paths in the model that instantiate the FSL expression

setModel

public void setModel(com.hp.hpl.jena.rdf.model.Model m)
Set the Jena model on which the path expression will be evaluated
This method should be used when the model is created, initialized and populated somewhere else.
When just evaluating the path expression on a file or URL, it is simpler to use methods evaluate(...)

Parameters:
m - the model on which to evaluate the expression

getModel

public com.hp.hpl.jena.rdf.model.Model getModel()
Get the Jena model on which the path expression is evaluated

Returns:
the Jena model

evaluatePath

public java.util.Vector evaluatePath(FSLPath p)
Evaluate a path expression on the repository set by setRepository(Repository r).
The initial set of nodes/arcs (i.e., the set of nodes or arcs that are going to be considered as potential starting points for matching paths) is:
1) all resource nodes in the graph if firstStepType = NODE_STEP and the first location step does not test for a literal node (i.e. it is not "text()");
2) all literal nodes in the graph if firstStepType = NODE_STEP and the first location step tests for a literal node (i.e. it is "text()");
3) all property arcs in the graph if firstStepType = ARC_STEP

Parameters:
p - the FSL path expression (use FSLPath.pathFactory() to build it from its String representation)
Returns:
a Vector containing Vectors that represent sequences of nodes/arcs that are instances of actual paths in the graph that match the FSL expression. These vectors are made of Jena com.hp.hpl.jena.rdf.model.Resource or com.hp.hpl.jena.rdf.model.Literal objects for node steps and com.hp.hpl.jena.rdf.model.Statement objects for arc steps. Naturally, one every two steps is a Resource or a Literal, the other being a Statement.
See Also:
evaluatePath(FSLPath p, Vector startSet)

evaluatePath

public java.util.Vector evaluatePath(FSLPath p,
                                     java.util.Vector startSet)
Evaluate a path expression on the repository set by setRepository(Repository r), only considering specific nodes/arcs in the graph as potential starting points for paths.

Parameters:
p - the FSL path expression (use FSLPath.pathFactory() to build it from its String representation)
startSet - The initial set of nodes/arcs (i.e., the set of nodes or arcs that are going to be considered as potential starting points for matching paths).
1) if firstStepType = NODE_STEP and the first location step does not test for a literal node (i.e. it is not "text()"), startSet should contain objects that implement org.openrdf.model.Resource;
2) if firstStepType = NODE_STEP and the first location step tests for a literal node (i.e. it is "text()"), startSet should contain objects that implement org.openrdf.model.Literal;
3) if firstStepType = ARC_STEP, startsSet should contain objects that implement org.openrdf.model.Statement
Returns:
a Vector containing Vectors that represent sequences of nodes/arcs that are instances of actual paths in the graph that match the FSL expression. These vectors are made of Jena com.hp.hpl.jena.rdf.model.Resource or com.hp.hpl.jena.rdf.model.Literal objects for node steps and com.hp.hpl.jena.rdf.model.Statement objects for arc steps. Naturally, one every two steps is a Resource or a Literal, the other being a Statement.
See Also:
evaluatePath(FSLPath p)

evaluatePathExpr

public java.util.Vector evaluatePathExpr(FSLPath expr,
                                         java.lang.Object nodeOrArc)
Specified by:
evaluatePathExpr in class FSLEvaluator

getLiteralsAsNumbers

public float[] getLiteralsAsNumbers(FSLPath expr,
                                    java.lang.Object nodeOrArc)
Specified by:
getLiteralsAsNumbers in class FSLEvaluator

getLiteralsAsStrings

public java.lang.String[] getLiteralsAsStrings(FSLPath expr,
                                               java.lang.Object nodeOrArc)
Specified by:
getLiteralsAsStrings in class FSLEvaluator

getFirstLiteralAsString

public java.lang.String getFirstLiteralAsString(FSLPath expr,
                                                java.lang.Object nodeOrArc)
Specified by:
getFirstLiteralAsString in class FSLEvaluator

getFirstLiteralAsNumber

public float getFirstLiteralAsNumber(FSLPath expr,
                                     java.lang.Object nodeOrArc)
Specified by:
getFirstLiteralAsNumber in class FSLEvaluator

fcLocalName

public java.lang.String fcLocalName(FSLPath expr,
                                    java.lang.Object nodeOrArc)
Specified by:
fcLocalName in class FSLEvaluator

fcNamespaceURI

public java.lang.String fcNamespaceURI(FSLPath expr,
                                       java.lang.Object nodeOrArc)
Specified by:
fcNamespaceURI in class FSLEvaluator

fcURI

public java.lang.String fcURI(FSLPath expr,
                              java.lang.Object nodeOrArc)
Specified by:
fcURI in class FSLEvaluator

fcLiteralValue

public java.lang.String fcLiteralValue(FSLPath expr,
                                       java.lang.Object nodeOrArc)
Specified by:
fcLiteralValue in class FSLEvaluator

fcLiteralDT

public java.lang.String fcLiteralDT(FSLPath expr,
                                    java.lang.Object nodeOrArc)
Specified by:
fcLiteralDT in class FSLEvaluator

error

public void error(java.lang.Exception ex)
Specified by:
error in interface com.hp.hpl.jena.rdf.model.RDFErrorHandler

fatalError

public void fatalError(java.lang.Exception ex)
Specified by:
fatalError in interface com.hp.hpl.jena.rdf.model.RDFErrorHandler

warning

public void warning(java.lang.Exception ex)
Specified by:
warning in interface com.hp.hpl.jena.rdf.model.RDFErrorHandler

printPath

public void printPath(java.util.Vector v)

main

public static void main(java.lang.String[] args)


Copyright © 2005 INRIA. All Rights Reserved
Licensed under the GNU LGPL. For full terms see the file COPYING.