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

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

Introduction

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

Prototype

public static String removeStartIgnoreCase(String str, String remove) 

Source Link

Document

Case insensitive removal of a substring if it is at the begining of a source string, otherwise returns the source string.

Usage

From source file:adalid.util.velocity.BaseBuilder.java

private String replaceAliasWithRootFolderName(String path) {
    String p = path + "/";
    if (StringUtils.startsWithIgnoreCase(p, SOURCE_PROJECT_ALIAS)) {
        p = SOURCE_PROJECT_ROOT_FOLDER_NAME + StringUtils.removeStartIgnoreCase(p, SOURCE_PROJECT_ALIAS);
        p = StringUtils.removeEnd(p, "/");
        return p;
    }/*from   w  w w . jav a  2  s.  c  o m*/
    return path;
}

From source file:adalid.util.velocity.BaseBuilder.java

private String finalisePath(String path) {
    String p = path + "/";
    if (StringUtils.startsWithIgnoreCase(p, SOURCE_PROJECT_ROOT_FOLDER_NAME)) {
        if (StringUtils.startsWithIgnoreCase(p, RESOURCES_PROJECT_FOLDER_NAME)) {
            p = "${resourcesProjectFolderPath}/"
                    + StringUtils.removeStartIgnoreCase(p, RESOURCES_PROJECT_FOLDER_NAME);
            p = p.replace("/src/conf/", "/${resourcesConfigurationFilesFolder}/");
            p = p.replace("/src/code/", "/${resourcesJavaMainFolder}/");
            p = p.replace("/src/copy/", "/${resourcesPacketsFolder}/");
            p = p.replace("/src/crop/", "/${resourcesBundlesFolder}/");
        } else if (StringUtils.startsWithIgnoreCase(p, LIB_PROJECT_FOLDER_NAME)) {
            p = "${libProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, LIB_PROJECT_FOLDER_NAME);
            p = p.replace("/src/conf/", "/${libConfigurationFilesFolder}/");
            p = p.replace("/src/java/code/", "/${libJavaMainFolder}/");
            p = p.replace("/src/java/copy/", "/${libJavaCopyFolder}/");
            p = p.replace("/src/java/crop/", "/${libJavaSourcesFolder}/");
        } else if (StringUtils.startsWithIgnoreCase(p, WAR_PROJECT_FOLDER_NAME)) {
            p = "${warProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, WAR_PROJECT_FOLDER_NAME);
            p = p.replace("/src/conf/", "/${warConfigurationFilesFolder}/");
            p = p.replace("/src/java/code/", "/${webJavaMainFolder}/");
            p = p.replace("/src/java/copy/", "/${webJavaCopyFolder}/");
            p = p.replace("/src/java/copy-1/", "/${webJavaCopy1Folder}/");
            p = p.replace("/src/java/copy-2/", "/${webJavaCopy2Folder}/");
            p = p.replace("/src/java/crop/", "/${webJavaSourcesFolder}/");
            p = p.replace("/web/WEB-INF/", "/${webConfigurationFilesFolder}/");
            p = p.replace("/web/code/", "/${webPagesMainFolder}/");
            p = p.replace("/web/copy/", "/${webPagesCopyFolder}/");
            p = p.replace("/web/crop/", "/${webPagesSourcesFolder}/");
            p = p.replace("/web/", "/${webPagesFolder}/");
        } else if (StringUtils.startsWithIgnoreCase(p, EJB_PROJECT_FOLDER_NAME)) {
            p = "${ejbProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, EJB_PROJECT_FOLDER_NAME);
            p = p.replace("/src/conf/", "/${ejbConfigurationFilesFolder}/");
            p = p.replace("/src/java/code/", "/${ejbJavaMainFolder}/");
            p = p.replace("/src/java/copy/", "/${ejbJavaCopyFolder}/");
            p = p.replace("/src/java/crop/", "/${ejbJavaSourcesFolder}/");
        } else if (StringUtils.startsWithIgnoreCase(p, EAR_PROJECT_FOLDER_NAME)) {
            p = "${earProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, EAR_PROJECT_FOLDER_NAME);
            p = p.replace("/src/conf/", "/${earConfigurationFilesFolder}/");
        } else {/* ww w.j  a va2s.c  om*/
            p = ROOT_FOLDER_SLASHED_PATH + "/" + BASE_FOLDER_NAME + p;
        }
        p = StringUtils.removeEnd(p, "/");
        return p;
    }
    return ROOT_FOLDER_SLASHED_PATH + "/" + BASE_FOLDER_NAME + path;
}

