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.spqr.pipeline.component.emitter.EmitterRuntimeEnvironment.java

/**
 * Initializes the runtime environment using the provided input
 * @param processingNodeId//  ww w. j  a v  a2 s. c o  m
 * @param pipelineId
 * @param emitter
 * @param queueConsumer
 * @throws RequiredInputMissingException
 */
public EmitterRuntimeEnvironment(final String processingNodeId, final String pipelineId, final Emitter emitter,
        final StreamingMessageQueueConsumer queueConsumer) 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 (emitter == null)
        throw new RequiredInputMissingException("Missing required emitter");
    if (queueConsumer == null)
        throw new RequiredInputMissingException("Missing required input queue consumer");
    //
    ///////////////////////////////////////////////////////////////////

    this.processingNodeId = StringUtils.lowerCase(StringUtils.trim(processingNodeId));
    this.pipelineId = StringUtils.lowerCase(StringUtils.trim(pipelineId));
    this.emitterId = StringUtils.lowerCase(StringUtils.trim(emitter.getId()));
    this.emitter = emitter;
    this.queueConsumer = queueConsumer;

    this.running = true;

    if (logger.isDebugEnabled())
        logger.debug("emitter init [node=" + this.processingNodeId + ", pipeline=" + this.pipelineId
                + ", emitter=" + this.emitterId + "]");

}

From source file:it.larusba.integration.neo4j.jsonloader.transformer.AttributeBasedJsonTransformer.java

/**
 * It recursively parses a <code>Map</code> representation of the JSON
 * document./*from   w  w w.  ja v  a2  s. co m*/
 * 
 * @param documentId
 * @param documentType
 * @param documentMap
 * @return
 */
@SuppressWarnings("unchecked")
public String transform(String documentId, String documentType, Map<String, Object> documentMap) {

    StringBuffer rootNode = new StringBuffer();
    List<String> childNodes = new ArrayList<String>();
    List<String> childRelationships = new ArrayList<String>();

    String nodeReference = (documentType != null) ? StringUtils.lowerCase(documentType) : "document";
    String nodeLabel = StringUtils.capitalize(nodeReference);

    rootNode.append("CREATE (").append(nodeReference).append(":").append(nodeLabel);

    boolean firstAttr = true;

    for (String attributeName : documentMap.keySet()) {

        Object attributeValue = documentMap.get(attributeName);

        if (attributeValue instanceof Map) {

            childNodes.add(transform(documentId, attributeName, (Map<String, Object>) attributeValue));

            childRelationships
                    .add(new StringBuffer().append("CREATE (").append(nodeReference).append(")-[").append(":")
                            .append(nodeReference.toUpperCase()).append("_").append(attributeName.toUpperCase())
                            .append("]->(").append(attributeName).append(")").toString());
        } else {

            if (firstAttr) {
                rootNode.append(" { ");

                if (documentId != null) {
                    rootNode.append("_documentId: '").append(documentId).append("', ");
                }

                firstAttr = false;
            } else {
                rootNode.append(", ");
            }

            if (attributeValue != null) {
                rootNode.append(attributeName).append(": ");

                if (attributeValue instanceof String) {
                    rootNode.append("'").append(attributeValue).append("'");
                } else {
                    rootNode.append(attributeValue);
                }
            }
        }
    }

    rootNode.append(" })");

    StringBuffer cypher = new StringBuffer();

    cypher.append(rootNode);

    for (String childNode : childNodes) {

        cypher.append("\n").append(childNode);
    }

    for (String childRelationship : childRelationships) {

        cypher.append("\n").append(childRelationship);
    }

    return cypher.toString();
}

From source file:com.norconex.importer.handler.tagger.impl.CharacterCaseTagger.java

@Override
public void tagApplicableDocument(String reference, InputStream document, ImporterMetadata metadata,
        boolean parsed) throws ImporterHandlerException {

    for (String fieldName : fieldCases.keySet()) {
        String type = fieldCases.get(fieldName);
        List<String> values = metadata.getStrings(fieldName);
        if (values != null) {
            for (int i = 0; i < values.size(); i++) {
                String value = values.get(i);
                if (CASE_UPPER.equals(type)) {
                    values.set(i, StringUtils.upperCase(value));
                } else if (CASE_LOWER.equals(type)) {
                    values.set(i, StringUtils.lowerCase(value));
                } else if (CASE_WORDS.equals(type)) {
                    values.set(i, WordUtils.capitalizeFully(value));
                } else {
                    LOG.warn("Unsupported character case type: " + type);
                }//from  www.  j  a  va 2 s .co m
            }
            metadata.setString(fieldName, values.toArray(ArrayUtils.EMPTY_STRING_ARRAY));
        }
    }
}

