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:cn.wanghaomiao.seimi.core.Seimi.java

private void sendRequest(String crawlerName, SeimiQueue queue, String[] startUrls) {
    if (ArrayUtils.isNotEmpty(startUrls)) {
        for (String url : startUrls) {
            Request request = new Request();
            String[] urlPies = url.split("##");
            if (urlPies.length >= 2 && StringUtils.lowerCase(urlPies[1]).equals("post")) {
                request.setHttpMethod(HttpMethod.POST);
            }/*from   ww  w.  j  av  a  2 s .c  om*/
            request.setCrawlerName(crawlerName);
            request.setUrl(url);
            request.setCallBack("start");
            queue.push(request);
            logger.info("{} url={} started", crawlerName, url);
        }
    } else {
        logger.error("crawler:{} can not find start urls!", crawlerName);
    }
}

From source file:com.ottogroup.bi.spqr.pipeline.component.source.SourceRuntimeEnvironment.java

/**
 * Initializes the runtime environment using the provided input
 * @param processingNodeId/*from w  ww .  j av  a  2s . co  m*/
 * @param pipelineId
 * @param source
 * @param queueProducer
 * @param executorService
 * @throws RequiredInputMissingException
 */
public SourceRuntimeEnvironment(final String processingNodeId, final String pipelineId, final Source source,
        final StreamingMessageQueueProducer queueProducer, final ExecutorService executorService)
        throws RequiredInputMissingException {

    ///////////////////////////////////////////////////////////////
    // validate input
    if (StringUtils.isBlank(processingNodeId))
        throw new RequiredInputMissingException("Missing required processing node identifier");
    if (StringUtils.isBlank(pipelineId))
        throw new RequiredInputMissingException("Missing required pipeline identifier");
    if (source == null)
        throw new RequiredInputMissingException("Missing required source");
    if (queueProducer == null)
        throw new RequiredInputMissingException("Missing required queue producer");
    if (executorService == null)
        throw new RequiredInputMissingException("Missing required executor service");
    //
    ///////////////////////////////////////////////////////////////

    this.processingNodeId = StringUtils.lowerCase(StringUtils.trim(processingNodeId));
    this.pipelineId = StringUtils.lowerCase(StringUtils.trim(pipelineId));
    this.sourceId = StringUtils.lowerCase(StringUtils.trim(source.getId()));
    this.source = source;
    this.source.setIncomingMessageCallback(this);
    this.queueProducer = queueProducer;
    this.executorService = executorService;

    this.executorService.submit(source);
    if (logger.isDebugEnabled())
        logger.debug("source runtime environment initialized [id=" + source.getId() + "]");
}

From source file:com.chessix.vas.service.ClasService.java

String getClasId(final String clasId) {
    return StringUtils.lowerCase(StringUtils.trimToEmpty(clasId));
}

From source file:fr.scc.elo.controller.EloController.java

@GET
@Produces({ MediaType.TEXT_HTML })
@Path("/match/manage/{taille}/winners/{w}/loosers/{l}/score/{s}/type/{t}/create/{c}")
public void saveMatchAndRestart(@Context HttpServletRequest http, @Context HttpServletResponse redirect,
        @BeanParam MatchRequest request, @PathParam("taille") Integer taille) throws IOException {
    Map<String, Object> map = getMatchMap(http, taille);
    try {// www.j  a v a2s  .  c om
        if (connectionService.acceptIPUpdate(http.getRemoteAddr())) {
            MatchResponse response = eloManager.manageMatch(StringUtils.lowerCase(request.getWinnerList()),
                    StringUtils.lowerCase(request.getLooserList()), request.getScore(), request.getTypeMatch(),
                    request.getCreatePlayers());
            map.put("status", response.getPlayersUpdated().size() + " players updated");
        } else {
            map.put("status", "Not allowed to save match");
        }
    } catch (Exception e) {
        map.put("status", e.getMessage());
    }
    redirect.sendRedirect("/rest/v1/elo/match/manage/" + taille);
}

From source file:com.ottogroup.bi.spqr.operator.kafka.emitter.KafkaTopicEmitter.java

/**
 * @see com.ottogroup.bi.spqr.pipeline.component.MicroPipelineComponent#initialize(java.util.Properties)
 *//*from  w ww  . j a  v a  2  s  .co  m*/
