Exemplo n.º 1
0
  public void appendScript(Appendable target) throws IOException {
    target.append(name).append('(');

    boolean first = true;
    List<?> parameters = getParameters();

    if (null != parameters) {
      for (Iterator<?> param = parameters.iterator(); param.hasNext(); ) {
        Object element = param.next();

        if (!first) {
          target.append(',');
        }

        if (null != element) {
          ScriptUtils.appendScript(target, element);
        } else {
          target.append("null");
        }

        first = false;
      }
    }

    target.append(")");
  }
Exemplo n.º 2
0
  @Override
  public Object execute(MapperContext ctx) {
    Element srcElement = null;
    Element startSrcElement = ScriptUtils.getStartElement(ctx);
    Path startfullPath = startSrcElement.getFormat().getFullPath();
    if (path.toString().startsWith(startfullPath.toString())) {
      srcElement = startSrcElement;
    } else {
      Element rootSrcElement = ctx.getRootSourceElement();
      Path rootFullPath = rootSrcElement.getFormat().getFullPath();
      if (path.toString().startsWith(rootFullPath.toString())) srcElement = rootSrcElement;
      else throw new RuntimeException(String.format("Wrong path '%s'", path));
    }
    Path currentPath = path.removeLeft(srcElement.getLevel() + 1);
    Element find = srcElement.getChildByPath(currentPath);
    if (find.getFormat().getType() != Type.NONE && find.getValue() != null)
      return find.getValue().get();

    return null;
  }