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.hubrick.vertx.s3.signature.AWS4SignatureBuilder.java

public AWS4SignatureBuilder header(final String headerName, final String headerValue) {
    Preconditions.checkArgument(StringUtils.isNotBlank(headerName), "headerName must not be blank");

    this.canonicalHeaders.put(StringUtils.lowerCase(headerName),
            StringUtils.trimToEmpty(headerValue).replaceAll(" +", " "));
    return this;
}

From source file:edu.emory.bmi.aiw.i2b2export.output.DataRowOutputFormatter.java

String getParam(Patient patient, I2b2ConceptEntity i2b2Concept) {
    switch (StringUtils.lowerCase(i2b2Concept.getColumnName())) {
    case "age_in_years_num":
        return patient.getAgeInYears();
    case "birth_date":
        return patient.getBirthDate();
    case "language_cd":
        return patient.getLanguage();
    case "marital_status_cd":
        return patient.getMaritalStatus();
    case "religion_cd":
        return patient.getReligion();
    case "race_cd":
        return patient.getRace();
    case "sex_cd":
        return patient.getSex();
    case "statecityzip_path_char":
        return patient.getStateCityZip();
    case "vital_status_cd":
        return patient.getVitalStatus();
    case "zipcode_char":
        return patient.getZipCode();
    default://w  w  w.j a v a  2 s .c o  m
        return "";
    }
}

From source file:net.eledge.android.europeana.search.SearchController.java

public List<FacetItem> getBreadcrumbs(Context context) {
    List<FacetItem> breadcrumbs = new ArrayList<>();
    FacetItem crumb;/* w  ww  . j  a va2s.  c o m*/
    for (String term : terms) {
        crumb = new FacetItem();
        crumb.itemType = FacetItemType.BREADCRUMB;
        crumb.facetType = FacetType.TEXT;
        crumb.description = term;
        crumb.facet = term;
        if (StringUtils.contains(term, ":")) {
            FacetType type = FacetType.safeValueOf(StringUtils.substringBefore(term, ":"));
            if (type != null) {
                crumb.facetType = type;
                crumb.description = StringUtils
                        .capitalize(StringUtils.lowerCase(GuiUtils.getString(context, type.resId))) + ":"
                        + type.createFacetLabel(context, StringUtils.substringAfter(term, ":"));
            }
        }
        breadcrumbs.add(crumb);
    }
    return breadcrumbs;
}

From source file:com.ottogroup.bi.spqr.metrics.MetricsHandler.java

/**
 * {@link JmxReporter#stop() Stops} the referenced {@link JmxReporter} but keeps it referenced
 * @param id//from   w  ww .  ja va 2  s  .  c o m
 */
public void stopJmxReporter(final String id) {
    String key = StringUtils.lowerCase(StringUtils.trim(id));
    JmxReporter jmxReporter = this.jmxReporters.get(key);
    if (jmxReporter != null) {
        jmxReporter.stop();
    }
}

From source file:com.ottogroup.bi.asap.component.operator.executor.OperatorExecutor.java

/**
 * Returns true if the referenced component is a subscriber to this source
 * @param subscriberId//  ww w  . j a  va2 s  . c o  m
 * @return
 * @throws RequiredInputMissingException
 */
public boolean isSubscriber(final String subscriberId) throws RequiredInputMissingException {

    ///////////////////////////////////////////////////////////////////////////
    // validate input
    if (StringUtils.isBlank(subscriberId))
        throw new RequiredInputMissingException("Missing required subscriber identifier");
    //
    ///////////////////////////////////////////////////////////////////////////

    return this.subscriberMailboxes.containsKey(StringUtils.trim(StringUtils.lowerCase(subscriberId)));
}

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

/**
 * Test case for {@link MicroPipelineManager#executePipeline(MicroPipelineConfiguration)} being provided a
 * valid configuration twice which leads to a {@link NonUniqueIdentifierException}
 *//*from  w ww.j  a va2  s. c  om*/
@Test
public void testExecutePipeline_withValidConfigurationTwice() throws Exception {
    MicroPipelineConfiguration cfg = new MicroPipelineConfiguration();
    cfg.setId("testExecutePipeline_withValidConfiguration");

    MicroPipeline pipeline = Mockito.mock(MicroPipeline.class);
    Mockito.when(pipeline.getId()).thenReturn(cfg.getId());

    MicroPipelineFactory factory = Mockito.mock(MicroPipelineFactory.class);
    Mockito.when(factory.instantiatePipeline(cfg, executorService)).thenReturn(pipeline);

    MicroPipelineManager manager = new MicroPipelineManager("id", factory, executorService);

    Assert.assertEquals("Values must be equal", StringUtils.lowerCase(StringUtils.trim(cfg.getId())),
            manager.executePipeline(cfg));
    Assert.assertEquals("Values must be equal", 1, manager.getNumOfRegisteredPipelines());

    Mockito.verify(factory).instantiatePipeline(cfg, executorService);

    try {
        manager.executePipeline(cfg);
        Assert.fail("A pipeline for that identifier already exists");
    } catch (NonUniqueIdentifierException e) {
        // expected
    }
}

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

