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:com.thinkbiganalytics.nifi.feedmgr.NifiEnvironmentProperties.java

/**
 * for a given property return the serviceName
 *//*w ww .ja  v  a  2  s .  com*/
public static String serviceNameForEnvironmentProperty(String envProperty) {
    String prop = envProperty;
    prop = StringUtils.substringAfter(prop, getPrefix());
    String serviceName = StringUtils.substringBefore(prop, ".");
    return serviceName;
}

From source file:com.gargoylesoftware.htmlunit.html.IEConditionalCommentExpressionEvaluator.java

/**
 * Evaluates the condition.// w  w  w. j  a  v a 2 s  . c  o m
 * @param condition the condition like "lt IE 7"
 * @param browserVersion the browser version. Note that currently it can only be an IE browser.
 * @return the evaluation result
 */
public static boolean evaluate(String condition, final BrowserVersion browserVersion) {
    condition = condition.trim();
    if ("IE".equals(condition)) {
        return true;
    } else if ("true".equals(condition)) {
        return true;
    } else if ("false".equals(condition)) {
        return false;
    } else if (condition.contains("&")) {
        return evaluate(StringUtils.substringBefore(condition, "&"), browserVersion)
                && evaluate(StringUtils.substringAfter(condition, "&"), browserVersion);
    } else if (condition.contains("|")) {
        return evaluate(StringUtils.substringBefore(condition, "|"), browserVersion)
                || evaluate(StringUtils.substringAfter(condition, "|"), browserVersion);
    } else if (condition.startsWith("!")) {
        return !evaluate(condition.substring(1), browserVersion);
    } else if (condition.startsWith("IE")) {
        final String currentVersion = Float.toString(browserVersion.getBrowserVersionNumeric());
        return currentVersion.startsWith(condition.substring(2).trim());
    } else if (condition.startsWith("lte IE")) {
        return browserVersion.getBrowserVersionNumeric() <= parseVersion(condition.substring(6));
    } else if (condition.startsWith("lt IE")) {
        return browserVersion.getBrowserVersionNumeric() < parseVersion(condition.substring(5));
    } else if (condition.startsWith("gt IE")) {
        return browserVersion.getBrowserVersionNumeric() > parseVersion(condition.substring(5));
    } else if (condition.startsWith("gte IE")) {
        return browserVersion.getBrowserVersionNumeric() >= parseVersion(condition.substring(6));
    } else if (condition.startsWith("lt")) {
        return true;
    } else if (condition.startsWith("gt")) {
        return false;
    } else if (condition.startsWith("(")) {
        // in fact not fully correct if () can be nested
        return evaluate(StringUtils.substringBetween(condition, "(", ")"), browserVersion);
    } else {
        return false;
    }
}

From source file:de.micromata.genome.util.text.StandardHeaderSplitter.java

/**
 * Split./*from   w  ww  .j  a  v a 2  s. com*/
 *
 * @param text the text
 * @return the pair
 * @throws IOException Signals that an I/O exception has occurred.
 */
public static Pair<String, Map<String, String>> split(String text) throws IOException {
    LineNumberReader lnr = new LineNumberReader(new StringReader(text));
    Map<String, String> headers = new HashMap<String, String>();
    String line = null;
    boolean leedingNewlines = true;
    while ((line = lnr.readLine()) != null) {
        if (StringUtils.isBlank(line)) {
            if (leedingNewlines == true) {// es kann sein, dass am Anfang die Newlines sind(wegen Code, etc)
                continue;
            } else {
                break;
            }
        }
        String key = StringUtils.substringBefore(line, ":");
        String value = StringUtils.substringAfter(line, ":");
        headers.put(StringUtils.trim(key), StringUtils.trim(value));
        leedingNewlines = false;
    }
    if (headers.size() == 0) {
        return new Pair<String, Map<String, String>>(text, headers);
    }
    return new Pair<String, Map<String, String>>(slurp(lnr), headers);
}

From source file:io.wcm.handler.url.rewriter.impl.UrlExternalizerTransformerConfig.java

