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:gobblin.data.management.retention.dataset.ConfigurableCleanableDataset.java
private void initWithSelectionPolicy(Config config, Properties jobProps) { String selectionPolicyKey = StringUtils.substringAfter(SELECTION_POLICY_CLASS_KEY, CONFIGURATION_KEY_PREFIX);//from w w w. j a v a2 s . co m String versionFinderKey = StringUtils.substringAfter(VERSION_FINDER_CLASS_KEY, CONFIGURATION_KEY_PREFIX); Preconditions.checkArgument(config.hasPath(versionFinderKey), String.format("Version finder class is required at %s in config %s", versionFinderKey, config.root().render(ConfigRenderOptions.concise()))); VersionFinderAndPolicyBuilder<T> builder = VersionFinderAndPolicy.builder(); builder.versionFinder(createVersionFinder(config.getString(versionFinderKey), config, jobProps)); if (config.hasPath(selectionPolicyKey)) { builder.versionSelectionPolicy(createSelectionPolicy( ConfigUtils.getString(config, selectionPolicyKey, SelectNothingPolicy.class.getName()), config, jobProps)); } for (Class<? extends RetentionActionFactory> factoryClass : RETENTION_ACTION_TYPES) { try { RetentionActionFactory factory = factoryClass.newInstance(); if (factory.canCreateWithConfig(config)) { builder.retentionAction((RetentionAction) factory.createRetentionAction(config, this.fs, ConfigUtils.propertiesToConfig(jobProps))); } } catch (InstantiationException | IllegalAccessException e) { Throwables.propagate(e); } } this.versionFindersAndPolicies.add(builder.build()); }
From source file:net.sf.dynamicreports.test.jasper.chart.ChartSeriesOrderTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);//from ww w. j a v a 2 s. com chartCountTest("summary.chart1", 1); JFreeChart chart = getChart("summary.chart1", 0); CategoryItemRenderer renderer1 = chart.getCategoryPlot().getRenderer(); CategoryDataset dataset1 = chart.getCategoryPlot().getDataset(); for (int i = 0; i < dataset1.getRowCount(); i++) { String key = (String) dataset1.getRowKey(i); Assert.assertNotNull("null series color", colors.get(key)); Assert.assertEquals("series color", colors.get(key), renderer1.getSeriesPaint(i)); } String[] categories = new String[] { "value1", "value2" }; String[] series = new String[] { "a", "b", "c", "d" }; Number[][] values = new Number[][] { { 5d, 2d, 4d, 2d }, { 3d, null, 2d, 4d } }; chartCategoryCountTest("summary.chart1", 0, 2); chartSeriesCountTest("summary.chart1", 0, 4); chartDataTest("summary.chart1", 0, categories, series, values); chartCountTest("summary.chart2", 1); chart = getChart("summary.chart2", 0); CategoryItemRenderer renderer2 = chart.getCategoryPlot().getRenderer(); CategoryDataset dataset2 = chart.getCategoryPlot().getDataset(); for (int i = 0; i < dataset2.getRowCount(); i++) { String key = (String) dataset2.getRowKey(i); key = StringUtils.substringAfter(key, GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY); Assert.assertNotNull("null series color", colors.get(key)); Assert.assertEquals("series color", colors.get(key), renderer2.getSeriesPaint(i)); } for (int i = 0; i < chart.getCategoryPlot().getFixedLegendItems().getItemCount(); i++) { LegendItem legendItem = chart.getCategoryPlot().getFixedLegendItems().get(i); Assert.assertNotNull("null series color", colors.get(legendItem.getLabel())); Assert.assertEquals("series color", colors.get(legendItem.getLabel()), legendItem.getFillPaint()); } series = new String[] { "1" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "a", "1" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "b", "1" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "c", "1" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "d", "2" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "a", "2" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "b", "2" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "c", "2" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "d" }; values = new Number[][] { { 1d, 2d, 3d, 0d, 4d, 0d, 1d, 2d }, { null, null, null, 0d, 3d, 0d, 2d, 4d } }; chartCategoryCountTest("summary.chart2", 0, 2); chartSeriesCountTest("summary.chart2", 0, 8); chartDataTest("summary.chart2", 0, categories, series, values); chartCountTest("summary.chart3", 1); chart = getChart("summary.chart3", 0); renderer1 = chart.getCategoryPlot().getRenderer(); dataset1 = chart.getCategoryPlot().getDataset(); for (int i = 0; i < dataset1.getRowCount(); i++) { String key = (String) dataset1.getRowKey(i); Assert.assertNotNull("null series color", colors.get(key)); Assert.assertEquals("series color", colors.get(key), renderer1.getSeriesPaint(i)); } categories = new String[] { "value1", "value2" }; series = new String[] { "d", "c", "b", "a" }; values = new Number[][] { { 2d, 4d, 2d, 5d }, { 4d, 2d, null, 3d } }; chartCategoryCountTest("summary.chart3", 0, 2); chartSeriesCountTest("summary.chart3", 0, 4); chartDataTest("summary.chart3", 0, categories, series, values); chartCountTest("summary.chart4", 1); chart = getChart("summary.chart4", 0); renderer2 = chart.getCategoryPlot().getRenderer(); dataset2 = chart.getCategoryPlot().getDataset(); for (int i = 0; i < dataset2.getRowCount(); i++) { String key = (String) dataset2.getRowKey(i); key = StringUtils.substringAfter(key, GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY); Assert.assertNotNull("null series color", colors.get(key)); Assert.assertEquals("series color", colors.get(key), renderer2.getSeriesPaint(i)); } for (int i = 0; i < chart.getCategoryPlot().getFixedLegendItems().getItemCount(); i++) { LegendItem legendItem = chart.getCategoryPlot().getFixedLegendItems().get(i); Assert.assertNotNull("null series color", colors.get(legendItem.getLabel())); Assert.assertEquals("series color", colors.get(legendItem.getLabel()), legendItem.getFillPaint()); } series = new String[] { "2" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "d", "2" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "c", "2" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "b", "2" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "a", "1" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "d", "1" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "c", "1" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "b", "1" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "a" }; values = new Number[][] { { 2d, 1d, 0d, 4d, 0d, 3d, 2d, 1d }, { 4d, 2d, 0d, 3d, 0d, null, null, null } }; chartCategoryCountTest("summary.chart4", 0, 2); chartSeriesCountTest("summary.chart4", 0, 8); chartDataTest("summary.chart4", 0, categories, series, values); chartCountTest("summary.chart5", 1); chart = getChart("summary.chart5", 0); renderer1 = chart.getCategoryPlot().getRenderer(); dataset1 = chart.getCategoryPlot().getDataset(); for (int i = 0; i < dataset1.getRowCount(); i++) { String key = (String) dataset1.getRowKey(i); Assert.assertNotNull("null series color", colors.get(key)); Assert.assertEquals("series color", colors.get(key), renderer1.getSeriesPaint(i)); } categories = new String[] { "value1", "value2" }; series = new String[] { "c", "b", "a", "d" }; values = new Number[][] { { 4d, 2d, 5d, 2d }, { 2d, null, 3d, 4d } }; chartCategoryCountTest("summary.chart5", 0, 2); chartSeriesCountTest("summary.chart5", 0, 4); chartDataTest("summary.chart5", 0, categories, series, values); chartCountTest("summary.chart6", 1); chart = getChart("summary.chart6", 0); renderer2 = chart.getCategoryPlot().getRenderer(); dataset2 = chart.getCategoryPlot().getDataset(); for (int i = 0; i < dataset2.getRowCount(); i++) { String key = (String) dataset2.getRowKey(i); key = StringUtils.substringAfter(key, GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY); Assert.assertNotNull("null series color", colors.get(key)); Assert.assertEquals("series color", colors.get(key), renderer2.getSeriesPaint(i)); } for (int i = 0; i < chart.getCategoryPlot().getFixedLegendItems().getItemCount(); i++) { LegendItem legendItem = chart.getCategoryPlot().getFixedLegendItems().get(i); Assert.assertNotNull("null series color", colors.get(legendItem.getLabel())); Assert.assertEquals("series color", colors.get(legendItem.getLabel()), legendItem.getFillPaint()); } series = new String[] { "1" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "c", "1" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "b", "1" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "a", "1" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "d", "2" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "c", "2" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "b", "2" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "a", "2" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "d" }; values = new Number[][] { { 3d, 2d, 1d, 0d, 1d, 0d, 4d, 2d }, { null, null, null, 0d, 2d, 0d, 3d, 4d } }; chartCategoryCountTest("summary.chart6", 0, 2); chartSeriesCountTest("summary.chart6", 0, 8); chartDataTest("summary.chart6", 0, categories, series, values); chartCountTest("summary.chart7", 1); chart = getChart("summary.chart7", 0); renderer1 = chart.getCategoryPlot().getRenderer(); dataset1 = chart.getCategoryPlot().getDataset(); for (int i = 0; i < dataset1.getRowCount(); i++) { String key = (String) dataset1.getRowKey(i); Assert.assertNotNull("null series color", colors.get(key)); Assert.assertEquals("series color", colors.get(key), renderer1.getSeriesPaint(i)); } categories = new String[] { "value1", "value2" }; series = new String[] { "d", "c", "b", "a" }; values = new Number[][] { { 2d, 5d, 2d, 4d }, { 4d, 3d, null, 2d } }; chartCategoryCountTest("summary.chart7", 0, 2); chartSeriesCountTest("summary.chart7", 0, 4); chartDataTest("summary.chart7", 0, categories, series, values); chartCountTest("summary.chart8", 1); chart = getChart("summary.chart8", 0); renderer2 = chart.getCategoryPlot().getRenderer(); dataset2 = chart.getCategoryPlot().getDataset(); for (int i = 0; i < dataset2.getRowCount(); i++) { String key = (String) dataset2.getRowKey(i); key = StringUtils.substringAfter(key, GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY); Assert.assertNotNull("null series color", colors.get(key)); Assert.assertEquals("series color", colors.get(key), renderer2.getSeriesPaint(i)); } for (int i = 0; i < chart.getCategoryPlot().getFixedLegendItems().getItemCount(); i++) { LegendItem legendItem = chart.getCategoryPlot().getFixedLegendItems().get(i); Assert.assertNotNull("null series color", colors.get(legendItem.getLabel())); Assert.assertEquals("series color", colors.get(legendItem.getLabel()), legendItem.getFillPaint()); } series = new String[] { "2" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "d", "2" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "a", "2" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "b", "2" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "c", "1" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "d", "1" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "a", "1" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "b", "1" + GroupedStackedBarRendererCustomizer.GROUP_SERIES_KEY + "c" }; values = new Number[][] { { 2d, 4d, 0d, 1d, 0d, 1d, 2d, 3d }, { 4d, 3d, 0d, 2d, 0d, null, null, null } }; chartCategoryCountTest("summary.chart8", 0, 2); chartSeriesCountTest("summary.chart8", 0, 8); chartDataTest("summary.chart8", 0, categories, series, values); chartCountTest("summary.chart9", 1); chart = getChart("summary.chart9", 0); renderer1 = chart.getCategoryPlot().getRenderer(); dataset1 = chart.getCategoryPlot().getDataset(); for (int i = 0; i < dataset1.getRowCount(); i++) { String key = (String) dataset1.getRowKey(i); Assert.assertNotNull("null series color", colors.get(key)); Assert.assertEquals("series color", colors.get(key), renderer1.getSeriesPaint(i)); } categories = new String[] { "value1", "value2" }; series = new String[] { "c", "d", "a", "b" }; values = new Number[][] { { 4d, 2d, 5d, 2d }, { 2d, 4d, 3d, null } }; chartCategoryCountTest("summary.chart9", 0, 2); chartSeriesCountTest("summary.chart9", 0, 4); chartDataTest("summary.chart9", 0, categories, series, values); chartCountTest("summary.chart10", 1); chart = getChart("summary.chart10", 0); renderer1 = chart.getCategoryPlot().getRenderer(); dataset1 = chart.getCategoryPlot().getDataset(); for (int i = 0; i < dataset1.getRowCount(); i++) { String key = (String) dataset1.getRowKey(i); Assert.assertNotNull("null series color", colors.get(key)); Assert.assertEquals("series color", colors.get(key), renderer1.getSeriesPaint(i)); } categories = new String[] { "value1", "value2" }; series = new String[] { "c", "b", "a", "d" }; values = new Number[][] { { 4d, 2d, 5d, 2d }, { 2d, null, 3d, 4d } }; chartCategoryCountTest("summary.chart10", 0, 2); chartSeriesCountTest("summary.chart10", 0, 4); chartDataTest("summary.chart10", 0, categories, series, values); }
From source file:jodtemplate.template.expression.DefaultExpressionHandler.java
private VariableExpression createVariableExpressionNoCheck(final String expressionBody) { String defaultValue = StringUtils.substringAfterLast(expressionBody, DEFAULT_VALUE_SEPARATOR).trim(); defaultValue = StringUtils.remove(defaultValue, '"'); final String variableWithParams = StringUtils.substringBefore(expressionBody, DEFAULT_VALUE_SEPARATOR); final String variable = StringUtils.substringBefore(variableWithParams, PARAMS_VALUE_SEPARATOR); final String paramsString = StringUtils.substringAfter(variableWithParams, PARAMS_VALUE_SEPARATOR); final List<String> params = Arrays.asList(StringUtils.split(paramsString, PARAMS_VALUE_SEPARATOR)); final VariableExpression variableExpression = new VariableExpression(variable, params, defaultValue); return variableExpression; }
From source file:io.wcm.devops.conga.tooling.maven.plugin.DefinitionPackageMojo.java
private String getPathForLog(File rootOutputDir, File file) throws IOException { String path = unifySlashes(file.getCanonicalPath()); String rootPath = unifySlashes(rootOutputDir.getCanonicalPath()) + "/"; return StringUtils.substringAfter(path, rootPath); }
From source file:com.gargoylesoftware.htmlunit.html.HtmlForm.java
/** * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br> * * Gets the request for a submission of this form with the specified SubmittableElement. * @param submitElement the element that caused the submit to occur * @return the request/* w w w . ja va2 s . co m*/ */ public WebRequest getWebRequest(final SubmittableElement submitElement) { final HtmlPage htmlPage = (HtmlPage) getPage(); final List<NameValuePair> parameters = getParameterListForSubmit(submitElement); final HttpMethod method; final String methodAttribute = getMethodAttribute(); if ("post".equalsIgnoreCase(methodAttribute)) { method = HttpMethod.POST; } else { if (!"get".equalsIgnoreCase(methodAttribute) && StringUtils.isNotBlank(methodAttribute)) { notifyIncorrectness("Incorrect submit method >" + getMethodAttribute() + "<. Using >GET<."); } method = HttpMethod.GET; } final BrowserVersion browser = getPage().getWebClient().getBrowserVersion(); String actionUrl = getActionAttribute(); String anchor = null; String queryFromFields = ""; if (HttpMethod.GET == method) { if (actionUrl.contains("#")) { anchor = StringUtils.substringAfter(actionUrl, "#"); } final String enc = getPage().getPageEncoding(); queryFromFields = URLEncodedUtils.format(Arrays.asList(NameValuePair.toHttpClient(parameters)), enc); // action may already contain some query parameters: they have to be removed actionUrl = StringUtils.substringBefore(actionUrl, "#"); actionUrl = StringUtils.substringBefore(actionUrl, "?"); parameters.clear(); // parameters have been added to query } URL url; try { if (actionUrl.isEmpty()) { url = WebClient.expandUrl(htmlPage.getUrl(), actionUrl); } else { url = htmlPage.getFullyQualifiedUrl(actionUrl); } if (!queryFromFields.isEmpty()) { url = UrlUtils.getUrlWithNewQuery(url, queryFromFields); } if (HttpMethod.GET == method && browser.hasFeature(FORM_SUBMISSION_URL_WITHOUT_HASH) && WebClient.URL_ABOUT_BLANK != url) { url = UrlUtils.getUrlWithNewRef(url, null); } else if (HttpMethod.POST == method && browser.hasFeature(FORM_SUBMISSION_URL_WITHOUT_HASH) && WebClient.URL_ABOUT_BLANK != url && StringUtils.isEmpty(actionUrl)) { url = UrlUtils.getUrlWithNewRef(url, null); } else if (anchor != null && WebClient.URL_ABOUT_BLANK != url) { url = UrlUtils.getUrlWithNewRef(url, anchor); } } catch (final MalformedURLException e) { throw new IllegalArgumentException("Not a valid url: " + actionUrl); } final WebRequest request = new WebRequest(url, method); request.setRequestParameters(parameters); if (HttpMethod.POST == method) { request.setEncodingType(FormEncodingType.getInstance(getEnctypeAttribute())); } request.setCharset(getSubmitCharset()); request.setAdditionalHeader("Referer", htmlPage.getUrl().toExternalForm()); return request; }
From source file:com.project.framework.dao.BaseDao.java
/** * count.//from w w w.ja va2s. c o m * * ????,???count?. */ public long countResult(final String queryString, final Map<String, ?> values) { String fromHql = queryString; //select??order by???count,?. fromHql = "from " + StringUtils.substringAfter(fromHql, "from"); fromHql = StringUtils.substringBefore(fromHql, "order by"); String countHql = "select count(*) " + fromHql; try { Long count = executeUniqueQuery(countHql, values); return count; } catch (Exception e) { throw new RuntimeException("queryString can't be auto count, queryString is:" + countHql, e); } }
From source file:com.neatresults.mgnltweaks.neatu2b.ui.form.field.composite.CompositeU2BFieldTransformer.java
public String getVideoId(Property<?> prop) { if (prop == null) { throw new NullPointerException( "Video is not set or name of the required field for this dialog is not correctly configured."); }/*from w w w .j a va2s .c om*/ String maybeId = (String) prop.getValue(); if (maybeId == null) { return null; } if (maybeId.startsWith("http")) { maybeId = StringUtils.substringBefore(StringUtils.substringAfter(maybeId, "?v="), "&"); } return maybeId; }
From source file:cn.wanghaomiao.xpath.core.XpathEvaluator.java
/** * //from ww w . ja va2 s . co m * * @param e * @param node * @return */ public Element filter(Element e, Node node) throws NoSuchFunctionException, NoSuchAxisException { if (node.getTagName().equals("*") || node.getTagName().equals(e.nodeName())) { if (node.getPredicate() != null && StringUtils.isNotBlank(node.getPredicate().getValue())) { Predicate p = node.getPredicate(); if (p.getOpEm() == null) { if (p.getValue().matches("\\d+") && getElIndex(e) == Integer.parseInt(p.getValue())) { return e; } else if (p.getValue().endsWith("()") && (Boolean) callFilterFunc(p.getValue().substring(0, p.getValue().length() - 2), e)) { return e; } else if (p.getValue().startsWith("@") && e.hasAttr(StringUtils.substringAfter(p.getValue(), "@"))) { return e; } //todo p.value ~= contains(./@href,'renren.com') } else { if (p.getLeft().matches("[^/]+\\(\\)")) { Object filterRes = p.getOpEm().excute( callFilterFunc(p.getLeft().substring(0, p.getLeft().length() - 2), e).toString(), p.getRight()); if (filterRes instanceof Boolean && (Boolean) filterRes) { return e; } else if (filterRes instanceof Integer && e.siblingIndex() == Integer.parseInt(filterRes.toString())) { return e; } } else if (p.getLeft().startsWith("@")) { String lValue = e.attr(p.getLeft().substring(1)); Object filterRes = p.getOpEm().excute(lValue, p.getRight()); if ((Boolean) filterRes) { return e; } } else { // ???xpath? List<Element> eltmp = new LinkedList<Element>(); eltmp.add(e); List<JXNode> rstmp = evaluate(p.getLeft(), new Elements(eltmp)); if ((Boolean) p.getOpEm().excute(StringUtils.join(rstmp, ""), p.getRight())) { return e; } } } } else { return e; } } return null; }
From source file:com.cognifide.aet.vs.mongodb.MongoDBClient.java
public static String getProjectNameFromDbName(String dbName) { return StringUtils.substringAfter(dbName, DB_NAME_SEPARATOR); }
From source file:de.crowdcode.kissmda.maven.plugin.KissMdaMojo.java
private void useTransformerNamesWithOrder(Injector parentInjector) throws MojoExecutionException, InstantiationException, IllegalAccessException, ClassNotFoundException { // Read the list and parse: // 1:de.crowdcode.kissmda.cartridges.extensions.ExtensionExamplesTransformer // Put it in a map and sort the content after the order Map<Integer, String> sortedtTransformerNameWithOrders = new TreeMap<Integer, String>(); for (String content : transformerNameWithOrders) { String order = StringUtils.substringBefore(content, ":"); Integer orderAsInt = Integer.decode(order); String transformerClazz = StringUtils.substringAfter(content, ":"); sortedtTransformerNameWithOrders.put(orderAsInt, transformerClazz); }/*from w ww. j ava 2s. c om*/ for (Map.Entry<Integer, String> entry : sortedtTransformerNameWithOrders.entrySet()) { // We need the counterpart Guice module for this transformer // In the same package but with Module as suffix String transformerClazzName = entry.getValue(); String guiceModuleClazzName = getGuiceModuleName(transformerClazzName); Class<? extends Transformer> transformerClazz = Class.forName(transformerClazzName) .asSubclass(Transformer.class); Class<? extends Module> guiceModuleClazz = Class.forName(guiceModuleClazzName).asSubclass(Module.class); logger.info("Start the transformation with following Transformer: " + transformerClazzName + " - order: " + entry.getKey()); // Create the transformer class with Guice module as child // injector and execute Injector injector = parentInjector.createChildInjector(guiceModuleClazz.newInstance()); Transformer transformer = injector.getInstance(transformerClazz); transformer.transform(context); logger.info("Stop the transformation with following Transformer:" + transformerClazzName); } }