List of usage examples for org.apache.commons.lang StringUtils join
public static String join(Collection<?> collection, String separator)
Joins the elements of the provided Collection
into a single String containing the provided elements.
From source file:net.sourceforge.fenixedu.domain.degreeStructure.EctsComparabilityTable.java
EctsComparabilityTable(String[] table) { char[] converted = new char[table.length]; for (int i = 0; i < table.length; i++) { if (table[i].trim().length() != 1 || table[i].trim().charAt(0) < 'A' || table[i].trim().charAt(0) > 'E') { throw new DomainException("error.ects.invalidTable", StringUtils.join(table, "<tab>")); }/* ww w. j a v a 2 s . c o m*/ converted[i] = table[i].trim().charAt(0); } this.table = converted; }
From source file:com.redhat.rhn.frontend.taglibs.list.decorators.test.PageSizeDecoratorTest.java
public void testConfigPageSizes() { List<Integer> custom = new LinkedList<Integer>(); custom.add(4);//ww w . ja v a2s .com custom.add(6); custom.add(7); custom.add(88); custom.add(99); custom.add(300); Config.get().setString(ConfigDefaults.PAGE_SIZES, StringUtils.join(custom.iterator(), ", ")); assertEquals(custom, PageSizeDecorator.getPageSizes()); assertTrue(custom.contains(PageSizeDecorator.getDefaultPageSize())); Config.get().setString(ConfigDefaults.DEFAULT_PAGE_SIZE, String.valueOf(custom.get(4) - 5)); assertTrue(custom.contains(PageSizeDecorator.getDefaultPageSize())); assertEquals(custom.get(3), (Integer) PageSizeDecorator.getDefaultPageSize()); }
From source file:de.tudarmstadt.ukp.dkpro.tc.ml.report.util.PrettyPrintUtils.java
/** * Pretty prints the feature set// w ww . j a v a2 s. c o m * * @param featureSet * a comma separated list with feature names in angle brackets as provided by the * discriminators.txt * @param cutPackageNames * whether to keep or cut packages in features names * @return a shorter representation of names */ public static String prettyPrintFeatureSet(String featureSet, boolean cutPackageNames) { List<String> buffer = new ArrayList<String>(); String[] splittedArgs = featureSet.substring(1, featureSet.length() - 1).split(","); for (String fullFeatureName : splittedArgs) { if (cutPackageNames) { buffer.add(cutPackageNames(fullFeatureName.trim())); } else { buffer.add(fullFeatureName.trim()); } } return StringUtils.join(buffer, ", "); }
From source file:com.stratio.explorer.cassandra.dto.RowsDTO.java
private String cellDto(List<CellData> cells) { List<Object> list = new ArrayList<>(); for (CellData cell : cells) { CellDTO cellDTO = CellDTOFactory.getDTO(cell); list.add(cellDTO.toDTO(cell));//from w w w . ja v a 2 s .c om } return StringUtils.join(list, StringConstants.TABULATOR); }
From source file:com.titankingdoms.dev.titanchat.command.defaults.EmoteCommand.java
@Override public void execute(CommandSender sender, Channel channel, String[] args) { String format = "* " + sender.getName() + " %message"; String message = StringUtils.join(args, " "); channel.processConversation(plugin.getParticipantManager().getParticipant(sender), format, message); }
From source file:com.incapture.slate.model.node.description.table.TableHeaderNode.java
@Override public String getContent() { return StringUtils.join(fields, " | "); }
From source file:info.archinnov.achilles.compound.CQLSliceQueryValidator.java
public <T> void validateComponentsForSliceQuery(SliceQuery<T> sliceQuery) { final List<Object> clusteringsFrom = sliceQuery.getClusteringsFrom(); final List<Object> clusteringsTo = sliceQuery.getClusteringsTo(); final OrderingMode validationOrdering = sliceQuery.getOrdering(); final int partitionComponentsSize = sliceQuery.partitionComponentsSize(); final String startDescription = StringUtils .join(clusteringsFrom.subList(partitionComponentsSize, clusteringsFrom.size()), ","); final String endDescription = StringUtils .join(clusteringsTo.subList(partitionComponentsSize, clusteringsTo.size()), ","); log.trace("Check components {} / {}", startDescription, endDescription); final int startIndex = getLastNonNullIndex(clusteringsFrom); final int endIndex = getLastNonNullIndex(clusteringsTo); // No more than 1 non-null component difference between clustering keys Validator.validateTrue(Math.abs(endIndex - startIndex) <= 1, "There should be no more than 1 component difference between clustering keys: [[%s]," + "[%s]", startDescription, endDescription); for (int i = partitionComponentsSize; i <= Math.max(startIndex, endIndex) - 1; i++) { Object startComp = clusteringsFrom.get(i); Object endComp = clusteringsTo.get(i); int comparisonResult = comparator.compare(startComp, endComp); Validator.validateTrue(comparisonResult == 0, (i + 1 - partitionComponentsSize) + "th component for clustering keys should be equal: [[%s],[%s]", startDescription, endDescription); }// ww w . jav a 2 s. c om if (startIndex > 0 && startIndex == endIndex) { Object startComp = clusteringsFrom.get(startIndex); Object endComp = clusteringsTo.get(endIndex); if (ASCENDING.equals(validationOrdering)) { Validator.validateTrue(comparator.compare(startComp, endComp) <= 0, "For slice query with ascending order, start clustering last component should be " + "'lesser or equal' to end clustering last component: [[%s],[%s]", startDescription, endDescription); } else { Validator.validateTrue(comparator.compare(startComp, endComp) >= 0, "For slice query with descending order, start clustering last component should be " + "'greater or equal' to end clustering last component: [[%s],[%s]", startDescription, endDescription); } } }
From source file:com.aliyun.odps.mapred.bridge.TaskUDTF.java
public TaskUDTF() { URL url = this.getClass().getClassLoader().getResource("jobconf.xml"); if (url == null) { URL[] urls = ((URLClassLoader) this.getClass().getClassLoader()).getURLs(); throw new RuntimeException( "Job configure file jobconf.xml not found. Classpath:" + StringUtils.join(urls, ":")); }/*from w ww . j a v a2s . c o m*/ conf = new BridgeJobConf(false); conf.addResource("jobconf.xml"); }
From source file:au.org.ala.delta.intkey.directives.DisplayCharacterOrderSeparateDirective.java
@Override protected BasicIntkeyDirectiveInvocation doProcess(IntkeyContext context, String data) throws Exception { Item taxonToSeparate;/*from w w w . j a v a2 s . co m*/ if (data == null) { List<Item> selectedTaxonInList = context.getDirectivePopulator().promptForTaxaByList( StringUtils.join(getControlWords(), " ").toUpperCase(), true, true, true, false, null, null); if (selectedTaxonInList == null || selectedTaxonInList.size() == 0) { // cancel return null; } else { taxonToSeparate = selectedTaxonInList.get(0); } } else { boolean parseError = false; int taxonNumber = 0; int totalNumberOfTaxa = context.getDataset().getNumberOfTaxa(); try { taxonNumber = Integer.parseInt(data); if (taxonNumber < 1 || taxonNumber > totalNumberOfTaxa) { parseError = true; } } catch (NumberFormatException ex) { parseError = true; } if (parseError) { throw new IntkeyDirectiveParseException("InvalidTaxonNumber.error", context.getDataset().getNumberOfTaxa()); } taxonToSeparate = context.getDataset().getItem(taxonNumber); } DisplayCharacterOrderSeparateDirectiveInvocation invoc = new DisplayCharacterOrderSeparateDirectiveInvocation( taxonToSeparate); return invoc; }
From source file:info.archinnov.achilles.logger.ThriftLoggerHelper.java
public static String format(List<Component<?>> components) { String formatted = "[]"; if (components != null && components.size() > 0) { List<String> componentsText = new ArrayList<String>(); int componentNb = components.size(); for (int i = 0; i < componentNb; i++) { Component<?> component = components.get(i); String componentValue; if (component.getSerializer() == ThriftSerializerUtils.BYTE_SRZ) { componentValue = ByteBufferUtil.getArray(component.getBytes())[0] + ""; } else { componentValue = component.getValue(component.getSerializer()).toString(); }// w w w . ja v a2s .c om if (i == componentNb - 1) { componentsText.add(componentValue + "(" + component.getEquality().name() + ")"); } else { componentsText.add(componentValue); } } formatted = '[' + StringUtils.join(componentsText, ':') + ']'; ; } return formatted; }