From source file:adalid.util.velocity.SecondBaseBuilder.java

private String finalisePath(String path) {
    String p = path + "/";
    if (StringUtils.startsWithIgnoreCase(p, SOURCE_PROJECT_ROOT_FOLDER_NAME)) {
        if (StringUtils.startsWithIgnoreCase(p, RESOURCES_PROJECT_FOLDER_NAME)) {
            p = "${resourcesProjectFolderPath}/"
                    + StringUtils.removeStartIgnoreCase(p, RESOURCES_PROJECT_FOLDER_NAME);
            p = p.replace("/src/main/resources/META-INF/", "/${resourcesConfigurationFilesFolder}/");
            p = p.replace("/src/main/resources/", "/${resourcesBundlesFolder}/");
            p = p.replace("/src/main/java/", "/${resourcesJavaMoreFolder}/");
        } else if (StringUtils.startsWithIgnoreCase(p, LIB_PROJECT_FOLDER_NAME)) {
            p = "${libProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, LIB_PROJECT_FOLDER_NAME);
            p = p.replace("/src/main/resources/META-INF/", "/${libConfigurationFilesFolder}/");
            p = p.replace("/src/main/java/", "/${libJavaMoreFolder}/");
        } else if (StringUtils.startsWithIgnoreCase(p, WAR_PROJECT_FOLDER_NAME)) {
            p = "${webProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, WAR_PROJECT_FOLDER_NAME);
            p = p.replace("/src/main/resources/META-INF/", "/${warConfigurationFilesFolder}/");
            p = p.replace("/src/main/java/", "/${webJavaMoreFolder}/");
            p = p.replace("/src/main/webapp/WEB-INF/", "/${webConfigurationFilesFolder}/");
            p = p.replace("/src/main/webapp/", "/${webPagesFolder}/");
        } else if (StringUtils.startsWithIgnoreCase(p, EJB_PROJECT_FOLDER_NAME)) {
            p = "${ejbProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, EJB_PROJECT_FOLDER_NAME);
            p = p.replace("/src/main/resources/META-INF/", "/${ejbConfigurationFilesFolder}/");
            p = p.replace("/src/main/java/", "/${ejbJavaMoreFolder}/");
        } else if (StringUtils.startsWithIgnoreCase(p, EAR_PROJECT_FOLDER_NAME)) {
            p = "${earProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, EAR_PROJECT_FOLDER_NAME);
            p = p.replace("/src/main/application/META-INF/", "/${earConfigurationFilesFolder}/");
        } else if (StringUtils.startsWithIgnoreCase(p, POM_PROJECT_FOLDER_NAME)) {
            p = "${rootProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, POM_PROJECT_FOLDER_NAME);
        } else {/*w  w w .  ja v  a  2  s.  c o  m*/
            p = ROOT_FOLDER_SLASHED_PATH + "/" + BASE_FOLDER_NAME + p;
        }
        p = StringUtils.removeEnd(p, "/");
        return p;
    }
    return ROOT_FOLDER_SLASHED_PATH + "/" + BASE_FOLDER_NAME + path;
}

From source file:com.microsoft.exchange.impl.ExchangeResponseUtilsImpl.java

@Override
public Set<String> parseResolveNamesResponse(ResolveNamesResponse response) {
    Set<String> addresses = new HashSet<String>();
    if (confirmSuccessOrWarning(response)) {
        ArrayOfResponseMessagesType arrayOfResponseMessagesType = response.getResponseMessages();
        List<JAXBElement<? extends ResponseMessageType>> responseMessagesList = arrayOfResponseMessagesType
                .getCreateItemResponseMessagesAndDeleteItemResponseMessagesAndGetItemResponseMessages();
        for (JAXBElement<? extends ResponseMessageType> element : responseMessagesList) {
            ResolveNamesResponseMessageType rnrmt = (ResolveNamesResponseMessageType) element.getValue();
            ArrayOfResolutionType arrayOfResolutionType = rnrmt.getResolutionSet();
            List<ResolutionType> resolutions = arrayOfResolutionType.getResolutions();
            for (ResolutionType resolution : resolutions) {
                ContactItemType contact = resolution.getContact();
                EmailAddressDictionaryType emailAddresses = contact.getEmailAddresses();
                List<EmailAddressDictionaryEntryType> entries = emailAddresses.getEntries();
                for (EmailAddressDictionaryEntryType entry : entries) {
                    String value = entry.getValue();
                    if (StringUtils.isNotBlank(value)) {
                        value = value.toLowerCase();
                        value = StringUtils.removeStartIgnoreCase(value, "smtp:");
                        addresses.add(value);
                    }//from   ww  w .ja v  a 2s  .c om
                }
            }
        }
    }
    return addresses;
}

