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

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

Introduction

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

Prototype

public static String substringAfter(String str, String separator) 

Source Link

Document

Gets the substring after the first occurrence of a separator.

Usage

From source file:io.github.microcks.web.filter.StaticResourcesFilter.java

@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain)
        throws IOException, ServletException {
    HttpServletRequest httpRequest = (HttpServletRequest) servletRequest;
    String contextPath = httpRequest.getContextPath();
    String requestURI = httpRequest.getRequestURI();
    requestURI = StringUtils.substringAfter(requestURI, contextPath);
    if (StringUtils.equals("/", requestURI)) {
        requestURI = "/index.html";
    }// w  ww  . ja v a 2 s .c  o m
    String newURI = "/dist" + requestURI;
    log.debug("Dispatching to URI: {}", newURI);
    servletRequest.getRequestDispatcher(newURI).forward(servletRequest, servletResponse);
}

From source file:com.github.fritaly.graphml4j.samples.GradleDependencies.java

/**
 * Computes and returns a label from the given value.
 *
 * @param value/*from w  ww  . j  a v  a2 s. co m*/
 *            a string identifying a dependency (group, artifact, version)
 *            generated by the Gradle dependencies task. Can't be null.
 * @return a string corresponding to a shorter label to uniquely identify a
 *         dependency.
 */
private static String computeLabel(String value) {
    // Examples of input values:
    // "org.springframework:spring-core:3.2.0.RELEASE (*)" => "spring-core:3.2.0.RELEASE"
    // "com.acme:acme-logging:1.16.0 -> 1.16.3 (*)" => "acme-logging:1.16.3"
    // "junit:junit:3.8.1 -> 4.8.1" => "junit:4.8.1"
    // "sun-jaxb:jaxb-impl:2.2" => "jaxb-impl:2.2"

    if (value.endsWith(" (*)")) {
        // Ex: "org.springframework:spring-core:3.2.0.RELEASE (*)" => "org.springframework:spring-core:3.2.0.RELEASE"
        value = value.replace(" (*)", "");
    }
    if (value.contains(" -> ")) {
        // Ex: "junit:junit:3.8.1 -> 4.8.1" => "junit:junit:4.8.1"
        final String version = StringUtils.substringAfter(value, " -> ");

        value = StringUtils.substringBeforeLast(value, ":") + ":" + version;
    }

    // Ex: "sun-jaxb:jaxb-impl:2.2" => "jaxb-impl:2.2"
    value = StringUtils.substringAfter(value, ":");

    return StringUtils.replace(value, ":", "\n");
}

From source file:net.contextfw.web.application.internal.development.ReloadingClassLoaderConf.java

private void addReloadablePackage(String str) {
    String name = StringUtils.substringBefore(str, ":");
    boolean recursive = Boolean.parseBoolean(StringUtils.substringAfter(str, ":"));

    String postfix = recursive ? "\\..+" : "\\.[^\\.]+";

    reloadablePackageNames.add(name);/*w  w  w  . j a v a2  s . co  m*/
    reloadablePackages.add(Pattern.compile("^" + name.replaceAll("\\.", "\\.") + postfix));
}

From source file:com.enonic.cms.business.portal.rendering.tracing.TraceMarkerHelper.java

public static String unwrapResultWithPortletMarker(RenderedWindowResult result) {
    String content = result.getContent();
    String contentUnwrapped = StringUtils.substringBetween(content, "<div id=\"marker-", "</div>");
    if (contentUnwrapped != null) {
        return StringUtils.substringAfter(contentUnwrapped, ">");
    } else {/*w ww  .  j a  v  a2  s .  c  om*/
        return content;
    }
}

From source file:info.magnolia.module.delta.BootstrapSingleResourceAndOrderBefore.java

public BootstrapSingleResourceAndOrderBefore(String name, String description, String resource,
        String orderBeforeName) {
    super(name, description);
    // TODO : these values should be provided by the BootstrapUtil/Helper once MAGNOLIA-1806 is done.
    String filename = StringUtils.substringAfterLast(resource, "/");
    String repository = StringUtils.substringBefore(filename, ".");
    String path = StringUtils.substringAfter(StringUtils.substringBeforeLast(filename, "."), ".");
    path = "/" + StringUtils.replace(path, ".", "/");

    addTask(new BootstrapSingleResource(name, description, resource));
    addTask(new OrderNodeBeforeTask(name, description, repository, path, orderBeforeName));
}

From source file:jetbrick.tools.chm.style.Javadoc8Style.java

@Override
public String getMethodFullName(String url) {
    String name = StringUtils.substringAfter(url, "#");
    int count = StringUtils.countMatches(name, "-");
    name = StringUtils.replaceOnce(name, "-", "(");
    for (int i = 0; i < count - 2; i++) {
        name = StringUtils.replaceOnce(name, "-", ", ");
    }/*from  w  w w .  j  a  va  2s. c o m*/
    name = StringUtils.replaceOnce(name, "-", ")");
    name = StringUtils.replace(name, ":A", "[]");
    return name;
}

