本文整理匯總了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());
}