本文整理汇总了Java中com.liferay.portal.kernel.util.HtmlUtil.escape方法的典型用法代码示例。如果您正苦于以下问题:Java HtmlUtil.escape方法的具体用法?Java HtmlUtil.escape怎么用?Java HtmlUtil.escape使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.liferay.portal.kernel.util.HtmlUtil
的用法示例。
在下文中一共展示了HtmlUtil.escape方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: formataEstrutura
import com.liferay.portal.kernel.util.HtmlUtil; //导入方法依赖的package包/类
/**
* Formata a estrutura para exibição
* @param texto
* @return
*/
public static String formataEstrutura(String texto) {
// Separa em duas linhas
Matcher m = PATTERN_ESTRUTURA.matcher(texto);
if (m.matches()) {
StringBuilder sb = new StringBuilder();
sb.append(m.group(1));
sb.append("\n");
sb.append(m.group(2));
texto = sb.toString();
}
texto = HtmlUtil.escape(texto);
return texto.replaceAll("\\n", "<br/>");
}
示例2: getHTML
import com.liferay.portal.kernel.util.HtmlUtil; //导入方法依赖的package包/类
public String getHTML(String bbcode) {
try {
bbcode = parse(bbcode);
}
catch (Exception e) {
_log.error("Unable to parse: " + bbcode, e);
bbcode = HtmlUtil.escape(bbcode);
}
return bbcode;
}
示例3: handleCode
import com.liferay.portal.kernel.util.HtmlUtil; //导入方法依赖的package包/类
protected void handleCode(
StringBundler sb, List<BBCodeItem> bbCodeItems, IntegerWrapper marker) {
sb.append("<div class=\"code\">");
String code = extractData(
bbCodeItems, marker, "code", BBCodeParser.TYPE_DATA, true);
code = HtmlUtil.escape(code);
code = code.replaceAll(StringPool.TAB, StringPool.FOUR_SPACES);
String[] lines = code.split("\r?\n");
String digits = String.valueOf(lines.length + 1);
for (int i = 0; i < lines.length; i++) {
String index = String.valueOf(i + 1);
sb.append("<span class=\"code-lines\">");
for (int j = 0; j < digits.length() - index.length(); j++) {
sb.append(StringPool.NBSP);
}
lines[i] = StringUtil.replace(
lines[i], StringPool.THREE_SPACES, " ");
lines[i] = StringUtil.replace(
lines[i], StringPool.DOUBLE_SPACE, " ");
sb.append(index);
sb.append("</span>");
sb.append(lines[i]);
if (index.length() < lines.length) {
sb.append("<br />");
}
}
sb.append("</div>");
}
示例4: obtemNomeDoUsuario
import com.liferay.portal.kernel.util.HtmlUtil; //导入方法依赖的package包/类
private void obtemNomeDoUsuario(RenderRequest request, ThemeDisplay td, User usuario) {
Locale locale = td.getLocale();
String nome = HtmlUtil.escape(usuario.getFullName());
if (td.isShowMyAccountIcon()) {
nome = "<a href=\"" + HtmlUtil.escape(td.getURLMyAccount().toString()) + "\">" + nome + "</a>";
}
request.setAttribute("logged-in", LanguageUtil.format(locale, "you-are-signed-in-as-x", nome));
}
示例5: updateFormScript
import com.liferay.portal.kernel.util.HtmlUtil; //导入方法依赖的package包/类
@Override
public Response updateFormScript(HttpServletRequest request, HttpHeaders header, Company company, Locale locale,
User user, ServiceContext serviceContext, long id, String partNo,
DossierPartContentInputUpdateModel input) {
DossierTemplateActions actions = new DossierTemplateActionsImpl();
long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));
BackendAuth auth = new BackendAuthImpl();
DossierPartContentInputUpdateModel result = new DossierPartContentInputUpdateModel();
try {
if (!auth.isAuth(serviceContext)) {
throw new UnauthenticationException();
}
if (!auth.hasResource(serviceContext, DossierTemplate.class.getName(), ActionKeys.ADD_ENTRY)) {
throw new UnauthorizationException();
}
String content = actions.updateFormScript(groupId, id, partNo, input.getValue(), serviceContext);
HtmlUtil.escape(content);
result.setValue(content);
return Response.status(200).entity(result).build();
} catch (Exception e) {
ErrorMsg error = new ErrorMsg();
if (e instanceof UnauthenticationException) {
error.setMessage("Non-Authoritative Information.");
error.setCode(HttpURLConnection.HTTP_NOT_AUTHORITATIVE);
error.setDescription("Non-Authoritative Information.");
return Response.status(HttpURLConnection.HTTP_NOT_AUTHORITATIVE).entity(error).build();
} else {
if (e instanceof UnauthorizationException) {
error.setMessage("Unauthorized.");
error.setCode(HttpURLConnection.HTTP_NOT_AUTHORITATIVE);
error.setDescription("Unauthorized.");
return Response.status(HttpURLConnection.HTTP_UNAUTHORIZED).entity(error).build();
} else {
error.setMessage("Internal Server Error");
error.setCode(HttpURLConnection.HTTP_FORBIDDEN);
error.setDescription(e.getMessage());
return Response.status(HttpURLConnection.HTTP_INTERNAL_ERROR).entity(error).build();
}
}
}
}
示例6: updateExtraContentScormActivities
import com.liferay.portal.kernel.util.HtmlUtil; //导入方法依赖的package包/类
public void updateExtraContentScormActivities (ActionRequest request, ActionResponse response) throws Exception {
String updateBD = ParamUtil.getString(request, "updateBD", "false");
List<LearningActivity> learningActivityList = LearningActivityLocalServiceUtil.getLearningActivities(0, LearningActivityLocalServiceUtil.getLearningActivitiesCount());
int conta = 1;
String todas ="<p>Actualizado en base de datos:</p>", sqlUpdate = "";
for(LearningActivity activity: learningActivityList) {
//Si es un scorm y tiene etiqueta scorm.
if (activity.getTypeId() == 9 && activity.getExtracontent().contains("<scorm>")) {
String uuid = LearningActivityLocalServiceUtil.getExtraContentValue(activity.getActId(), "uuid");
String openWindow = LearningActivityLocalServiceUtil.getExtraContentValue(activity.getActId(), "openWindow");
String assetEntry = LearningActivityLocalServiceUtil.getExtraContentValue(activity.getActId(), "assetEntry");
if (Validator.isNull(uuid) && Validator.isNotNull(assetEntry) && Validator.isNumber(assetEntry)) {
AssetEntry entry = AssetEntryLocalServiceUtil.getEntry(Long.valueOf(assetEntry));
AssetRenderer scorm = AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(entry.getClassName()).getAssetRenderer(entry.getClassPK());
uuid = scorm.getUuid();
if (Validator.isNotNull(openWindow)) {
String key = "lms.scorm.windowable."+entry.getClassName();
if (Validator.isNull(key)) {
key = "false";
}
openWindow = PropsUtil.get(key);
}
}
if(updateBD.equals("false")){
//Componemos la consulta para actualizar.
String newExtraContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <scorm>";
if (Validator.isNotNull(openWindow)) {
newExtraContent += "<openWindow>"+openWindow +"<openWindow/>";
}
if (Validator.isNotNull(uuid)) {
newExtraContent += "<uuid>"+uuid +"<uuid/>";
}
if (Validator.isNotNull(assetEntry)) {
newExtraContent += "<assetEntry>"+assetEntry +"</assetEntry>";
}
newExtraContent += "</scorm>";
String updateQuery = "UPDATE lms_learningactivity SET extracontent = '"+newExtraContent+"' WHERE actId = "+activity.getActId()+";<br />";
sqlUpdate += HtmlUtil.escape(updateQuery);
}
//Actualizamos en la bd.
else if(updateBD.equals("true")){
//Borramos lo que había.
activity.setExtracontent("<scorm></scorm>");
LearningActivityLocalServiceUtil.updateLearningActivity(activity);
//Anadimos los campos.
LearningActivityLocalServiceUtil.setExtraContentValue(activity.getActId(), "openWindow", openWindow);
LearningActivityLocalServiceUtil.setExtraContentValue(activity.getActId(), "uuid", uuid);
LearningActivityLocalServiceUtil.setExtraContentValue(activity.getActId(), "assetEntry", assetEntry);
todas += "<p>Número: "+ (conta++) +", Activity: "+activity.getTitle(Locale.getDefault())+"<br /> openWindow: " + openWindow+"<br /> uuid: " + uuid+"<br /> assetEntry: " + assetEntry+"</p>";
}
}
}
if(updateBD.equals("true")){
response.setRenderParameter("resultados", todas);
}else if(updateBD.equals("false")){
response.setRenderParameter("resultados", sqlUpdate);
}
}
示例7: handleData
import com.liferay.portal.kernel.util.HtmlUtil; //导入方法依赖的package包/类
protected void handleData(
StringBundler sb, List<BBCodeItem> bbCodeItems, Stack<String> tags,
IntegerWrapper marker, BBCodeItem bbCodeItem) {
String value = HtmlUtil.escape(bbCodeItem.getValue());
value = handleNewLine(bbCodeItems, tags, marker, value);
for (int i = 0; i < _EMOTICONS.length; i++) {
String[] emoticon = _EMOTICONS[i];
value = StringUtil.replace(value, emoticon[1], emoticon[0]);
}
sb.append(value);
}
示例8: getSampleData
import com.liferay.portal.kernel.util.HtmlUtil; //导入方法依赖的package包/类
@Override
public Response getSampleData(HttpServletRequest request, HttpHeaders header, Company company, Locale locale,
User user, ServiceContext serviceContext, long id, String partNo) {
DossierTemplateActions actions = new DossierTemplateActionsImpl();
long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));
DossierPartContentInputUpdateModel result = new DossierPartContentInputUpdateModel();
try {
String content = actions.getSample(groupId, id, partNo);
HtmlUtil.escape(content);
result.setValue(content);
return Response.status(200).entity(result).build();
} catch (Exception e) {
ErrorMsg error = new ErrorMsg();
error.setMessage("Content not found!");
error.setCode(404);
error.setDescription(e.getMessage());
return Response.status(404).entity(error).build();
}
}