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:com.hangum.tadpole.engine.sql.util.OracleObjectCompileUtils.java

/**
 * view compile/*  w w w .j a v a2s . c o m*/
 * 
 * @param selection
 * @param userDB
 */
public static String viewCompile(String viewName, UserDBDAO userDB) throws Exception {
    //  ? DEBUG? ? ? ?.

    TableDAO viewDao = new TableDAO();
    if (StringUtils.contains(viewName, '.')) {
        //??   ?? ...
        viewDao.setSchema_name(StringUtils.substringBefore(viewName, "."));
        viewDao.setTable_name(StringUtils.substringAfter(viewName, "."));
        viewDao.setSysName(StringUtils.substringAfter(viewName, "."));
    } else {
        //    ?    .
        viewDao.setSchema_name(userDB.getSchema());
        viewDao.setTable_name(viewName);
        viewDao.setSysName(viewName);
    }

    return viewCompile(viewDao, userDB);
}

From source file:jetbrick.tools.chm.reader.AnchorNameManager.java

public static String replaceAnchor(String url) {
    String anchor = StringUtils.substringAfter(url, "#");
    if ("".equals(anchor))
        return url;
    return StringUtils.substringBefore(url, "#") + "#" + getNewAnchorName(anchor);
}

From source file:eionet.cr.util.FolderUtil.java

/**
 * Extract ACL path for special folders: projects and home. Until DDC not done, main project/home folder ACL is used
 *
 * @param uri uri of the folder//from w  ww.  j a  v a  2s.  c o m
 * @param specialFolderName - special folder prefix in the name
 * @return String acl path of th given folder
 */
public static String extractSpecialAclPath(String uri, String specialFolderName) {
    String appHome = GeneralConfig.getProperty(GeneralConfig.APPLICATION_HOME_URL);
    String aclPath = StringUtils.substringAfter(uri, appHome);

    if (aclPath.startsWith("/" + specialFolderName)) {
        String path = extractPathInSpecialFolder(uri, specialFolderName);
        if (!StringUtils.isBlank(path)) {
            String[] tokens = path.split("/");
            if (tokens != null && tokens.length > 0) {
                aclPath = "/" + specialFolderName + "/" + tokens[0];
            }
        }
    }

    return aclPath;
}

From source file:com.opengamma.master.position.DealAttributeEncoder.java

public static Deal read(Map<String, String> tradeAttributes) {
    String dealClass = tradeAttributes.get(DEAL_CLASSNAME);
    Deal deal = null;//  ww w .  ja  v a  2  s  .  c o  m
    if (dealClass != null) {
        Class<?> cls;
        try {
            cls = DealAttributeEncoder.class.getClassLoader().loadClass(dealClass);
        } catch (ClassNotFoundException ex) {
            throw new OpenGammaRuntimeException("Unable to load deal class", ex);
        }
        MetaBean metaBean = JodaBeanUtils.metaBean(cls);
        deal = (Deal) metaBean.builder().build();
        for (Map.Entry<String, String> entry : tradeAttributes.entrySet()) {
            String key = entry.getKey();
            if (key.startsWith(DEAL_PREFIX) && !key.equals(DEAL_CLASSNAME) && !key.equals(DEAL_TYPE)) {
                String propertyName = StringUtils.substringAfter(key, DEAL_PREFIX);
                if (metaBean.metaPropertyExists(propertyName)) {
                    MetaProperty<?> mp = metaBean.metaProperty(propertyName);
                    String value = entry.getValue();
                    if (s_logger.isDebugEnabled()) {
                        s_logger.debug("Setting property {}({}) with value {}",
                                new Object[] { mp, mp.propertyType(), value });
                    }
                    mp.setString(deal, value);
                }
            }
        }
    }
    return deal;
}

From source file:com.haulmont.cuba.security.global.UserUtils.java

private static String parseParam(String param, String firstName, String lastName, String middleName)
        throws ParseException {
    if (param == null || param.length() == 0)
        throw new ParseException("Pattern error", 0);
    String last = StringUtils.substringAfter(param, "|");
    String first = StringUtils.upperCase(StringUtils.substringBefore(param, "|"));
    if (first == null || first.length() == 0)
        throw new ParseException("Pattern error", 0);
    char type = first.charAt(0);
    boolean all = true;
    int length = 0;
    if (first.length() > 1) {
        char ch = first.charAt(1);
        switch (ch) {
        case 'F':
        case 'L':
        case 'M':
            if (first.length() != 2 || type != ch)
                throw new ParseException("Pattern error", 2);
            break;
        default:/*from  ww  w.  ja  v  a 2  s  .co  m*/
            length = Integer.parseInt(first.substring(1, first.length()));
            break;
        }
    } else {
        all = false;
        length = 1;
    }
    switch (type) {
    case 'F':
        first = firstName;
        break;
    case 'L':
        first = lastName;
        break;
    case 'M':
        first = middleName;
        break;
    default:
        throw new ParseException("Pattern error", 0);
    }
    if (!all) {
        first = StringUtils.left(first, length);
    }
    return (first.length() > 0) ? first + last : "";
}