@GET
@Path("/show/name/{n}/elo/{e}/type/{t}/save/{s}/delete/{d}")
public Response managePlayer(@BeanParam PlayerRequest request) throws EloException {
    return Response.ok()
            .entity(eloManager//from  w  w  w.  ja  va2 s. c om
                    .managePlayer(StringUtils.lowerCase(request.getName()), request.getElo(),
                            request.getTypeMatch(), request.getCreatePlayers(), request.getDeletePlayers())
                    .toString())
            .build();
}

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

/**
 * Shuts down the referenced pipeline/*from w w  w  .  j a v  a2  s. c  o m*/
 * @param pipelineId
 */
public String shutdownPipeline(final String pipelineId) {

    String id = StringUtils.lowerCase(StringUtils.trim(pipelineId));
    MicroPipeline pipeline = this.pipelines.get(id);
    if (pipeline != null) {
        pipeline.shutdown();
        this.pipelines.remove(id);

        if (logger.isDebugEnabled())
            logger.debug("pipeline shutdown[id=" + pipelineId + "]");
    }

    return pipelineId;
}

From source file:com.ottogroup.bi.spqr.metrics.MetricsHandler.java

/**
 * {@link JmxReporter#start() Starts} the referenced {@link JmxReporter}
 * @param id//from   w  w  w. j a v  a 2s  . c  o  m
 */
public void startJmxReporter(final String id) {
    String key = StringUtils.lowerCase(StringUtils.trim(id));
    JmxReporter jmxReporter = this.jmxReporters.get(key);
    if (jmxReporter != null) {
        jmxReporter.start();
    }
}

From source file:com.widowcrawler.exo.parse.Parser.java

