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


Java StringEscapeUtils類代碼示例

本文整理匯總了Java中org.apache.commons.lang3.StringEscapeUtils的典型用法代碼示例。如果您正苦於以下問題:Java StringEscapeUtils類的具體用法?Java StringEscapeUtils怎麽用?Java StringEscapeUtils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


StringEscapeUtils類屬於org.apache.commons.lang3包,在下文中一共展示了StringEscapeUtils類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: encodeURIinUTF8

import org.apache.commons.lang3.StringEscapeUtils; //導入依賴的package包/類
public static String encodeURIinUTF8(String uri) {
    if (uri.startsWith("<http://dbpedia.org/resource/")) {            
        int splitPoint = uri.lastIndexOf("/")+1;
        String infix = uri.substring(splitPoint, uri.length()-1);
        if (infix.contains("%")) {
            return uri;
        }
        try {
            infix = infix.replace("\\\\", "\\");
            infix = StringEscapeUtils.unescapeJava(infix);
            infix = URLEncoder.encode(infix, "UTF-8");            
        } catch (UnsupportedEncodingException ex) {
            System.err.println("Encoding exception: "+ex);
        }
        uri = uri.substring(0, splitPoint) + infix + ">";            
    }
    return uri;
}
 
開發者ID:vefthym,項目名稱:MinoanER,代碼行數:19,代碼來源:Utils.java

示例2: abbr

import org.apache.commons.lang3.StringEscapeUtils; //導入依賴的package包/類
/**
 * 縮略字符串(不區分中英文字符)
 *
 * @param str    目標字符串
 * @param length 截取長度
 * @return
 */
public static String abbr(String str, int length) {
	if (str == null) {
		return "";
	}
	try {
		StringBuilder sb = new StringBuilder();
		int currentLength = 0;
		for (char c : replaceHtml(StringEscapeUtils.unescapeHtml4(str)).toCharArray()) {
			currentLength += String.valueOf(c).getBytes("GBK").length;
			if (currentLength <= length - 3) {
				sb.append(c);
			} else {
				sb.append("...");
				break;
			}
		}
		return sb.toString();
	} catch (UnsupportedEncodingException e) {
		e.printStackTrace();
	}
	return "";
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:30,代碼來源:StringUtils.java

示例3: doPost

import org.apache.commons.lang3.StringEscapeUtils; //導入依賴的package包/類
/**
 * doPost method to handle operations: like review, save hotel, check Expedia link.
 *
 * @param request
 * @param response
 * @throws IOException
 */
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
    List<String> types = getTypes();
    String type = StringEscapeUtils.escapeHtml4(request.getParameter("type"));
    String id = StringEscapeUtils.escapeHtml4(request.getParameter("id"));
    String username = getUsername(request);
    PrintWriter out = response.getWriter();

    if (username != null && types.contains(type)) {
        try {
            out.println(dbhandler.setLike(type, id, username));
        }
        catch (SQLException e) {
            System.out.println(e);
        }
    }
}
 
開發者ID:brianisadog,項目名稱:hotelApp,代碼行數:25,代碼來源:LikeServlet.java

示例4: prepareBugDescriptionForBugCreation

import org.apache.commons.lang3.StringEscapeUtils; //導入依賴的package包/類
/**
 * Prepares the description of bug body. By adding build url, a nice header, a note and
 * excaptes html tags, json tags.
 *
 * @param description
 * @return
 */
private String prepareBugDescriptionForBugCreation(String description)
{
    description = "*[Automation failed tests]*\n" +
            "||Testcase failing|| Parameters||\n" +
            description + "\n" +
            System.getProperty(AUTO_CREATE_ADDITIONAL_DETAILS,
                    configuration.getProperty(AUTO_CREATE_ADDITIONAL_DETAILS, "")) + "\n" +
            "Build url: " + buildUrl;
    description = description + "\n\n\n" + "Note: This bug is created automatically by DolphinNG." +
            " Please do not edit summary line of the bug.";
    description = StringEscapeUtils.escapeHtml3(description);
    description = StringEscapeUtils.escapeHtml4(description);
    description = JSONObject.escape(description);
    return description;
}
 
