@Override public String[] getTargetVarNames(AggregatorConfig aggregatorConfig) { Config config = (Config) aggregatorConfig; String targetName = StringUtils.isNotNullAndNotEmpty(config.targetName) ? config.targetName : config.onMaxVarName; String[] setVarNames = config.setVarNames != null ? config.setVarNames : new String[0]; return createOutputFeatureNames(targetName, setVarNames); } }
private static String[] createOutputFeatureNames(String targetName, String[] setVarNames) { if (StringUtils.isNullOrEmpty(targetName)) { throw new IllegalArgumentException("targetName must not be empty"); } String[] featureNames = new String[setVarNames.length + 2]; featureNames[0] = targetName + "_max"; featureNames[1] = targetName + "_mjd"; System.arraycopy(setVarNames, 0, featureNames, 2, setVarNames.length); return featureNames; }
private static void addSourceProductsVariable(Map<String, String> variables) { List<String> varValueList = new ArrayList<String>(); for (Map.Entry<String, String> entry : variables.entrySet()) { if (entry.getKey().matches("sourceProduct[0-9]+")) { varValueList.add(entry.getValue()); } } variables.put("sourceProducts", StringUtils.arrayToCsv(varValueList.toArray())); }
public static AutoGrouping parse(String text) { String[][] paths; if (StringUtils.isNotNullAndNotEmpty(text)) { String[] pathTexts = StringUtils.toStringArray(text, PATH_SEPARATOR); paths = new String[pathTexts.length][]; for (int i = 0; i < paths.length; i++) { paths[i] = StringUtils.toStringArray(pathTexts[i], GROUP_SEPARATOR); } return new AutoGroupingImpl(paths); } else { return null; } }
private static int[] getHistogramBins(Element bandStatisticsElem) { final String histogramValues = bandStatisticsElem.getChildTextTrim(DimapProductConstants.TAG_HISTOGRAM); if (StringUtils.isNullOrEmpty(histogramValues)) { return null; } return StringUtils.toIntArray(histogramValues, null); }
final Element mapInfoElement = horCsElem.getChild(DimapProductConstants.TAG_GEOCODING_MAP_INFO); final String mapInfoText = mapInfoElement.getTextTrim(); if (!StringUtils.isNullOrEmpty(mapInfoText)) { final String[] mapInfoStrings = StringUtils.toStringArray(mapInfoText, null); final int offs = mapInfoStrings.length % 11; pixelX = Float.parseFloat(mapInfoStrings[1 + offs]);
final int[] bins = band.getStx().getHistogramBins(); if (bins != null && bins.length > 0) { sXmlW.printLine(indent + 2, DimapProductConstants.TAG_HISTOGRAM, StringUtils.arrayToCsv(bins)); sXmlW.println(cppTags[0]); sXmlW.printLine(indent + 3, DimapProductConstants.TAG_SAMPLE, point.getSample()); if (StringUtils.isNotNullAndNotEmpty(point.getLabel())) { sXmlW.printLine(indent + 3, DimapProductConstants.TAG_LABEL, point.getLabel());
private boolean isFileExtensionValid(File file) { String fileExtension = FileUtils.getExtension(file); if (fileExtension != null) { return StringUtils.contains(getDefaultFileExtensions(), fileExtension.toLowerCase()); } return false; }
public BeamFileFilter(String formatName, String extension, String description) { this(formatName, StringUtils.toStringArray(extension, ","), description); }
/** * Gets a comma separate value string for the given array object. * * @param array the array object of values. * @return a comma separate value string for the given array object. * @throws IllegalArgumentException if the given Object is not an <code>array</code> or <code>null</code>. */ public static String arrayToCsv(final Object array) { return arrayToString(array, ","); }
final String[] allNames = StringUtils.toStringArray(maskNameListModel.toArray()); for (int i = 0; i < allNames.length; i++) { String name = allNames[i]; if (StringUtils.contains(currentSelectedMaskNames, name)) { maskNameList.getCheckBoxListSelectionModel().addSelectionInterval(i, i);
public void testJoinAndSplit() { Object[] tokensOrig = {"Fischer's", "Fritz", "fischt", "frische", "", "Fische"}; String textOrig1 = "Fischer's Fritz fischt frische Fische"; String textOrig2 = "Fischer's|Fritz|fischt|frische||Fische"; assertEquals(StringUtils.join(tokensOrig, " "), textOrig1); assertEquals(StringUtils.join(tokensOrig, "|"), textOrig2); assertEquals(ArrayUtils.equalArrays(StringUtils.split(textOrig1, new char[]{' '}, false), tokensOrig), true); assertEquals(ArrayUtils.equalArrays(StringUtils.split(textOrig2, new char[]{'|'}, false), tokensOrig), true); }
private static String createValidNodeName(final String originalBandName) { String name = StringUtils.createValidName(originalBandName, null, '_'); while (name.startsWith("_")) { name = name.substring(1); } while (name.endsWith("_")) { name = name.substring(0, name.length() - 1); } return name; } }
/** * Joins the given array of tokens to a new text string. The given separator string is put between each of the * tokens. If a token in the array is <code>null</code> or empty, an empty string string is appended to the * resulting text. The resulting text string will always contain <code>tokens.length - 1</code> separators, if the * separator is not part of one of the tokens itself. * * @param tokens the list of tokens to join, must not be null * @param separator the separator string, must not be null * @return the list of tokens as a text string * @throws IllegalArgumentException if one of the arguments was null * @see #join(Object[], String) */ public static String join(List tokens, String separator) { if (tokens == null) { throw new IllegalArgumentException(UtilConstants.MSG_NULL_TOKEN); } return join(tokens.toArray(), separator); }
void exportPlacemarks() { final BeamFileChooser fileChooser = new BeamFileChooser(); fileChooser.setDialogTitle(MessageFormat.format("Export {0}(s)", StringUtils.firstLetterUp(placemarkDescriptor.getRoleLabel()))); /*I18N*/ setComponentName(fileChooser, "Export_Selected"); fileChooser.addChoosableFileFilter(PlacemarkIO.createTextFileFilter()); BeamFileFilter beamFileFilter = fileChooser.getBeamFileFilter(); String fileExtension = FileUtils.getExtension(file); if (fileExtension == null || !StringUtils.contains(beamFileFilter.getExtensions(), fileExtension)) { file = FileUtils.ensureExtension(file, beamFileFilter.getDefaultExtension());
@Override public DecodeQualification getDecodeQualification(Object object) { File file = getFile(object); if (file != null) { String fileExt = FileUtils.getExtension(file); if (fileExt != null && StringUtils.contains(getDefaultFileExtensions(), fileExt.toLowerCase())) { return DecodeQualification.SUITABLE; } } return DecodeQualification.UNABLE; }
/** * Decodes the "band_names" attribute string into a new band name * * @param names a csv list of band names * @param layerIdx the index requested * @return the decoded band name */ public static String decodeBandName(String names, int layerIdx) { String strRet = "."; String[] namesArray; namesArray = StringUtils.toStringArray(names, ","); strRet += namesArray[layerIdx]; strRet = strRet.trim(); return strRet; }
@Override public String toString(Object obj) { return StringUtils.arrayToString(obj, ","); }
/** * Creates a valid filename for the given source name. The method returns a string which is the given name where * each occurence of a character which is not a letter, a digit or one of '_', '-', '.' is replaced by an * underscore. The returned string always has the same length as the source name. * * @param name the source name, must not be <code>null</code> */ public static String createValidFilename(String name) { Guardian.assertNotNull("name", name); return StringUtils.createValidName(name, new char[]{'_', '-', '.'}, '_'); }
String[] toStringArray(long totalNettoTime) { String[] strings = new String[7]; strings[0] = opAlias; strings[1] = opClass; strings[2] = opType; strings[3] = String.format("%d", asMillis(bruttoNanos)); strings[4] = String.format("%d", asMillis(nettoNanos)); strings[5] = String.format("%.2f", 100.0f * nettoNanos / totalNettoTime); ArrayList<String> nameList = new ArrayList<>(bandNameSet); Collections.sort(nameList); strings[6] = StringUtils.join(nameList, ","); return strings; } }