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

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

Introduction

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

Prototype

public static String substring(final String str, int start) 

Source Link

Document

Gets a substring from the specified String avoiding exceptions.

A negative start position can be used to start n characters from the end of the String.

A null String will return null .

Usage

From source file:fi.foyt.fni.utils.licenses.CreativeCommonsUtils.java

public static CreativeCommonsLicense parseLicenseUrl(String url) {
    if (StringUtils.isNotBlank(url)) {
        boolean secure = url.startsWith("https:");

        url = url.substring(secure ? 6 : 5);

        if (StringUtils.startsWith(url, CreativeCommonsLicense.URL_PREFIX)) {
            String[] parts = StringUtils.substring(url, CreativeCommonsLicense.URL_PREFIX.length()).split("/");
            if (parts.length == 1) {
                // Public domain ? 
                if (StringUtils.equals(parts[0], "publicdomain")) {
                    return new CreativeCommonsLicense(secure, new String[] { "publicdomain" }, "", "");
                } else {
                    // Without jurisdiction and version
                    return new CreativeCommonsLicense(secure, parts[0].split("-"), "3.0", "");
                }//from  w  w  w . j av  a 2  s  .c  om
            } else if (parts.length == 2) {
                // Without jurisdiction
                return new CreativeCommonsLicense(secure, parts[0].split("-"), parts[1], "");
            } else if (parts.length == 3) {
                // With jurisdiction
                return new CreativeCommonsLicense(secure, parts[0].split("-"), parts[1], parts[2]);
            }
        }
    }

    return null;
}

From source file:com.quancheng.plugin.common.CommonUtils.java

public static String findPojoTypeFromCache(String sourceType, Map<String, String> pojoTypes) {
    String type = StringUtils.substring(sourceType, StringUtils.lastIndexOf(sourceType, ".") + 1);
    return pojoTypes.get(type);
}

From source file:com.quancheng.plugin.common.CommonUtils.java

public static String findNotIncludePackageType(String sourceType) {
    String type = StringUtils.substring(sourceType, StringUtils.lastIndexOf(sourceType, ".") + 1);
    return type;//  w ww.ja va 2  s.co  m
}

From source file:de.jcup.egradle.core.util.StringUtilsAccess.java

public static String substring(String str, int start) {
    return StringUtils.substring(str, start);
}

From source file:jodtemplate.util.Utils.java

public static String removePrefixSeparator(final String path) {
    final String prefix = FilenameUtils.getPrefix(path);
    if ("/".equals(prefix) || "\\".equals(prefix)) {
        return StringUtils.substring(path, 1);
    }/*from ww w.  j  a  v  a  2  s  .co m*/
    return path;
}

From source file:ch.cyberduck.core.transfer.symlink.AbstractSymlinkResolver.java

@Override
public String relativize(final String base, final String name) {
    final String parent = PathNormalizer.parent(base, Path.DELIMITER);
    if (name.startsWith(parent)) {
        return StringUtils.substring(name, parent.length() + 1);
    } else {/*from  www. jav  a  2s. c  o m*/
        return String.format("..%s%s", Path.DELIMITER, this.relativize(parent, name));
    }
}

From source file:kenh.expl.functions.Substring.java

public String process(String str, int start) {
    return StringUtils.substring(str, start);
}

From source file:ch.cyberduck.core.local.TildeExpander.java

public String expand(final String name) {
    if (name.startsWith(Local.HOME)) {
        final String expanded = preferences.getProperty("local.user.home") + StringUtils.substring(name, 1);
        if (log.isDebugEnabled()) {
            if (!StringUtils.equals(expanded, name)) {
                log.debug(String.format("Expanded %s to %s", name, expanded));
            }//from ww  w .  j  a  va 2 s  .  c  o m
        }
        return expanded;
    }
    return name;
}

From source file:com.omnigon.aem.handlebars.helpers.GetUniqueIdHelper.java

@Override
public CharSequence apply(Object context, Options options) throws IOException {
    if (TagType.VAR == options.tagType || TagType.SUB_EXPRESSION == options.tagType) {
        int contextHashCode = context.hashCode();
        String scriptPath = options.fn.filename();
        String uniqueId = UniqueId.generateUniqueId(scriptPath + contextHashCode);
        return ID_PREFIX + StringUtils.substring(uniqueId, uniqueId.length() - ID_SIZE);
    }/*from  ww  w. j  a  v  a2  s .  c om*/
    return StringUtils.EMPTY;
}

From source file:cn.vlabs.clb.server.web.FileInfo.java

public String getExt() {
    return StringUtils.substring(this.getFileName().toLowerCase(), this.getFileName().lastIndexOf(".") + 1);
}