開發者ID:basavaraj1985,項目名稱:DolphinNG,代碼行數:23,代碼來源:JIRAClient.java

示例5: apply

import org.apache.commons.lang3.StringEscapeUtils; //導入依賴的package包/類
@Override
public void apply(ApiRequest request, ApiResponse response, WebSocketSession session) {
    String msg = StringEscapeUtils.escapeHtml4(request.getMsg());
    if (StringUtils.isBlank(msg)) {
        return;
    }
    Map<String, Object> attributes = session.getAttributes();
    String id = session.getId();
    DrawPlayerInfo info = ((DrawPlayerInfo) attributes.get("info"));
    DrawGuessContext ctx = (DrawGuessContext) attributes.get("ctx");
    DrawGameStatus status = ctx.status();
    ArrayList<String> msgs = new ArrayList<>(2);
    if (status == DrawGameStatus.RUN) {
        if (StringUtils.equals(id, ctx.getCurrentUser())) {
            protectSecret(info, ctx, msg, msgs);
        } else {
            processGussPerson(info, ctx, msg, msgs);
        }
    } else {
        msgs.add("<b>" + info.getName() + "</b>: " + msg);
    }
    response.setCode(DrawCode.DRAW_MSG.getCode()).setData(msgs);
}
 
開發者ID:csdbianhua,項目名稱:telemarket-skittle-alley,代碼行數:24,代碼來源:UserMsgHandler.java

示例6: createInstance

import org.apache.commons.lang3.StringEscapeUtils; //導入依賴的package包/類
/**
 * Creates a new chat instance.
 * 
 * @return The unique id that identifies the created instance
 */
public String createInstance() {
	final String query = this.mServiceUrl + CREATE_REQUEST;
	try {
		final List<String> content = getWebContent(query);
		// If the answer is empty there was some error
		if (content.isEmpty()) {
			return null;
		}

		// The first line contains the id
		final String firstLine = content.iterator().next();
		if (firstLine.trim().isEmpty()) {
			return null;
		}
		return StringEscapeUtils.unescapeHtml4(firstLine);
	} catch (final IOException e) {
		// Ignore the exception and return null
		return null;
	}
}
 
開發者ID:ZabuzaW,項目名稱:BrainBridge,代碼行數:26,代碼來源:BrainBridgeAPI.java

示例7: convertMessage

