Package com.google.template.soy.data

Examples of com.google.template.soy.data.SoyData


  }


  @Override protected SoyData visitNotOpNode(NotOpNode node) {

    SoyData operand = visit(node.getChild(0));
    return convertResult( ! operand.toBoolean() );
  }
View Full Code Here


  }


  @Override protected SoyData visitTimesOpNode(TimesOpNode node) {

    SoyData operand0 = visit(node.getChild(0));
    SoyData operand1 = visit(node.getChild(1));
    if (operand0 instanceof IntegerData && operand1 instanceof IntegerData) {
      return convertResult(operand0.integerValue() * operand1.integerValue());
    } else {
      return convertResult(operand0.numberValue() * operand1.numberValue());
    }
  }
View Full Code Here

  }


  @Override protected SoyData visitDivideByOpNode(DivideByOpNode node) {

    SoyData operand0 = visit(node.getChild(0));
    SoyData operand1 = visit(node.getChild(1));
    // Note: Soy always performs floating-point division, even on two integers (like JavaScript).
    return convertResult(operand0.numberValue() / operand1.numberValue());
  }
View Full Code Here

  }


  @Override protected SoyData visitModOpNode(ModOpNode node) {

    SoyData operand0 = visit(node.getChild(0));
    SoyData operand1 = visit(node.getChild(1));
    return convertResult(operand0.integerValue() % operand1.integerValue());
  }
View Full Code Here

  // Private helpers.


  @Override protected SoyData resolveDataRefFirstKey(DataRefNode dataRefNode) {

    SoyData value = super.resolveDataRefFirstKey(dataRefNode);
    if (value instanceof UndefinedData) {
      throw new RenderException("Encountered undefined reference during preevaluation.");
    }
    return value;
  }
View Full Code Here

  }


  @Override protected SoyData visitPlusOpNode(PlusOpNode node) {

    SoyData operand0 = visit(node.getChild(0));
    SoyData operand1 = visit(node.getChild(1));
    if (operand0 instanceof IntegerData && operand1 instanceof IntegerData) {
      return convertResult(operand0.integerValue() + operand1.integerValue());
    } else if (operand0 instanceof StringData || operand1 instanceof StringData) {
      // String concatenation. Note we're calling toString() instead of stringValue() in case one
      // of the operands needs to be coerced to a string.
      return convertResult(operand0.toString() + operand1.toString());
    } else {
      return convertResult(operand0.numberValue() + operand1.numberValue());
    }
  }
View Full Code Here

  }


  @Override protected SoyData visitMinusOpNode(MinusOpNode node) {

    SoyData operand0 = visit(node.getChild(0));
    SoyData operand1 = visit(node.getChild(1));
    if (operand0 instanceof IntegerData && operand1 instanceof IntegerData) {
      return convertResult(operand0.integerValue() - operand1.integerValue());
    } else {
      return convertResult(operand0.numberValue() - operand1.numberValue());
    }
  }
View Full Code Here

  }


  @Override protected SoyData visitLessThanOpNode(LessThanOpNode node) {

    SoyData operand0 = visit(node.getChild(0));
    SoyData operand1 = visit(node.getChild(1));
    if (operand0 instanceof IntegerData && operand1 instanceof IntegerData) {
      return convertResult(operand0.integerValue() < operand1.integerValue());
    } else {
      return convertResult(operand0.numberValue() < operand1.numberValue());
    }
  }
View Full Code Here

  }


  @Override protected SoyData visitGreaterThanOpNode(GreaterThanOpNode node) {

    SoyData operand0 = visit(node.getChild(0));
    SoyData operand1 = visit(node.getChild(1));
    if (operand0 instanceof IntegerData && operand1 instanceof IntegerData) {
      return convertResult(operand0.integerValue() > operand1.integerValue());
    } else {
      return convertResult(operand0.numberValue() > operand1.numberValue());
    }
  }
View Full Code Here

  }


  @Override protected SoyData visitLessThanOrEqualOpNode(LessThanOrEqualOpNode node) {

    SoyData operand0 = visit(node.getChild(0));
    SoyData operand1 = visit(node.getChild(1));
    if (operand0 instanceof IntegerData && operand1 instanceof IntegerData) {
      return convertResult(operand0.integerValue() <= operand1.integerValue());
    } else {
      return convertResult(operand0.numberValue() <= operand1.numberValue());
    }
  }
View Full Code Here

TOP

Related Classes of com.google.template.soy.data.SoyData

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.