public Sitemap parse(InputStream inputStream) throws XMLStreamException, SitemapParseException {

    final XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(inputStream, "utf-8");

    final Sitemap retval = new Sitemap(new HashSet<>());

    final Set<SitemapURL> sitemapURLs = new HashSet<>();
    SitemapURL.Builder urlBuilder = null;
    String urlContent;/*from  www .j  ava2s. c om*/

    reader.getEventType();

    while (reader.hasNext()) {
        switch (state) {
        case START:
            reader.nextTag();

            if (StringUtils.equalsIgnoreCase(reader.getLocalName(), URLSET_TAG_NAME)) {
                state = State.URLSET;
            } else if (StringUtils.equalsIgnoreCase(reader.getLocalName(), SITEMAPINDEX_TAG_NAME)) {
                state = State.SITEMAPINDEX;
            } else {
                String message = "Invalid root element. Must be either urlset or sitemapindex";
                logger.error(message);
                throw new SitemapParseException(message);
            }

            break;

        case END:
            // consume all end tags
            if (reader.getEventType() != XMLStreamConstants.END_ELEMENT) {
                String message = decorate("There should be only one root element in each sitemap.xml",
                        reader.getLocation());
                logger.error(message);
                throw new SitemapParseException(message);
            }

            reader.next();
            break;

        /////////////////////
        // URLSET Hierarchy
        /////////////////////
        case URLSET:
            // If we're done with the URLs, we're done overall
            if (reader.nextTag() == XMLStreamConstants.END_ELEMENT) {
                state = State.END;
                break;
            }

            // Check that we're entering into a <url> element
            if (!StringUtils.equalsIgnoreCase(reader.getLocalName(), URL_TAG_NAME)) {
                String message = "A <urlset> element can only contain <url> elements. Found: "
                        + reader.getLocalName();
                logger.error(message);
                throw new SitemapParseException(message);
            }

            urlBuilder = new SitemapURL.Builder();
            state = State.URL;
            break;

        case URL:
            reader.nextTag();

            if (reader.getEventType() == XMLStreamConstants.START_ELEMENT) {
                //logger.info("reader.getLocalName(): " + reader.getLocalName());
                switch (StringUtils.lowerCase(reader.getLocalName())) {
                case LOC_TAG_NAME:
                    state = State.URL_PROP_LOC;
                    break;
                case LASTMOD_TAG_NAME:
                    state = State.URL_PROP_LASTMOD;
                    break;
                case CHANGEFREQ_TAG_NAME:
                    state = State.URL_PROP_CHANGEFREQ;
                    break;
                case PRIORITY_TAG_NAME:
                    state = State.URL_PROP_PRIORITY;
                    break;
                case MOBILE_TAG_NAME:
                    state = State.URL_PROP_MOBILE;
                    break;
                default:
                    String message = "Unexpected tag in url: " + reader.getLocalName();
                    logger.error(message);
                    throw new SitemapParseException(message);
                }
            } else if (reader.getEventType() == XMLStreamConstants.END_ELEMENT) {
                // we're done collecting the data for this URL
                assert urlBuilder != null;
                sitemapURLs.add(urlBuilder.build());
                urlBuilder = new SitemapURL.Builder();
                state = State.URLSET;
            }
            break;

        case URL_PROP_LOC:
            urlContent = reader.getElementText();

            try {
                assert urlBuilder != null;
                urlBuilder.withLocation(new URL(StringUtils.trimToNull(urlContent)));

            } catch (MalformedURLException ex) {
                String message = String.format("Malformed URL found: %s", urlContent);
                logger.error(message);
                throw new SitemapParseException(message);
            }
            state = State.URL;
            break;

        case URL_PROP_LASTMOD:
            assert urlBuilder != null;
            urlBuilder.withLastModified(DateTime.parse(reader.getElementText()));
            state = State.URL;
            break;

        case URL_PROP_CHANGEFREQ:
            assert urlBuilder != null;
            urlBuilder.withChangeFrequency(ChangeFreq.valueOf(StringUtils.upperCase(reader.getElementText())));
            state = State.URL;
            break;

        case URL_PROP_PRIORITY:
            assert urlBuilder != null;
            urlBuilder.withPriority(Double.valueOf(reader.getElementText()));
            state = State.URL;
            break;

        case URL_PROP_MOBILE:
            assert urlBuilder != null;
            urlBuilder.withIsMobileContent(true);
            // consume until "end tag" of self-closing tag
            // Also works if someone puts content in
            reader.getElementText();
            state = State.URL;
            break;

        ///////////////////////////
        // SITEMAPINDEX Hierarchy
        ///////////////////////////
        case SITEMAPINDEX:
            // If we're done with all the Sitemaps, we're done overall
            if (reader.nextTag() == XMLStreamConstants.END_ELEMENT) {
                state = State.END;
                break;
            }

            state = State.SITEMAP;
            break;

        case SITEMAP:
            if (!StringUtils.equalsIgnoreCase(reader.getLocalName(), SITEMAP_TAG_NAME)) {
                throw new SitemapParseException("A <sitemapindex> element can only contain <sitemap> elements");
            }

            reader.nextTag();

            if (reader.getEventType() == XMLStreamConstants.START_ELEMENT) {
                switch (StringUtils.lowerCase(reader.getLocalName())) {
                case LOC_TAG_NAME:
                    state = State.URL_PROP_LOC;
                    break;
                case LASTMOD_TAG_NAME:
                    state = State.URL_PROP_LASTMOD;
                    break;
                default:
                    throw new SitemapParseException("Unexpected tag in sitemap: " + reader.getLocalName());
                }
            } else if (reader.getEventType() == XMLStreamConstants.END_ELEMENT) {
                // we're done collecting the data for this URL
                assert urlBuilder != null;
                sitemapURLs.add(urlBuilder.build());
                urlBuilder = new SitemapURL.Builder();
                state = State.URLSET;
            }

        case SITEMAP_PROP_LOC:
            urlContent = reader.getElementText();

            try {
                URL sitemapURL = new URL(StringUtils.trimToNull(urlContent));

                Sitemap temp = Retry.retry(() -> {
                    try {
                        return Exo.parse(sitemapURL.toString());
                    } catch (Exception ex) {
                        throw new RuntimeException(ex);
                    }
                });

                retval.merge(temp);

            } catch (MalformedURLException ex) {
                String message = String.format("Malformed URL found: %s", urlContent);
                logger.error(message);
                throw new SitemapParseException(message);

            } catch (InterruptedException e) {
                logger.warn("Thread interrupted while (re)trying");
                Thread.currentThread().interrupt();

            } catch (RetryFailedException e) {
                String message = String.format("Failed to retrieve sitemap of sitemap index at %s", urlContent);
                logger.error(message);
                throw new SitemapParseException(message);
            }

            state = State.URL;
            break;

        case SITEMAP_PROP_LASTMOD:
            // Do nothing with this data for now
            reader.getElementText();
            break;
        }

        //System.out.println(state);
    }

    return retval.merge(new Sitemap(sitemapURLs));
}