From source file:adalid.util.meta.sql.MetaPlatformSql.java

private String getTemplate(File propertiesFile) {
    String slashedPath;//  w  ww.  j ava  2 s  . co m
    String shortestPath = null;
    String propertiesFilePath = propertiesFile.getPath().replace(FILE_SEPARATOR, "/");
    String[] velocityFileResourceLoaderPathArray = VelocityEngineer.getFileResourceLoaderPathArray();
    if (velocityFileResourceLoaderPathArray != null && velocityFileResourceLoaderPathArray.length > 0) {
        for (String path : velocityFileResourceLoaderPathArray) {
            slashedPath = path.replace(FILE_SEPARATOR, "/");
            if (StringUtils.startsWithIgnoreCase(propertiesFilePath, slashedPath)) {
                if (shortestPath == null || slashedPath.length() < shortestPath.length()) {
                    shortestPath = slashedPath;
                }
            }
        }
    }
    if (shortestPath == null) {
        return propertiesFile.getName();
    }
    String template = StringUtils.removeStartIgnoreCase(propertiesFilePath, shortestPath);
    return StringUtils.removeStartIgnoreCase(template, "/");
}

From source file:com.mirth.connect.connectors.http.HttpDispatcher.java

private void processDigestChallenge(AuthCache authCache, HttpHost target, Credentials credentials,
        HttpRequest request, HttpContext context) throws AuthenticationException {
    Header authHeader = request.getFirstHeader("Authorization");
    /*/*  www.  ja v  a2  s  .  co m*/
     * Since we're going to be replacing the header, we remove it here. If the header is invalid
     * or the challenge fails, we still want to remove the header, because otherwise it will
     * interfere with reactive authentication.
     */
    request.removeHeaders("Authorization");

    if (authHeader != null) {
        String authValue = authHeader.getValue();

        // The Authorization header value will be in the form: Digest param1="value1", param2="value2"
        if (StringUtils.startsWithIgnoreCase(authValue, AuthSchemes.DIGEST)) {
            DigestScheme digestScheme = new DigestScheme();

            // Get the actual parameters by stripping off the "Digest"
            authValue = StringUtils.removeStartIgnoreCase(authValue, AuthSchemes.DIGEST).trim();
            Matcher matcher = AUTH_HEADER_PATTERN.matcher(authValue);

            while (matcher.find()) {
                // We found a param="value" group
                String group = matcher.group();
                int index = group.indexOf('=');
                String name = group.substring(0, index).trim();
                String value = group.substring(index + 1).trim();

                // Strip off any quotes in the value
                if (value.startsWith("\"")) {
                    value = value.substring(1);
                }
                if (value.endsWith("\"")) {
                    value = value.substring(0, value.length() - 1);
                }

                logger.debug("Overriding Digest Parameter: " + name + "=\"" + value + "\"");
                digestScheme.overrideParamter(name, value);
            }

            // Since this is preemptive, we need to actually process the challenge beforehand
            request.addHeader(digestScheme.authenticate(credentials, request, context));
            authCache.put(target, digestScheme);
        }
    }
}

From source file:adalid.util.meta.sql.MetaPlatformSql.java

private String rootlessPath(File file) {
    return StringUtils.removeStart(StringUtils.removeStartIgnoreCase(file.getPath(), getRoot().getPath()),
            FILE_SEPARATOR);
}

From source file:com.hangum.tadpole.rdb.core.editors.main.MainEditor.java

/**
 * execute query/*ww w  . j  a v  a2  s.  c om*/
 * 
 * @param reqQuery
 */
public void executeCommand(final RequestQuery reqQuery) {
    //   . 
    if (StringUtils.isEmpty(reqQuery.getSql()))
        return;

    String strCheckSQL = SQLUtil.removeCommentAndOthers(userDB, reqQuery.getSql());
    if (StringUtils.startsWithIgnoreCase(strCheckSQL, "desc ")) {
        String strObject = StringUtils.removeStartIgnoreCase(strCheckSQL, "desc ");
        DialogUtil.popupDMLDialog(getUserDB(), strObject);
    } else {
        resultMainComposite.executeCommand(reqQuery);
    }

    // google analytic
    AnalyticCaller.track(MainEditor.ID, "executeCommand"); //$NON-NLS-1$
}

