Search in sources :

Example 1 with ObjectListValueElement

use of com.inova8.pathql.element.ObjectListValueElement in project com.inova8.intelligentgraph by peterjohnlawrence.

the class PathPatternVisitor method visitPropertyListNotEmpty.

/**
 * Visit property list not empty.
 *
 * @param ctx the ctx
 * @return the fact filter element
 */
@Override
public FactFilterElement visitPropertyListNotEmpty(PropertyListNotEmptyContext ctx) {
    // propertyListNotEmpty :   verbObjectList ( ';' ( verbObjectList )? )* ;
    FactFilterElement propertyListNotEmptyElement = new FactFilterElement(this.repositoryContext);
    ArrayList<VerbObjectList> propertyListNotEmpty = new ArrayList<VerbObjectList>();
    for (VerbObjectListContext verbObjectListContext : ctx.verbObjectList()) {
        PathElement verb = visit(verbObjectListContext.verb());
        ObjectListValueElement objectList = (ObjectListValueElement) visit(verbObjectListContext.objectList());
        VerbObjectList verbObjectList = new VerbObjectList(this.repositoryContext);
        if (verb instanceof ValueElement) {
            verbObjectList.setFilterOperator(((FilterOperatorValueElement) verb).getFilterOperator());
        } else if (verb instanceof PredicateElement) {
            verbObjectList.setPredicate(((PredicateElement) verb));
        }
        verbObjectList.setObjectList(objectList.getObjectList());
        propertyListNotEmpty.add(verbObjectList);
    }
    propertyListNotEmptyElement.setPropertyListNotEmpty(propertyListNotEmpty);
    return propertyListNotEmptyElement;
}
Also used : ObjectListValueElement(com.inova8.pathql.element.ObjectListValueElement) ValueElement(com.inova8.pathql.element.ValueElement) ObjectListValueElement(com.inova8.pathql.element.ObjectListValueElement) IriRefValueElement(com.inova8.pathql.element.IriRefValueElement) FilterOperatorValueElement(com.inova8.pathql.element.FilterOperatorValueElement) LiteralValueElement(com.inova8.pathql.element.LiteralValueElement) SequencePathElement(com.inova8.pathql.element.SequencePathElement) BoundPathElement(com.inova8.pathql.element.BoundPathElement) PathElement(com.inova8.pathql.element.PathElement) AlternativePathElement(com.inova8.pathql.element.AlternativePathElement) QueryOptionsPathElement(com.inova8.pathql.element.QueryOptionsPathElement) VerbObjectListContext(com.inova8.pathql.pathPattern.PathPatternParser.VerbObjectListContext) PredicateElement(com.inova8.pathql.element.PredicateElement) ArrayList(java.util.ArrayList) VerbObjectList(com.inova8.pathql.element.VerbObjectList) FactFilterElement(com.inova8.pathql.element.FactFilterElement)

Example 2 with ObjectListValueElement

use of com.inova8.pathql.element.ObjectListValueElement in project com.inova8.intelligentgraph by peterjohnlawrence.

the class PathPatternVisitor method visitObjectList.

/**
 * Visit object list.
 *
 * @param ctx the ctx
 * @return the object list value element
 */
@Override
public ObjectListValueElement visitObjectList(ObjectListContext ctx) {
    // objectList : object ( ',' object )*;
    // object : iriRef  | literal | factFilterPattern | BINDVARIABLE  ;
    ArrayList<ObjectElement> objectList = new ArrayList<ObjectElement>();
    for (ObjectContext objectContext : ctx.object()) {
        if (objectContext.iriRef() != null) {
            objectList.add((ObjectElement) visit(objectContext.iriRef()));
        } else if (objectContext.literal() != null) {
            objectList.add((ObjectElement) visit(objectContext.literal()));
        } else if (objectContext.factFilterPattern() != null) {
            objectList.add((ObjectElement) visit(objectContext.factFilterPattern()));
        } else if (objectContext.BINDVARIABLE() != null) {
            String bindVariableIndex = objectContext.BINDVARIABLE().getText().substring(1);
            BindVariableElement bindVariableElement = new BindVariableElement(this.repositoryContext);
            bindVariableElement.setBindVariableIndex(Integer.parseInt(bindVariableIndex));
            objectList.add((ObjectElement) bindVariableElement);
        }
    }
    ObjectListValueElement objectListElement = new ObjectListValueElement(this.repositoryContext);
    objectListElement.setObjectList(objectList);
    return objectListElement;
}
Also used : ObjectListValueElement(com.inova8.pathql.element.ObjectListValueElement) BindVariableElement(com.inova8.pathql.element.BindVariableElement) ArrayList(java.util.ArrayList) ObjectElement(com.inova8.pathql.element.ObjectElement) ObjectContext(com.inova8.pathql.pathPattern.PathPatternParser.ObjectContext)

Aggregations

ObjectListValueElement (com.inova8.pathql.element.ObjectListValueElement)2 ArrayList (java.util.ArrayList)2 AlternativePathElement (com.inova8.pathql.element.AlternativePathElement)1 BindVariableElement (com.inova8.pathql.element.BindVariableElement)1 BoundPathElement (com.inova8.pathql.element.BoundPathElement)1 FactFilterElement (com.inova8.pathql.element.FactFilterElement)1 FilterOperatorValueElement (com.inova8.pathql.element.FilterOperatorValueElement)1 IriRefValueElement (com.inova8.pathql.element.IriRefValueElement)1 LiteralValueElement (com.inova8.pathql.element.LiteralValueElement)1 ObjectElement (com.inova8.pathql.element.ObjectElement)1 PathElement (com.inova8.pathql.element.PathElement)1 PredicateElement (com.inova8.pathql.element.PredicateElement)1 QueryOptionsPathElement (com.inova8.pathql.element.QueryOptionsPathElement)1 SequencePathElement (com.inova8.pathql.element.SequencePathElement)1 ValueElement (com.inova8.pathql.element.ValueElement)1 VerbObjectList (com.inova8.pathql.element.VerbObjectList)1 ObjectContext (com.inova8.pathql.pathPattern.PathPatternParser.ObjectContext)1 VerbObjectListContext (com.inova8.pathql.pathPattern.PathPatternParser.VerbObjectListContext)1