import org.apache.commons.lang3.StringEscapeUtils; //導入依賴的package包/類
private String convertMessage(String message, Map<String, String> headers) {
    String newMessage = message;
    JsonElement msgRootElement = parser.parse(message);
    if (msgRootElement instanceof JsonObject) {
        JsonObject msgRoot = (JsonObject)msgRootElement;

        JsonElement element = msgRoot.get(PAYLOAD_ELEMENT_KEY);
        if (element != null) {
            if (!element.isJsonObject()) {
                //convert payLoad to a json object if it is not already
                msgRoot.remove(PAYLOAD_ELEMENT_KEY);
                String realPayload = element.getAsString();
                String escapedPayload = StringEscapeUtils.unescapeJava(realPayload);
                msgRoot.add(PAYLOAD_ELEMENT_KEY, parser.parse(escapedPayload));
            }
        }
        JsonElement hdrElement = GSON.toJsonTree(headers);
        msgRoot.add("msgHeaders", hdrElement);
        newMessage = GSON.toJson(msgRoot);
        if (logger.isDebugEnabled()) {
            logger.debug("message to be indexed " + newMessage);
        }
    }
    return newMessage;
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:26,代碼來源:DLQMessageProcessor.java

示例8: annotationToJson

import org.apache.commons.lang3.StringEscapeUtils; //導入依賴的package包/類
public static String annotationToJson(SpanAnnotation annotation) {
    StringBuilder sb = new StringBuilder("{\n");
    sb.append("name : '").append(annotation.getName()).append("',\n");
    sb.append("startToken : sentence[").append(annotation.getStartTokenIndex()).append("],\n");
    sb.append("endToken : sentence[").append(annotation.getEndTokenIndex()).append("]\n");
    if (annotation.getFeatures().size() > 0) {
        sb.append(",features:{");
        for (Map.Entry<String, String> entry : annotation.getFeatures().entrySet()) {
            sb.append("\"").append(StringEscapeUtils.escapeEcmaScript(entry.getKey())).append("\" : \"").append(StringEscapeUtils.escapeEcmaScript(entry.getValue())).append("\",\n");
        }
        sb.delete(sb.length() - 2, sb.length());
        sb.append("}");
    }
    sb.append("}");

    return sb.toString();
}
 
開發者ID:radsimu,項目名稱:UaicNlpToolkit,代碼行數:18,代碼來源:StateMachine.java

示例9: findCrumb

import org.apache.commons.lang3.StringEscapeUtils; //導入依賴的package包/類
public String findCrumb(List<String> lines) {
    String crumb = "";
    String rtn = "";
    for (String l : lines) {
        if (l.indexOf("CrumbStore") > -1) {
            rtn = l;
            break;
        }
    }
    // ,"CrumbStore":{"crumb":"OKSUqghoLs8"        
    if (rtn != null && !rtn.isEmpty()) {
        String[] vals = rtn.split(":");                 // get third item
        crumb = vals[2].replace("\"", "");              // strip quotes
        crumb = StringEscapeUtils.unescapeJava(crumb);  // unescape escaped values (particularly, \u002f
        }
    return crumb;
}
 
開發者ID:bradlucas,項目名稱:get-yahoo-quotes-java,代碼行數:18,代碼來源:GetYahooQuotes.java

示例10: doPost

import org.apache.commons.lang3.StringEscapeUtils; //導入依賴的package包/類
/**
 * doPost method to display "who liked this review" modal data.
 *
 * @param request
 * @param response
 * @throws IOException
 */
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
    String type = StringEscapeUtils.escapeHtml4(request.getParameter("type"));
    String id = StringEscapeUtils.escapeHtml4(request.getParameter("id"));
    PrintWriter out = response.getWriter();

    if (getUsername(request) != null) {

        try {
            if (type.equals("review")) {
                out.println(showReviewLikes(id));
            }
        }
        catch (SQLException e){
            System.out.println(e);
        }
    }
}
 
開發者ID:brianisadog,項目名稱:hotelApp,代碼行數:26,代碼來源:ShowLikeServlet.java

示例11: doGet

import org.apache.commons.lang3.StringEscapeUtils; //導入依賴的package包/類
/**
 * doGet method to display the body and footer of review modal.
 *
 * @param request
 * @param response
 * @throws IOException
 */
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
    String type = StringEscapeUtils.escapeHtml4(request.getParameter("type"));
    String id = StringEscapeUtils.escapeHtml4(request.getParameter("id"));
    StringBuilder sb = new StringBuilder();
    PrintWriter out = response.getWriter();

    if (getUsername(request) != null) {
        try {
            sb.append(body(id, type));
            sb.append(footer(type));
            out.println(sb.toString());
        }
        catch (SQLException e) {
            System.out.println(e);
        }
    }
}
 
開發者ID:brianisadog,項目名稱:hotelApp,代碼行數:26,代碼來源:ReviewModalServlet.java

示例12: review

import org.apache.commons.lang3.StringEscapeUtils; //導入依賴的package包/類
/**
 * Displays a review apply.
 *
 * @param model
 * @param id
 * @return
 * @throws ShepherException
 */
