Search in sources :

Example 1 with BindVariableElement

use of com.inova8.pathql.element.BindVariableElement 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

BindVariableElement (com.inova8.pathql.element.BindVariableElement)1 ObjectElement (com.inova8.pathql.element.ObjectElement)1 ObjectListValueElement (com.inova8.pathql.element.ObjectListValueElement)1 ObjectContext (com.inova8.pathql.pathPattern.PathPatternParser.ObjectContext)1 ArrayList (java.util.ArrayList)1