当前位置: 首页>>代码示例>>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;未经允许,请勿转载。