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

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

Introduction

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

Prototype

public static String lowerCase(final String str) 

Source Link

Document

Converts a String to lower case as per String#toLowerCase() .

A null input String returns null .

 StringUtils.lowerCase(null)  = null StringUtils.lowerCase("")    = "" StringUtils.lowerCase("aBc") = "abc" 

Note: As described in the documentation for String#toLowerCase() , the result of this method is affected by the current locale.

Usage

From source file:com.ottogroup.bi.streaming.sink.kafka.KafkaProducerBuilder.java

/**
 * Adds a new key/value pair to properties
 * @param key/*from  w  ww  .  j a  v  a 2  s  .  c  o  m*/
 * @param value
 * @return
 */
public KafkaProducerBuilder<T> addProperty(final String key, final String value) {
    if (StringUtils.isNotBlank(key) && value != null)
        this.properties.put(StringUtils.lowerCase(StringUtils.trim(key)), value);
    return this;
}

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

@Test
public void testNoCaseSensitive() throws Exception {
    final String name = UUID.randomUUID().toString();
    FinderLocal l = new FinderLocal(System.getProperty("java.io.tmpdir"), name);
    new DefaultLocalTouchFeature().touch(l);
    assertTrue(l.exists());/*  w  ww .ja  va 2 s  . c o  m*/
    assertTrue(new FinderLocal(System.getProperty("java.io.tmpdir"), StringUtils.upperCase(name)).exists());
    assertTrue(new FinderLocal(System.getProperty("java.io.tmpdir"), StringUtils.lowerCase(name)).exists());
    l.delete();
}

From source file:com.google.api.tools.framework.model.BoundedDiagCollector.java

@Override
public void addDiag(Diag diag) {
    int capacity = capacityByKind.containsKey(diag.getKind()) ? capacityByKind.get(diag.getKind()) : 0;
    int currentCount = listByKind(diag.getKind()).size();
    if (currentCount < capacity) {
        diags.add(diag);/* www .  j ava  2  s.c  o  m*/
    } else if (currentCount == capacity) {
        final String msg = String.format(
                "Hit max count(%d) of allowed %s. No more diags of this kind will be logged.", capacity,
                StringUtils.lowerCase(diag.getKind().toString()));

        diags.add(Diag.create(SimpleLocation.TOPLEVEL, "%s", diag.getKind(), msg));

        // Try to short circuit proceeding in a known bad state (to avoid potential timeouts in
        // trying process REALLY bad configuration).
        if (diag.getKind() == Kind.ERROR) {
            throw new TooManyDiagsException(msg);
        }
    }
}

From source file:com.callidusrobotics.object.actor.AbstractActor.java

public String getNameFirstPerson() {
    return "The " + StringUtils.lowerCase(name);
}

From source file:com.threewks.thundr.http.service.gae.HttpResponseImpl.java

@Override
public List<String> getHeaders(String name) {
    response();// ww  w.  j  a va2s. c  o m
    List<String> headers = headersLower.get(StringUtils.lowerCase(name));
    return headers == null ? null : Collections.unmodifiableList(headers);
}

From source file:com.bekwam.resignator.commands.KeytoolCommand.java

public List<KeystoreEntry> findKeystoreEntries(String keytoolExec, String keystore, String storepass)
        throws CommandExecutionException {

    List<KeystoreEntry> entries = new ArrayList<>();

    Preconditions.checkNotNull(keytoolExec);
    Preconditions.checkNotNull(keystore);
    Preconditions.checkNotNull(storepass);

    File outputFile = null;//w  w w.  j ava2 s .  c o m

    try {

        String[] cmdAndArgs = { keytoolExec, "-keystore", keystore, "-storepass", storepass, "-list" };

        File resignatorDir = new File(System.getProperty("user.home"), ".resignator");

        String outputFileName = OUTPUTFILE_PREFIX
                + StringUtils.lowerCase(RandomStringUtils.randomAlphabetic(12)) + OUTPUTFILE_SUFFIX;

        outputFile = new File(resignatorDir, outputFileName);

        ProcessBuilder pb = new ProcessBuilder(cmdAndArgs);
        pb.redirectErrorStream(false);
        pb.redirectOutput(outputFile);

        Process p = pb.start();

        boolean exitted = p.waitFor(TIMEOUT_SECS, TimeUnit.SECONDS);

        if (exitted) {

            if (p.exitValue() == 0) {

                BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(outputFile)));
                entries.addAll(parseKeystoreEntries(br));
                br.close();

            } else {

                String firstLine = "";
                if (outputFile != null && outputFile.exists()) {
                    BufferedReader br = new BufferedReader(new FileReader(outputFile));
                    firstLine = br.readLine();
                    br.close();
                }

                if (logger.isErrorEnabled()) {
                    logger.error("error running exec={}; firstLine={}", keytoolExec, firstLine);
                }

                throw new CommandExecutionException(
                        "Command '" + keytoolExec + "' failed to run" + newLine + firstLine);
            }

        } else {

            if (logger.isErrorEnabled()) {
                logger.error("command '" + keytoolExec + "' timed out");
            }

            throw new CommandExecutionException("Command '" + keytoolExec + "' timed out");
        }

    } catch (Exception exc) { // includes interrupted exception

        if (logger.isErrorEnabled()) {
            logger.error("error running keytool", exc);
        }

        throw new CommandExecutionException("Error running keytool command" + newLine + exc.getMessage());

    } finally {
        if (outputFile != null) {
            outputFile.delete();
        }
    }

    return entries;
}

