List of usage examples for org.apache.commons.lang3 StringUtils substringAfter
public static String substringAfter(final String str, final String separator)
Gets the substring after the first occurrence of a separator.
From source file:de.blizzy.documentr.TestUtil.java
public static String removeViewPrefix(String view) { return view.contains(":") ? StringUtils.substringAfter(view, ":") : view; //$NON-NLS-1$ //$NON-NLS-2$ }
From source file:io.wcm.testing.mock.sling.servlet.MockSlingHttpServletResponse.java
@Override public void setContentType(final String type) { this.contentType = type; if (StringUtils.contains(this.contentType, CHARSET_SEPARATOR)) { this.characterEncoding = StringUtils.substringAfter(this.contentType, CHARSET_SEPARATOR); this.contentType = StringUtils.substringBefore(this.contentType, CHARSET_SEPARATOR); }/*from www . j av a 2 s . c o m*/ }
From source file:com.bmw.spdxeditor.SPDXPreferencesPage.java
@Override protected Control createContents(Composite parent) { IPreferenceStore store = getPreferenceStore(); String fileCreatorValue = store.getString(DEFAULT_FILE_CREATOR); String fileCreatorType = null; if (StringUtils.isEmpty(fileCreatorValue)) { fileCreatorValue = "NOASSERTION"; fileCreatorType = ""; } else {//from w ww. java2s.c om fileCreatorType = StringUtils.substringBefore(fileCreatorValue, ":"); fileCreatorValue = StringUtils.substringAfter(fileCreatorValue, ":").trim(); } // Describe layout for this group panel GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 3; parent.setLayout(gridLayout); Label lbl = new Label(parent, SWT.NONE); lbl.setText("Package creator default"); // Person, Organization, Tool String items[] = { "Person", "Organization", "Tool", "" }; creatorTypes = new Combo(parent, SWT.READ_ONLY); creatorTypes.setItems(items); creatorTypes.setText(fileCreatorType); creatorText = new Text(parent, SWT.BORDER); creatorText.setText(fileCreatorValue); return null; }
From source file:io.cloudslang.lang.compiler.modeller.transformers.AbstractForTransformer.java
public TransformModellingResult<LoopStatement> transformToLoopStatement(String rawData, boolean isParallelLoop) { List<RuntimeException> errors = new ArrayList<>(); Accumulator dependencyAccumulator = extractFunctionData("${" + rawData + "}"); if (StringUtils.isEmpty(rawData)) { errors.add(new RuntimeException("For statement is empty.")); return new BasicTransformModellingResult<>(null, errors); }/*ww w . j a v a2s .c om*/ LoopStatement loopStatement = null; String varName; String collectionExpression; Pattern regexSimpleFor = Pattern.compile(FOR_REGEX); Matcher matcherSimpleFor = regexSimpleFor.matcher(rawData); try { if (matcherSimpleFor.find()) { // case: value in variable_name varName = matcherSimpleFor.group(2); collectionExpression = matcherSimpleFor.group(4); loopStatement = createLoopStatement(varName, collectionExpression, dependencyAccumulator, isParallelLoop); } else { String beforeInKeyword = StringUtils.substringBefore(rawData, FOR_IN_KEYWORD); collectionExpression = StringUtils.substringAfter(rawData, FOR_IN_KEYWORD).trim(); Pattern regexKeyValueFor = Pattern.compile(KEY_VALUE_PAIR_REGEX); Matcher matcherKeyValueFor = regexKeyValueFor.matcher(beforeInKeyword); if (matcherKeyValueFor.find()) { // case: key, value String keyName = matcherKeyValueFor.group(2); String valueName = matcherKeyValueFor.group(6); loopStatement = createMapForLoopStatement(keyName, valueName, collectionExpression, dependencyAccumulator); } else { // case: value in expression_other_than_variable_name varName = beforeInKeyword.trim(); loopStatement = createLoopStatement(varName, collectionExpression, dependencyAccumulator, isParallelLoop); } } } catch (RuntimeException rex) { errors.add(rex); } return new BasicTransformModellingResult<>(loopStatement, errors); }
From source file:io.wcm.handler.media.spi.helpers.AbstractMediaHandlerConfig.java
@Override public double getDefaultImageQuality(String mimeType) { if (StringUtils.isNotEmpty(mimeType)) { String format = StringUtils.substringAfter(mimeType.toLowerCase(), "image/"); if (StringUtils.equals(format, "jpg") || StringUtils.equals(format, "jpeg")) { return DEFAULT_JPEG_QUALITY; } else if (StringUtils.equals(format, "gif")) { return 256d; // 256 colors }/*from w w w . j a va2 s. co m*/ } // return quality "1" for all other mime types return 1d; }
From source file:net.sf.dynamicreports.design.transformation.chartcustomizer.GroupedStackedBarRendererCustomizer.java
@Override public void customize(JFreeChart chart, ReportParameters reportParameters) { this.seriesColors = new LinkedHashMap<String, Paint>(); this.map = null; Set<String> groups = new LinkedHashSet<String>(); CategoryDataset dataset = chart.getCategoryPlot().getDataset(); for (int i = 0; i < dataset.getRowCount(); i++) { String rowKey = (String) dataset.getRowKey(i); String group = StringUtils.substringBefore(rowKey, GROUP_SERIES_KEY); String series = StringUtils.substringAfter(rowKey, GROUP_SERIES_KEY); if (map == null) { map = new KeyToGroupMap(group); }//from ww w . ja v a 2s . c o m map.mapKeyToGroup(rowKey, group); groups.add(group); if (!seriesColors.containsKey(series)) { Paint paint = chart.getCategoryPlot().getDrawingSupplier().getNextPaint(); seriesColors.put(series, paint); } } DefaultCategoryDataset newDataset = new DefaultCategoryDataset(); for (Object column : dataset.getColumnKeys()) { for (String group : groups) { for (String series : seriesColors.keySet()) { try { Number value = dataset.getValue(group + GROUP_SERIES_KEY + series, (Comparable<?>) column); newDataset.addValue(value, group + GROUP_SERIES_KEY + series, (Comparable<?>) column); } catch (UnknownKeyException e) { newDataset.addValue(0, group + GROUP_SERIES_KEY + series, (Comparable<?>) column); } } } } dataset = newDataset; GroupedStackedBarRenderer renderer = new GroupedStackedBarRenderer(); renderer.setSeriesToGroupMap(map); StackedBarRenderer categoryRenderer = (StackedBarRenderer) chart.getCategoryPlot().getRenderer(); renderer.setBaseItemLabelsVisible(categoryRenderer.getBaseItemLabelsVisible()); renderer.setBaseItemLabelFont(categoryRenderer.getBaseItemLabelFont()); renderer.setBaseItemLabelPaint(categoryRenderer.getBaseItemLabelPaint()); renderer.setBaseItemLabelGenerator(categoryRenderer.getBaseItemLabelGenerator()); renderer.setShadowVisible(categoryRenderer.getShadowsVisible()); renderer.setItemMargin(0.10); renderer.setDrawBarOutline(false); for (int i = 0; i < dataset.getRowCount(); i++) { String rowKey = (String) dataset.getRowKey(i); String score = StringUtils.substringAfter(rowKey, GROUP_SERIES_KEY); renderer.setSeriesPaint(i, seriesColors.get(score)); } CategoryAxis domainAxis = chart.getCategoryPlot().getDomainAxis(); SubCategoryAxis newDomainAxis = new SubCategoryAxis(domainAxis.getLabel()); newDomainAxis.setLabelFont(domainAxis.getLabelFont()); newDomainAxis.setTickLabelFont(domainAxis.getTickLabelFont()); newDomainAxis.setLabelPaint(domainAxis.getLabelPaint()); newDomainAxis.setTickLabelPaint(domainAxis.getTickLabelPaint()); newDomainAxis.setAxisLinePaint(domainAxis.getAxisLinePaint()); newDomainAxis.setTickMarkPaint(domainAxis.getTickMarkPaint()); newDomainAxis.setTickLabelsVisible(domainAxis.isTickLabelsVisible()); newDomainAxis.setTickMarksVisible(domainAxis.isTickMarksVisible()); newDomainAxis.setCategoryMargin(0.05); for (String group : groups) { newDomainAxis.addSubCategory(group); } CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setDomainAxis(newDomainAxis); plot.setRenderer(renderer); LegendItemCollection legendItems = new LegendItemCollection(); for (String item : seriesColors.keySet()) { legendItems.add(new LegendItem(item, seriesColors.get(item))); } plot.setFixedLegendItems(legendItems); chart.getCategoryPlot().setDataset(dataset); }
From source file:io.wcm.devops.conga.plugins.sling.fileheader.OsgiConfigFileHeader.java
@Override public FileHeaderContext extract(FileContext file) { try {//ww w . j av a2 s . co m String content = FileUtils.readFileToString(file.getFile(), file.getCharset()); String[] contentLines = StringUtils.split(content, "\n"); if (contentLines.length > 0 && StringUtils.startsWith(contentLines[0], getCommentLinePrefix())) { String fullComment = StringUtils .trim(StringUtils.substringAfter(contentLines[0], getCommentBlockStart())); List<String> lines = ImmutableList.of(fullComment); return new FileHeaderContext().commentLines(lines); } } catch (IOException ex) { throw new GeneratorException("Unable parse add file header from " + file.getCanonicalPath(), ex); } return null; }
From source file:com.evolveum.midpoint.model.impl.dataModel.dot.DotMappingRelation.java
@Nullable private String getLabel(String defaultLabel, boolean showConstant) { ExpressionType expression = getMapping().getExpression(); if (expression == null || expression.getExpressionEvaluator().isEmpty()) { return defaultLabel; }/*ww w .java2 s . c o m*/ if (expression.getExpressionEvaluator().size() > 1) { return "> 1 evaluator"; // TODO multivalues } JAXBElement<?> evalElement = expression.getExpressionEvaluator().get(0); Object eval = evalElement.getValue(); if (QNameUtil.match(evalElement.getName(), SchemaConstants.C_VALUE)) { if (showConstant) { String str = getStringConstant(eval); return "\'" + StringUtils.abbreviate(str, MAX_CONSTANT_WIDTH) + "\'"; } else { return "constant"; } } else if (eval instanceof AsIsExpressionEvaluatorType) { return defaultLabel; } else if (eval instanceof ScriptExpressionEvaluatorType) { ScriptExpressionEvaluatorType script = (ScriptExpressionEvaluatorType) eval; if (script.getLanguage() == null) { return "groovy"; } else { return StringUtils.substringAfter(script.getLanguage(), "#"); } } else { return evalElement.getName().getLocalPart(); } }
From source file:de.jfachwert.post.Ort.java
private static String[] split(String name) { String input = StringUtils.trimToEmpty(name); String[] splitted = new String[] { "", input }; if (input.contains(" ")) { try {/*w ww.j a v a2 s . c o m*/ String plz = PLZ.validate(StringUtils.substringBefore(input, " ")); splitted[0] = plz; splitted[1] = StringUtils.substringAfter(input, " ").trim(); } catch (ValidationException ex) { LOG.log(Level.FINE, "no PLZ inside '" + name + "' found:", ex); } } return splitted; }
From source file:com.neatresults.mgnltweaks.ui.contentapp.browser.QueryableJcrContainer.java
@Override protected QueryResult executeQuery(String statement, String language, long limit, long offset) throws RepositoryException { log.debug("ST: {}", statement); String[] segments = StringUtils.split(path, "/"); // templates needs 2 queries - one for website and one for config if ("templates".equals(segments[2])) { // pages/* w w w .ja va 2 s . c om*/ QueryResult res1 = super.executeQuery(statement, language, limit, offset); // config this.setWorkspace(RepositoryConstants.CONFIG); statement = StringUtils.substringBefore(statement, " where ") + " where" // id references (availability, autogeneration, ...) + " contains(t.*,'" + segments[1] + ":" + StringUtils.substringAfter(path, "/templates/") + "')" // extends + buildExtends(path); log.debug("ST2: {}", statement); QueryResult res2 = super.executeQuery(statement, language, limit, offset); return new AggregatedQueryResult(res1, res2); } this.setWorkspace(RepositoryConstants.CONFIG); return super.executeQuery(statement, language, limit, offset); }