/** * Formats a string (typically a component {@link Description}) into an * appropriate set of HTML paragraphs ('p' tag). * * @param str * @return */ public static String createHtmlParagraphs(String str) { if (Strings.isNullOrEmpty(str)) { return ""; } str = "<p>" + str + "</p>"; str = StringUtils.replaceAll(str, "\n\n", "\n"); str = StringUtils.replaceAll(str, "\n", "</p><p>"); return str; } }
private void createTemporaryHadoopConfFile(final File hadoopConfDir, final String filename, final String templateName) throws IOException { final File coreSiteFile = new File(hadoopConfDir, filename); try (InputStream inputStream = getClass().getResourceAsStream(templateName)) { final BufferedReader reader = FileHelper.getBufferedReader(inputStream, FileHelper.UTF_8_ENCODING); try (Writer writer = FileHelper.getWriter(coreSiteFile)) { String line = reader.readLine(); while (line != null) { line = StringUtils.replaceAll(line, "${HDFS_HOSTNAME}", _defaultFs.getHost()); line = StringUtils.replaceAll(line, "${HDFS_PORT}", _defaultFs.getPort() + ""); writer.write(line); line = reader.readLine(); } writer.flush(); } } }
/** * Creates a string with all variable names replaced with dynamic values * coming from the {@link InputRow}'s values. * * @param str * the string to prepare with variables * @param inputRow * the input row containing the dynamic values to insert into the * string * @return */ protected String applyVariablesToString(final String str, final InputRow inputRow) { if (Strings.isNullOrEmpty(str)) { return null; } String result = str; final List<Object> values = inputRow.getValues(input); for (int i = 0; i < input.length; i++) { final Object value = values.get(i); final String valueStr; if (value == null) { valueStr = ""; } else { valueStr = value.toString(); } result = StringUtils.replaceAll(result, variableNames[i], valueStr); } return result; }
} else { string = StringUtils.replaceWhitespaces(string, ""); string = StringUtils.replaceAll(string, "-", ""); string = StringUtils.replaceAll(string, "_", ""); string = StringUtils.replaceAll(string, "|", ""); string = StringUtils.replaceAll(string, "*", ""); string = string.toUpperCase(); if (string.isEmpty()) {
path = StringUtils.replaceAll(path, "\\", "/"); if (!absolute) {
if (name != null) { name = StringUtils.replaceWhitespaces(name, ""); name = StringUtils.replaceAll(name, "_", ""); name = StringUtils.replaceAll(name, "-", ""); name = name.toLowerCase(); if ("id".equals(name) || (tableName + "id").equals(name) || (tableName + "number").equals(name) || (
public void addProperties(final Collection<ConfiguredPropertyDescriptor> properties) { for (final ConfiguredPropertyDescriptor propertyDescriptor : properties) { final PropertyWidget<?> propertyWidget = getPropertyWidget(propertyDescriptor); // some properties may not have a PropertyWidget if (propertyWidget != null) { final JComponent component = propertyWidget.getWidget(); // some properties may have a PropertyWidget implementation that // is "invisible", ie. the JComponent is not returned if (component != null) { final String propertyName = propertyDescriptor.getName(); String description = propertyDescriptor.getDescription(); description = StringUtils.replaceAll(description, "\n", " "); addFormEntry(propertyName, description, component); } } } }