private static Map<String, String> toElementAttributeNamesMap(String[] elementAttributeNames) {
    Map<String, String> map = new HashMap<>();
    for (String item : elementAttributeNames) {
        String elementName = StringUtils.trim(StringUtils.substringBefore(item, ELEMENT_ATTRIBUTE_SEPARATOR));
        String attributeName = StringUtils.trim(StringUtils.substringAfter(item, ELEMENT_ATTRIBUTE_SEPARATOR));
        if (StringUtils.isBlank(elementName) || StringUtils.isBlank(attributeName)) {
            log.info("Invalid URL externalizier transformer configuration - skipping invalid element entry: "
                    + item);//from  w  w  w . j ava  2s. c  o  m
        } else if (map.containsKey(elementName)) {
            log.info("Invalid URL externalizier transformer configuration - skipping duplicate element name: "
                    + item);
        } else {
            map.put(elementName, attributeName);
        }
    }
    return map;
}

From source file:com.u2apple.rt.ui.worker.DeviceQueryWorker.java

@Override
protected List<AndroidDeviceRanking> doInBackground() throws Exception {
    DeviceDao deviceDao = new DeviceDao();
    List<AndroidDevice> devices;
    if (query.contains("like")) {
        String model = StringUtils.substringAfter(query, "like");
        devices = deviceDao.queryLikeModel(model.trim());
    } else {//  ww  w.j  a  v a  2s  . c o m
        devices = deviceDao.queryByModel(query.trim());
    }
    return AndroidDeviceUtils.parse(devices);
}

From source file:com.palantir.docker.compose.configuration.RemoteHostIpResolver.java

@Override
public String resolveIp(String dockerHost) {
    return Optional.ofNullable(emptyToNull(dockerHost))
            .map(host -> StringUtils.substringAfter(host, TCP_PROTOCOL))
            .map(ipAndMaybePort -> StringUtils.substringBefore(ipAndMaybePort, ":"))
            .orElseThrow(() -> new IllegalArgumentException("DOCKER_HOST cannot be blank/null"));
}

From source file:bear.core.Registry.java

public Task<Object, TaskResult<?>> getByName(String name) {
    String className;//from ww  w.ja v a 2s .  c o m
    String taskName;

    if (!name.contains(".")) {
        className = "Bear";
    } else {
        className = StringUtils.substringBefore(name, ".");
    }

    taskName = StringUtils.substringAfter(name, ".");

    return getTask(className, taskName);
}

From source file:com.epam.ta.reportportal.database.entity.item.issue.ExternalSystemType.java

public static Optional<String> knownIssue(String summary) {
    if (summary.trim().startsWith(ISSUE_MARKER)) {
        return Optional.of(StringUtils.substringAfter(summary, ISSUE_MARKER));
    } else {//w  w  w  . j  a  v  a 2  s . c  om
        return Optional.empty();
    }
}

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

public DependentFeed(String categoryAndFeed) {
    super();/*from w  w  w . ja  v  a  2s.  com*/
    this.categoryName = StringUtils.substringBefore(categoryAndFeed, ".");
    this.feedName = StringUtils.substringAfter(categoryAndFeed, ".");
    this.categoryAndFeed = categoryAndFeed;
}

From source file:com.yiji.openapi.sdk.util.BeanMapper.java

@SuppressWarnings({ "unchecked", "rawtypes" })
public static Map<String, Object> deepMap(Object source, String[] properties) throws Exception {

    Map<String, Object> map = Maps.newHashMap();
    for (String property : properties) {
        if (StringUtils.contains(property, ".")) {
            String currentProperty = StringUtils.substringBefore(property, ".");
            String remainProperties = StringUtils.substringAfter(property, ".");
            Map<String, Object> remainMap = deepMap(BeanUtils.getDeclaredProperty(source, currentProperty),
                    new String[] { remainProperties });
            if (map.get(currentProperty) != null) {
                ((Map) map.get(currentProperty)).putAll(remainMap);
            } else {
                map.put(currentProperty, remainMap);
            }//  ww w . j  a  v  a2s.c o  m

        } else {
            Object value = BeanUtils.getDeclaredProperty(source, property);
            if (value instanceof Collection) {

            }
            map.put(property, value);
        }
    }
    return map;
}