From source file:adalid.commons.velocity.Writer.java

private void writeFile(WriterContext templateWriterContext, File templatePropertiesFile) {
    VelocityContext fileContext = templateWriterContext.getVelocityContextClone();
    TLB.setProgrammers(templateWriterContext.programmers);
    TLB.setWrapperClasses(templateWriterContext.wrapperClasses);
    Properties properties = mergeProperties(fileContext, templatePropertiesFile);
    putStrings(fileContext, properties);
    //      String rootPath = getRootPath(fileContext);
    String userPath = pathString(USER_DIR);
    String temptype = StringUtils.defaultIfBlank(properties.getProperty(TP_TYPE), TP_TYPE_VELOCITY);
    String template = StringUtils.trimToNull(properties.getProperty(TP_TEMPLATE));
    String filePath = StringUtils.trimToNull(properties.getProperty(TP_PATH));
    String filePack = StringUtils.trimToNull(properties.getProperty(TP_PACKAGE));
    String fileName = StringUtils.trimToNull(properties.getProperty(TP_FILE));
    String preserve = StringUtils.trimToNull(properties.getProperty(TP_PRESERVE));
    String charset1 = StringUtils.trimToNull(properties.getProperty(TP_ENCODING));
    String charset2 = StringUtils.trimToNull(properties.getProperty(TP_CHARSET));
    String root = getRoot().getPath();
    String raiz = root.replace('\\', '/');
    String hint = "; check property \"{0}\" at file \"{1}\"";
    if (ArrayUtils.contains(TP_TYPE_ARRAY, temptype)) {
    } else {// w w  w . j  a  v a2 s  .co  m
        String pattern = "failed to obtain a valid template type" + hint;
        String message = MessageFormat.format(pattern, TP_TYPE, templatePropertiesFile);
        logger.error(message);
        errors++;
        return;
    }
    if (template == null) {
        String pattern = "failed to obtain a valid template name" + hint;
        String message = MessageFormat.format(pattern, TP_TEMPLATE, templatePropertiesFile);
        logger.error(message);
        errors++;
        return;
    }
    if (fileName == null) {
        String pattern = "failed to obtain a valid file name" + hint;
        String message = MessageFormat.format(pattern, TP_FILE, templatePropertiesFile);
        logger.error(message);
        errors++;
        return;
    }
    String templatePathString = pathString(template);
    String templatePath = StringUtils.substringBeforeLast(templatePathString, FILE_SEPARATOR);
    fileContext.put(VC_TEMPLATE, StringEscapeUtils.escapeJava(templatePathString));
    fileContext.put(VC_TEMPLATE_PATH, StringUtils.replace(templatePath, FILE_SEPARATOR, SLASH));
    fileContext.put(VC_FILE, fileName);
    if (filePath == null) {
        //          filePath = rootPath;
        filePath = userPath;
    } else {
        filePath = pathString(filePath);
        if (isRelativePath(filePath)) {
            if (filePath.startsWith(FILE_SEPARATOR)) {
                //                  filePath = rootPath + filePath;
                filePath = userPath + filePath;
            } else {
                //                  filePath = rootPath + FILE_SEPARATOR + filePath;
                filePath = userPath + FILE_SEPARATOR + filePath;
            }
        }
    }
    fileContext.put(VC_PATH, StringEscapeUtils.escapeJava(filePath));
    if (filePack != null) {
        filePath += FILE_SEPARATOR + pathString(StringUtils.replace(filePack, DOT, SLASH));
        fileContext.put(VC_PACKAGE, dottedString(filePack));
    }
    File path = new File(filePath);
    if (path.exists()) {
        if (path.isDirectory() && path.canWrite()) {
        } else {
            String pattern = "{2} is not a valid directory" + hint;
            String message = MessageFormat.format(pattern, TP_PATH, templatePropertiesFile, path);
            logger.error(message);
            errors++;
            return;
        }
    } else if (path.mkdirs()) {
    } else {
        String pattern = "{2} is not a valid path" + hint;
        String message = MessageFormat.format(pattern, TP_PATH, templatePropertiesFile, path);
        logger.error(message);
        errors++;
        return;
    }
    String fullname = path.getPath() + FILE_SEPARATOR + fileName;
    String slashedPath = fullname.replace('\\', '/');
    File file = new File(fullname);
    if (file.exists()) {
        String regex, pattern, message;
        for (Pattern fxp : fileExclusionPatterns) {
            regex = fxp.pattern();
            if (slashedPath.matches(regex)) {
                excludedFiles++;
                pattern = "file {0} will be deleted; it matches exclusion expression \"{1}\"";
                message = MessageFormat.format(pattern, StringUtils.removeStartIgnoreCase(slashedPath, raiz),
                        regex);
                log(_alertLevel, message);
                warnings++;
                FileUtils.deleteQuietly(file);
                return;
            }
        }
        if (BitUtils.valueOf(preserve)) {
            preservedFiles++;
            pattern = "file {2} will not be replaced" + hint;
            message = MessageFormat.format(pattern, TP_PRESERVE, templatePropertiesFile, fullname);
            log(_detailLevel, message);
            return;
        }
        for (Pattern fxp : filePreservationPatterns) {
            regex = fxp.pattern();
            if (slashedPath.matches(regex)) {
                preservedFiles++;
                pattern = "file {0} will not be replaced; it matches preservation expression \"{1}\"";
                message = MessageFormat.format(pattern, StringUtils.removeStartIgnoreCase(slashedPath, raiz),
                        regex);
                log(_alertLevel, message);
                warnings++;
                return;
            }
        }
    } else {
        String regex, pattern, message;
        for (Pattern fxp : fileExclusionPatterns) {
            regex = fxp.pattern();
            if (slashedPath.matches(regex)) {
                excludedFiles++;
                pattern = "file {0} will not be written; it matches exclusion expression \"{1}\"";
                message = MessageFormat.format(pattern, StringUtils.removeStartIgnoreCase(slashedPath, raiz),
                        regex);
                log(_alertLevel, message);
                warnings++;
                return;
            }
        }
    }
    if (charset1 != null && !Charset.isSupported(charset1)) {
        String pattern = "{2} is not a supported character set" + hint;
        String message = MessageFormat.format(pattern, TP_ENCODING, templatePropertiesFile, charset1);
        logger.error(message);
        errors++;
        return;
    }
    if (charset2 != null && !Charset.isSupported(charset2)) {
        String pattern = "{2} is not a supported character set" + hint;
        String message = MessageFormat.format(pattern, TP_CHARSET, templatePropertiesFile, charset2);
        logger.error(message);
        errors++;
        return;
    }
    fileContext.put(VC_FILE_PATH, StringEscapeUtils.escapeJava(filePath));
    fileContext.put(VC_FILE_NAME, StringEscapeUtils.escapeJava(fileName));
    fileContext.put(VC_FILE_PATH_NAME, StringEscapeUtils.escapeJava(fullname));
    fileContext.put(VC_FILE_PATH_FILE, path);
    if (temptype.equals(TP_TYPE_VELOCITY)) {
        writeFile(fileContext, template, fullname, charset1, charset2);
    } else {
        writeFile(template, fullname);
    }
    executeFile(fileContext, templatePropertiesFile);
}

