当前位置: 首页>>代码示例>>Java>>正文


Java Generator.escape方法代码示例

本文整理汇总了Java中com.google.gwt.core.ext.Generator.escape方法的典型用法代码示例。如果您正苦于以下问题:Java Generator.escape方法的具体用法?Java Generator.escape怎么用?Java Generator.escape使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwt.core.ext.Generator的用法示例。


在下文中一共展示了Generator.escape方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getValueToOutput

import com.google.gwt.core.ext.Generator; //导入方法依赖的package包/类
private static <T> String getValueToOutput(Key<T> key, T instance) {
  Type type = key.getTypeLiteral().getType();

  if (type == String.class) {
    return "\"" + Generator.escape(instance.toString()) + "\"";
  } else if (type == Class.class) {
    return toClassReference((Class<?>) instance);
  } else if (type == Character.class) {
    return "'" + (Character.valueOf('\'').equals(instance) ? "\\" : "") + instance + "'";
  } else if (type == Float.class) {
    return instance.toString() + "f";
  } else if (type == Long.class) {
    return instance.toString() + "L";
  } else if (type == Double.class) {
    return instance.toString() + "d";
  } else if (instance instanceof Number || instance instanceof Boolean) {
    return instance.toString(); // Includes int & short.
  } else if (instance instanceof Enum) {
    return toEnumReference(((Enum<?>) instance));
  } else {
    throw new IllegalArgumentException("Attempted to create a constant binding with a "
        + "non-constant type: " + type);
  }
}
 
开发者ID:google-code-export,项目名称:google-gin,代码行数:25,代码来源:BindConstantBinding.java

示例2: resolveExpression

import com.google.gwt.core.ext.Generator; //导入方法依赖的package包/类
public static String resolveExpression(String instance, String path, String prefix, String suffix) {
  String expression = path.replace(".", "().") + "()";

  if (!Strings.isNullOrEmpty(instance)) {
    expression = instance + "." + expression;
  }

  if (!Strings.isNullOrEmpty(prefix)) {
    expression = "\"" + Generator.escape(prefix) + "\" + " + expression;
  }

  if (!Strings.isNullOrEmpty(suffix)) {
    expression += " + \"" + Generator.escape(suffix) + "\"";
  }

  return expression;
}
 
开发者ID:jDramaix,项目名称:gss.gwt,代码行数:18,代码来源:CssDotPathNode.java

示例3: flushInternalStringBuilder

import com.google.gwt.core.ext.Generator; //导入方法依赖的package包/类
/**
 * Read what the internal StringBuilder used by the CompactPrinter has already built. Escape it.
 * and reset the internal StringBuilder
 * @return
 */
private String flushInternalStringBuilder() {
  String content = "\"" + Generator.escape(sb.toString()) + "\"";
  sb = new StringBuilder();

  return content;
}
 
开发者ID:jDramaix,项目名称:gss.gwt,代码行数:12,代码来源:CssPrinter.java

示例4: asLiteral

import com.google.gwt.core.ext.Generator; //导入方法依赖的package包/类
/**
 * Returns the literal value of an object that is suitable for inclusion in Java Source code.
 *
 * <p>
 * Supports all types that {@link Annotation} value can have.
 * </p>
 *
 *
 * @throws IllegalArgumentException if the type of the object does not have a java literal form.
 */
public static String asLiteral(final Object value) throws IllegalArgumentException {
  final Class<?> clazz = value.getClass();

  if (clazz.isArray()) {
    final StringBuilder sb = new StringBuilder();
    final Object[] array = (Object[]) value;

    sb.append("new " + clazz.getComponentType().getCanonicalName() + "[] {");
    boolean first = true;
    for (final Object object : array) {
      if (first) {
        first = false;
      } else {
        sb.append(',');
      }
      sb.append(asLiteral(object));
    }
    sb.append('}');
    return sb.toString();
  }

  if (value instanceof Boolean) {
    return JBooleanLiteral.get(((Boolean) value).booleanValue()).toSource();
  } else if (value instanceof Byte) {
    return JIntLiteral.get(((Byte) value).byteValue()).toSource();
  } else if (value instanceof Character) {
    return JCharLiteral.get(((Character) value).charValue()).toSource();
  } else if (value instanceof Class<?>) {
    return ((Class<?>) (Class<?>) value).getCanonicalName() + ".class";
  } else if (value instanceof Double) {
    return JDoubleLiteral.get(((Double) value).doubleValue()).toSource();
  } else if (value instanceof Enum) {
    return value.getClass().getCanonicalName() + "." + ((Enum<?>) value).name();
  } else if (value instanceof Float) {
    return JFloatLiteral.get(((Float) value).floatValue()).toSource();
  } else if (value instanceof Integer) {
    return JIntLiteral.get(((Integer) value).intValue()).toSource();
  } else if (value instanceof Long) {
    return JLongLiteral.get(((Long) value).longValue()).toSource();
  } else if (value instanceof String) {
    return '"' + Generator.escape((String) value) + '"';
  } else {
    // TODO(nchalko) handle Annotation types
    throw new IllegalArgumentException(
        value.getClass() + " can not be represented as a Java Literal.");
  }
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:58,代码来源:GwtSpecificValidatorCreator.java

示例5: translate

import com.google.gwt.core.ext.Generator; //导入方法依赖的package包/类
private String translate(final String encoded) {
  return Generator.escape(new LexerForMarkup()
    .setLinkAttributes("class=\"local-link\"")
    .lex(encoded)
    .toSource());
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:7,代码来源:ElementalGenerator.java

示例6: toCss

import com.google.gwt.core.ext.Generator; //导入方法依赖的package包/类
@Override
public String toCss() {
  return Generator.escape(value);
}
 
开发者ID:jDramaix,项目名称:gss.gwt,代码行数:5,代码来源:SimpleValue.java

示例7: escape

import com.google.gwt.core.ext.Generator; //导入方法依赖的package包/类
/**
 * @param text
 * @return
 */
protected String escape(final String text) {
  return Generator.escape(text);
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:8,代码来源:AbstractHtmlGenerator.java


注:本文中的com.google.gwt.core.ext.Generator.escape方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。