コード例 #1
0
    @Override
    protected String parseFromInternal(String expression) {
      if (expression.startsWith("|| ")) {
        m_isAnOr = true;
      }

      if (expression.startsWith("|| ") || expression.startsWith("&& ")) {
        expression = expression.substring(3, expression.length());
      }

      if (expression.charAt(0) == '!') {
        setNegated(true);
        expression = expression.substring(1, expression.length());
      }

      if (expression.charAt(0) != '(') {
        throw new IllegalArgumentException("Malformed expression! Was expecting a \"(\"");
      }

      expression = expression.substring(1, expression.length());

      while (expression.charAt(0) != ')') {
        int offset = 3;

        if (expression.charAt(offset) == '(') {
          ExpressionNode child = new BracketNode();
          expression = child.parseFromInternal(expression);
          m_children.add(child);
        } else {
          // must be an ExpressionClause
          ExpressionNode child = new ExpressionClause();
          expression = child.parseFromInternal(expression);
          m_children.add(child);
        }
      }

      if (m_children.size() > 0) {
        m_children.get(0).setShowAndOr(false);
      }

      return expression;
    }
コード例 #2
0
  /**
   * Initialize with respect to the incoming instance format
   *
   * @param data the incoming instance format
   */
  protected void init(Instances data) {
    m_indexOfTrueStep = -1;
    m_indexOfFalseStep = -1;
    m_connectedFormat = data;

    if (m_downstream == null) {
      return;
    }

    if (m_downstream[0] != null
        && ((BeanCommon) m_downstream[0]).getCustomName().equals(m_customNameOfTrueStep)) {
      m_indexOfTrueStep = 0;
    }
    if (m_downstream[0] != null
        && ((BeanCommon) m_downstream[0]).getCustomName().equals(m_customNameOfFalseStep)) {
      m_indexOfFalseStep = 0;
    }

    if (m_downstream[1] != null
        && ((BeanCommon) m_downstream[1]).getCustomName().equals(m_customNameOfTrueStep)) {
      m_indexOfTrueStep = 1;
    }
    if (m_downstream[1] != null
        && ((BeanCommon) m_downstream[1]).getCustomName().equals(m_customNameOfFalseStep)) {
      m_indexOfFalseStep = 1;
    }

    if (m_env == null) {
      m_env = Environment.getSystemWide();
    }

    try {
      if (m_expressionString != null && m_expressionString.length() > 0) {
        m_root = new BracketNode();
        m_root.parseFromInternal(m_expressionString);
      }
      if (m_root != null) {
        m_root.init(data, m_env);
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      stop();
      m_busy = false;
    }
  }