Package org.apache.cocoon.precept.stores.dom.simple

Examples of org.apache.cocoon.precept.stores.dom.simple.Node


  private Node createNode(String xpath) throws InvalidXPathSyntaxException {
    try {
      StringBuffer currentPath = new StringBuffer();
      StringTokenizer tok = new StringTokenizer(xpath, "/", false);
      Node currentParent = root;
      boolean first = true;
      while (tok.hasMoreTokens()) {
        String level = tok.nextToken();
        if (!first) {
          currentPath.append("/");
        }
        else {
          first = false;
        }
        if (level.endsWith("[1]")) {
          level = level.substring(0, level.length() - 3);
        }
        currentPath.append(level);
        Node node = (Node) index.get(currentPath.toString());
        if (node != null) {
          getLogger().debug("found node [" + String.valueOf(currentPath) + "] in index");
          currentParent = node;
        }
        else {
View Full Code Here


  public void setValue(String xpath, Object value) throws PreceptorViolationException, InvalidXPathSyntaxException {
    setValue(xpath, value, null);
  }

  public void setValue(String xpath, Object value, Context context) throws PreceptorViolationException, InvalidXPathSyntaxException {
    Node node = (Node) index.get(xpath);
    if (node != null) {
      node.setValue((String) value);
    }
    else {
      if (preceptor != null) {
        getLogger().debug("checking preceptor for [" + String.valueOf(xpath) + "]");
        if (preceptor.isValidNode(xpath)) {
          node = createNode(xpath);
          node.setValue((String) value);
        }
        else {
          throw new PreceptorViolationException("[" + String.valueOf(xpath) + "] is prohibited by preceptor");
        }
      }
      else {
        getLogger().debug("no preceptor");
        node = createNode(xpath);
        node.setValue((String) value);
      }
    }
  }
View Full Code Here

      }
    }
  }

  public Object getValue(String xpath) throws InvalidXPathSyntaxException, NoSuchNodeException {
    Node node = (Node) index.get(xpath);
    if (node != null) {
      return (node.getValue());
    }
    else {
      throw new NoSuchNodeException(xpath);
    }
  }
View Full Code Here

    }
    return (all);
  }

  public List validate(String xpath, Context context) throws InvalidXPathSyntaxException, NoSuchNodeException {
    Node node = (Node) index.get(xpath);
    if (node != null) {
      ArrayList result = null;
      List constraints = node.getConstraints();
      if (constraints != null) {
        for (Iterator it = constraints.iterator(); it.hasNext();) {
          Constraint constraint = (Constraint) it.next();
          if (constraint.isSatisfiedBy(getValue(xpath), context )) {
            getLogger().debug("[" + String.valueOf(xpath) + "] constraint [" + String.valueOf(constraint) + "] is satisfied");
View Full Code Here

  private Node createNode(String xpath) throws InvalidXPathSyntaxException {
    try {
      StringBuffer currentPath = new StringBuffer();
      StringTokenizer tok = new StringTokenizer(xpath, "/", false);
      Node currentParent = root;
      boolean first = true;
      while (tok.hasMoreTokens()) {
        String level = tok.nextToken();
        if (!first) {
          currentPath.append("/");
        }
        else {
          first = false;
        }
        if (level.endsWith("[1]")) {
          level = level.substring(0, level.length() - 3);
        }
        currentPath.append(level);
        Node node = (Node) index.get(currentPath.toString());
        if (node != null) {
          getLogger().debug("found node [" + String.valueOf(currentPath) + "] in index");
          currentParent = node;
        }
        else {
View Full Code Here

      return (null);
    }
  }

  private Node lookupNode( String xpath ) {
    Node node = (Node) index.get(xpath);
    if (node == null) {
      node = (Node) index.get(xpath + "[1]");
    }
    return(node);
  }
View Full Code Here

  public void setValue(String xpath, Object value) throws PreceptorViolationException, InvalidXPathSyntaxException {
    setValue(xpath, value, null);
  }

  public void setValue(String xpath, Object value, Context context) throws PreceptorViolationException, InvalidXPathSyntaxException {
    Node node = lookupNode(xpath);

    if (node != null) {
      node.setValue((String) value);
    }
    else {
      if (preceptor != null) {
        getLogger().debug("checking preceptor for [" + String.valueOf(xpath) + "]");
        if (preceptor.isValidNode(xpath)) {
          node = createNode(xpath);
          node.setValue((String) value);
        }
        else {
          throw new PreceptorViolationException("[" + String.valueOf(xpath) + "] is prohibited by preceptor");
        }
      }
      else {
        getLogger().debug("no preceptor");
        node = createNode(xpath);
        node.setValue((String) value);
      }
    }
  }
View Full Code Here

      }
    }
  }

  public Object getValue(String xpath) throws InvalidXPathSyntaxException, NoSuchNodeException {
    Node node = lookupNode(xpath);
    if (node != null) {
      return (node.getValue());
    }
    else {
      throw new NoSuchNodeException(xpath);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.cocoon.precept.stores.dom.simple.Node

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.