本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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.");
}
}
示例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());
}
示例6: toCss
import com.google.gwt.core.ext.Generator; //导入方法依赖的package包/类
@Override
public String toCss() {
return Generator.escape(value);
}
示例7: escape
import com.google.gwt.core.ext.Generator; //导入方法依赖的package包/类
/**
* @param text
* @return
*/
protected String escape(final String text) {
return Generator.escape(text);
}