List of usage examples for org.apache.commons.lang StringUtils remove
public static String remove(String str, char remove)
Removes all occurrences of a character from within the source string.
From source file:org.talend.dataprep.schema.csv.CSVSerializer.java
private String cleanCharacters(final String value) { return StringUtils.remove(value, '\u0000'); }
From source file:org.talend.dataprep.util.NumericHelper.java
/** * Checks whether <code>str</code> can be parsed by {@link BigDecimalParser} without throwing an exception. * @param str The string to be tested, can be <code>null</code> or empty. * @return <code>true</code> if string can be parsed by {@link BigDecimalParser}, <code>false</code> otherwise. *///from ww w .j ava2s. c o m public static boolean isBigDecimal(String str) { if (StringUtils.isEmpty(str)) { return false; } // Check for (nnnn) values (negative values in accounting). String strForValidation = StringUtils.remove(str, ' '); if (strForValidation.lastIndexOf('(') == 0 && strForValidation.lastIndexOf(')') == strForValidation.length() - 1) { strForValidation = strForValidation.substring(1, strForValidation.length() - 1); // Keep only nnnn } if (!StringUtils.containsOnly(strForValidation, ALLOWED_NUMERIC_CHARACTERS) && !isValid(strForValidation, new BigDecimalValidator())) { return false; } // Support for values that starts with ',' or '.' (like .5 or ,5). if (strForValidation.charAt(0) == ',' || strForValidation.charAt(0) == '.') { return true; } // Try custom decimal formats DecimalFormat[] supportedFormats = { BigDecimalParser.EU_DECIMAL_PATTERN, BigDecimalParser.EU_SCIENTIFIC_DECIMAL_PATTERN, BigDecimalParser.US_DECIMAL_PATTERN, BigDecimalParser.US_SCIENTIFIC_DECIMAL_PATTERN }; for (DecimalFormat supportedFormat : supportedFormats) { try { if (supportedFormat.parse(strForValidation) != null) { return true; } } catch (ParseException e) { LOGGER.debug("Unable to parse '{}' using custom decimal format '{}'.", strForValidation, supportedFormat.toPattern(), e); } } return false; }
From source file:org.talend.designer.webservice.ui.WebServiceUI.java
private void synchronizeInputLinks(TableToTablesLinker<Object, Object> tabTotabLink, List<org.talend.core.model.metadata.IMetadataColumn> llist) { try {/* w ww.jav a 2 s . c o m*/ List<LinkDescriptor<TableItem, Object, Table, Object>> links = tabTotabLink.getLinksManager() .getLinks(); List<LinkDescriptor<TableItem, Object, Table, Object>> removeLinks = new ArrayList<LinkDescriptor<TableItem, Object, Table, Object>>(); for (LinkDescriptor<TableItem, Object, Table, Object> link : links) { boolean isExistColumn = false; IExtremityLink extremity = link.getExtremity1(); IMetadataColumn c = null; if (extremity.getDataItem() instanceof IMetadataColumn) { c = (IMetadataColumn) extremity.getDataItem(); } if (c != null) { for (IMetadataColumn column : llist) { if (c.getLabel().equals(column.getLabel())) { extremity.setDataItem(column); isExistColumn = true; break; } } if (!isExistColumn) { removeLinks.add(link); for (InputMappingData inputData : inputMappingList) { InputMappingData dataItem = (InputMappingData) link.getExtremity2().getDataItem(); if (inputData == dataItem) { inputData.setInputColumnValue(StringUtils .remove(inputData.getInputColumnValue(), "input." + c.getLabel()).trim()); } } } } } for (LinkDescriptor<TableItem, Object, Table, Object> link : removeLinks) { tabTotabLink.getLinksManager().removeLink(link); } expressinPutTableView.getExtendedTableViewer().getTableViewerCreator().refresh(); tabTotabLink.getBackgroundRefresher().refreshBackground(); } catch (Exception e) { tabTotabLink.clearLinks(); } }
From source file:org.talend.utils.sql.TalendTypeConvert.java
/** * //from w w w. jav a 2s. c o m * DOC qiongli Comment method "convertToObject". * * @param talendType * @param value * @param datePattern:just for date type then parse with the given pattern(format). * @return */ public static Object convertToObject(String talendType, String value, String datePattern) { Object object = null; // bug 19036 .remove the epmty string, '\r','\n'. value = value.trim(); value = StringUtils.remove(value, "\r"); value = StringUtils.remove(value, "\n"); try { if (talendType.equals(talendTypeName(Boolean.class))) { object = Boolean.valueOf(value).booleanValue(); } else if (talendType.equals(talendTypeName(Byte.class))) { object = Byte.valueOf(value).byteValue(); } else if (talendType.equals(talendTypeName(Date.class))) { // MOD qiongli 2011-10-27 TDQ-3802. if (datePattern == null || StringUtils.EMPTY.equals(datePattern.trim())) { datePattern = "yyyy-MM-dd"; } else { datePattern = StringUtils.replace(datePattern, "\"", StringUtils.EMPTY); } // add the parameter 'Locale.US' because make like 'AM/PM' could be parsed.then format and output as // the given 'datePattern' SimpleDateFormat sdf = new SimpleDateFormat(datePattern, Locale.US); object = sdf.parse(value); } else if (talendType.equals(talendTypeName(Double.class))) { object = Double.parseDouble(value); } else if (talendType.equals(talendTypeName(Float.class))) { object = Float.parseFloat(value); } else if (talendType.equals(talendTypeName(Integer.class))) { object = Integer.parseInt(value); } else if (talendType.equals(talendTypeName(Long.class))) { object = Long.parseLong(value); } else if (talendType.equals(talendTypeName(Short.class))) { object = Short.parseShort(value); } else if (talendType.equals(talendTypeName(String.class)) || talendType.equals(talendTypeName(Character.class))) { object = value; } } catch (ClassCastException ce) { return null; } catch (Exception e) { return null; } return object; }
From source file:org.talend.utils.sql.TalendTypeConvert.java
/** * /*from w w w.jav a2 s. c o m*/ * Convert the TalendType to Java type. * * @param talendType * @return */ public static String convertToJavaType(String talendType) { if (talendType == null) { return ""; } talendType = StringUtils.remove(talendType, idStr); return talendType; }
From source file:org.trzcinka.intellitrac.dto.Report.java
/** * Returns proper query string, that is, with newlines removed. * * @return proper query string, that is, with newlines removed. *//*from w ww. j a v a 2 s . c o m*/ public String getProperQuery() { return StringUtils.remove(query, "\n"); }
From source file:org.twinkql.result.DefaultMatchExpressionParser.java
/** * Parses the rdf node method./*from www . j a v a2s. c om*/ * * @param query the query * @return the match expression */ private MatchExpression parseRdfNodeMethod(String query) { String[] queryParts = StringUtils.split(query, DOT); if (queryParts == null || queryParts.length != 2) { throw new MatchConditionParseException(query); } return new JenaRdfNodeMatchExpression(StringUtils.remove(queryParts[0], '?').trim(), StringUtils.removeEnd(queryParts[1].trim(), METHOD)); }
From source file:org.twinkql.result.DefaultMatchExpressionParser.java
/** * Parses the equals.//from www .jav a2 s . c om * * @param query the query * @return the match expression */ private MatchExpression parseEquals(String query) { String[] queryParts = StringUtils.split(query, EQUALS); if (queryParts == null || queryParts.length != 2) { throw new MatchConditionParseException(query); } return new EqualsMatchExpression(StringUtils.remove(queryParts[0], '?').trim(), queryParts[1].trim()); }
From source file:org.webguitoolkit.ui.util.export.ExcelTableExport.java
protected void writeStringCell(HSSFCell cell, IConverter converter, Object obj, IDataBag dbag) { // most are string catch them first to save instance checks // remove html linebreaks from tabledate String tableData = obj.toString(); if (converter != null) { tableData = (String) converter.convert(String.class, obj); }/*from ww w .j a va2s . c o m*/ // replace html-line-breaks if (tableData.contains("<br/>") || tableData.contains("<br>")) { tableData = tableData.replaceAll("<br\\/>", " "); tableData = tableData.replaceAll("<br>", " "); } // replace html-blanks tableData = StringUtils.replace(tableData, " ", " "); // image filter - image tags will be deleted String imgOpenTag = "<img"; String imgCloseTag = ">"; while (StringUtils.contains(tableData, imgOpenTag) && StringUtils.contains(tableData, imgCloseTag)) { tableData = StringUtils.remove(tableData, imgOpenTag + StringUtils.substringBetween(tableData, imgOpenTag, imgCloseTag) + imgCloseTag); } cell.setCellValue(new HSSFRichTextString(tableData)); if (getExcelContentstyle() != null) { cell.setCellStyle(getExcelContentstyle()); } }
From source file:org.xmatthew.spy2servers.component.spy.jmx.TomcatJmxSpyComponent.java
@Override protected void inspectMBean(ObjectInstance objectInstance, MBeanServerConnection mbsc) throws Exception { super.inspectMBean(objectInstance, mbsc); String mBeanClass = objectInstance.getClassName(); ObjectName objectName = objectInstance.getObjectName(); if (BASEMODELBEAN_CLASS.equals(mBeanClass) || BASEMODELBAEN_CLASS_CHANGED.equals(mBeanClass)) { String type = objectName.getKeyProperty(JmxSpySupportComponent.TYPE); String name = objectName.getKeyProperty(JmxSpySupportComponent.NAME); name = StringUtils.remove(name, "\""); //is a DataSource mbean if (DATASOURCE.equals(type)) { dataSourceMBeanSpy(name, getAttributesAsMap(objectName.toString(), mbsc, getDataSourceKeys())); } else if (MANAGER.equals(type)) { //is a web module mbean }/*from ww w .j a v a 2s . c o m*/ } }