public void initialize(Properties properties)
        throws RequiredInputMissingException, ComponentInitializationFailedException {

    /////////////////////////////////////////////////////////////////////////
    // input extraction and validation

    if (properties == null)
        throw new RequiredInputMissingException("Missing required properties");

    clientId = StringUtils.lowerCase(StringUtils.trim(properties.getProperty(CFG_OPT_KAFKA_CLIENT_ID)));
    if (StringUtils.isBlank(clientId))
        throw new RequiredInputMissingException("Missing required kafka client id");

    zookeeperConnect = StringUtils
            .lowerCase(StringUtils.trim(properties.getProperty(CFG_OPT_ZOOKEEPER_CONNECT)));
    if (StringUtils.isBlank(zookeeperConnect))
        throw new RequiredInputMissingException("Missing required zookeeper connect");

    topicId = StringUtils.lowerCase(StringUtils.trim(properties.getProperty(CFG_OPT_TOPIC_ID)));
    if (StringUtils.isBlank(topicId))
        throw new RequiredInputMissingException("Missing required topic");

    brokerList = StringUtils.lowerCase(StringUtils.trim(properties.getProperty(CFG_OPT_BROKER_LIST)));
    if (StringUtils.isBlank(brokerList))
        throw new RequiredInputMissingException("Missing required broker list");

    String charsetName = StringUtils.trim(properties.getProperty(CFG_OPT_CHARSET));
    try {
        if (StringUtils.isNotBlank(charsetName))
            charset = Charset.forName(charsetName);
        else
            charset = Charset.forName("UTF-8");
    } catch (Exception e) {
        throw new RequiredInputMissingException(
                "Invalid character set provided: " + charsetName + ". Error: " + e.getMessage());
    }

    messageAcking = StringUtils
            .equalsIgnoreCase(StringUtils.trim(properties.getProperty(CFG_OPT_MESSAGE_ACKING)), "true");
    //
    /////////////////////////////////////////////////////////////////////////

    if (logger.isDebugEnabled())
        logger.debug("kafka emitter[id=" + this.id + ", client=" + clientId + ", topic=" + topicId + ", broker="
                + brokerList + ", zookeeper=" + zookeeperConnect + ", charset=" + charset.name()
                + ", messageAck=" + messageAcking + "]");

    // initialize the producer only if it is not already exist --- typically assigned through test case!
    if (kafkaProducer == null) {
        Properties props = new Properties();
        props.put(CFG_ZK_CONNECT, zookeeperConnect);
        props.put(CFG_BROKER_LIST, brokerList);
        props.put(CFG_REQUEST_REQUIRED_ACKS, (messageAcking ? "1" : "0"));
        props.put(CFG_CLIENT_ID, clientId);
        this.kafkaProducer = new Producer<>(new ProducerConfig(props));
    }
}

From source file:com.nike.cerberus.service.VaultPolicyService.java

/**
 * Outputs the expected policy name format used in Vault.
 *
 * @param sdbName Safe deposit box name.
 * @param roleName Role for safe deposit box.
 * @return Formatted policy name./*  ww w . j  a  v  a2 s .c  o  m*/
 */
public String buildPolicyName(final String sdbName, final String roleName) {
    Preconditions.checkArgument(StringUtils.isNotBlank(sdbName), "sdbName cannot be blank!");
    Preconditions.checkArgument(StringUtils.isNotBlank(roleName), "roleName cannot be blank!");

    final StringBuilder sb = new StringBuilder();
    sb.append(slugger.toSlug(sdbName));
    sb.append('-');
    sb.append(StringUtils.lowerCase(roleName));
    return sb.toString();
}

From source file:com.xpn.xwiki.plugin.lucene.DocumentData.java

private void getObjectContentAsText(StringBuilder contentText, BaseObject baseObject, String property,
        XWikiContext context) {//from w w  w  .  j a  v a 2  s . c  om
    BaseProperty baseProperty = (BaseProperty) baseObject.getField(property);
    // FIXME Can baseProperty really be null?
    if (baseProperty != null && baseProperty.getValue() != null) {
        if (!(baseObject.getXClass(context).getField(property) instanceof PasswordClass)) {
            contentText.append(StringUtils.lowerCase(baseProperty.getValue().toString()));
        }
    }
}

From source file:com.ottogroup.bi.asap.resman.node.ProcessingNodeManager.java

/**
 * Shuts down the referenced processing node by sending a corresponding message and removing it from internal handler map 
 * @param processingNodeId//w  ww .j  ava  2 s  .c  o m
 * @return
 * @throws RequiredInputMissingException
 */
public String shutdownProcessingNode(final String processingNodeId)
        throws RequiredInputMissingException, UnknownProcessingNodeException {

    ///////////////////////////////////////////////////////
    // validate input
    if (StringUtils.isBlank(processingNodeId))
        throw new RequiredInputMissingException("Missing processing node identifier");
    String pid = StringUtils.lowerCase(StringUtils.trim(processingNodeId));
    if (!this.processingNodes.containsKey(pid))
        throw new UnknownProcessingNodeException(
                "Referenced processing node '" + processingNodeId + "' unknown to node manager");
    //
    ///////////////////////////////////////////////////////

    final ProcessingNode node = this.processingNodes.remove(pid);
    node.shutdown();

    if (logger.isDebugEnabled())
        logger.debug("processing node shutdown [id=" + node.getId() + ", protocol=" + node.getProtocol()
                + ", host=" + node.getHost() + ", servicePort=" + node.getServicePort() + ", adminPort="
                + node.getAdminPort() + "]");

    return processingNodeId;
}

