Package com.google.template.soy.javasrc.restricted

Examples of com.google.template.soy.javasrc.restricted.JavaExpr


        "Math.max(" + arg0.getText() + ", " + arg1.getText() + ")", Integer.MAX_VALUE);
  }


  @Override public JavaExpr computeForJavaSrc(List<JavaExpr> args) {
    JavaExpr arg0 = args.get(0);
    JavaExpr arg1 = args.get(1);

    return JavaCodeUtils.genJavaExprForNumberToNumberBinaryFunction(
        "Math.max", "$$max", arg0, arg1);
  }
View Full Code Here


    return new JsExpr("soy.$$getMapKeys(" + arg.getText() + ")", Integer.MAX_VALUE);
  }


  @Override public JavaExpr computeForJavaSrc(List<JavaExpr> args) {
    JavaExpr arg = args.get(0);

    return toIntegerJavaExpr(
        JavaCodeUtils.genNewListData(
            "(" + JavaCodeUtils.genMaybeCast(arg, SoyMapData.class) + ").getKeys()"));
  }
View Full Code Here

  public void testComputeForJavaSrc() {

    RoundFunction roundFunction = new RoundFunction();

    JavaExpr floatExpr = new JavaExpr("FLOAT_JAVA_CODE", FloatData.class, Integer.MAX_VALUE);
    assertEquals(new JavaExpr("com.google.template.soy.javasrc.codedeps.SoyUtils.$$round(" +
                              "FLOAT_JAVA_CODE, null)",
                              NumberData.class, Integer.MAX_VALUE),
                 roundFunction.computeForJavaSrc(ImmutableList.of(floatExpr)));

    JavaExpr numDigitsAfterPtExpr =
        new JavaExpr("NUM_DIGITS_JAVA_CODE", IntegerData.class, Integer.MAX_VALUE);
    assertEquals(new JavaExpr("com.google.template.soy.javasrc.codedeps.SoyUtils.$$round(" +
                              "FLOAT_JAVA_CODE, NUM_DIGITS_JAVA_CODE)",
                              NumberData.class, Integer.MAX_VALUE),
                 roundFunction.computeForJavaSrc(
                     ImmutableList.of(floatExpr, numDigitsAfterPtExpr)));
  }
View Full Code Here


  public void testComputeForJavaSrc() {

    FloorFunction floorFunction = new FloorFunction();
    JavaExpr expr = new JavaExpr("JAVA_CODE", FloatData.class, Integer.MAX_VALUE);
    assertEquals(
        new JavaExpr(
            "com.google.template.soy.data.restricted.IntegerData.forValue(" +
                "(int) Math.floor(JAVA_CODE.numberValue()))",
            IntegerData.class, Integer.MAX_VALUE),
        floorFunction.computeForJavaSrc(ImmutableList.of(expr)));
  }
