Example usage for org.apache.commons.lang3 StringUtils substringAfter

List of usage examples for org.apache.commons.lang3 StringUtils substringAfter

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils substringAfter.

Prototype

public static String substringAfter(final String str, final String separator) 

Source Link

Document

Gets the substring after the first occurrence of a separator.

Usage

From source file:de.jfachwert.bank.GeldbetragIT.java

private static int getNumberOfFailedTests() throws IOException {
    Path resultsFile = Paths.get("target", "tck-results.txt");
    List<String> lines = Files.readAllLines(resultsFile);
    String testsFailedLine = lines.get(lines.size() - 1);
    String n = StringUtils.substringAfter(testsFailedLine, ":").trim();
    return Integer.parseInt(n);
}

From source file:com.thinkbiganalytics.metadata.api.sla.FeedExecutedSinceFeed.java

public FeedExecutedSinceFeed(@JsonProperty("sinceCategoryAndFeedName") String sinceCategoryAndFeed,
        @JsonProperty("categoryAndFeed") String categoryAndFeed) {
    super(categoryAndFeed);
    this.sinceCategoryAndFeedName = sinceCategoryAndFeed;
    this.sinceCategoryName = StringUtils.substringBefore(sinceCategoryAndFeedName, ".");
    this.sinceFeedName = StringUtils.substringAfter(sinceCategoryAndFeedName, ".");
}

From source file:com.sketchy.drawing.DrawingSize.java

public static DrawingSize parse(String string) {
    double width = 0;
    double height = 0;

    String upperCasedString = StringUtils.upperCase(string);
    String widthString = StringUtils.substringBefore(upperCasedString, "X").trim();
    String heightString = StringUtils.substringAfter(upperCasedString, "X").trim();

    widthString = StringUtils.substringBeforeLast(widthString, "MM");
    heightString = StringUtils.substringBefore(heightString, " ");
    heightString = StringUtils.substringBeforeLast(heightString, "MM");

    try {/*from ww w .j a va 2  s. c  o  m*/
        width = Double.parseDouble(widthString);
        height = Double.parseDouble(heightString);
    } catch (Exception e) {
        throw new RuntimeException("Invalid Drawing Size! '" + string + "'");
    }

    if ((width <= 0) || (height <= 0)) {
        throw new RuntimeException("Invalid Drawing Size! '" + string + "'");
    }
    return new DrawingSize(width, height);
}

From source file:io.knotx.launcher.SystemPropsConfiguration.java

public SystemPropsConfiguration(String identifier) {
    envConfig = System.getProperties().entrySet().stream()
            .filter(entry -> onlyPropertyForIdentifier(entry, identifier))
            .collect(Collectors.toMap(
                    entry -> StringUtils.substringAfter((String) entry.getKey(), identifier + "."),
                    entry -> new Value((String) entry.getValue())));
}

From source file:com.eryansky.common.orm.core.PropertyFilters.java

/**
 * ?//from  w w w .  j ava  2s  .c  o m
 * <p>
 *    
 * </p>
 * <code>
 *    PropertyFilters.get("EQS_propertyName","maurice")
 * </code>
 * 
 * @param expression ?
 * @param matchValue 
 * 
 * @return {@link PropertyFilter}
 */
@SuppressWarnings("static-access")
public static PropertyFilter get(String expression, String matchValue) {

    Assert.hasText(expression, "??");

    String restrictionsNameAndClassType = StringUtils.substringBefore(expression, "_");

    String restrictionsName = StringUtils.substring(restrictionsNameAndClassType, 0,
            restrictionsNameAndClassType.length() - 1);
    String classType = StringUtils.substring(restrictionsNameAndClassType,
            restrictionsNameAndClassType.length() - 1, restrictionsNameAndClassType.length());

    FieldType FieldType = null;
    try {
        FieldType = FieldType.valueOf(classType);
    } catch (Exception e) {
        throw new IllegalAccessError(
                "[" + expression + "]??,?:" + classType);
    }

    String[] propertyNames = null;

    if (StringUtils.contains(expression, "_OR_")) {
        String temp = StringUtils.substringAfter(expression, restrictionsNameAndClassType + "_");
        propertyNames = StringUtils.splitByWholeSeparator(temp, "_OR_");
    } else {
        propertyNames = new String[1];
        propertyNames[0] = StringUtils.substringAfterLast(expression, "_");
    }

    return new PropertyFilter(restrictionsName, FieldType, propertyNames, matchValue);
}

From source file:com.ppcxy.cyfm.showcase.demos.utilities.string.ApacheStringUtilsDemo.java

@Test
public void substring() {
    String input = "hahakaka";
    String result = StringUtils.substringAfter(input, "ha");
    assertThat(result).isEqualTo("hakaka");

    result = StringUtils.substringAfterLast(input, "ha");
    assertThat(result).isEqualTo("kaka");

    assertThat(StringUtils.substringBetween("'haha'", "'")).isEqualTo("haha");
    assertThat(StringUtils.substringBetween("{haha}", "{", "}")).isEqualTo("haha");
}

From source file:com.github.dactiv.orm.core.PropertyFilters.java

/**
 * ?/*  w  w w .j av a 2 s .c  o m*/
 * <p>
 *    
 * </p>
 * <code>
 *    PropertyFilters.build("EQS_propertyName","maurice")
 * </code>
 * 
 * @param expression ?
 * @param matchValue 
 * 
 * @return {@link PropertyFilter}
 */
