List of usage examples for org.apache.commons.lang3 StringEscapeUtils unescapeHtml4
public static final String unescapeHtml4(final String input)
Unescapes a string containing entity escapes to a string containing the actual Unicode characters corresponding to the escapes.
From source file:org.tinymediamanager.ui.actions.WikiAction.java
@Override public void actionPerformed(ActionEvent e) { String url = StringEscapeUtils.unescapeHtml4("https://github.com/tinyMediaManager/tinyMediaManager/wiki"); try {//www . jav a 2 s. co m TmmUIHelper.browseUrl(url); } catch (Exception e1) { LOGGER.error("FAQ", e1); MessageManager.instance.pushMessage(new Message(MessageLevel.ERROR, url, "message.erroropenurl", new String[] { ":", e1.getLocalizedMessage() })); } }
From source file:org.voltdb.exportclient.ExportToFileClient.java
public ExportToFileClient(char delimiter, String nonce, File outdir, int period, String dateformatString, String fullDelimiters, int firstfield, boolean useAdminPorts, boolean batched, boolean withSchema, int throughputMonitorPeriod, boolean autodiscoverTopolgy) { super(useAdminPorts, throughputMonitorPeriod, autodiscoverTopolgy); m_delimiter = delimiter;/*w ww .j av a 2 s. co m*/ m_extension = (delimiter == ',') ? ".csv" : ".tsv"; m_nonce = nonce; m_outDir = outdir; m_tableDecoders = new HashMap<Long, HashMap<String, ExportToFileDecoder>>(); m_period = period; m_dateFormatOriginalString = dateformatString; // SimpleDateFormat isn't threadsafe // ThreadLocal variables should protect them, lamely. m_dateformat = new ThreadLocal<SimpleDateFormat>() { @Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat(m_dateFormatOriginalString); } }; m_ODBCDateformat = new ThreadLocal<SimpleDateFormat>() { @Override protected SimpleDateFormat initialValue() { return new SimpleDateFormat(ODBC_DATE_FORMAT_STRING); } }; m_firstfield = firstfield; m_batched = batched; m_withSchema = withSchema; if (fullDelimiters != null) { fullDelimiters = StringEscapeUtils.unescapeHtml4(fullDelimiters); m_fullDelimiters = new char[4]; for (int i = 0; i < 4; i++) { m_fullDelimiters[i] = fullDelimiters.charAt(i); //System.out.printf("FULL DELIMETER %d: %c\n", i, m_fullDelimiters[i]); } } else { m_fullDelimiters = null; } // init the batch system with the first batch assert (m_current == null); m_current = new PeriodicExportContext(new Date()); // schedule rotations every m_period minutes TimerTask rotateTask = new TimerTask() { @Override public void run() { roll(new Date()); } }; m_timer.scheduleAtFixedRate(rotateTask, 1000 * 60 * m_period, 1000 * 60 * m_period); }
From source file:org.voltdb.exportclient.ExportToFileClient.java
public static void main(String[] args) { String[] volt_servers = null; String user = null;//from www.j a v a 2 s . c o m String password = null; String nonce = null; char delimiter = '\0'; File outdir = null; int firstfield = 0; int period = 60; char connect = ' '; // either ' ', 'c' or 'a' String dateformatString = "yyyyMMddHHmmss"; boolean batched = false; boolean withSchema = false; String fullDelimiters = null; int throughputMonitorPeriod = 0; boolean autodiscoverTopolgy = true; for (int ii = 0; ii < args.length; ii++) { String arg = args[ii]; if (arg.equals("--help")) { printHelpAndQuit(0); } else if (arg.equals("--discard")) { System.err.println("Option \"--discard\" is no longer supported."); System.err.println("Try org.voltdb.exportclient.DiscardingExportClient."); printHelpAndQuit(-1); } else if (arg.equals("--skipinternals")) { firstfield = 6; } else if (arg.equals("--connect")) { if (args.length < ii + 1) { System.err.println("Error: Not enough args following --connect"); printHelpAndQuit(-1); } String connectStr = args[ii + 1]; if (connectStr.equalsIgnoreCase("admin")) { connect = 'a'; } else if (connectStr.equalsIgnoreCase("client")) { connect = 'c'; } else { System.err.println("Error: --type must be one of \"admin\" or \"client\""); printHelpAndQuit(-1); } ii++; } else if (arg.equals("--servers")) { if (args.length < ii + 1) { System.err.println("Error: Not enough args following --servers"); printHelpAndQuit(-1); } volt_servers = args[ii + 1].split(","); ii++; } else if (arg.equals("--type")) { if (args.length < ii + 1) { System.err.println("Error: Not enough args following --type"); printHelpAndQuit(-1); } String type = args[ii + 1]; if (type.equalsIgnoreCase("csv")) { delimiter = ','; } else if (type.equalsIgnoreCase("tsv")) { delimiter = '\t'; } else { System.err.println("Error: --type must be one of CSV or TSV"); printHelpAndQuit(-1); } ii++; } else if (arg.equals("--outdir")) { if (args.length < ii + 1) { System.err.println("Error: Not enough args following --outdir"); printHelpAndQuit(-1); } boolean invalidDir = false; outdir = new File(args[ii + 1]); if (!outdir.exists()) { if (!outdir.mkdir()) { System.err.println("Error: " + outdir.getPath() + " cannot be created"); invalidDir = true; } } if (!outdir.canRead()) { System.err.println("Error: " + outdir.getPath() + " does not have read permission set"); invalidDir = true; } if (!outdir.canExecute()) { System.err.println("Error: " + outdir.getPath() + " does not have execute permission set"); invalidDir = true; } if (!outdir.canWrite()) { System.err.println("Error: " + outdir.getPath() + " does not have write permission set"); invalidDir = true; } if (invalidDir) { System.exit(-1); } ii++; } else if (arg.equals("--nonce")) { if (args.length < ii + 1) { System.err.println("Error: Not enough args following --nonce"); printHelpAndQuit(-1); } nonce = args[ii + 1]; ii++; } else if (arg.equals("--user")) { if (args.length < ii + 1) { System.err.println("Error: Not enough args following --user"); printHelpAndQuit(-1); } user = args[ii + 1]; ii++; } else if (arg.equals("--password")) { if (args.length < ii + 1) { System.err.println("Error: Not enough args following --password"); printHelpAndQuit(-1); } password = args[ii + 1]; ii++; } else if (arg.equals("--period")) { if (args.length < ii + 1) { System.err.println("Error: Not enough args following --period"); printHelpAndQuit(-1); } period = Integer.parseInt(args[ii + 1]); if (period < 1) { System.err.println("Error: Specified value for --period must be >= 1."); printHelpAndQuit(-1); } ii++; } else if (arg.equals("--dateformat")) { if (args.length < ii + 1) { System.err.println("Error: Not enough args following --dateformat"); printHelpAndQuit(-1); } dateformatString = args[ii + 1].trim(); ii++; } else if (arg.equals("--batched")) { batched = true; } else if (arg.equals("--with-schema")) { withSchema = true; } else if (arg.equals("--delimiters")) { if (args.length < ii + 1) { System.err.println("Error: Not enough args following --delimiters"); printHelpAndQuit(-1); } fullDelimiters = args[ii + 1].trim(); ii++; String charsAsStr = StringEscapeUtils.unescapeHtml4(fullDelimiters.trim()); if (charsAsStr.length() != 4) { System.err.println( "The delimiter set must contain exactly 4 characters (after any html escaping)."); printHelpAndQuit(-1); } } else if (arg.equals("--disable-topology-autodiscovery")) { autodiscoverTopolgy = false; } else if (arg.equals("--throughput-monitor-period")) { if (args.length < ii + 1) { System.err.println("Error: Not enough args following --throughput-monitor-period"); printHelpAndQuit(-1); } throughputMonitorPeriod = Integer.parseInt(args[ii + 1].trim()); ii++; } else { System.err.println("Unrecognized parameter " + arg); System.exit(-1); } } // Check args for validity if (volt_servers == null || volt_servers.length < 1) { System.err.println("ExportToFile: must provide at least one VoltDB server"); printHelpAndQuit(-1); } if (connect == ' ') { System.err.println( "ExportToFile: must specify connection type as admin or client using --connect argument"); printHelpAndQuit(-1); } assert ((connect == 'c') || (connect == 'a')); if (user == null) { user = ""; } if (password == null) { password = ""; } if (nonce == null) { System.err.println("ExportToFile: must provide a filename nonce"); printHelpAndQuit(-1); } if (outdir == null) { outdir = new File("."); } if (delimiter == '\0') { System.err.println("ExportToFile: must provide an output type"); printHelpAndQuit(-1); } // create the export to file client ExportToFileClient client = new ExportToFileClient(delimiter, nonce, outdir, period, dateformatString, fullDelimiters, firstfield, connect == 'a', batched, withSchema, throughputMonitorPeriod, autodiscoverTopolgy); // add all of the servers specified for (String server : volt_servers) { server = server.trim(); client.m_commandLineServerArgs.add(server); client.addServerInfo(server, connect == 'a'); } // add credentials (default blanks used if none specified) client.addCredentials(user, password); // main loop try { client.run(); } catch (ExportClientException e) { e.printStackTrace(); System.exit(-1); } }
From source file:org.whispersystems.bithub.views.TransactionView.java
private String parseDestinationFromMessage(String message) { message = StringEscapeUtils.unescapeHtml4(message); int startToken = message.indexOf("__"); if (startToken == -1) { return "Unknown"; }/*from w w w . j a va 2 s . com*/ int endToken = message.indexOf("__", startToken + 1); if (endToken == -1) { return "Unknown"; } return message.substring(startToken + 2, endToken); }
From source file:org.whispersystems.bithub.views.TransactionView.java
private String parseUrlFromMessage(String message) throws ParseException { message = StringEscapeUtils.unescapeHtml4(message); int urlIndex = message.indexOf("https://"); return message.substring(urlIndex).trim(); }
From source file:org.wikipedia.citolytics.cpa.utils.StringUtils.java
/** * Unescapes special entity char sequences like < to its UTF-8 representation. * All ISO-8859-1, HTML4 and Basic entities will be translated. * * @param text the text that will be unescaped * @return the unescaped version of the string text *///from w ww . j a v a 2s . c o m public static String unescapeEntities(String text) { CharSequenceTranslator iso = new LookupTranslator(EntityArrays.ISO8859_1_UNESCAPE()); CharSequenceTranslator basic = new LookupTranslator(EntityArrays.BASIC_UNESCAPE()); //CharSequenceTranslator html4 = new LookupTranslator(EntityArrays.HTML40_EXTENDED_UNESCAPE()); return StringEscapeUtils.unescapeHtml4(iso.translate(basic.translate(text))); }
From source file:org.xlrnet.metadict.engines.nobordbok.OrdbokEngine.java
@NotNull private Optional<MonolingualEntry> processTableRow(@NotNull Element tableRow, @NotNull Language language) { MonolingualEntryBuilder entryBuilder = ImmutableMonolingualEntry.builder(); DictionaryObjectBuilder objectBuilder = ImmutableDictionaryObject.builder().setLanguage(language); // Extract general form Element oppslagsord = tableRow.getElementsByClass("oppslagsord").first(); if (oppslagsord != null) { extractGeneralForm(objectBuilder, oppslagsord); } else {//from www .java2s. c om LOGGER.warn("Unable to find main element - skipping entry."); return Optional.empty(); } // Extract wordclass and determine entrytype String wordClass = tableRow.getElementsByClass("oppsgramordklasse").first().text(); entryBuilder.setEntryType(resolveEntryTypeWithWordClass(wordClass)); // Get meanings Elements meaningCandidates = tableRow.select(".artikkelinnhold > .utvidet > .tyding"); if (meaningCandidates.size() == 0) meaningCandidates = tableRow.select(".artikkelinnhold > .utvidet"); meaningCandidates.forEach(e -> { String meaning = e.childNodes().stream() .filter(node -> (node instanceof TextNode) || (!((Element) node).hasClass("doemeliste") && !node.hasAttr("style") && !((Element) node).hasClass("utvidet") && !((Element) node).hasClass("artikkelinnhold") && !((Element) node).hasClass("kompakt"))) .map((Node n) -> { if (n instanceof Element) return ((Element) n).text(); else return n.toString(); }).collect(Collectors.joining()); meaning = StringEscapeUtils.unescapeHtml4(meaning); meaning = StringUtils.strip(meaning); if (StringUtils.isNotBlank(meaning)) objectBuilder.addMeaning(meaning); }); entryBuilder.setContent(objectBuilder.build()); return Optional.of(entryBuilder.build()); }
From source file:org.xwiki.rendering.internal.parser.xwiki10.UnescapeHTMLFilter.java
private String unescapeNonHtmlContent(String content) { return StringEscapeUtils.unescapeHtml4(content); }
From source file:pah9qdmoviereviews.NYTMovieReview.java
public void setDisplayTitle(String displayTitle) { this.displayTitle = StringEscapeUtils.unescapeHtml4(displayTitle); }
From source file:pah9qdmoviereviews.NYTMovieReview.java
public void setMpaaRating(String mpaaRating) { this.mpaaRating = StringEscapeUtils.unescapeHtml4(mpaaRating); }