From source file:eu.openanalytics.rsb.config.PersistedConfigurationAdapter.java

private String getDefaultNodeName() {
    // find something unique about the running node like the location of resource
    final URL resourceUrl = getClass().getResource("/META-INF/spring/core-beans.xml");
    final String uniqueId = Long.toHexString(Math.abs((long) resourceUrl.toExternalForm().hashCode()));
    return StringUtils.lowerCase(Constants.HOST_NAME + "-" + uniqueId);
}

From source file:apm.generate.Generate.java

public static void parameters(String packageName, String moduleName, String className, String classAuthor,
        String functionName, String tableName, String entityContent, String flag) throws Exception {
    // ==========  ?? ====================
    // ??????//  w w w  . j a v  a2 s  .  c  o  m
    // ?{packageName}/{moduleName}/{dao,entity,service,web}/{subModuleName}/{className}
    // packageName ????applicationContext.xmlsrping-mvc.xml?base-package?packagesToScan?4?

    //String packageName = "lms.modules";//???

    //String moduleName = "test";         //???sys
    String subModuleName = ""; // ?????? 
    //String className = "test";         // ??user
    //String classAuthor = "htd";         // ThinkGem
    //String functionName = "";         //??

    // ???
    Boolean isEnable = true;

    // ==========  ?? ====================

    if (!isEnable) {
        //logger.error("????isEnable = true");
        System.out.println("????isEnable = true");
        return;
    }

    if (StringUtils.isBlank(moduleName) || StringUtils.isBlank(moduleName) || StringUtils.isBlank(className)
            || StringUtils.isBlank(functionName)) {
        //logger.error("??????????????");
        System.out.println("??????????????");
        return;
    }

    // ?
    String separator = File.separator;

    // ?
    File projectPath = new DefaultResourceLoader().getResource("").getFile();
    while (!new File(projectPath.getPath() + separator + "src" + separator + "main").exists()) {
        projectPath = projectPath.getParentFile();
    }
    //logger.info("Project Path: {}", projectPath);
    System.out.println("-------------------------------------------------");
    System.out.println(":" + projectPath);
    // ?
    String tplPath = StringUtils.replace(projectPath + "/src/main/java/apm/generate/template", "/", separator);
    //logger.info("Template Path: {}", tplPath);
    System.out.println("?:" + tplPath);
    // Java
    String javaPath = StringUtils.replaceEach(
            projectPath + "/src/main/java/" + StringUtils.lowerCase(packageName), new String[] { "/", "." },
            new String[] { separator, separator });
    //logger.info("Java Path: {}", javaPath);
    System.out.println("Java:" + javaPath);
    // 
    String viewPath = StringUtils.replace(projectPath + "/src/main/webapp/WEB-INF/views", "/", separator);
    //logger.info("View Path: {}", viewPath);
    System.out.println(":" + viewPath);
    // ???
    Configuration cfg = new Configuration();
    cfg.setDirectoryForTemplateLoading(new File(tplPath));

    // ???
    Map<String, String> model = Maps.newHashMap();
    model.put("packageName", StringUtils.lowerCase(packageName));
    model.put("moduleName", moduleName);
    model.put("subModuleName",
            StringUtils.isNotBlank(subModuleName) ? "." + StringUtils.lowerCase(subModuleName) : "");
    model.put("className", StringUtils.uncapitalize(className));
    model.put("ClassName", StringUtils.capitalize(className));
    model.put("classAuthor", StringUtils.isNotBlank(classAuthor) ? classAuthor : "Generate Tools");
    model.put("classVersion", DateUtils.getDate());
    model.put("functionName", functionName);
    model.put("tableName", tableName);

    model.put("urlPrefix", "/" + model.get("className"));
    model.put("viewUrlPrefix", "/" + model.get("moduleName"));
    model.put("returnPrefix", "modules" + //StringUtils.substringAfterLast(model.get("packageName"),".")+"/"+
            model.get("viewUrlPrefix") + "/" + model.get("className"));
    model.put("viewPrefix", //StringUtils.substringAfterLast(model.get("packageName"),".")+"/"+
            model.get("urlPrefix"));

    model.put("permissionPrefix", model.get("className"));
    String[] strs = entityContent.split("##");
    model.put("columnContent", strs[0]);
    model.put("entityContent", strs[1]);

    System.out.println("-------------------------?------------------------");
    Template template = null;
    String content = null;
    String filePath = null;
    if (flag.indexOf("entity") != -1 || flag.length() == 0) {
        // ? Entity
        template = cfg.getTemplate("entity.ftl");
        content = FreeMarkers.renderTemplate(template, model);
        filePath = javaPath + separator + model.get("moduleName") + separator + "entity" + separator
                + StringUtils.lowerCase(subModuleName) + model.get("ClassName") + ".java";
        writeFile(content, filePath);
        System.out.println("? Entity:" + filePath);
    }

    if (flag.indexOf("dao") != -1 || flag.length() == 0) {

        // ? Dao
        template = cfg.getTemplate("dao.ftl");
        content = FreeMarkers.renderTemplate(template, model);
        filePath = javaPath + separator + model.get("moduleName") + separator + "dao" + separator
                + StringUtils.lowerCase(subModuleName) + model.get("ClassName") + "Dao.java";
        writeFile(content, filePath);
        System.out.println("? Dao:" + filePath);

    }

    if (flag.indexOf("service") != -1 || flag.length() == 0) {

        // ? Service
        template = cfg.getTemplate("service.ftl");
        content = FreeMarkers.renderTemplate(template, model);
        filePath = javaPath + separator + model.get("moduleName") + separator + "service" + separator
                + StringUtils.lowerCase(subModuleName) + model.get("ClassName") + "Service.java";
        writeFile(content, filePath);
        System.out.println("? Service:" + filePath);

    }

    if (flag.indexOf("controler") != -1 || flag.length() == 0) {

        // ? Controller
        template = cfg.getTemplate("controller.ftl");
        content = FreeMarkers.renderTemplate(template, model);
        filePath = javaPath + separator + model.get("moduleName") + separator + "web" + separator
                + StringUtils.lowerCase(subModuleName) + model.get("ClassName") + "Controller.java";
        writeFile(content, filePath);
        System.out.println("? Controller:" + filePath);

    }

    if (flag.indexOf("form") != -1 || flag.length() == 0) {

        // ? ViewForm
        template = cfg.getTemplate("viewForm.ftl");
        content = FreeMarkers.renderTemplate(template, model);
        filePath = viewPath + separator + StringUtils.substringAfterLast(model.get("packageName"), ".")
                + separator + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName)
                + model.get("className") + "Form.jsp";
        writeFile(content, filePath);
        System.out.println("? ViewForm:" + filePath);

    }

    if (flag.indexOf("list") != -1 || flag.length() == 0) {

        // ? ViewList
        template = cfg.getTemplate("viewList.ftl");
        content = FreeMarkers.renderTemplate(template, model);
        filePath = viewPath + separator + StringUtils.substringAfterLast(model.get("packageName"), ".")
                + separator + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName)
                + model.get("className") + "List.jsp";
        writeFile(content, filePath);
        System.out.println("? ViewList:" + filePath);

    }

}