View Full Code Here

  public void testComputeForJavaSrc() {

    MaxFunction maxFunction = new MaxFunction();

    JavaExpr expr0 = new JavaExpr("JAVA_CODE_0", IntegerData.class, Integer.MAX_VALUE);
    JavaExpr expr1 = new JavaExpr("JAVA_CODE_1", IntegerData.class, Integer.MAX_VALUE);
    assertEquals(
        new JavaExpr(
            "com.google.template.soy.data.restricted.IntegerData.forValue(" +
                "Math.max(JAVA_CODE_0.integerValue(), JAVA_CODE_1.integerValue()))",
            IntegerData.class, Integer.MAX_VALUE),
        maxFunction.computeForJavaSrc(ImmutableList.of(expr0, expr1)));

    expr0 = new JavaExpr("JAVA_CODE_0", FloatData.class, Integer.MAX_VALUE);
    expr1 = new JavaExpr("JAVA_CODE_1", FloatData.class, Integer.MAX_VALUE);
    assertEquals(
        new JavaExpr(
            "com.google.template.soy.data.restricted.FloatData.forValue(" +
                "Math.max(JAVA_CODE_0.floatValue(), JAVA_CODE_1.floatValue()))",
            FloatData.class, Integer.MAX_VALUE),
        maxFunction.computeForJavaSrc(ImmutableList.of(expr0, expr1)));

    expr0 = new JavaExpr("JAVA_CODE_0", IntegerData.class, Integer.MAX_VALUE);
    expr1 = new JavaExpr("JAVA_CODE_1", FloatData.class, Integer.MAX_VALUE);
    assertEquals(
        new JavaExpr(
            "com.google.template.soy.data.restricted.FloatData.forValue(" +
                "Math.max(JAVA_CODE_0.floatValue(), JAVA_CODE_1.floatValue()))",
            FloatData.class, Integer.MAX_VALUE),
        maxFunction.computeForJavaSrc(ImmutableList.of(expr0, expr1)));

    expr0 = new JavaExpr("JAVA_CODE_0", NumberData.class, Integer.MAX_VALUE);
    expr1 = new JavaExpr("JAVA_CODE_1", SoyData.class, Integer.MAX_VALUE);
    assertEquals(
        new JavaExpr(
            "com.google.template.soy.javasrc.codedeps.SoyUtils.$$max(" +
                "JAVA_CODE_0," +
                " (com.google.template.soy.data.restricted.NumberData) JAVA_CODE_1)",
            NumberData.class, Integer.MAX_VALUE),
        maxFunction.computeForJavaSrc(ImmutableList.of(expr0, expr1)));
View Full Code Here

  public void testComputeForJavaSrc() {

    LengthFunction lengthFunction = new LengthFunction();

    JavaExpr expr = new JavaExpr("JAVA_CODE", SoyListData.class, Integer.MAX_VALUE);
    assertEquals(
        new JavaExpr(
            "com.google.template.soy.data.restricted.IntegerData.forValue((JAVA_CODE).length())",
            IntegerData.class, Integer.MAX_VALUE),
        lengthFunction.computeForJavaSrc(ImmutableList.of(expr)));

    expr = new JavaExpr("JAVA_CODE", SoyData.class, Integer.MAX_VALUE);
    assertEquals(
        new JavaExpr(
            "com.google.template.soy.data.restricted.IntegerData.forValue(" +
                "((com.google.template.soy.data.SoyListData) JAVA_CODE).length())",
            IntegerData.class, Integer.MAX_VALUE),
        lengthFunction.computeForJavaSrc(ImmutableList.of(expr)));
  }
View Full Code Here


  public void testComputeForJavaSrc() {

    CeilingFunction ceilingFunction = new CeilingFunction();
    JavaExpr expr = new JavaExpr("JAVA_CODE", FloatData.class, Integer.MAX_VALUE);
    assertEquals(
        new JavaExpr(
            "com.google.template.soy.data.restricted.IntegerData.forValue(" +
                "(int) Math.ceil(JAVA_CODE.numberValue()))",
            IntegerData.class, Integer.MAX_VALUE),
        ceilingFunction.computeForJavaSrc(ImmutableList.of(expr)));
  }
View Full Code Here

  public void testComputeForJavaSrc() {

    KeysFunction keysFunction = new KeysFunction();

    JavaExpr expr = new JavaExpr("JAVA_CODE", SoyMapData.class, Integer.MAX_VALUE);
    assertEquals(
        new JavaExpr(
            "new com.google.template.soy.data.SoyListData((JAVA_CODE).getKeys())",
            IntegerData.class, Integer.MAX_VALUE),
        keysFunction.computeForJavaSrc(ImmutableList.of(expr)));

    expr = new JavaExpr("JAVA_CODE", SoyData.class, Integer.MAX_VALUE);
    assertEquals(
        new JavaExpr(
            "new com.google.template.soy.data.SoyListData(" +
                "((com.google.template.soy.data.SoyMapData) JAVA_CODE).getKeys())",
            IntegerData.class, Integer.MAX_VALUE),
        keysFunction.computeForJavaSrc(ImmutableList.of(expr)));
  }
View Full Code Here

  }


  @Override
  public JavaExpr applyForJavaSrc(JavaExpr value, List<JavaExpr> args) {
    return new JavaExpr(
        JavaCodeUtils.genNewStringData(
            JavaCodeUtils.genFunctionCall(
                JavaCodeUtils.UTILS_LIB + ".$$" + name.substring(1),
                JavaCodeUtils.genMaybeCast(value, SoyData.class))),
        StringData.class, Integer.MAX_VALUE);
View Full Code Here

    return new JsExpr("soy.$$changeNewlineToBr(" + value.getText() + ")", Integer.MAX_VALUE);
  }


  @Override public JavaExpr applyForJavaSrc(JavaExpr value, List<JavaExpr> args) {
    return new JavaExpr(
        JavaCodeUtils.genFunctionCall(
            JavaCodeUtils.UTILS_LIB + ".$$changeNewlineToBr", value.getText()),
        String.class, Integer.MAX_VALUE);
  }
View Full Code Here

TOP

Related Classes of com.google.template.soy.javasrc.restricted.JavaExpr

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.