use of com.inova8.pathql.pathPattern.PathPatternParser in project com.inova8.intelligentgraph by peterjohnlawrence.
the class PathPatternQueryExpressionTests method prepareElement.
/**
* Prepare element.
*
* @param input the input
* @return the path element
* @throws RecognitionException the recognition exception
*/
private PathElement prepareElement(CharStream input) throws RecognitionException {
PathPatternLexer lexer = new PathPatternLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
PathPatternParser parser = new PathPatternParser(tokens);
PathPatternContext pathPatternTree = parser.pathPattern();
PathPatternVisitor pathPatternVisitor = new PathPatternVisitor(repositoryContext);
PathElement element = pathPatternVisitor.visit(pathPatternTree);
element.indexVisitor(null, 0, null);
element.setIterations(Iterations.create(element));
// element.setPathBindings(PathBindings.create(element));
return element;
}
use of com.inova8.pathql.pathPattern.PathPatternParser in project com.inova8.intelligentgraph by peterjohnlawrence.
the class PathPatternTests method prepareElement.
/**
* Prepare element.
*
* @param input the input
* @return the path element
* @throws RecognitionException the recognition exception
*/
private PathElement prepareElement(CharStream input) throws RecognitionException {
PathPatternLexer lexer = new PathPatternLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
PathPatternParser parser = new PathPatternParser(tokens);
PathPatternContext pathPatternTree = parser.pathPattern();
PathPatternVisitor pathPatternVisitor = new PathPatternVisitor(repositoryContext);
PathElement element = pathPatternVisitor.visit(pathPatternTree);
return element;
}
use of com.inova8.pathql.pathPattern.PathPatternParser in project com.inova8.intelligentgraph by peterjohnlawrence.
the class PathParser method parseIriRef.
/**
* Parses the iri ref.
*
* @param repositoryContext the repository context
* @param uriPattern the uri pattern
* @return the iri ref value element
* @throws RecognitionException the recognition exception
* @throws PathPatternException the path pattern exception
*/
public static IriRefValueElement parseIriRef(RepositoryContext repositoryContext, String uriPattern) throws RecognitionException, PathPatternException {
try {
pathPatternVisitor = new PathPatternVisitor(repositoryContext);
CharStream input = CharStreams.fromString(uriPattern);
PathPatternLexer lexer = new PathPatternLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
PathPatternParser parser = new PathPatternParser(tokens);
IriRefContext pathPatternTree = parser.iriRef();
PathElement iriRefValueElement = pathPatternVisitor.visit(pathPatternTree);
return (IriRefValueElement) iriRefValueElement;
} catch (Exception qe) {
throw new PathPatternException(qe.getMessage(), null);
}
}
use of com.inova8.pathql.pathPattern.PathPatternParser in project com.inova8.intelligentgraph by peterjohnlawrence.
the class PathParser method parsePredicate.
/**
* Parses the predicate.
*
* @param repositoryContext the repository context
* @param uriPattern the uri pattern
* @return the predicate element
* @throws RecognitionException the recognition exception
* @throws PathPatternException the path pattern exception
*/
public static PredicateElement parsePredicate(RepositoryContext repositoryContext, String uriPattern) throws RecognitionException, PathPatternException {
pathPatternVisitor = new PathPatternVisitor(repositoryContext);
CharStream input = CharStreams.fromString(uriPattern);
PathPatternLexer lexer = new PathPatternLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
PathPatternParser parser = new PathPatternParser(tokens);
PathEltOrInverseContext pathPatternTree = parser.pathEltOrInverse();
PathElement iriRefValueElement = pathPatternVisitor.visit(pathPatternTree);
return (PredicateElement) iriRefValueElement;
}
use of com.inova8.pathql.pathPattern.PathPatternParser in project com.inova8.intelligentgraph by peterjohnlawrence.
the class PathParser method parsePathPattern.
// @Deprecated
// public static PathElement parsePathPattern(Thing thing, String pathPattern)
// throws RecognitionException, PathPatternException {
// PathPatternVisitor pathPatternVisitor = new PathPatternVisitor(thing);
// PathElement pathElement = pathPatternParser(pathPattern, pathPatternVisitor);
// return pathElement;
// }
// public static PathElement parsePathPattern(String pathPattern)
// throws RecognitionException, PathPatternException {
// PathPatternVisitor pathPatternVisitor = new PathPatternVisitor();
// PathElement pathElement = pathPatternParser(pathPattern, pathPatternVisitor);
// return pathElement;
// }
/**
* Parses the path pattern.
*
* @param repositoryContext the repository context
* @param pathPattern the path pattern
* @return the path element
* @throws RecognitionException the recognition exception
* @throws PathPatternException the path pattern exception
*/
public static PathElement parsePathPattern(RepositoryContext repositoryContext, String pathPattern) throws RecognitionException, PathPatternException {
PathPatternVisitor pathPatternVisitor = new PathPatternVisitor(repositoryContext);
PathElement pathElement = pathPatternParser(pathPattern, pathPatternVisitor);
return pathElement;
}
Aggregations