List of usage examples for org.apache.commons.lang3 StringEscapeUtils escapeHtml4
public static final String escapeHtml4(final String input)
Escapes the characters in a String using HTML entities.
For example:
"bread" & "butter"
"bread" & "butter"
.
From source file:org.knime.ext.textprocessing.nodes.view.documentviewer2.DocumentPanel2.java
private String escapeHTMLIfSelected(String str) { str = replaceWhitespacesWithPlaceholder(str); str = replaceWhitespacesWithHtml(str); if (!m_docViewModel.isDisableHtmlTags()) { str = StringEscapeUtils.escapeHtml4(str); }/*from w w w . j a v a2s . co m*/ str = cleanWhitespaces(str); return str; }
From source file:org.kuali.coeus.common.framework.sponsor.term.SponsorTerm.java
/** * Gets the description attribute. * @return Returns the description. */ public String getEscapedDescription() { return StringEscapeUtils.escapeHtml4(description); }
From source file:org.kuali.mobility.tours.service.ToursServiceImpl.java
@Override public Kml createTourKml(Tour tour) { Kml kml = KmlFactory.createKml();//from ww w . j ava 2 s. c o m Document document = new Document(); kml.setFeature(document); final Style style = document.createAndAddStyle().withId("PathStyle"); style.createAndSetLineStyle().withColor("FF0000FF").withWidth(3.0d); final Folder folder = document.createAndAddFolder().withName("Points of Interest").withOpen(true) .withDescription("The points of interest selected for this tour."); int i = 0; for (POI poi : tour.getPointsOfInterest()) { folder.createAndAddPlacemark().withId("poi" + i).withName(poi.getName()) .withDescription(getPoiDescription(poi)).createAndSetPoint() .addToCoordinates(poi.getLongitude() + "," + poi.getLatitude() + ",0"); i++; } List<Point> polyLine = decodePolyLine(tour.getPath()); LineString lineString = document.createAndAddPlacemark().withName(tour.getName()) .withDescription(tour.getDescription()).withStyleUrl("PathStyle").createAndSetLineString() .withTessellate(true).withAltitudeMode(AltitudeMode.CLAMP_TO_GROUND); for (Point p : polyLine) { lineString.addToCoordinates(p.getLongitude(), p.getLatitude()); } Map<Integer, List<Integer>> poiPathIndices = findPoiTourIndices(polyLine, tour.getPointsOfInterest()); de.micromata.opengis.kml.v_2_2_0.gx.Tour kmlTour = document.createAndAddTour() .withName(StringEscapeUtils.escapeHtml4(tour.getName())); Playlist playlist = kmlTour.createAndSetPlaylist(); double heading = 0; double flyTime = 3; Point lastPoint = null; int index = 0; List<POI> pois = tour.getPointsOfInterest(); for (Point vertex : polyLine) { if (lastPoint != null) { heading = Spherical.computeHeading(lastPoint, vertex); flyTime = computeFlyTime(lastPoint, vertex); buildFlyTo(playlist, vertex, heading, FlyToMode.SMOOTH, flyTime); } else { buildFlyTo(playlist, vertex, heading, FlyToMode.BOUNCE, flyTime); } lastPoint = vertex; if (!poiPathIndices.isEmpty() && poiPathIndices.get(index) != null) { List<Integer> poiIndices = poiPathIndices.get(index); for (int poiIndex : poiIndices) { POI poi = pois.get(poiIndex); Point point = new Point(poi.getLatitude(), poi.getLongitude()); heading = Spherical.computeHeading(lastPoint, point); flyTime = computeFlyTime(lastPoint, point); buildFlyTo(playlist, point, heading, FlyToMode.SMOOTH, flyTime); // buildShowHideBalloon(playlist, "poi" + poiIndex, true); playlist.createAndAddWait(); // buildShowHideBalloon(playlist, "poi" + poiIndex, false); lastPoint = point; } } index++; } return kml; }
From source file:org.kuali.mobility.tours.service.ToursServiceImpl.java
private String getPoiDescription(POI poi) { String description = StringEscapeUtils.escapeHtml4(poi.getDescription()); if (poi.getUrl() != null && poi.getUrl().length() > 0) { description += "<br /><a href=\"" + poi.getUrl() + "\" target=\"_blank\">" + poi.getUrl() + "</a>"; }//from ww w . j a v a2 s .com return description; }
From source file:org.locationtech.jtstest.util.StringUtil.java
public static String escapeHTML(String s) { return StringEscapeUtils.escapeHtml4(s); }
From source file:org.mayocat.shop.front.util.ContextUtils.java
public static String safeString(String string) { return string == null ? null : StringEscapeUtils.escapeHtml4(string); }
From source file:org.messic.server.tld.EscapeMessic.java
public static String escapeHTML(String texto) { String result = StringEscapeUtils.escapeHtml4(texto); return result; }
From source file:org.messic.server.tld.EscapeMessic.java
public static String escapeAll(String texto) { String result = StringEscapeUtils.escapeEcmaScript(StringEscapeUtils.escapeHtml4(texto)); return result; }
From source file:org.miloss.fgsms.common.Utility.java
/** * HTML encodes strings to prevent CXS, if the parameter is an null or * empty, an empty string is returned, but never null * * @param s/*from w ww. j av a 2s. c o m*/ * @return */ public static String encodeHTML(String s) { if (s == null || s.length() == 0) { return ""; } return StringEscapeUtils.escapeHtml4(s); /*StringBuffer out = new StringBuffer(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c > 127 || c == '"' || c == '<' || c == '>') { out.append("&#" + (int) c + ";"); } else { out.append(c); } } return out.toString();*/ }
From source file:org.miloss.fgsms.common.UtilityTest.java
@Test public void testStringEscaping() throws Exception { String url = "http://something:99/path/something?wsdl"; System.out.println(url);/*from www .j a v a 2s.c om*/ String encoded = StringEscapeUtils.escapeHtml4(url); System.out.println(encoded); String back = StringEscapeUtils.unescapeHtml4(encoded); System.out.println(back); assertEquals(url, back); }