Node
- the node type used by the backend
Author: Sebastian Schaffertpublic class LDPath<Node> extends Object
Constructor and Description |
---|
LDPath(RDFBackend<Node> backend)
Initialise a new LDPath instance for querying the backend passed as argument with the default configuration.
|
LDPath(RDFBackend<Node> backend,
Configuration<Node> config)
Initialise a new LDPath instance for querying the backend passed as argument with a custom configuration
for default functions, transformers and namespaces.
|
Modifier and Type | Method and Description |
---|---|
Configuration<Node> |
getConfig()
Return the configuration underlying this LDPath instance.
|
Set<SelectorFunction<Node>> |
getFunctions()
Return the collection of selector functions registered with this LDPath instance.
|
Map<String,NodeTransformer<?,Node>> |
getTransformers() |
Program<Node> |
parseProgram(Reader program)
Parse a program passed as argument and return it for further use.
|
Collection<Node> |
pathQuery(Node context,
String path,
Map<String,String> namespaces)
Execute a single path query starting from the given context node and return a collection of nodes resulting
from the selection.
|
Collection<Node> |
pathQuery(Node context,
String path,
Map<String,String> namespaces,
Map<Node,List<Node>> paths)
Execute a single path query starting from the given context node and return a collection of nodes resulting
from the selection.
|
<T> Collection<T> |
pathTransform(Node context,
String path,
Map<String,String> namespaces)
Execute a single path query starting from the given context node and return a collection of nodes resulting
from the selection.
|
Map<String,Collection<?>> |
programQuery(Node context,
Reader program)
Evaluate a path program passed as argument starting from the given context node and return a mapping for
each field in the program to the selected values.
|
void |
registerFunction(SelectorFunction<Node> function)
Register a selector function to be used in LDPath.
|
void |
registerTransformer(String typeUri,
NodeTransformer<?,Node> transformer)
Register a result transformer for a type URI.
|
public LDPath(RDFBackend<Node> backend)
backend
- public LDPath(RDFBackend<Node> backend, Configuration<Node> config)
backend
- config
- public Collection<Node> pathQuery(Node context, String path, Map<String,String> namespaces) throws LDPathParseException
foaf:knows / foaf:name
Note that since this method returns a collection of nodes, no transformations can be used.context
- the context node where to start the path querypath
- the LDPath path specificationnamespaces
- an optional map mapping namespace prefixes to URIs (used for lookups of prefixes used in the path);
can be nullLDPathParseException
- when the path passed as argument is not validpublic Collection<Node> pathQuery(Node context, String path, Map<String,String> namespaces, Map<Node,List<Node>> paths) throws LDPathParseException
foaf:knows / foaf:name
Note that since this method returns a collection of nodes, no transformations can be used.context
- the context node where to start the path querypath
- the LDPath path specificationnamespaces
- an optional map mapping namespace prefixes to URIs (used for lookups of prefixes used in the path);
can be nullLDPathParseException
- when the path passed as argument is not validpublic <T> Collection<T> pathTransform(Node context, String path, Map<String,String> namespaces) throws LDPathParseException
foaf:knows / foaf:name
Note that since this method returns a collection of nodes, no transformations can be used.context
- the context node where to start the path querypath
- the LDPath path specificationnamespaces
- an optional map mapping namespace prefixes to URIs (used for lookups of prefixes used in the path);
can be nullLDPathParseException
- when the path passed as argument is not validpublic Map<String,Collection<?>> programQuery(Node context, Reader program) throws LDPathParseException
context
- program
- LDPathParseException
public Program<Node> parseProgram(Reader program) throws LDPathParseException
program
- a reader containing the program in LDPath syntaxLDPathParseException
public void registerFunction(SelectorFunction<Node> function)
function
- public Set<SelectorFunction<Node>> getFunctions()
public void registerTransformer(String typeUri, NodeTransformer<?,Node> transformer)
typeUri
- a URI identifying the type for which to use this transformer; can be specified in path programstransformer
- instance of a node transformerpublic Map<String,NodeTransformer<?,Node>> getTransformers()
public Configuration<Node> getConfig()
Copyright © 2012–2018 The Apache Software Foundation. All rights reserved.