From source file:com.google.gdt.eclipse.designer.hosted.tdt.Utils.java

static String getDevLibLocation(final IModuleDescription moduleDescription) {
    String userJarFolder = getUserJarFolder(moduleDescription);
    // try to find gwt-dev.jar in classpath
    {/*from   w  w w.j  av a 2  s.c om*/
        String devLocation = ExecutionUtils.runObject(new RunnableObjectEx<String>() {
            public String runObject() throws Exception {
                List<String> locations = moduleDescription.getLocations();
                return getDevJarLocation(locations);
            }
        });
        if (devLocation != null) {
            return devLocation;
        }
    }
    // Maven
    if (userJarFolder.contains("/gwt/gwt-user/")) {
        String gwtFolder = StringUtils.substringBefore(userJarFolder, "/gwt-user/");
        String versionString = StringUtils.substringAfter(userJarFolder, "/gwt/gwt-user/");
        String devFolder = gwtFolder + "/gwt-dev/" + versionString;
        String devFileName = "gwt-dev-" + versionString + ".jar";
        String devLocation = devFolder + "/" + devFileName;
        if (new File(devLocation).exists()) {
            return devLocation;
        }
    }
    // gwt-dev in same folder as gwt-user.jar
    String path = userJarFolder + "/gwt-dev.jar";
    if (new File(path).exists()) {
        return path;
    }
    // no gwt-dev
    return null;
}

From source file:info.joseluismartin.gtc.VeCache.java

/**
 * {@inheritDoc}/* ww  w .j  a  v a  2s. co  m*/
 */
@Override
protected Tile parseTile(String uri) {
    Tile tile = null;
    try {
        if (!uri.startsWith("tiles/"))
            uri = StringUtils.substringAfter(uri, "tiles/");

        String[] query = uri.split("\\?");
        String quad = query[0].substring(1); // drop 'r'
        Map<String, String> params = getParameterMap(query[1]);
        int xyz[] = queadToXyz(quad);
        tile = new VeTile(xyz[0], xyz[1], xyz[2], params.get("g"), params.get("mkt"));
        tile.setMimeType("image/jpeg");
    } catch (Exception e) {
        log.error(e);
    }

    return tile;
}

From source file:info.magnolia.cms.security.auth.Base64CallbackHandler.java

/**
 * @param credentials Base64 encoded string
 * *//*w w  w .  j a va  2s.  c o  m*/
public Base64CallbackHandler(String credentials) {
    credentials = getDecodedCredentials(credentials.substring(6).trim());
    this.name = StringUtils.substringBefore(credentials, ":");
    this.pswd = StringUtils.substringAfter(credentials, ":").toCharArray();
}

From source file:com.datasalt.utils.commons.URLUtils.java

/**
   Extract parameters from a url so that Ning (or other crawling utilities) 
   can properly encode them if necessary. This was necesssary for facebook requests, 
   which are bundled with "next urls" that have funny characters in them such as this 
           // w w  w  . ja  v  a2 s .  c o m
   "122524694445860|7fc6dd5fe13b43c09dad009d.1-1056745212|An3Xub_HEDRsGxVPkmy71VdkFhQ"
 * @param url
 */
public static Hashtable<String, String> extractParameters(String url) {
    Hashtable<String, String> pars = new Hashtable<String, String>();
    if (!url.contains("?")) {
        log.warn("WARNING : URL HAS NO PARAMETERS ! " + url);
        return pars;
    }
    String parameters = StringUtils.substringAfter(url, "?");
    for (String pairs : parameters.split("&")) {
        String[] nv = pairs.split("=");
        pars.put(nv[0], nv[1]);
    }
    return pars;
}

From source file:cec.easyshop.cockpits.ticket.email.context.AcceleratorCustomerTicketContext.java

@Override
public String getTo() {
    if (getTicket().getCustomer() instanceof CustomerModel) {
        String result = StringUtils.EMPTY;
        final CustomerModel ticketCustomer = (CustomerModel) getTicket().getCustomer();
        if (CustomerType.GUEST.equals(ticketCustomer.getType())) {
            result = StringUtils.substringAfter(getTicket().getCustomer().getUid(), PIPE);
        } else {/*from ww w.  j  a  va2  s . c om*/
            result = ticketCustomer.getUid();
        }
        return result;
    }
    return super.getTo();
}