From source file:com.ottogroup.bi.asap.resman.pipeline.PipelineManager.java

/**
 * Instantiates the provided pipeline on a set of processing nodes
 * @param pipelineConfiguration/*from   ww  w.ja v a 2 s.c  o m*/
 * @return
 * @throws RequiredInputMissingException
 * @throws RemoteClientConnectionFailedException 
 * @throws IOException 
 */
public PipelineDeploymentProfile instantiatePipeline(final MicroPipelineConfiguration pipelineConfiguration)
        throws RequiredInputMissingException, PipelineAlreadyRegisteredException {

    ///////////////////////////////////////////////////////////
    // validate input
    if (pipelineConfiguration == null)
        throw new RequiredInputMissingException("Missing required pipeline configuration");
    String pid = StringUtils.lowerCase(StringUtils.trim(pipelineConfiguration.getId()));
    if (this.pipelineDeployments.containsKey(pid))
        throw new PipelineAlreadyRegisteredException("A pipeline already exists for identifier '"
                + pipelineConfiguration.getId() + "'. To replace an existing pipeline use updateOrInstantiate");
    // TODO validate pipeline configuration
    //
    ///////////////////////////////////////////////////////////

    final PipelineDeploymentProfile profile = processingNodeManager.instantiatePipeline(
            new PipelineDeploymentProfile(pipelineConfiguration.getId(), pipelineConfiguration));
    this.pipelineDeployments.put(StringUtils.lowerCase(StringUtils.trim(pipelineConfiguration.getId())),
            profile);

    return profile;
}

From source file:com.jdy.ddj.common.orm.PageRequest.java

/**
 * ???.//from  w  w w  .  j a va  2s .  c o  m
 *
 * @param orderDir ?descasc,?','.
 */
public void setOrderDir(final String orderDir) {
    if (orderDir == null) {
        return;
    }
    String lowcaseOrderDir = StringUtils.lowerCase(orderDir);

    //order?
    String[] orderDirs = StringUtils.split(lowcaseOrderDir, ',');
    for (String orderDirStr : orderDirs) {
        if (!StringUtils.equals(Sort.DESC, orderDirStr) && !StringUtils.equals(Sort.ASC, orderDirStr)) {
            throw new IllegalArgumentException("??" + orderDirStr + "??");
        }
    }

    this.orderDir = lowcaseOrderDir;
}