From source file:adalid.commons.velocity.Writer.java

private String getTemplate(File propertiesFile) {
    String slashedPath;/*from  w  ww .j a  v  a 2s .co  m*/
    String shortestPath = null;
    String propertiesFilePath = propertiesFile.getPath().replace(FILE_SEPARATOR, SLASH);
    String[] velocityFileResourceLoaderPathArray = VelocityEngineer.getFileResourceLoaderPathArray();
    if (velocityFileResourceLoaderPathArray != null && velocityFileResourceLoaderPathArray.length > 0) {
        for (String path : velocityFileResourceLoaderPathArray) {
            //              slashedPath = path.replace(FILE_SEPARATOR, SLASH);
            slashedPath = StringUtils.removeEnd(path.replace(FILE_SEPARATOR, SLASH), SLASH) + SLASH;
            if (StringUtils.startsWithIgnoreCase(propertiesFilePath, slashedPath)) {
                if (shortestPath == null || slashedPath.length() < shortestPath.length()) {
                    shortestPath = slashedPath;
                }
            }
        }
    }
    if (shortestPath == null) {
        return propertiesFile.getName();
    }
    String template = StringUtils.removeStartIgnoreCase(propertiesFilePath, shortestPath);
    //      return StringUtils.removeStartIgnoreCase(template, SLASH);
    return template;
}