Package org.dbwiki.data.query.xpath

Examples of org.dbwiki.data.query.xpath.XPathComponent


    SchemaNode entity = ((GroupSchemaNode)parentEntity).children().get(entityName);
    if (entity == null) {
      throw new WikiQueryException(WikiQueryException.InvalidQueryStatement, "Unknown entity " + entityName + " as child of " + parentEntity.label());
    }
   
    XPathComponent pathElement = null;
    if (token.children().size() == 2) {
      XAQLToken conditionToken = token.children().get(1);
      if (conditionToken.type() == XAQLToken.INDEX_CONDITION) {
        int index = -1;
        try {
          index = Integer.parseInt(conditionToken.children().firstElement().value());
        } catch (java.lang.NumberFormatException nfe) {
          throw new WikiQueryException(WikiQueryException.InvalidQueryStatement, "Invalid number format " + conditionToken.children().firstElement().value());
        }
        pathElement = new XPathComponent(entity, new IndexCondition(index));
      } else {
        Condition condition = null;
        if (conditionToken.children().size() > 1) {
          Conjunction conjunction = new Conjunction();
          for (int iCondition = 0; iCondition < conditionToken.children().size(); iCondition++) {
            conjunction.add(new ConditionGenerator().getCondition(entity, versionIndex, conditionToken.children().get(iCondition).children(), this));
          }
          condition = conjunction;
        } else {
          condition = new ConditionGenerator().getCondition(entity, versionIndex, conditionToken.children().get(0).children(), this);
        }
        pathElement = new XPathComponent(entity, new SubPathCondition(condition));
      }
    } else {
      pathElement = new XPathComponent(entity);
    }
   
    if (pathTokens.hasNext()) {
      return new XPath(pathElement, new RelativeTargetPathGenerator().getTargetPath(entity, versionIndex, pathTokens));
    } else {
View Full Code Here


    String entityName = token.children().firstElement().value();
    if (!rootEntity.label().equals(entityName)) {
      throw new WikiQueryException(WikiQueryException.InvalidQueryStatement, "Unknown entity " + entityName + " as root of the database");
    }
   
    XPathComponent pathElement = null;
    if (token.children().size() == 2) {
      XAQLToken conditionToken = token.children().get(1);
      if (conditionToken.type() == XAQLToken.INDEX_CONDITION) {
        int index = -1;
        try {
          index = Integer.parseInt(conditionToken.children().firstElement().value());
        } catch (java.lang.NumberFormatException nfe) {
          throw new WikiQueryException(WikiQueryException.InvalidQueryStatement, "Invalid number format " + conditionToken.children().firstElement().value());
        }
        pathElement = new XPathComponent(rootEntity, new IndexCondition(index));
      } else {
        Condition condition = null;
        if (conditionToken.children().size() > 1) {
          Conjunction conjunction = new Conjunction();
          for (int iCondition = 0; iCondition < conditionToken.children().size(); iCondition++) {
            conjunction.add(new ConditionGenerator().getCondition(rootEntity, versionIndex, conditionToken.children().get(iCondition).children(), new RelativeTargetPathGenerator()));
          }
          condition = conjunction;
        } else {
          condition = new ConditionGenerator().getCondition(rootEntity, versionIndex, conditionToken.children().get(0).children(), new RelativeTargetPathGenerator());
        }
        pathElement = new XPathComponent(rootEntity, new SubPathCondition(condition));
      }
    } else {
      pathElement = new XPathComponent(rootEntity);
    }
   
    if (pathTokens.hasNext()) {
      return new XPath(pathElement, new RelativeTargetPathGenerator().getTargetPath(rootEntity, versionIndex, pathTokens));
    } else {
View Full Code Here

TOP

Related Classes of org.dbwiki.data.query.xpath.XPathComponent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.