當前位置: 首頁>>代碼示例>>Java>>正文


Java StringEscapeUtils.escapeJava方法代碼示例

本文整理匯總了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;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:29,代碼來源:TaggingServiceImpl.java

示例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);
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:24,代碼來源:TextInspector.java

示例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);
	}
 
開發者ID:eclipse,項目名稱:scanning,代碼行數:16,代碼來源:ActivemqConnectorServiceJsonMarshallingTest.java

示例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;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:10,代碼來源:Graph.java

示例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, "\\/", "/");
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:7,代碼來源:ExtendedPropertiesLayout.java

示例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());
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:8,代碼來源:TextUtil.java


注:本文中的org.apache.commons.lang.StringEscapeUtils.escapeJava方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。