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

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


  }


  @Override public JavaExpr applyForJavaSrc(JavaExpr value, List<JavaExpr> args) {

    return new JavaExpr(
        JavaCodeUtils.genFunctionCall(
            JavaCodeUtils.UTILS_LIB + ".$$insertWordBreaks",
            JavaCodeUtils.genCoerceString(value),
            JavaCodeUtils.genIntegerValue(args.get(0))),
        String.class, Integer.MAX_VALUE);
View Full Code Here


    String valueExprText = JavaCodeUtils.genCoerceString(value);
    String maxLenExprText = JavaCodeUtils.genIntegerValue(args.get(0));
    String doAddEllipsisExprText =
        (args.size() == 2) ? JavaCodeUtils.genBooleanValue(args.get(1)) : "true" /*default*/;

    return new JavaExpr(
        JavaCodeUtils.genFunctionCall(
            JavaCodeUtils.UTILS_LIB + ".$$truncate",
            valueExprText, maxLenExprText, doAddEllipsisExprText),
        String.class, Integer.MAX_VALUE);
  }
View Full Code Here

  }


  public void testApplyForJavaSrc() {

    JavaExpr dataRef = new JavaExpr("stringValue", StringData.class, Integer.MAX_VALUE);
    assertEquals(
        "com.google.template.soy.data.restricted.StringData.forValue(" +
            "com.google.template.soy.internal.i18n.SoyBidiUtils.getBidiFormatter(" +
            "1).spanWrap(stringValue.toString(), true))",
        BIDI_SPAN_WRAP_DIRECTIVE_FOR_STATIC_LTR.applyForJavaSrc(
View Full Code Here

  }


  public void testComputeForJavaSrc() {

    JavaExpr textExpr = new JavaExpr("TEXT_JAVA_CODE", StringData.class, Integer.MAX_VALUE);
    assertEquals(
        new JavaExpr(
            "com.google.template.soy.data.restricted.StringData.forValue(" +
                "com.google.template.soy.internal.i18n.SoyBidiUtils.getBidiFormatter(" +
                "1).markAfter(TEXT_JAVA_CODE.toString(), false))",
            StringData.class, Integer.MAX_VALUE),
        BIDI_MARK_AFTER_FUNCTION_FOR_STATIC_LTR.computeForJavaSrc(ImmutableList.of(textExpr)));
    assertEquals(
        new JavaExpr(
            "com.google.template.soy.data.restricted.StringData.forValue(" +
                "com.google.template.soy.internal.i18n.SoyBidiUtils.getBidiFormatter(" +
                "IS_RTL?-1:1).markAfter(TEXT_JAVA_CODE.toString(), false))",
            StringData.class, Integer.MAX_VALUE),
        BIDI_MARK_AFTER_FUNCTION_FOR_ISRTL_CODE_SNIPPET.computeForJavaSrc(
            ImmutableList.of(textExpr)));

    JavaExpr isHtmlExpr = new JavaExpr("IS_HTML_JAVA_CODE", BooleanData.class, Integer.MAX_VALUE);
    assertEquals(
        new JavaExpr(
            "com.google.template.soy.data.restricted.StringData.forValue(" +
                "com.google.template.soy.internal.i18n.SoyBidiUtils.getBidiFormatter(" +
                "-1).markAfter(TEXT_JAVA_CODE.toString(), IS_HTML_JAVA_CODE.toBoolean()))",
            StringData.class, Integer.MAX_VALUE),
        BIDI_MARK_AFTER_FUNCTION_FOR_STATIC_RTL.computeForJavaSrc(
            ImmutableList.of(textExpr, isHtmlExpr)));
    assertEquals(
        new JavaExpr(
            "com.google.template.soy.data.restricted.StringData.forValue(" +
                "com.google.template.soy.internal.i18n.SoyBidiUtils.getBidiFormatter(" +
                "IS_RTL?-1:1).markAfter(TEXT_JAVA_CODE.toString(), IS_HTML_JAVA_CODE.toBoolean()))",
            StringData.class, Integer.MAX_VALUE),
        BIDI_MARK_AFTER_FUNCTION_FOR_ISRTL_CODE_SNIPPET.computeForJavaSrc(
View Full Code Here


  public void testComputeForJavaSrc() {

    assertEquals(
        new JavaExpr(
            "com.google.template.soy.data.restricted.IntegerData.forValue(1)",
            IntegerData.class, Integer.MAX_VALUE),
        BIDI_GLOBAL_DIR_FUNCTION_FOR_STATIC_LTR.computeForJavaSrc(ImmutableList.<JavaExpr>of()));
    assertEquals(
        new JavaExpr(
            "com.google.template.soy.data.restricted.IntegerData.forValue(-1)",
            IntegerData.class, Integer.MAX_VALUE),
        BIDI_GLOBAL_DIR_FUNCTION_FOR_STATIC_RTL.computeForJavaSrc(ImmutableList.<JavaExpr>of()));
    assertEquals(
        new JavaExpr(
            "com.google.template.soy.data.restricted.IntegerData.forValue(IS_RTL?-1:1)",
            IntegerData.class, Integer.MAX_VALUE),
        BIDI_GLOBAL_DIR_FUNCTION_FOR_ISRTL_CODE_SNIPPET.computeForJavaSrc(
            ImmutableList.<JavaExpr>of()));
  }
View Full Code Here

  }


  public void testApplyForJavaSrc() {

    JavaExpr dataRef = new JavaExpr("myKey", StringData.class, Integer.MAX_VALUE);
    assertEquals(
        "com.google.template.soy.data.restricted.StringData.forValue(" +
            "com.google.template.soy.internal.i18n.SoyBidiUtils.getBidiFormatter(" +
            "1).unicodeWrap(myKey.toString(), true))",
        BIDI_UNICODE_WRAP_DIRECTIVE_FOR_STATIC_LTR.applyForJavaSrc(
View Full Code Here


  public void testComputeForJavaSrc() {

    assertEquals(
        new JavaExpr(
            "com.google.template.soy.data.restricted.StringData.forValue(\"left\")",
            StringData.class, Integer.MAX_VALUE),
        BIDI_START_EDGE_FUNCTION_FOR_STATIC_LTR.computeForJavaSrc(ImmutableList.<JavaExpr>of()));
    assertEquals(
        new JavaExpr(
            "com.google.template.soy.data.restricted.StringData.forValue(\"right\")",
            StringData.class, Integer.MAX_VALUE),
        BIDI_START_EDGE_FUNCTION_FOR_STATIC_RTL.computeForJavaSrc(ImmutableList.<JavaExpr>of()));
    assertEquals(
        new JavaExpr(
            "com.google.template.soy.data.restricted.StringData.forValue(" +
                "com.google.template.soy.internal.i18n.SoyBidiUtils.getBidiFormatter(" +
                "IS_RTL?-1:1).startEdge())",
            StringData.class, Integer.MAX_VALUE),
        BIDI_START_EDGE_FUNCTION_FOR_ISRTL_CODE_SNIPPET.computeForJavaSrc(
View Full Code Here

                     ImmutableList.of(textExpr, isHtmlExpr)));
  }


  public void testComputeForJavaSrc() {
    JavaExpr textExpr = new JavaExpr("TEXT_JAVA_CODE", StringData.class, Integer.MAX_VALUE);
    assertEquals(
        new JavaExpr(
            "new com.google.template.soy.data.SanitizedContent(" +
                "com.google.template.soy.internal.i18n.SoyBidiUtils.getBidiFormatter(" +
                "1).dirAttr(TEXT_JAVA_CODE.toString(), false), " +
                "com.google.template.soy.data.SanitizedContent.ContentKind.ATTRIBUTES" +
            ")",
            StringData.class, Integer.MAX_VALUE),
        BIDI_DIR_ATTR_FUNCTION_FOR_STATIC_LTR.computeForJavaSrc(ImmutableList.of(textExpr)));
    assertEquals(
        new JavaExpr(
            "new com.google.template.soy.data.SanitizedContent(" +
                "com.google.template.soy.internal.i18n.SoyBidiUtils.getBidiFormatter(" +
                "IS_RTL?-1:1).dirAttr(TEXT_JAVA_CODE.toString(), false), " +
                "com.google.template.soy.data.SanitizedContent.ContentKind.ATTRIBUTES" +
            ")",
            StringData.class, Integer.MAX_VALUE),
        BIDI_DIR_ATTR_FUNCTION_FOR_ISRTL_CODE_SNIPPET.computeForJavaSrc(
            ImmutableList.of(textExpr)));

    JavaExpr isHtmlExpr = new JavaExpr("IS_HTML_JAVA_CODE", BooleanData.class, Integer.MAX_VALUE);
    assertEquals(
        new JavaExpr(
            "new com.google.template.soy.data.SanitizedContent(" +
                "com.google.template.soy.internal.i18n.SoyBidiUtils.getBidiFormatter(" +
                "-1).dirAttr(TEXT_JAVA_CODE.toString(), IS_HTML_JAVA_CODE.toBoolean()), " +
                "com.google.template.soy.data.SanitizedContent.ContentKind.ATTRIBUTES" +
            ")",
            StringData.class, Integer.MAX_VALUE),
        BIDI_DIR_ATTR_FUNCTION_FOR_STATIC_RTL.computeForJavaSrc(
            ImmutableList.of(textExpr, isHtmlExpr)));
    assertEquals(
        new JavaExpr(
            "new com.google.template.soy.data.SanitizedContent(" +
                "com.google.template.soy.internal.i18n.SoyBidiUtils.getBidiFormatter(" +
                "IS_RTL?-1:1).dirAttr(TEXT_JAVA_CODE.toString(), IS_HTML_JAVA_CODE.toBoolean()), " +
                "com.google.template.soy.data.SanitizedContent.ContentKind.ATTRIBUTES" +
            ")",
View Full Code Here

  public void testComputeForJavaSrc() {

    BidiTextDirFunction bidiTextDirFunction = new BidiTextDirFunction();

    JavaExpr textExpr = new JavaExpr("TEXT_JAVA_CODE", StringData.class, Integer.MAX_VALUE);
    assertEquals(
        new JavaExpr(
            "com.google.template.soy.data.restricted.IntegerData.forValue(" +
                "com.google.template.soy.internal.i18n.BidiUtils.estimateDirection(" +
                "TEXT_JAVA_CODE.toString(), false" +
                ").ord)",
            IntegerData.class, Integer.MAX_VALUE),
        bidiTextDirFunction.computeForJavaSrc(ImmutableList.of(textExpr)));

    JavaExpr isHtmlExpr = new JavaExpr("IS_HTML_JAVA_CODE", BooleanData.class, Integer.MAX_VALUE);
    assertEquals(
        new JavaExpr(
            "com.google.template.soy.data.restricted.IntegerData.forValue(" +
                "com.google.template.soy.internal.i18n.BidiUtils.estimateDirection(" +
                "TEXT_JAVA_CODE.toString(), IS_HTML_JAVA_CODE.toBoolean()" +
                ").ord)",
            IntegerData.class, Integer.MAX_VALUE),
View Full Code Here


  public void testComputeForJavaSrc() {

    assertEquals(
        new JavaExpr(
            "com.google.template.soy.data.restricted.StringData.forValue(\"\\u200E\")",
            StringData.class, Integer.MAX_VALUE),
        BIDI_MARK_FUNCTION_FOR_STATIC_LTR.computeForJavaSrc(ImmutableList.<JavaExpr>of()));
    assertEquals(
        new JavaExpr(
            "com.google.template.soy.data.restricted.StringData.forValue(\"\\u200F\")",
            StringData.class, Integer.MAX_VALUE),
        BIDI_MARK_FUNCTION_FOR_STATIC_RTL.computeForJavaSrc(ImmutableList.<JavaExpr>of()));
    assertEquals(
        new JavaExpr(
            "com.google.template.soy.data.restricted.StringData.forValue(" +
                "com.google.template.soy.internal.i18n.SoyBidiUtils.getBidiFormatter(" +
                "IS_RTL?-1:1).mark())",
            StringData.class, Integer.MAX_VALUE),
        BIDI_MARK_FUNCTION_FOR_ISRTL_CODE_SNIPPET.computeForJavaSrc(ImmutableList.<JavaExpr>of()));
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.