private void addElementsToProperties(List elements, Properties props, String parentPath) {

    for (java.lang.Object o : elements) {
      Node ele = (Node) o;
      if (ele.getNodeType() != 1) { // text
        continue;
      }
      String contents = ele.getText().trim();

      String newParentPath = "";

      if (!StringUtils.isEmpty(parentPath)) {
        newParentPath = parentPath + ".";
      }
      newParentPath += ele.getName();

      if (!StringUtils.isEmpty(contents)) {
        props.setProperty(newParentPath, contents);
      }
      if (ele instanceof Element) {
        List children = ((Element) ele).content();

        addElementsToProperties(children, props, newParentPath);
      }
    }
  }
  public Map createVariableContext(
      final String className,
      final String text,
      final ProcessBuildContext context,
      final String[] globals) {
    final Map map = new HashMap();

    map.put("methodName", className);

    map.put("package", context.getPkg().getName());

    map.put("processClassName", StringUtils.ucFirst(context.getProcessDescr().getClassName()));

    map.put(
        "invokerClassName",
        context.getProcessDescr().getClassName() + StringUtils.ucFirst(className) + "Invoker");

    if (text != null) {
      map.put("text", text);

      map.put("hashCode", new Integer(text.hashCode()));
    }

    final List globalTypes = new ArrayList(globals.length);
    for (int i = 0, length = globals.length; i < length; i++) {
      globalTypes.add(context.getPkg().getGlobals().get(globals[i]).replace('$', '.'));
    }

    map.put("globals", globals);

    map.put("globalTypes", globalTypes);

    return map;
  }
  public void setProperty(String name, String value) {
    name = name.trim();
    if (StringUtils.isEmpty(name)) {
      return;
    }

    if (name.equals("drools.dialect.default")) {
      setDefaultDialect(value);
    } else if (name.startsWith("drools.accumulate.function")) {
      addAccumulateFunction(name.substring(name.lastIndexOf('.')), value);
    } else if (name.startsWith("drools.evaluator.")) {
      this.evaluatorRegistry.addEvaluatorDefinition(value);
    } else if (name.equals("drools.dump.dir")) {
      buildDumpDirectory(value);
    } else if (name.equals(DROOLS_PARSER_PROCESS_STRING_ESCAPES)) {
      setProcessStringEscapes(Boolean.parseBoolean(value));
    }
  }
  public void generatTemplates(
      final String ruleTemplate,
      final String invokerTemplate,
      final ProcessBuildContext context,
      final String className,
      final Map vars,
      final Object invokerLookup,
      final BaseDescr descrLookup) {
    TemplateRegistry registry = getRuleTemplateRegistry();

    context
        .getMethods()
        .add(
            TemplateRuntime.execute(
                registry.getNamedTemplate(ruleTemplate),
                null,
                new MapVariableResolverFactory(vars),
                registry));

    registry = getInvokerTemplateRegistry();
    final String invokerClassName =
        context.getPkg().getName()
            + "."
            + context.getProcessDescr().getClassName()
            + StringUtils.ucFirst(className)
            + "Invoker";

    context
        .getInvokers()
        .put(
            invokerClassName,
            TemplateRuntime.execute(
                registry.getNamedTemplate(invokerTemplate),
                null,
                new MapVariableResolverFactory(vars),
                registry));

    context.getInvokerLookups().put(invokerClassName, invokerLookup);
    context.getDescrLookups().put(invokerClassName, descrLookup);
  }
  public String getProperty(String name) {
    name = name.trim();
    if (StringUtils.isEmpty(name)) {
      return null;
    }

    if (name.equals("drools.dialect.default")) {
      return getDefaultDialect();
    } else if (name.startsWith("drools.accumulate.function")) {
      return this.accumulateFunctions.get(name);
    } else if (name.startsWith("drools.evaluator.")) {
      return this.evaluatorRegistry
          .getEvaluatorDefinition(name.substring(name.lastIndexOf('.')))
          .getClass()
          .getName();
    } else if (name.equals("drools.dump.dir")) {
      return Boolean.toString(this.dumpDirectory != null);
    } else if (name.equals(DROOLS_PARSER_PROCESS_STRING_ESCAPES)) {
      return String.valueOf(isProcessStringEscapes());
    }
    return null;
  }