From source file:com.ottogroup.bi.spqr.pipeline.queue.chronicle.DefaultStreamingMessageQueue.java

/**
 * @see com.ottogroup.bi.spqr.pipeline.queue.StreamingMessageQueue#initialize(java.util.Properties)
 *//* w w  w  .j a v a  2  s.  c  om*/
public void initialize(Properties properties) throws RequiredInputMissingException {

    ////////////////////////////////////////////////////////////////////////////////
    // extract and validate input
    if (properties == null)
        throw new RequiredInputMissingException("Missing required properties");

    if (StringUtils.isBlank(this.id))
        throw new RequiredInputMissingException("Missing required queue identifier");

    if (StringUtils.equalsIgnoreCase(
            StringUtils.trim(properties.getProperty(CFG_CHRONICLE_QUEUE_DELETE_ON_EXIT)), "false"))
        this.deleteOnExit = false;

    this.basePath = StringUtils.lowerCase(StringUtils.trim(properties.getProperty(CFG_CHRONICLE_QUEUE_PATH)));
    if (StringUtils.isBlank(this.basePath))
        this.basePath = System.getProperty("java.io.tmpdir");

    String tmpCycleFormat = StringUtils
            .trim(properties.getProperty(CFG_CHRONICLE_QUEUE_CYCLE_FORMAT, "yyyy-MM-dd-HH-mm"));
    if (StringUtils.isNotBlank(tmpCycleFormat))
        this.cycleFormat = tmpCycleFormat;

    String pathToChronicle = this.basePath;
    if (!StringUtils.endsWith(pathToChronicle, File.separator))
        pathToChronicle = pathToChronicle + File.separator;
    pathToChronicle = pathToChronicle + id;

    try {
        this.queueRollingInterval = TimeUnit.MINUTES.toMillis(
                Long.parseLong(StringUtils.trim(properties.getProperty(CFG_CHRONICLE_QUEUE_ROLLING_INTERVAL))));

        if (this.queueRollingInterval < VanillaChronicle.MIN_CYCLE_LENGTH) {
            this.queueRollingInterval = VanillaChronicle.MIN_CYCLE_LENGTH;
        }
    } catch (Exception e) {
        logger.info("Invalid queue rolling interval found: " + e.getMessage() + ". Using default: "
                + TimeUnit.MINUTES.toMillis(60));
    }

    this.queueWaitStrategy = getWaitStrategy(
            StringUtils.trim(properties.getProperty(CFG_QUEUE_MESSAGE_WAIT_STRATEGY)));

    //
    ////////////////////////////////////////////////////////////////////////////////

    // clears the queue if requested 
    if (this.deleteOnExit) {
        ChronicleTools.deleteDirOnExit(pathToChronicle);
        ChronicleTools.deleteOnExit(pathToChronicle);
    }

    try {
        this.chronicle = ChronicleQueueBuilder.vanilla(pathToChronicle)
                .cycleLength((int) this.queueRollingInterval).cycleFormat(this.cycleFormat).build();
        this.queueConsumer = new DefaultStreamingMessageQueueConsumer(this.getId(),
                this.chronicle.createTailer(), this.queueWaitStrategy);
        this.queueProducer = new DefaultStreamingMessageQueueProducer(this.getId(),
                this.chronicle.createAppender(), this.queueWaitStrategy);
    } catch (IOException e) {
        throw new RuntimeException(
                "Failed to initialize chronicle at '" + pathToChronicle + "'. Error: " + e.getMessage());
    }

    logger.info("queue[type=chronicle, id=" + this.id + ", deleteOnExist=" + this.deleteOnExit + ", path="
            + pathToChronicle + "']");
}

From source file:cn.sixlab.sixutil.StrUtil.java

/**
 * ???????/*from  w w w .ja va 2 s.  c  om*/
 *
 * @param ulStr ??
 * @param isFirstLower ???
 * @return ??@{code isFirstLower}true????
 * @since 1.0.0
 */
public static String getCamel(String ulStr, boolean isFirstLower) {
    StringBuffer result = new StringBuffer();

    String[] ulArray = ulStr.split("_");

    boolean isFirst = true;
    for (String s : ulArray) {
        if (StringUtils.isNotEmpty(s)) {
            s = StringUtils.lowerCase(s);
            if (isFirst && isFirstLower) {
                isFirst = false;
                result.append(s);
            } else {
                result.append(StringUtils.swapCase(s.substring(0, 1))).append(s.substring(1, s.length()));
            }
        }
    }

    return result.toString();
}