From source file:com.igrow.mall.common.util.Struts2Utils.java

/**
 * .//from w w  w. j av a 2  s  . c om
        
 * eg.
 * render("text/plain", "hello", "encoding:GBK");
 * render("text/plain", "hello", "no-cache:false");
 * render("text/plain", "hello", "encoding:GBK", "no-cache:false");
 * 
 * @param headers ??header??"encoding:""no-cache:",UTF-8true.
 */
public static void render(final String contentType, final String content, final String... headers) {
    try {
        //?headers?
        String encoding = ENCODING_DEFAULT;
        boolean noCache = NOCACHE_DEFAULT;
        for (String header : headers) {
            String headerName = StringUtils.substringBefore(header, ":");
            String headerValue = StringUtils.substringAfter(header, ":");

            if (StringUtils.equalsIgnoreCase(headerName, ENCODING_PREFIX)) {
                encoding = headerValue;
            } else if (StringUtils.equalsIgnoreCase(headerName, NOCACHE_PREFIX)) {
                noCache = Boolean.parseBoolean(headerValue);
            } else
                throw new IllegalArgumentException(headerName + "??header");
        }

        HttpServletResponse response = ServletActionContext.getResponse();

        //headers?
        String fullContentType = contentType + ";charset=" + encoding;
        response.setContentType(fullContentType);
        if (noCache) {
            response.setHeader("Pragma", "No-cache");
            response.setHeader("Cache-Control", "no-cache");
            response.setDateHeader("Expires", 0);
        }

        response.getWriter().write(content);
        response.getWriter().flush();

    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
}

From source file:com.alibaba.otter.node.etl.common.io.ArchiveBeanIntegration.java

public void test_pack() {
    ArchiveBean archiveBean = new ArchiveBean();
    try {/*from   w  w  w. j  av a  2s  .c o  m*/
        archiveBean.afterPropertiesSet();
        archiveBean.setUseLocalFileMutliThread(false);
    } catch (Exception e1) {
        want.fail();
    }

    File file = new File("/tmp/otter/test");
    Collection<File> allFiles = FileUtils.listFiles(file, new String[] { "jpg" }, true);

    List<FileData> fileDatas = new ArrayList<FileData>();
    for (File files : allFiles) {
        FileData data = new FileData();
        // data.setPath("wsproduct_repository/product_sku/76/84/32/84/768432847_10.summ.jpg");
        data.setPath(StringUtils.substringAfter(files.getAbsolutePath(), "/tmp/otter/test"));
        fileDatas.add(data);
    }

    File archiveFile = new File("/tmp/otter/test.gzip");
    if (archiveFile.exists()) {
        archiveFile.delete();
    }

    boolean result = archiveBean.pack(archiveFile, fileDatas, new ArchiveRetriverCallback<FileData>() {

        public InputStream retrive(FileData source) {
            return new LazyFileInputStream(new File("/tmp/otter/test", source.getPath()));
        }
    });

    if (!result) {
        want.fail();
    }

}

From source file:info.magnolia.test.mock.jcr.MockQueryResult.java

public MockQueryResult(Session session, String statement, String language) {
    this.session = session;
    type = StringUtils.substringBefore(StringUtils.substringAfter(statement.toLowerCase(), " from "), " where ")
            .trim();//from   w  w  w  . j a  v a2 s. com

    if (Query.JCR_SQL2.equals(language)) {
        // strip off square brackets required to encapsulate type for sql2 queries
        type = type.substring(1, type.length() - 1);

        String where = StringUtils.substringAfter(statement, "where").trim();
        if (where.indexOf("name()") != -1) {
            // try to get name we are searching for
            name = StringUtils.substringBefore(
                    StringUtils.substringAfter(StringUtils.substringAfter(where, "name()"), "'"), "'");
        }
    }
}

From source file:fr.dutra.tools.maven.deptree.core.TgfParser.java

/**
 * sample line structure:/*from w  ww.  j  a  v  a2 s  .co  m*/
 * <pre>
 * -1437430659 com.ibm:mqjms:jar:6.0.0:runtime
 * #
 * 1770590530 96632433 compile
 * </pre>
 */
private void parseLine() {
    String line = this.lines.get(this.lineIndex);
    if ("#".equals(line)) {
        this.phase = ParsePhase.EDGE;
    } else if (this.phase == ParsePhase.NODE) {
        String id = StringUtils.substringBefore(line, " ");
        String artifact;
        if (line.contains("active project artifact:")) {
            artifact = extractActiveProjectArtifact();
        } else {
            artifact = StringUtils.substringAfter(line, " ");
        }
        Node node = parseArtifactString(artifact);
        if (root == null) {
            this.root = node;
        }
        nodes.put(id, node);
    } else {
        String parentId = StringUtils.substringBefore(line, " ");
        String childId = StringUtils.substringBetween(line, " ");
        Node parent = nodes.get(parentId);
        Node child = nodes.get(childId);
        parent.addChildNode(child);
    }
}