@SuppressWarnings("static-access")
public static PropertyFilter build(String expression, String matchValue) {

    Assert.hasText(expression, "??");

    String restrictionsNameAndClassType = StringUtils.substringBefore(expression, "_");

    String restrictionsName = StringUtils.substring(restrictionsNameAndClassType, 0,
            restrictionsNameAndClassType.length() - 1);
    String classType = StringUtils.substring(restrictionsNameAndClassType,
            restrictionsNameAndClassType.length() - 1, restrictionsNameAndClassType.length());

    FieldType FieldType = null;
    try {
        FieldType = FieldType.valueOf(classType);
    } catch (Exception e) {
        throw new IllegalAccessError(
                "[" + expression + "]??,?:" + classType);
    }

    String[] propertyNames = null;

    if (StringUtils.contains(expression, "_OR_")) {
        String temp = StringUtils.substringAfter(expression, restrictionsNameAndClassType + "_");
        propertyNames = StringUtils.splitByWholeSeparator(temp, "_OR_");
    } else {
        propertyNames = new String[1];
        propertyNames[0] = StringUtils.substringAfterLast(expression, "_");
    }

    return new PropertyFilter(restrictionsName, FieldType, propertyNames, matchValue);
}

From source file:com.muk.services.processor.BearerTokenAuthPrincipalProcessor.java

@Override
public void process(Exchange exchange) throws Exception {

    String bearerToken = RestConstants.Rest.anonymousToken;

    if (exchange.getIn().getHeaders().containsKey(HttpHeaders.AUTHORIZATION)) {
        bearerToken = StringUtils
                .substringAfter(exchange.getIn().getHeader(HttpHeaders.AUTHORIZATION, String.class), "Bearer ");
    }//from w  w  w  . ja  v a2s . c o  m

    // create an Authentication object
    // build a new bearer token type
    final BearerAuthenticationToken authToken = new BearerAuthenticationToken(bearerToken);

    // wrap it in a Subject
    final Subject subject = new Subject();
    subject.getPrincipals().add(authToken);

    // place the Subject in the In message
    exchange.getIn().setHeader(Exchange.AUTHENTICATION, subject);
}

From source file:com.jiwhiz.web.filter.StaticResourcesProductionFilter.java

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    HttpServletRequest httpRequest = (HttpServletRequest) request;
    String contextPath = ((HttpServletRequest) request).getContextPath();
    String requestURI = httpRequest.getRequestURI();
    requestURI = StringUtils.substringAfter(requestURI, contextPath);
    if (StringUtils.equals("/", requestURI)) {
        requestURI = "/index.html";
    }/* ww  w.ja  v  a2s . c om*/
    String newURI = "/dist" + requestURI;
    request.getRequestDispatcher(newURI).forward(request, response);
}

From source file:de.blizzy.documentr.markdown.macro.impl.GoogleDocsMacro.java

@Override
public String getHtml(IMacroContext macroContext) {
    String macroParams = macroContext.getParameters();
    String googleUrl = StringUtils.substringBefore(macroParams, " ").trim(); //$NON-NLS-1$
    String width = StringUtils.substringAfter(macroParams, " ").trim(); //$NON-NLS-1$

    UriComponents uriComponents = UriComponentsBuilder.fromHttpUrl(googleUrl).build();
    String path = uriComponents.getPath();
    MultiValueMap<String, String> params = uriComponents.getQueryParams();
    if (path.startsWith("/spreadsheet/")) { //$NON-NLS-1$
        String key = params.get("key").get(0); //$NON-NLS-1$
        UriComponents components = UriComponentsBuilder.fromHttpUrl("https://docs.google.com/spreadsheet/pub") //$NON-NLS-1$
                .queryParam("key", key) //$NON-NLS-1$
                .queryParam("output", "html") //$NON-NLS-1$ //$NON-NLS-2$
                .queryParam("widget", "true") //$NON-NLS-1$ //$NON-NLS-2$
                .build();//from   w ww .  ja v a  2  s  .co  m
        return buildIframe(components);
    } else if (path.startsWith("/document/")) { //$NON-NLS-1$
        String id = params.get("id").get(0); //$NON-NLS-1$
        UriComponents components = UriComponentsBuilder.fromHttpUrl("https://docs.google.com/document/pub") //$NON-NLS-1$
                .queryParam("id", id) //$NON-NLS-1$
                .queryParam("embedded", "true") //$NON-NLS-1$ //$NON-NLS-2$
                .build();
        return buildIframe(components);
    } else if (path.startsWith("/presentation/")) { //$NON-NLS-1$
        String id = params.get("id").get(0); //$NON-NLS-1$
        UriComponents components = UriComponentsBuilder
                .fromHttpUrl("https://docs.google.com/presentation/embed") //$NON-NLS-1$
                .queryParam("id", id) //$NON-NLS-1$
                .queryParam("start", "false") //$NON-NLS-1$ //$NON-NLS-2$
                .queryParam("loop", "false") //$NON-NLS-1$ //$NON-NLS-2$
                .queryParam("delayms", String.valueOf(TimeUnit.MILLISECONDS.convert(3, TimeUnit.SECONDS))) //$NON-NLS-1$
                .build();
        return buildIframe(components);
    } else if (path.startsWith("/drawings/")) { //$NON-NLS-1$
        String id = params.get("id").get(0); //$NON-NLS-1$
        if (StringUtils.isBlank(width)) {
            width = "960"; //$NON-NLS-1$
        }
        UriComponents components = UriComponentsBuilder.fromHttpUrl("https://docs.google.com/drawings/pub") //$NON-NLS-1$
                .queryParam("id", id) //$NON-NLS-1$
                .queryParam("w", width) //$NON-NLS-1$
                .build();
        return buildImg(components);
    } else {
        return null;
    }
}