From source file:com.ottogroup.bi.spqr.pipeline.MicroPipelineValidator.java

/**
 * Validates the contents of a provided {@link MicroPipelineConfiguration} for being compliant with a required format
 * and errors that may be inferred from provided contents
 * @param configuration/*from  w  ww.j a  v a  2  s .c  o m*/
 * @return
 */
public MicroPipelineValidationResult validate(final MicroPipelineConfiguration configuration) {

    ///////////////////////////////////////////////////////////////////////////////////
    // validate configuration, components and queues for not being null 
    if (configuration == null)
        return MicroPipelineValidationResult.MISSING_CONFIGURATION;
    if (configuration.getComponents() == null || configuration.getComponents().isEmpty())
        return MicroPipelineValidationResult.MISSING_COMPONENTS;
    if (configuration.getQueues() == null || configuration.getQueues().isEmpty())
        return MicroPipelineValidationResult.MISSING_QUEUES;
    //
    ///////////////////////////////////////////////////////////////////////////////////

    ///////////////////////////////////////////////////////////////////////////////////
    // validate queues and store their identifiers in set for further look-ups executed
    // on component evaluation
    Set<String> queueIdentifiers = new HashSet<>();
    for (final StreamingMessageQueueConfiguration queueCfg : configuration.getQueues()) {

        // queue identifier must neither be null nor empty
        if (StringUtils.isBlank(queueCfg.getId()))
            return MicroPipelineValidationResult.MISSING_QUEUE_ID;

        // convert to trimmed lower-case representation and check if it is unique
        String tempId = StringUtils.lowerCase(StringUtils.trim(queueCfg.getId()));
        if (queueIdentifiers.contains(tempId))
            return MicroPipelineValidationResult.NON_UNIQUE_QUEUE_ID;
        queueIdentifiers.add(tempId);
    }
    //
    ///////////////////////////////////////////////////////////////////////////////////

    ///////////////////////////////////////////////////////////////////////////////////
    // validate components
    Set<String> componentIdentifiers = new HashSet<>();
    for (final MicroPipelineComponentConfiguration componentCfg : configuration.getComponents()) {

        MicroPipelineValidationResult componentValidationResult = validateComponent(componentCfg,
                queueIdentifiers, componentIdentifiers);
        if (componentValidationResult != MicroPipelineValidationResult.OK)
            return componentValidationResult;

        // add identifier to set of managed components
        componentIdentifiers.add(StringUtils.lowerCase(StringUtils.trim(componentCfg.getId())));
    }
    //
    ///////////////////////////////////////////////////////////////////////////////////

    // no errors found so far which could be inferred from configuration 
    return MicroPipelineValidationResult.OK;

}

From source file:info.magnolia.ui.mediaeditor.action.CropImageAction.java

@Override
protected List<ActionContext> getActionContextList() {
    List<ActionContext> result = new ArrayList<ActionContext>();
    result.add(new ActionContext(new InternalMediaEditorActionDefinition("crop",
            i18n.translate("ui-mediaeditor.action.crop.label"), true), new ActionListener() {
                @Override//from  ww w  .j  a va2s .co m
                public void onActionFired(String actionName, Object... actionContextParams) {
                    dataSource.startAction(StringUtils.lowerCase(getDefinition().getLabel()));
                    cropField.execute();
                    eventBus.fireEvent(new MediaEditorInternalEvent(EventType.APPLY));
                }
            }));

    result.add(new ActionContext(new InternalMediaEditorActionDefinition("cancel",
            i18n.translate("ui-mediaeditor.internalAction.cancel.label"), true), new ActionListener() {
                @Override
                public void onActionFired(String actionName, Object... actionContextParams) {
                    eventBus.fireEvent(new MediaEditorInternalEvent(EventType.CANCEL_ALL));
                }
            }));

    return result;
}

From source file:com.threewks.thundr.http.SyntheticHttpServletResponse.java

@Override
public void setContentType(String type) {
    String[] contentTypeAndCharacterEncoding = type == null ? new String[] { null } : type.split(";");
    this.contentType = StringUtils.trim(StringUtils.lowerCase(contentTypeAndCharacterEncoding[0]));
    if (contentTypeAndCharacterEncoding.length > 1) {
        String encoding = StringUtils.trimToEmpty(contentTypeAndCharacterEncoding[1]);
        encoding = encoding.replaceAll("(?i)charset=", "");
        setCharacterEncoding(encoding);//from w w  w.j  a  va 2s. com
    }
}

