Package org.formulacompiler.compiler

Examples of org.formulacompiler.compiler.Operator


        _stringBuilder.append( '"' );
      }

    }
    else if (_expr instanceof ExpressionNodeForOperator) {
      final Operator operator = ((ExpressionNodeForOperator) _expr).getOperator();
      final List<ExpressionNode> arguments = _expr.arguments();
      final int argCount = arguments.size();
      final boolean parenthesesNeeded = _context != null &&
          !(operator.equals( _context ) && COMMUTATIVE_OPERATORS.contains( operator ));
      switch (argCount) {
        case 0:
          _stringBuilder.append( operator.getSymbol() );
          break;
        case 1:
          if (parenthesesNeeded) _stringBuilder.append( '(' );
          final boolean isPrefix = operator.isPrefix();
          if (isPrefix) _stringBuilder.append( operator.getSymbol() );
          append( _stringBuilder, arguments.get( 0 ), _baseCell, operator );
          if (!isPrefix) _stringBuilder.append( operator.getSymbol() );
          if (parenthesesNeeded) _stringBuilder.append( ')' );
          break;
        default:
          if (parenthesesNeeded) _stringBuilder.append( '(' );
          appendArguments( _stringBuilder, arguments, operator.getSymbol(), _baseCell, operator );
          if (parenthesesNeeded) _stringBuilder.append( ')' );
          break;
      }
    }
    else if (_expr instanceof ExpressionNodeForFunction) {
View Full Code Here


        _stringBuilder.append( '"' );
      }

    }
    else if (_expr instanceof ExpressionNodeForOperator) {
      final Operator operator = ((ExpressionNodeForOperator) _expr).getOperator();
      final List<ExpressionNode> arguments = _expr.arguments();
      final int argCount = arguments.size();
      final boolean parenthesesNeeded = _context != null &&
          !(operator.equals( _context ) && COMMUTATIVE_OPERATORS.contains( operator ));
      switch (argCount) {
        case 0:
          _stringBuilder.append( operator.getSymbol() );
          break;
        case 1:
          if (parenthesesNeeded) _stringBuilder.append( '(' );
          final boolean isPrefix = operator.isPrefix();
          if (isPrefix) _stringBuilder.append( operator.getSymbol() );
          append( _stringBuilder, arguments.get( 0 ), _baseCell, operator );
          if (!isPrefix) _stringBuilder.append( operator.getSymbol() );
          if (parenthesesNeeded) _stringBuilder.append( ')' );
          break;
        default:
          if (parenthesesNeeded) _stringBuilder.append( '(' );
          appendArguments( _stringBuilder, arguments, operator.getSymbol(), _baseCell, operator );
          if (parenthesesNeeded) _stringBuilder.append( ')' );
          break;
      }
    }
    else if (_expr instanceof ExpressionNodeForFunction) {
View Full Code Here

    }

    private ExpressionNode buildFilterByExample( int _tableCol, final String _criterion, DataType _type )
        throws CompilerException
    {
      Operator comparison = Operator.EQUAL;
      int valueStartsAt = 0;
      if (_criterion.startsWith( "=" )) {
        valueStartsAt = 1;
      }
      else if (_criterion.startsWith( "<>" )) {
View Full Code Here

    }

    private ExpressionNode buildFilterByExample( int _tableCol, String _comparison, List<ExpressionNode> _args,
        ExpressionNode _criterion )
    {
      Operator comparison;
      if (_comparison.equals( "=" )) comparison = Operator.EQUAL;
      else if (_comparison.equals( "<>" )) comparison = Operator.NOTEQUAL;
      else if (_comparison.equals( "<=" )) comparison = Operator.LESSOREQUAL;
      else if (_comparison.equals( ">=" )) comparison = Operator.GREATEROREQUAL;
      else if (_comparison.equals( "<" )) comparison = Operator.LESS;
View Full Code Here


  @Override
  protected TypedResult evaluateToConst( TypedResult... _args ) throws InterpreterException
  {
    final Operator operator = ((ExpressionNodeForOperator) node()).getOperator();
    return new ConstResult( type().compute( operator, valuesOf( _args ) ), node().getDataType() );
  }
View Full Code Here

    final void compileTest() throws CompilerException
    {
      if (this.node instanceof ExpressionNodeForOperator) {
        final ExpressionNodeForOperator opNode = (ExpressionNodeForOperator) this.node;
        final Operator operator = opNode.getOperator();

        switch (operator) {

          case EQUAL:
          case NOTEQUAL:
View Full Code Here


  protected void compileOperator( ExpressionNodeForOperator _node ) throws CompilerException
  {
    final List<ExpressionNode> args = _node.arguments();
    final Operator op = _node.getOperator();
    switch (args.size()) {

      case 0:
        throw new CompilerException.UnsupportedExpression(
            "Internal error: must have at least one argument for operator node " + _node.describe() + "." );
View Full Code Here

TOP

Related Classes of org.formulacompiler.compiler.Operator

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.