本文整理汇总了Java中org.apache.commons.lang.StringEscapeUtils.escapeJava方法的典型用法代码示例。如果您正苦于以下问题:Java StringEscapeUtils.escapeJava方法的具体用法?Java StringEscapeUtils.escapeJava怎么用?Java StringEscapeUtils.escapeJava使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang.StringEscapeUtils
的用法示例。
在下文中一共展示了StringEscapeUtils.escapeJava方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTagNodeRef
import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
/**
* Gets the node reference for a given tag.
* <p>
* Returns null if tag is not present and not created.
*
* @param storeRef store reference
* @param tag tag
* @param create create a node if one doesn't exist?
* @return NodeRef tag node reference or null not exist
*/
private NodeRef getTagNodeRef(StoreRef storeRef, String tag, boolean create)
{
for (String forbiddenSequence : FORBIDDEN_TAGS_SEQUENCES)
{
if (create && tag.contains(forbiddenSequence))
{
throw new IllegalArgumentException("Tag name must not contain " + StringEscapeUtils.escapeJava(forbiddenSequence) + " char sequence");
}
}
NodeRef tagNodeRef = null;
Collection<ChildAssociationRef> results = this.categoryService.getRootCategories(storeRef, ContentModel.ASPECT_TAGGABLE, tag, create);
if (!results.isEmpty())
{
tagNodeRef = results.iterator().next().getChildRef();
}
return tagNodeRef;
}
示例2: scalar
import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
@Override
public String scalar(Object value, Inspection options) {
if(options.quote()) {
if(value instanceof Character) {
final char c = (char) value;
switch(c) {
case '\'': return "'\\''";
case '"': return "'\"'";
default: return "'" + StringEscapeUtils.escapeJava(String.valueOf(c)) + "'";
}
} else if(value instanceof String) {
return "\"" + StringEscapeUtils.escapeJava((String) value) + "\"";
}
}
if(value instanceof Class) {
// Short class names are usually enough
return ((Class) value).getSimpleName();
}
// everything else
return String.valueOf(value);
}
示例3: tearDown
import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
@After
public void tearDown() throws Exception {
if (json != null) {
// So we can see what's going on
// System.out.println("JSON: " + json);
// To make it easy to replace expected JSON values in the code when we're sure they're correct
@SuppressWarnings("unused")
String javaLiteralForJSONString = '"' + StringEscapeUtils.escapeJava(json) + '"';
// System.out.println("Java literal:\n" + javaLiteralForJSONString);
}
json = null;
marshaller = null;
ActivemqConnectorService.setJsonMarshaller(null);
}
示例4: wrapSafeString
import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
private static String wrapSafeString(String label) {
if (label.indexOf(',') >= 0) {
if (label.length()>14) {
label = label.replaceAll(",", ",\n");
}
}
label = "\"" + StringEscapeUtils.escapeJava(label) + "\"";
return label;
}
示例5: escapeValue
import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
@SuppressWarnings("nls")
private String escapeValue(Object value)
{
String escapedValue = StringEscapeUtils.escapeJava(String.valueOf(value));
return StringUtils.replace(escapedValue, "\\/", "/");
}
示例6: escapeString
import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
/**
* Escapes the toString() representation of {@code obj} for use in a literal string.
* This is useful for interpolating variables into script strings, as well as in other situations.
*/
public static String escapeString(Object obj) {
return obj == null ? null : StringEscapeUtils.escapeJava(obj.toString());
}