List of usage examples for org.apache.commons.lang3 StringUtils chop
public static String chop(final String str)
Remove the last character from a String.
If the String ends in \r\n , then remove both of them.
StringUtils.chop(null) = null StringUtils.chop("") = "" StringUtils.chop("abc \r") = "abc " StringUtils.chop("abc\n") = "abc" StringUtils.chop("abc\r\n") = "abc" StringUtils.chop("abc") = "ab" StringUtils.chop("abc\nabc") = "abc\nab" StringUtils.chop("a") = "" StringUtils.chop("\r") = "" StringUtils.chop("\n") = "" StringUtils.chop("\r\n") = ""
From source file:org.bonitasoft.web.designer.utils.assertions.JsAssert.java
/** * For each string lines we trim them to avoid whitespace issue when comparing strings */// w ww. j a v a 2s .c o m private String trimEachLines(String string) { String[] lines = string.split(System.lineSeparator()); StringBuilder sb = new StringBuilder(); for (String line : lines) { sb.append(StringUtils.trim(line)).append(System.lineSeparator()); } return StringUtils.chop(sb.toString()); }
From source file:org.dbgl.util.FileUtils.java
public static File[] findFileSequence(File f) { List<File> result = new ArrayList<File>(); result.add(f);/* w w w. ja v a2 s .co m*/ int i = 1; String name = FilenameUtils.removeExtension(f.getName()); String ext = FilenameUtils.getExtension(f.getName()); if (name.endsWith(String.valueOf(i))) { File dir = f.getParentFile(); if (dir != null) { File[] files = dir.listFiles(new FileFilter() { public boolean accept(File f) { return f.isFile(); } }); String[] fileNames = getNames(files); if (files != null) { int index; do { i++; String nextFileName = StringUtils.chop(name) + String.valueOf(i) + FilenameUtils.EXTENSION_SEPARATOR + ext; index = ArrayUtils.indexOf(fileNames, nextFileName); if (index >= 0) { result.add(files[index]); } } while (index >= 0); } } } return result.toArray(new File[0]); }
From source file:org.jasig.ssp.util.importer.job.csv.RawItemFlatFileHeaderCallback.java
@Override public void writeHeader(Writer writer) throws IOException { StringBuffer header = new StringBuffer(); if (columnNames == null) { logger.error("Column names not found"); throw new IOException("Unable to write table, column names not found"); }/*from ww w. j av a2s. c o m*/ for (String columnName : columnNames) { header.append(columnName).append(delimiter); } writer.write(StringUtils.chop(header.toString())); }
From source file:org.kalypso.commons.java.lang.Strings.java
/** * @deprecated removes all white spaces at beginning and end of an string (see perl, ruby, etc) *///from w w w .j a va2 s. c o m @Deprecated public static String chop(final String s) { return StringUtils.chop(s); }
From source file:org.kalypso.ogc.sensor.filter.filters.interval.IntervalSourceHandler.java
/** * @param srcFieldWasEmpty//from w w w. j a va2 s . c o m * if values has been empty, take source reference of other */ public static String mergeSourceReference(final String base, final String other) { final String[] baseSources = DataSourceHelper.getSources(base); final String[] otherSources = DataSourceHelper.getSources(other); final Set<String> allReferences = new TreeSet<>(); allReferences.addAll(Arrays.asList(baseSources)); allReferences.addAll(Arrays.asList(otherSources)); allReferences.remove(SOURCE_INITIAL_VALUE); if (allReferences.isEmpty()) return String.format("%s%s?source_0=%s", IDataSourceItem.FILTER_SOURCE, IntervalFilter.FILTER_ID, //$NON-NLS-1$ SOURCE_EXTENDED); else { final StringBuffer buffer = new StringBuffer(); buffer.append(String.format("%s%s?", IDataSourceItem.FILTER_SOURCE, IntervalFilter.FILTER_ID)); //$NON-NLS-1$ final String[] sourceArray = allReferences.toArray(new String[] {}); for (int i = 0; i < sourceArray.length; i++) buffer.append(String.format("source_%d=%s&", i, sourceArray[i])); //$NON-NLS-1$ return StringUtils.chop(buffer.toString()); } }
From source file:org.kalypso.ogc.sensor.zml.ObservationMarshaller.java
private static String buildStringAxis(final ITupleModel model, final IAxis axis) throws SensorException { final StringBuffer buffer = new StringBuffer(); for (int i = 0; i < model.size(); i++) { buffer.append(model.get(i, axis)).append(";"); //$NON-NLS-1$ }//ww w.j a v a 2 s.c o m return StringUtils.chop(buffer.toString()); }
From source file:org.kalypso.ogc.sensor.zml.ObservationMarshaller.java
private String buildStringDateAxis(final ITupleModel model, final IAxis axis) throws SensorException { final StringBuilder buffer = new StringBuilder(); final DateParser dateParser = getDateParser(m_timezone); for (int i = 0; i < model.size(); i++) { final Object obj = model.get(i, axis); buffer.append(dateParser.toString(obj)).append(";"); //$NON-NLS-1$ }//from w w w.j a va 2s . c om return StringUtils.chop(buffer.toString()); }
From source file:org.kalypso.ogc.sensor.zml.ObservationMarshaller.java
/** * Uses the default toString() method of the elements *///w w w .j a v a2 s . c o m private static String buildStringNumberAxis(final ITupleModel model, final IAxis axis) throws SensorException { final StringBuffer buffer = new StringBuffer(); for (int i = 0; i < model.size(); i++) { final Object elt = model.get(i, axis); if (elt == null) LOG.warning(Messages.getString("org.kalypso.ogc.sensor.zml.ZmlFactory.24") + i //$NON-NLS-1$ + Messages.getString("org.kalypso.ogc.sensor.zml.ZmlFactory.25") + axis); //$NON-NLS-1$ buffer.append(elt).append(";"); //$NON-NLS-1$ } return StringUtils.chop(buffer.toString()); }
From source file:org.kalypso.ui.rrm.internal.gml.feature.view.dialogs.ChooseTimeseriesDialog.java
protected void setWeights(final int[] weights) { final StringBuffer buffer = new StringBuffer(); for (final int weight : weights) { buffer.append(String.format(Messages.getString("EditTimeseriesDialog_3"), weight)); //$NON-NLS-1$ }//w ww. ja va2 s.co m final IDialogSettings settings = KalypsoUIRRMPlugin.getDefault().getDialogSettings(); settings.put(DIALOG_SASH_FORM_WEIGHTS, StringUtils.chop(buffer.toString())); }
From source file:org.kalypso.zml.ui.table.nat.tooltip.ZmlTableTooltip.java
private String getModelTooltip(final IZmlModelValueCell cell) { final IZmlModelColumn column = cell.getColumn(); final DataColumn type = column.getDataColumn(); final StringBuffer buffer = new StringBuffer(); final String indexAxis = type.getIndexAxis(); final String valueAxis = type.getValueAxis(); if (Objects.isNotNull(indexAxis)) buffer.append(buildInfoText(Messages.ZmlTableTooltip_1, indexAxis)); if (Objects.isNotNull(valueAxis)) buffer.append(buildInfoText(Messages.ZmlTableTooltip_2, valueAxis)); return StringUtils.chop(buffer.toString()); }