List of usage examples for org.apache.commons.lang3 StringEscapeUtils unescapeJava
public static final String unescapeJava(final String input)
Unescapes any Java literals found in the String .
From source file:com.streamsets.pipeline.stage.origin.http.HttpClientDSource.java
@Override protected Source createSource() { conf.entityDelimiter = StringEscapeUtils.unescapeJava(conf.entityDelimiter); conf.dataFormatConfig.jsonContent = JsonMode.MULTIPLE_OBJECTS; // Only mode that is currently supported. return new HttpClientSource(conf); }
From source file:de.micromata.tpsb.doc.parser.TypeUtils.java
License:asdf
/** * Checks if s is quoted "asdfasdf" and removed it. * /*from www .ja v a 2s. c o m*/ * @param s the string to unquote * @return the string without the quotes */ public static String unqoteString(String s) { if (s == null) { return s; } if (s.startsWith("\"") == false) { return s; } s = s.substring(1, s.length() - 1); s = StringEscapeUtils.unescapeJava(s); return s; }
From source file:com.fecresgam.dbsd.translator.dto.columns.CommonColumn.java
public CommonColumn(final String name, final DataType type, final List<ColumnOption> options, final String description) { this.name = name; this.type = type; this.options = options; this.description = StringEscapeUtils.unescapeJava(description); }
From source file:com.hpcloud.mon.common.model.metric.Metrics.java
/** * Returns the Metric for the {@code metricJson}. * //from w w w .ja v a2s . com * @throws RuntimeException if an error occurs while parsing {@code metricJson} */ public static Metric fromJson(byte[] metricJson) { try { String jsonStr = StringEscapeUtils.unescapeJava(new String(metricJson, "UTF-8")); return OBJECT_MAPPER.readValue(jsonStr, Metric.class); } catch (Exception e) { throw Exceptions.uncheck(e, "Failed to parse metric json: %s", new String(metricJson)); } }
From source file:ca.hedlund.jiss.preprocessor.InfoPreprocessor.java
@Override public boolean preprocessCommand(JissModel jissModel, String orig, StringBuffer cmd) { final String c = cmd.toString(); if (c.equals(INFO_CMD)) { // clear string cmd.setLength(0);// w ww . j av a 2 s. c o m final ScriptEngine se = jissModel.getScriptEngine(); final ScriptEngineFactory seFactory = se.getFactory(); final boolean incnl = !seFactory.getOutputStatement("").startsWith("println"); final String infoCmd = seFactory.getOutputStatement(INFO_TXT + (incnl ? "\\n" : "")); final String langCmd = seFactory.getOutputStatement("Language:" + seFactory.getLanguageName() + " " + seFactory.getLanguageVersion() + (incnl ? "\\n" : "")); final String engineCmd = seFactory.getOutputStatement("Engine:" + seFactory.getEngineName() + " " + seFactory.getEngineVersion() + (incnl ? "\\n" : "")); final String program = seFactory.getProgram(infoCmd, langCmd, engineCmd); cmd.append(StringEscapeUtils.unescapeJava(program)); } // we want the scripting engine to handle the replaced command return false; }
From source file:io.github.seleniumquery.by.firstgen.css.attributes.ClassAttributeCssSelector.java
@Override public ConditionSimpleComponent conditionToXPath(ArgumentMap argumentMap, Selector simpleSelector, AttributeCondition attributeCondition) { String wantedClassName = attributeCondition.getValue(); String unescapedClassName = StringEscapeUtils.unescapeJava(wantedClassName); // nothing to do, everyone supports filtering by class return new ConditionSimpleComponent( "[contains(concat(' ', normalize-space(@class), ' '), ' " + unescapedClassName + " ')]"); }
From source file:com.oneops.search.msg.processor.es.DLQMessageProcessor.java
private String convertMessage(String message, Map<String, String> headers) { String newMessage = message;/*from ww w .ja v a 2 s . c o m*/ 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; }
From source file:com.splicemachine.derby.impl.sql.execute.operations.export.ExportParams.java
public ExportParams(String directory, boolean compression, int replicationCount, String characterEncoding, String fieldDelimiter, String quoteChar) throws StandardException { setDirectory(directory);//from w w w . ja v a 2 s . c om setCompression(compression); setReplicationCount((short) replicationCount); setCharacterEncoding(characterEncoding); setDefaultFieldDelimiter(StringEscapeUtils.unescapeJava(fieldDelimiter)); setQuoteChar(StringEscapeUtils.unescapeJava(quoteChar)); }
From source file:dk.nodes.webservice.parser.NJSON.java
static String toString(Object value) { if (value instanceof String) { return StringEscapeUtils.unescapeJava(String.valueOf(value)); } else if (value != null) { return String.valueOf(value); }/*from w ww .jav a2 s .co m*/ return null; }
From source file:com.gettextresourcebundle.GettextResourceBundle.java
/** * initialize the ResourceBundle from a PO file * //from w ww. j ava 2s.c o m * if * * @param reader the reader to read the contents of the PO file from */ private void init(LineNumberReader reader) { if (reader != null) { String line = null; String key = null; String value = null; try { while ((line = reader.readLine()) != null) { if (line.startsWith("#")) { LOG.trace(reader.getLineNumber() + ": Parsing PO file, comment skipped [" + line + "]"); } else if (line.trim().length() == 0) { LOG.trace(reader.getLineNumber() + ": Parsing PO file, whitespace line skipped"); } else { Matcher matcher = LINE_PATTERN.matcher(line); if (matcher.matches()) { String type = matcher.group(1); String str = matcher.group(2); if ("msgid".equals(type)) { if (key != null && value != null) { LOG.debug( "Parsing PO file, key,value pair found [" + key + " => " + value + "]"); resources.put(StringEscapeUtils.unescapeJava(key), StringEscapeUtils.unescapeJava(value)); key = null; value = null; } key = str; LOG.trace(reader.getLineNumber() + ": Parsing PO file, msgid found [" + key + "]"); } else if ("msgstr".equals(type)) { value = str; LOG.trace( reader.getLineNumber() + ": Parsing PO file, msgstr found [" + value + "]"); } else if (type == null || type.length() == 0) { if (value == null) { LOG.trace(reader.getLineNumber() + ": Parsing PO file, addition to msgid found [" + str + "]"); key += str; } else { LOG.trace(reader.getLineNumber() + ": Parsing PO file, addition to msgstr found [" + str + "]"); value += str; } } } else { LOG.error(reader.getLineNumber() + ": Parsing PO file, invalid syntax [" + line + "]"); } } } if (key != null && value != null) { LOG.debug("Parsing PO file, key,value pair found [" + key + " => " + value + "]"); resources.put(StringEscapeUtils.unescapeJava(key), StringEscapeUtils.unescapeJava(value)); key = null; value = null; } } catch (IOException e) { LOG.error("GettextResourceBundle could not be initialized", e); } } else { LOG.warn("GettextResourceBundle could not be initialized, input was null"); } LOG.info("GettextResourceBundle initialization complete, " + resources.size() + " resources loaded"); }