From source file:com.threewks.thundr.gmail.GmailAdminController.java

/**
 * Endpoint for google to call back to once authentication has been verified.
 * This requires the callback to be defined in Google API Console under the Authorized redirect URIs
 * otherwise google will not be able to redirect back this endpoint
 * <p>/*from  w  ww. j  a  v a2  s. co m*/
 * If using credentialId you will need to make sure your callbackUrl and credentialId=paramValue is included.
 * otherwise it won't match.
 *
 * @param code
 * @param credentialId
 * @return
 * @throws IOException
 */
public StringView oauthCallback(String code, String credentialId) throws IOException {
    Logger.info("credentialId %s and code %s", credentialId, code);

    String callBackUrlWithCredentialId = StringUtils.isNotBlank(credentialId)
            ? addQueryParamCredential(callbackUrl, credentialId)
            : callbackUrl;

    GoogleTokenResponse tokenResponse = flow.newTokenRequest(code).setRedirectUri(callBackUrlWithCredentialId)
            .execute();

    credentialId = StringUtils
            .lowerCase(StringUtils.isBlank(credentialId) ? GmailMailer.CREDENTIAL_USER_ID : credentialId);

    flow.createAndStoreCredential(tokenResponse, credentialId);

    return new StringView("Gmail setup complete");
}

From source file:ke.co.tawi.babblesms.server.servlet.upload.UploadUtil.java

/**
 * Checks that an uploaded Contact file is in proper order.
 * /*from   w w w .j  a  v a2s .c om*/
 * @param file
 * @return the feedback of having inspected the file, whether it was proper
 */
protected String inspectContactFile(File file) {
    String feedback = ContactUpload.UPLOAD_SUCCESS;
    int count = 1;

    LineIterator lineIterator = null;
    try {
        lineIterator = FileUtils.lineIterator(file, "UTF-8");

        String line;
        String[] rowTokens, phoneTokens, networkTokens;
        String network;
        while (lineIterator.hasNext()) {
            line = lineIterator.nextLine();

            rowTokens = StringUtils.split(line, ',');

            if (rowTokens.length != 3 && line.length() > 0) {// Every row must have 3 columns
                return ("Invalid format on line " + count + ": " + line);
            }

            phoneTokens = StringUtils.split(rowTokens[1], ';');
            networkTokens = StringUtils.split(rowTokens[2], ';');

            // Check that the number of phone numbers and number of networks match
            if (phoneTokens.length != networkTokens.length) {
                return ("Invalid format on line " + count + ": " + line);
            }

            // Check that the phone numbers contain only numbers or spaces
            for (String phone : phoneTokens) {
                if (!StringUtils.isNumericSpace(phone)) {
                    return ("Invalid number on line " + count + ": " + line);
                }
            }

            // Check to see that only valid networks have been provided
            for (String s : networkTokens) {
                network = StringUtils.lowerCase(StringUtils.trimToEmpty(s));
                if (!networkList.contains(network)) {
                    return ("Invalid network on line " + count + ": " + line);
                }
            }

            count++;
        }

    } catch (IOException e) {
        logger.error("IOException when inspecting: " + file);
        logger.error(e);

    } finally {
        if (lineIterator != null) {
            lineIterator.close();
        }
    }

    return feedback;
}

From source file:com.jredrain.tag.Page.java

/**
 * ???.//  www. ja  v  a 2 s  .  com
 *
 * @param order
 *            ?descasc,?','.
 */
public void setOrder(final String order) {
    // order?
    String[] orders = StringUtils.split(StringUtils.lowerCase(order), ',');
    for (String orderStr : orders) {
        if (!StringUtils.equals(DESC, orderStr) && !StringUtils.equals(ASC, orderStr))
            throw new IllegalArgumentException("??" + orderStr + "??");
    }

    this.order = StringUtils.lowerCase(order);
}

From source file:fr.scc.elo.service.impl.EloServiceImpl.java

@Override
public List<Player> removeTest() {
    playerService.getAllPlayers().stream()
            .filter(p -> !StringUtils.contains(p.getName(), ".")
                    || !StringUtils.equals(p.getName(), StringUtils.lowerCase(p.getName())))
            .forEach(player -> playerService.deletePlayer(player));
    return playerService.getAllPlayers();
}