当前位置: 首页>>代码示例>>Java>>正文


Java StringEscapeUtils.escapeHtml方法代码示例

本文整理汇总了Java中org.apache.commons.lang.StringEscapeUtils.escapeHtml方法的典型用法代码示例。如果您正苦于以下问题:Java StringEscapeUtils.escapeHtml方法的具体用法?Java StringEscapeUtils.escapeHtml怎么用?Java StringEscapeUtils.escapeHtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang.StringEscapeUtils的用法示例。


在下文中一共展示了StringEscapeUtils.escapeHtml方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createGraphMethodNode

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
/**
 * Creates the graph method node and sets the label, methodName, methodSignature, methodBody and nodeMethod attributes on the node.
 *
 * @param src
 * @author Shashank B S
 */
private void createGraphMethodNode(VFMethod src) {
	if (graph.getNode(src.getId() + "") == null) {
		Node createdNode = graph.addNode(src.getId() + "");
		String methodName = src.getSootMethod().getName();
		String escapedMethodName = StringEscapeUtils.escapeHtml(methodName);
		String escapedMethodSignature = StringEscapeUtils.escapeHtml(src.getSootMethod().getSignature());
		createdNode.setAttribute("ui.label", methodName);
		createdNode.setAttribute("nodeData.methodName", escapedMethodName);
		createdNode.setAttribute("nodeData.methodSignature", escapedMethodSignature);
		String methodBody = src.getBody().toString();
		methodBody = Pattern.compile("^[ ]{4}", Pattern.MULTILINE).matcher(methodBody).replaceAll(""); // remove indentation at line start
		methodBody = methodBody.replaceAll("\n{2,}", "\n"); // replace empty lines
		String escapedMethodBody = StringEscapeUtils.escapeHtml(methodBody);
		String hexColor = getCodeBackgroundColor();
		createdNode.setAttribute("nodeData.methodBody", "<code><pre style=\"color: #000000; background-color: #"+hexColor+"\">" + escapedMethodBody + "</pre></code>");
		createdNode.setAttribute("nodeMethod", src);
	}
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:25,代码来源:GraphManager.java

示例2: checkStorageInfoOrSendError

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
private boolean checkStorageInfoOrSendError(JNStorage storage,
    HttpServletRequest request, HttpServletResponse response)
    throws IOException {
  int myNsId = storage.getNamespaceID();
  String myClusterId = storage.getClusterID();
  
  String theirStorageInfoString = StringEscapeUtils.escapeHtml(
      request.getParameter(STORAGEINFO_PARAM));

  if (theirStorageInfoString != null) {
    int theirNsId = StorageInfo.getNsIdFromColonSeparatedString(
        theirStorageInfoString);
    String theirClusterId = StorageInfo.getClusterIdFromColonSeparatedString(
        theirStorageInfoString);
    if (myNsId != theirNsId || !myClusterId.equals(theirClusterId)) {
      String msg = "This node has namespaceId '" + myNsId + " and clusterId '"
          + myClusterId + "' but the requesting node expected '" + theirNsId
          + "' and '" + theirClusterId + "'";
      response.sendError(HttpServletResponse.SC_FORBIDDEN, msg);
      LOG.warn("Received an invalid request file transfer request from " +
          request.getRemoteAddr() + ": " + msg);
      return false;
    }
  }
  return true;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:GetJournalEditServlet.java

示例3: generate

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
public static void generate(final long hashCode, final StringBuilder content, final CharSequence[] successors, boolean notescurl) {
	content.append("<html>\n<head></head>\n<body>\n");
	// This helps in making the page text different even for the same number
	// of URLs, but not always.
	content.append("<h1>").append((char)((hashCode & 0xF) + 'A')).append((char)((hashCode >>> 4 & 0xF) + 'A')).append((char)((hashCode >>> 8 & 0xF) + 'A')).append((char)((hashCode >>> 12 & 0xF) + 'A')).append("</h1>\n");
	for (final CharSequence s : successors) {
		String ref = s.toString();
		if (!notescurl) ref = StringEscapeUtils.escapeHtml(s.toString());
		content.append("<p>Lorem ipsum dolor sit amet <a href=\""
				+ ref
				+ "\">"
				+ ref
				+ "</a>, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n");
	}
	content.append("</body>\n</html>\n");
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:17,代码来源:NamedGraphServerHttpProxy.java

示例4: GBUserGridRowDTO

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
public GBUserGridRowDTO(User user) {
this.id = user.getUserId().toString();
this.rowName = StringEscapeUtils.escapeHtml(user.getLastName() + " " + user.getFirstName());
this.firstName = user.getFirstName();
this.lastName = user.getLastName();
this.login = user.getLogin();
this.setPortraitId(user.getPortraitUuid());
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:GBUserGridRowDTO.java

示例5: getActivityStatusStr

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
/**
    * Returns the activity status string which is a reference to an image
    *
    * @param learnerProgress
    * @param activity
    * @return
    */
   private String getActivityStatusStr(LearnerProgress learnerProgress, Activity activity) {

final String IMAGES_DIR = Configuration.get(ConfigurationKeys.SERVER_URL) + "images";
if (learnerProgress != null) {
    byte statusByte = learnerProgress.getProgressState(activity);
    if (statusByte == LearnerProgress.ACTIVITY_ATTEMPTED && learnerProgress.getCurrentActivity() != null) {
	return "<i class='fa fa-cog' title='"
		+ StringEscapeUtils.escapeHtml(learnerProgress.getCurrentActivity().getTitle()) + "'></i>";
    } else if (statusByte == LearnerProgress.ACTIVITY_COMPLETED) {
	return "<i class='fa fa-check text-success'></i>";
    }
}
return "-";
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:GradebookService.java

示例6: getReflectionsJSON

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
/**
    * Get Paged Reflections
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    */
   public ActionForward getReflectionsJSON(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws IOException, ServletException, ToolException, JSONException {

Long toolSessionId = WebUtil.readLongParam(request, QaAppConstants.TOOL_SESSION_ID);

// paging parameters of tablesorter
int size = WebUtil.readIntParam(request, "size");
int page = WebUtil.readIntParam(request, "page");
Integer sortByName = WebUtil.readIntParam(request, "column[0]", true);
String searchString = request.getParameter("fcol[0]");

int sorting = QaAppConstants.SORT_BY_NO;
if (sortByName != null) {
    sorting = sortByName.equals(0) ? QaAppConstants.SORT_BY_USERNAME_ASC : QaAppConstants.SORT_BY_USERNAME_DESC;
}

//return user list according to the given sessionID
IQaService qaService = getQAService();
List<Object[]> users = qaService.getUserReflectionsForTablesorter(toolSessionId, page, size, sorting,
	searchString);

JSONArray rows = new JSONArray();
JSONObject responsedata = new JSONObject();
responsedata.put("total_rows", qaService.getCountUsersBySessionWithSearch(toolSessionId, searchString));

for (Object[] userAndReflection : users) {
    JSONObject responseRow = new JSONObject();
    responseRow.put("username", StringEscapeUtils.escapeHtml((String) userAndReflection[1]));
    if (userAndReflection.length > 2 && userAndReflection[2] != null) {
	String reflection = StringEscapeUtils.escapeHtml((String) userAndReflection[2]);
	responseRow.put(QaAppConstants.NOTEBOOK, reflection.replaceAll("\n", "<br>"));
    }
    rows.put(responseRow);
}
responsedata.put("rows", rows);
response.setContentType("application/json;charset=utf-8");
response.getWriter().print(new String(responsedata.toString()));
return null;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:49,代码来源:QaMonitoringAction.java

示例7: escape

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
public String escape(String s) {
    return StringEscapeUtils.escapeHtml(s);
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:4,代码来源:JadeTemplateEngine.java

示例8: getHeader

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
@Override    
public String getHeader(String name) {    
    return StringEscapeUtils.escapeHtml(super.getHeader(name));    
}
 
开发者ID:xiachuanshou,项目名称:shop-manager,代码行数:5,代码来源:XssHttpServletRequestWrapper.java

示例9: getParameter

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
@Override    
public String getParameter(String name) {    
    return StringEscapeUtils.escapeHtml(super.getParameter(name));    
}
 
开发者ID:xiachuanshou,项目名称:shop-manager,代码行数:5,代码来源:XssHttpServletRequestWrapper.java

示例10: createControlFlowGraphNode

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
/**
 * Creates the CFG node and sets the label, unit, escapedHTMLunit, unitType, inSet, outSet, color attributes.
 *
 * @param node
 * @author Shashank B S
 */
private void createControlFlowGraphNode(VFNode node) {
	if (graph.getNode(node.getId() + "") == null) {
		Node createdNode = graph.addNode(node.getId() + "");
		Unit unit = node.getUnit();
		String label = unit.toString();
		try {
			UnitFormatter formatter = UnitFormatterFactory.createFormatter(unit);
			//UnitFormatter formatter = new DefaultFormatter();
			label = formatter.format(unit, maxLength);
		} catch (Exception e) {
			logger.error("Unit formatting failed", e);
		}

		createdNode.setAttribute("ui.label", label);
		String str = unit.toString();
		String escapedNodename = StringEscapeUtils.escapeHtml(str);
		createdNode.setAttribute("unit", str);
		createdNode.setAttribute("nodeData.unit", escapedNodename);

		createdNode.setAttribute("nodeData.unitType", node.getUnit().getClass());
		String str1 = Optional.fromNullable(node.getVFUnit().getInSet()).or("n/a").toString();
		String nodeInSet = StringEscapeUtils.escapeHtml(str1);
		String str2 = Optional.fromNullable(node.getVFUnit().getOutSet()).or("n/a").toString();
		String nodeOutSet = StringEscapeUtils.escapeHtml(str2);

		createdNode.setAttribute("nodeData.inSet", nodeInSet);
		createdNode.setAttribute("nodeData.outSet", nodeOutSet);

		Map<String, String> customAttributes = node.getVFUnit().getHmCustAttr();
		String attributeData = "";
		if(!customAttributes.isEmpty())
		{
			Iterator<Entry<String, String>> customAttributeIterator = customAttributes.entrySet().iterator();
			while(customAttributeIterator.hasNext())
			{
				Entry<String, String> curr = customAttributeIterator.next();
				attributeData += curr.getKey() + " : " + curr.getValue();
				attributeData += "<br />";
			}
			createdNode.setAttribute(nodeAttributesString, attributeData);
		}

		createdNode.setAttribute("nodeUnit", node);
		Color nodeColor = new Color(new ProjectPreferences().getColorForNode(node.getUnit().getClass().getName().toString()));
		createdNode.addAttribute("ui.color", nodeColor);
	}
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:54,代码来源:GraphManager.java

示例11: viewDirList

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
private void viewDirList(ViewItemResource resource, FileHandle fileHandle, HttpServletResponse response)
	throws IOException
{
	final String dirPath = resource.getFileDirectoryPath();

	response.setContentType("text/html");

	try (PrintWriter writer = new PrintWriter(new PrintStream(response.getOutputStream())))
	{
		writer.print("<html><head></head><body><h1>");
		writer.print(CurrentLocale.get("viewitem.section.dirlistsection.tle"));
		writer.print("</h1><b>");
		writer.print(CurrentLocale.get("viewitem.section.dirlistsection.listing",
			StringEscapeUtils.escapeHtml(resource.getViewableItem().getItemdir() + dirPath)));
		writer.print("</b><ul id=\"listing\">\n");

		if( dirPath.length() == 0 )
		{
			String xml = StringEscapeUtils.escapeHtml(XML_NAME);
			writer.print("<li><a href=\"");
			writer.print(xml);
			writer.print("\">");
			writer.print(xml);
			writer.print("</a></li>\n");
		}

		FileEntry[] aszFileList = fileSystemService.enumerate(fileHandle, dirPath, null);
		if( !Check.isEmpty(aszFileList) )
		{
			for( FileEntry entry : aszFileList )
			{
				String szFile = entry.getName();
				szFile = URLUtils.urlEncode(szFile, false);
				String name = szFile;
				if( entry.isFolder() )
				{
					szFile += "/~";
				}
				writer.print("<li><a href=\"");
				writer.print(szFile);
				writer.print("\">");
				writer.print(name);
				writer.print("</a></li>");
			}
		}
		writer.print("</ul></body></html>");
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:49,代码来源:DirListViewer.java

示例12: getAnswersJSON

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
private ActionForward getAnswersJSON(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws JSONException, IOException {

Long sessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID);
Long questionUid = WebUtil.readLongParam(request, SurveyConstants.ATTR_QUESTION_UID);

// paging parameters of tablesorter
int size = WebUtil.readIntParam(request, "size");
int page = WebUtil.readIntParam(request, "page");
Integer sortByName = WebUtil.readIntParam(request, "column[0]", true);
String searchString = request.getParameter("fcol[0]");

int sorting = SurveyConstants.SORT_BY_DEAFAULT;
if (sortByName != null) {
    sorting = sortByName.equals(0) ? SurveyConstants.SORT_BY_NAME_ASC : SurveyConstants.SORT_BY_NAME_DESC;
}

// return user list according to the given sessionID
ISurveyService service = getSurveyService();
SurveyQuestion question = service.getQuestion(questionUid);
List<Object[]> users = service.getQuestionAnswersForTablesorter(sessionId, questionUid, page, size, sorting,
	searchString);

JSONArray rows = new JSONArray();
JSONObject responsedata = new JSONObject();
responsedata.put("total_rows", service.getCountUsersBySession(sessionId, searchString));

for (Object[] userAndAnswers : users) {

    JSONObject responseRow = new JSONObject();

    SurveyUser user = (SurveyUser) userAndAnswers[0];
    responseRow.put(SurveyConstants.ATTR_USER_NAME,
	    StringEscapeUtils.escapeHtml(user.getLastName() + " " + user.getFirstName()));
    responseRow.put(SurveyConstants.ATTR_USER_ID, user.getUserId());

    if (userAndAnswers.length > 1 && userAndAnswers[1] != null) {
	responseRow.put("choices", SurveyWebUtils.getChoiceList((String) userAndAnswers[1]));
    }
    if (userAndAnswers.length > 2 && userAndAnswers[2] != null) {
	// Data is handled differently in learner depending on whether
	// it is an extra text added
	// to a multiple choice, or a free text entry. So need to handle
	// the output differently.
	// See learner/result.jsp and its handling of question.type == 3
	// vs question.appendText
	String answer;
	if (question.getType() == SurveyConstants.QUESTION_TYPE_TEXT_ENTRY) {
	    // don't escape as it was escaped & BR'd before saving
	    answer = (String) userAndAnswers[2];
	} else {
	    // need to escape it, as it isn't escaped in the database
	    answer = StringEscapeUtils.escapeHtml((String) userAndAnswers[2]);
	    answer = answer.replaceAll("\n", "<br>");
	}
	responseRow.put("answerText", answer);
    }
    if (userAndAnswers.length > 3 && userAndAnswers[3] != null) {
	responseRow.put(SurveyConstants.ATTR_PORTRAIT_ID, ((Number)userAndAnswers[3]).longValue());
    }
    rows.put(responseRow);
}
responsedata.put("rows", rows);
response.setContentType("application/json;charset=utf-8");
response.getWriter().print(new String(responsedata.toString()));
return null;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:68,代码来源:MonitoringAction.java

示例13: getReflectionsJSON

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
private ActionForward getReflectionsJSON(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws JSONException, IOException {

Long sessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID);

// paging parameters of tablesorter
int size = WebUtil.readIntParam(request, "size");
int page = WebUtil.readIntParam(request, "page");
Integer sortByName = WebUtil.readIntParam(request, "column[0]", true);
String searchString = request.getParameter("fcol[0]");

int sorting = SurveyConstants.SORT_BY_DEAFAULT;
if (sortByName != null) {
    sorting = sortByName.equals(0) ? SurveyConstants.SORT_BY_NAME_ASC : SurveyConstants.SORT_BY_NAME_DESC;
}

// return user list according to the given sessionID
ISurveyService service = getSurveyService();
List<Object[]> users = service.getUserReflectionsForTablesorter(sessionId, page, size, sorting, searchString);

JSONArray rows = new JSONArray();
JSONObject responsedata = new JSONObject();
responsedata.put("total_rows", service.getCountUsersBySession(sessionId, searchString));

for (Object[] userAndReflection : users) {

    JSONObject responseRow = new JSONObject();

    SurveyUser user = (SurveyUser) userAndReflection[0];
    responseRow.put(SurveyConstants.ATTR_USER_NAME,
	    StringEscapeUtils.escapeHtml(user.getLastName() + " " + user.getFirstName()));
    responseRow.put(SurveyConstants.ATTR_USER_ID, user.getUserId());
    
    if (userAndReflection.length > 1 && userAndReflection[1] != null) {
	String reflection = StringEscapeUtils.escapeHtml((String) userAndReflection[1]);
	responseRow.put(SurveyConstants.ATTR_REFLECTION, reflection.replaceAll("\n", "<br>"));
    }

    if (userAndReflection.length > 2 && userAndReflection[2] != null) {
	responseRow.put(SurveyConstants.ATTR_PORTRAIT_ID, ((Number)userAndReflection[2]).longValue());
    }

    rows.put(responseRow);
}
responsedata.put("rows", rows);
response.setContentType("application/json;charset=utf-8");
response.getWriter().print(new String(responsedata.toString()));
return null;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:50,代码来源:MonitoringAction.java

示例14: toStringArray

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
@Override
   public ArrayList<String> toStringArray(GBGridView view) {
ArrayList<String> ret = new ArrayList<String>();

ret.add(id.toString());

rowName = StringEscapeUtils.escapeHtml(rowName);

if (view == GBGridView.MON_COURSE) {
    if (gradebookMonitorURL != null && gradebookMonitorURL.length() != 0) {
	ret.add("<a href='javascript:launchPopup(\"" + gradebookMonitorURL + "\",\"" + rowName
		+ "\",1220,600)'>" + rowName + "</a>");
    } else {
	ret.add(rowName);
    }
    ret.add(subGroup);
    ret.add(startDate != null ? convertDateToString(startDate, null) : CELL_EMPTY);
    ret.add((medianTimeTaken != null && medianTimeTaken != 0) ? convertTimeToString(medianTimeTaken)
	    : CELL_EMPTY);
    ret.add((averageMark != null) ? GradebookUtil.niceFormatting(averageMark, displayMarkAsPercent) : CELL_EMPTY);

} else if ((view == GBGridView.LRN_COURSE) || (view == GBGridView.MON_USER)) {
    if (gradebookLearnerURL != null && gradebookLearnerURL.length() != 0) {
	ret.add("<a href='javascript:launchPopup(\"" + gradebookLearnerURL + "\",\"" + rowName + "\",796,570)'>"
		+ rowName + "</a>");
    } else {
	ret.add(rowName);
    }
    ret.add(subGroup);
    ret.add((status != null) ? status : CELL_EMPTY);
    ret.add(startDate != null ? convertDateToString(startDate, null) : CELL_EMPTY);
    ret.add(finishDate != null ? convertDateToString(finishDate, null) : CELL_EMPTY);
    ret.add(feedback);
    ret.add((medianTimeTaken != null && medianTimeTaken != 0)
	    ? toItalic(convertTimeToString(medianTimeTaken)) : CELL_EMPTY);
    ret.add((timeTaken != null) ? convertTimeToString(timeTaken) : CELL_EMPTY);
    ret.add((averageMark != null) ? toItalic(GradebookUtil.niceFormatting(averageMark, displayMarkAsPercent)) : CELL_EMPTY);
    ret.add((mark != null) ? GradebookUtil.niceFormatting(mark, displayMarkAsPercent) : CELL_EMPTY);

    //plain lesson list case
} else if (view == GBGridView.LIST) {
    ret.add(rowName);
}
return ret;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:46,代码来源:GBLessonGridRowDTO.java

示例15: htmlEscape

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
/**
 * Html 转码.
 */
public static String htmlEscape(String html) {
	return StringEscapeUtils.escapeHtml(html);
}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:7,代码来源:EncodeUtils.java


注:本文中的org.apache.commons.lang.StringEscapeUtils.escapeHtml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。