@RequestMapping(value = "reviews/{id}", method = RequestMethod.GET)
public String review(Model model, @PathVariable(value = "id") long id) throws ShepherException {
    ReviewRequest reviewRequest = reviewService.get(id);
    if (reviewRequest == null) {
        throw ShepherException.createNoSuchReviewException();
    }
    reviewService.rejectIfExpired(reviewRequest);
    model.addAttribute("clusters", ClusterUtil.getClusters());
    model.addAttribute("cluster", reviewRequest.getCluster());
    model.addAttribute("paths", reviewRequest.getPath().split("/"));
    model.addAttribute("reviewRequest", reviewRequest);
    model.addAttribute("content", StringEscapeUtils.escapeHtml4(reviewRequest.getSnapshotContent()));
    model.addAttribute("newContent", StringEscapeUtils.escapeHtml4(reviewRequest.getNewSnapshotContent()));

    String backPath = reviewRequest.getPath();
    if (reviewRequest.getAction() == Action.DELETE.getValue()) {
        backPath = ParentPathParser.getParent(backPath);
    }
    model.addAttribute("backPath", backPath);
    model.addAttribute("canReview", permissionService.isPathMaster(userHolder.getUser().getName(),
            reviewRequest.getCluster(), reviewRequest.getPath()));
    return "review/review";
}
 
開發者ID:XiaoMi,項目名稱:shepher,代碼行數:32,代碼來源:ReviewController.java

示例13: getTitle

import org.apache.commons.lang3.StringEscapeUtils; //導入依賴的package包/類
public final String getTitle(String s) {
  int start = s.indexOf(XML_START_TAG_TITLE);
  int end = s.indexOf(XML_END_TAG_TITLE, start);
  if (start < 0 || end < 0) {
    return "";
  }
  return StringEscapeUtils.unescapeHtml4(s.substring(start + 7, end));
}
 
開發者ID:asmehra95,項目名稱:wiseowl,代碼行數:9,代碼來源:WikiClean.java

示例14: getClassInitBodyUnescaped

import org.apache.commons.lang3.StringEscapeUtils; //導入依賴的package包/類
public String getClassInitBodyUnescaped(){
	if(classInitBody==null)
		return null;
	
	Pattern pattern = Pattern.compile("\\t+");
    Matcher matcher = pattern.matcher(StringEscapeUtils.unescapeJava(this.classInitBody));
    StringBuilder sb=new StringBuilder(StringEscapeUtils.unescapeJava(this.classInitBody));
    
    while(matcher.find()){
    	sb.insert(matcher.start(), CodeStringBuilder.getTabString());
    }
    
    String tempString=sb.toString();
    
    pattern=Pattern.compile("\\n+");
    matcher=pattern.matcher(tempString);
    
    while(matcher.find()){
    	sb.insert(matcher.end(), CodeStringBuilder.getTabString());
    }
	return sb.toString();
}
 
開發者ID:shoaib-a-khan,項目名稱:iConA,代碼行數:23,代碼來源:ClassDAO.java

示例15: getLastPatchFile

import org.apache.commons.lang3.StringEscapeUtils; //導入依賴的package包/類
protected File getLastPatchFile(String baseApkVersion,
                                String productName,
                                File outPatchDir) throws IOException {
    try {
        String httpUrl = ((TpatchInput)input).LAST_PATCH_URL +
                "baseVersion=" +
                baseApkVersion +
                "&productIdentifier=" +
                productName;
        String response = HttpClientUtils.getUrl(httpUrl);
        if (StringUtils.isBlank(response) ||
                response.equals("\"\"")) {
            return null;
        }
        File downLoadFolder = new File(outPatchDir, "LastPatch");
        downLoadFolder.mkdirs();
        File downLoadFile = new File(downLoadFolder, "lastpatch.tpatch");
        String downLoadUrl = StringEscapeUtils.unescapeJava(response);
        downloadTPath(downLoadUrl.substring(1, downLoadUrl.length() - 1), downLoadFile);

        return downLoadFile;
    } catch (Exception e) {
        return null;
    }
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:26,代碼來源:TPatchTool.java


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