List of usage examples for org.apache.commons.lang3 StringEscapeUtils escapeXml10
public static String escapeXml10(final String input)
Escapes the characters in a String using XML entities.
For example: "bread" & "butter" => "bread" & "butter" .
From source file:org.codice.ddf.confluence.source.ConfluenceInputTransformer.java
private void parseBody(MetacardImpl metacard, Object json, String bodyExpansion, String confluenceType) { String[] expansion;/*from w w w .java 2 s. co m*/ if (bodyExpansion != null) { expansion = bodyExpansion.split("\\."); } else { expansion = new String[] { "body", "view", "value" }; } Object body = getJsonElement(json, expansion); if (body != null) { String cleanedText = body.toString().replaceAll("<.*?>", " "); String description = cleanedText; if (description.length() > DESCRIPTION_SIZE) { description = description.substring(0, DESCRIPTION_SIZE) + "..."; } if (StringUtils.isNotEmpty(description)) { String xmlSafeString = StringEscapeUtils.escapeXml10(cleanedText); metacard.setAttribute(Metacard.DESCRIPTION, description); metacard.setAttribute(Metacard.METADATA, String.format(PRODUCT_XML, confluenceType, xmlSafeString)); metacard.setAttribute(Confluence.BODY_TEXT, xmlSafeString); } } if (confluenceType.equals("attachment")) { Object comment = getJsonElement(json, METADATA, "comment"); if (comment != null) { metacard.setAttribute(Metacard.DESCRIPTION, comment.toString()); } Object mediaType = getJsonElement(json, METADATA, "mediaType"); if (mediaType != null) { metacard.setAttribute(Media.TYPE, mediaType.toString()); } } else { metacard.setAttribute(Media.TYPE, "text/html"); } }
From source file:org.easyxml.xml.Attribute.java
/** * Set the value of this attribute./*from w ww . j a v a 2 s. c o m*/ * * @param value * - New value to be set. */ public void setValue(String value) { if (value == null) { throw new InvalidParameterException("Value of an attribute cannot be null!"); } this.value = StringEscapeUtils.escapeXml10(StringUtils.trim(value)); }
From source file:org.easyxml.xml.Element.java
/** * /*from w ww. ja v a 2s. c o m*/ * Set the innerText of the element * * @param value * - New innerText value. */ public void setValue(String value) { this.value = StringEscapeUtils.escapeXml10(StringUtils.trim(value)); }
From source file:org.easyxml.xml.Element.java
/** * //from w w w. java 2 s. com * Append new Text Node to existing innerText, it is called to merge * multiple text node as the innerText. * * @param value * - Text to be appended. * * @param appendFormat * - Format of how to append new text node to existing text node. * * The first '%s' denote the existing text, the second '%s' would * be replaced with formatted value. */ public void appendValue(String value, String appendFormat) { String formattedValue = StringEscapeUtils.escapeXml10(StringUtils.trim(value)); if (this.value == null || this.value.length() == 0) { this.value = formattedValue; } else if (!StringUtils.isBlank(formattedValue)) { this.value = String.format(appendFormat, this.value, formattedValue); } }
From source file:org.esupportail.publisher.service.factories.impl.VisibilityFactoryImpl.java
private VisibilityAbstract from(@NotNull SubjectKeyExtended model) { switch (model.getKeyType()) { case GROUP:/*from w w w.j av a 2 s. c om*/ if (Arrays.asList(environment.getActiveProfiles()).contains(Constants.SPRING_PROFILE_WS_GROUP)) { return new VisibilityGroup(StringEscapeUtils.escapeXml10(model.getKeyValue())); } //return new VisibilityRegex(externalUserHelper.getUserGroupAttribute(), Pattern.quote(StringEscapeUtils.escapeXml10(model.getKeyId()))); return new VisibilityRegular(externalUserHelper.getUserGroupAttribute(), StringEscapeUtils.escapeXml10(model.getKeyValue())); case PERSON: return new VisibilityRegular(externalUserHelper.getUserIdAttribute(), model.getKeyValue()); case PERSON_ATTR: return new VisibilityRegular(model.getKeyAttribute(), model.getKeyValue()); case PERSON_ATTR_REGEX: return new VisibilityRegex(model.getKeyAttribute(), model.getKeyValue()); default: throw new IllegalArgumentException("Unknown SubjectType not managed :" + model.getKeyType()); } }
From source file:org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.LanePropertyWriter.java
public void setName(String value) { lane.setName(StringEscapeUtils.escapeXml10(value.trim())); CustomElement.name.of(lane).set(value); }
From source file:org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.LanePropertyWriterTest.java
@Test public void JBPM_7523_shouldPreserveNameChars() { Lane lane = bpmn2.createLane();/*from w w w .j a v a2s .c om*/ PropertyWriterFactory writerFactory = new PropertyWriterFactory(); LanePropertyWriter w = writerFactory.of(lane); String aWeirdName = " XXX !!@@ <><> "; String aWeirdDoc = " XXX !!@@ <><> Docs "; w.setName(aWeirdName); w.setDocumentation(aWeirdDoc); assertThat(lane.getName()).isEqualTo(StringEscapeUtils.escapeXml10(aWeirdName.trim())); assertThat(CustomElement.name.of(lane).get()).isEqualTo(asCData(aWeirdName)); assertThat(lane.getDocumentation().get(0).getText()).isEqualTo(asCData(aWeirdDoc)); }
From source file:org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriter.java
public void setName(String value) { if (value == null || value.isEmpty()) { return;/*from ww w .j a va 2 s.c o m*/ } flowElement.setName(StringEscapeUtils.escapeXml10(value.trim())); CustomElement.name.of(flowElement).set(value); }
From source file:org.mcisb.util.xml.XmlWriter.java
/** * /*from w w w. j av a 2 s . c o m*/ * @param characters * @throws XMLStreamException */ public void writeCharacters(final String characters) throws XMLStreamException { writeCharacters(eventFactory.createCharacters(StringEscapeUtils.escapeXml10(characters))); }
From source file:org.moe.gradle.utils.JUnitTestCollector.java
private static String getXMLString(String str) { return StringEscapeUtils.escapeXml10(str); }