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

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

Introduction

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

Prototype

public static String lowerCase(String str, Locale locale) 

Source Link

Document

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

Usage

From source file:com.tesora.dve.db.NativeType.java

/**
 * Make sure the type name is always the same.  Sets the name to lower case with spaces instead of '_'
 * // w w  w  .  j  a  va2  s  . c o  m
 * Does the 'opposite' of fixNameForEnum.
 * 
 * @param name
 * @return
 */
public static String fixName(String name, boolean stripEnum) {
    final String[] matches = new String[] { "enum", "set" };
    final String[] replacements = new String[] { "enum", "set" };
    for (int i = 0; i < matches.length; i++) {
        if (StringUtils.startsWith(StringUtils.lowerCase(name, Locale.ENGLISH), matches[i])) {
            if (stripEnum) {
                return replacements[i];
            }
            return matches[i] + name.substring(matches[i].length());
        }

    }

    return name == null ? null : StringUtils.lowerCase(name.replaceAll("_", " "), Locale.ENGLISH);
}

From source file:com.tesora.dve.db.NativeType.java

/**
 * This method is to make sure that when mapping a string to a type (through, say, enum.valueOf), the format is always
 * the same. Inherited classes should use this to set up their own enum's of valid types.
 * /* w w  w.jav  a  2  s.c o m*/
 * Does the 'opposite' of fixName.
 * 
 * @param name
 * @return
 */
public static String fixNameForType(String name) {
    if (StringUtils.startsWith(StringUtils.lowerCase(name, Locale.ENGLISH), "enum")) {
        return "ENUM";
    }

    return name == null ? null : StringUtils.replace(name.toUpperCase(Locale.ENGLISH), " ", "_");
}

From source file:com.adobe.acs.commons.errorpagehandler.impl.ErrorPageHandlerImpl.java

@SuppressWarnings("squid:S1149")
private void configure(ComponentContext componentContext) {
    Dictionary<?, ?> config = componentContext.getProperties();
    final String legacyPrefix = "prop.";

    this.enabled = PropertiesUtil.toBoolean(config.get(PROP_ENABLED),
            PropertiesUtil.toBoolean(config.get(legacyPrefix + PROP_ENABLED), DEFAULT_ENABLED));

    this.vanityDispatchCheckEnabled = PropertiesUtil.toBoolean(config.get(PROP_VANITY_DISPATCH_ENABLED),
            PropertiesUtil.toBoolean(config.get(legacyPrefix + PROP_VANITY_DISPATCH_ENABLED),
                    DEFAULT_VANITY_DISPATCH_ENABLED));

    /** Error Pages **/

    this.systemErrorPagePath = PropertiesUtil.toString(config.get(PROP_ERROR_PAGE_PATH), PropertiesUtil
            .toString(config.get(legacyPrefix + PROP_ERROR_PAGE_PATH), DEFAULT_SYSTEM_ERROR_PAGE_PATH_DEFAULT));

    this.errorPageExtension = PropertiesUtil.toString(config.get(PROP_ERROR_PAGE_EXTENSION), PropertiesUtil
            .toString(config.get(legacyPrefix + PROP_ERROR_PAGE_EXTENSION), DEFAULT_ERROR_PAGE_EXTENSION));

    this.fallbackErrorName = PropertiesUtil.toString(config.get(PROP_FALLBACK_ERROR_NAME), PropertiesUtil
            .toString(config.get(legacyPrefix + PROP_FALLBACK_ERROR_NAME), DEFAULT_FALLBACK_ERROR_NAME));

    this.pathMap = configurePathMap(PropertiesUtil.toStringArray(config.get(PROP_SEARCH_PATHS),
            PropertiesUtil.toStringArray(config.get(legacyPrefix + PROP_SEARCH_PATHS), DEFAULT_SEARCH_PATHS)));

    /** Not Found Handling **/
    this.notFoundBehavior = PropertiesUtil.toString(config.get(PROP_NOT_FOUND_DEFAULT_BEHAVIOR),
            DEFAULT_NOT_FOUND_DEFAULT_BEHAVIOR);

    String[] tmpNotFoundExclusionPatterns = PropertiesUtil.toStringArray(
            config.get(PROP_NOT_FOUND_EXCLUSION_PATH_PATTERNS), DEFAULT_NOT_FOUND_EXCLUSION_PATH_PATTERNS);

    this.notFoundExclusionPatterns = new ArrayList<Pattern>();
    for (final String tmpPattern : tmpNotFoundExclusionPatterns) {
        this.notFoundExclusionPatterns.add(Pattern.compile(tmpPattern));
    }//ww  w .j a va  2 s .  c o m

    /** Error Page Cache **/

    int ttl = PropertiesUtil.toInteger(config.get(PROP_TTL),
            PropertiesUtil.toInteger(LEGACY_PROP_TTL, DEFAULT_TTL));

    boolean serveAuthenticatedFromCache = PropertiesUtil
            .toBoolean(config.get(PROP_SERVE_AUTHENTICATED_FROM_CACHE), PropertiesUtil.toBoolean(
                    LEGACY_PROP_SERVE_AUTHENTICATED_FROM_CACHE, DEFAULT_SERVE_AUTHENTICATED_FROM_CACHE));
    try {
        cache = new ErrorPageCacheImpl(ttl, serveAuthenticatedFromCache);

        Dictionary<String, Object> serviceProps = new Hashtable<String, Object>();
        serviceProps.put("jmx.objectname", "com.adobe.acs.commons:type=ErrorPageHandlerCache");

        cacheRegistration = componentContext.getBundleContext().registerService(DynamicMBean.class.getName(),
                cache, serviceProps);
    } catch (NotCompliantMBeanException e) {
        log.error("Unable to create cache", e);
    }

    /** Error Images **/

    this.errorImagesEnabled = PropertiesUtil.toBoolean(config.get(PROP_ERROR_IMAGES_ENABLED),
            DEFAULT_ERROR_IMAGES_ENABLED);

    this.errorImagePath = PropertiesUtil.toString(config.get(PROP_ERROR_IMAGE_PATH), DEFAULT_ERROR_IMAGE_PATH);

    // Absolute path
    if (StringUtils.startsWith(this.errorImagePath, "/")) {
        ResourceResolver serviceResourceResolver = null;
        try {
            Map<String, Object> authInfo = Collections.singletonMap(ResourceResolverFactory.SUBSERVICE,
                    (Object) SERVICE_NAME);
            serviceResourceResolver = resourceResolverFactory.getServiceResourceResolver(authInfo);
            final Resource resource = serviceResourceResolver.resolve(this.errorImagePath);

            if (resource != null && resource.isResourceType(JcrConstants.NT_FILE)) {
                final PathInfo pathInfo = new PathInfo(this.errorImagePath);

                if (!StringUtils.equals("img", pathInfo.getSelectorString())
                        || StringUtils.isBlank(pathInfo.getExtension())) {

                    log.warn("Absolute Error Image Path paths to nt:files should have '.img.XXX' "
                            + "selector.extension");
                }
            }
        } catch (LoginException e) {
            log.error("Could not get admin resource resolver to inspect validity of absolute errorImagePath");
        } finally {
            if (serviceResourceResolver != null) {
                serviceResourceResolver.close();
            }
        }
    }

    this.errorImageExtensions = PropertiesUtil.toStringArray(config.get(PROP_ERROR_IMAGE_EXTENSIONS),
            DEFAULT_ERROR_IMAGE_EXTENSIONS);

    for (int i = 0; i < errorImageExtensions.length; i++) {
        this.errorImageExtensions[i] = StringUtils.lowerCase(errorImageExtensions[i], Locale.ENGLISH);
    }

    final StringWriter sw = new StringWriter();
    final PrintWriter pw = new PrintWriter(sw);

    pw.println();
    pw.printf("Enabled: %s", this.enabled).println();
    pw.printf("System Error Page Path: %s", this.systemErrorPagePath).println();
    pw.printf("Error Page Extension: %s", this.errorPageExtension).println();
    pw.printf("Fallback Error Page Name: %s", this.fallbackErrorName).println();

    pw.printf("Resource Not Found - Behavior: %s", this.notFoundBehavior).println();
    pw.printf("Resource Not Found - Exclusion Path Patterns %s", Arrays.toString(tmpNotFoundExclusionPatterns))
            .println();

    pw.printf("Cache - TTL: %s", ttl).println();
    pw.printf("Cache - Serve Authenticated: %s", serveAuthenticatedFromCache).println();

    pw.printf("Error Images - Enabled: %s", this.errorImagesEnabled).println();
    pw.printf("Error Images - Path: %s", this.errorImagePath).println();
    pw.printf("Error Images - Extensions: %s", Arrays.toString(this.errorImageExtensions)).println();

    log.debug(sw.toString());
}

From source file:at.bitfire.davdroid.mirakel.resource.LocalAddressBook.java

protected static String xNameToLabel(String xname) {
    // "X-MY_PROPERTY"
    // 1. ensure lower case -> "x-my_property"
    // 2. remove x- from beginning -> "my_property"
    // 3. replace "_" by " " -> "my property"
    // 4. capitalize -> "My Property"
    String lowerCase = StringUtils.lowerCase(xname, Locale.US),
            withoutPrefix = StringUtils.removeStart(lowerCase, "x-"),
            withSpaces = StringUtils.replace(withoutPrefix, "_", " ");
    return WordUtils.capitalize(withSpaces);
}

From source file:org.gravidence.gravifon.db.ArtistsDBClient.java

/**
 * Retrieves existing artist {@link ArtistDocument documents}.<p>
 * Makes sure that <code>name</code> written in lower case
 * since <code>main/all_artist_variations</code> view is case sensitive.
 * /*from   ww w .ja  va2s  .  co m*/
 * @param name artist name
 * @return list of artist details documents if found, <code>null</code> otherwise
 */
public List<ArtistDocument> retrieveArtistsByName(String name) {
    ViewQueryArguments args = new ViewQueryArguments().addKey(StringUtils.lowerCase(name, Locale.ENGLISH))
            .addIncludeDocs(true);

    List<ArtistDocument> documents = ViewQueryExecutor.queryDocuments(viewMainAllArtistVariationsTarget, args,
            ArtistDocument.class);

    return documents;
}

From source file:org.gravidence.gravifon.db.LabelsDBClient.java

/**
 * Retrieves existing label {@link LabelDocument documents}.<p>
 * Makes sure that <code>name</code> written in lower case
 * since <code>main/all_label_variations</code> view is case sensitive.
 * //from  w w w  . j a  v a 2  s  .c  om
 * @param name label name
 * @return list of label details documents if found, <code>null</code> otherwise
 */
public List<LabelDocument> retrieveLabelsByName(String name) {
    ViewQueryArguments args = new ViewQueryArguments().addKey(StringUtils.lowerCase(name, Locale.ENGLISH))
            .addIncludeDocs(true);

    List<LabelDocument> documents = ViewQueryExecutor.queryDocuments(viewMainAllLabelVariationsTarget, args,
            LabelDocument.class);

    return documents;
}

From source file:org.gravidence.gravifon.util.BasicUtils.java

/**
 * Converts a string to lower case using {@link Locale.ENGLISH ENGLISH} locale.
 * //from ww w  . j a  v a  2 s  . c o m
 * @param value string value
 * @return string value in lower case
 */
public static String lowerCase(String value) {
    return StringUtils.lowerCase(value, Locale.ENGLISH);
}

From source file:org.sakaiproject.signup.logic.SakaiFacadeImpl.java

/**
 * {@inheritDoc}//from   w  w  w.jav a  2s  .c o m
 */
public String getUserDisplayLastFirstName(String userId) {
    try {
        String dispLastName = userDirectoryService.getUser(userId).getLastName();
        if (dispLastName != null) {
            dispLastName = StringUtils.lowerCase(dispLastName, rb.getLocale());
            dispLastName = StringUtils.capitalize(dispLastName);
        }
        String dispFirstName = userDirectoryService.getUser(userId).getFirstName();
        if (dispFirstName != null) {
            dispFirstName = StringUtils.lowerCase(dispFirstName, rb.getLocale());
            dispFirstName = StringUtils.capitalize(dispFirstName);
        }
        String displayname = null;
        if ((dispLastName == null || dispLastName.isEmpty())
                && (dispFirstName == null || dispFirstName.isEmpty())) {
            //Case: local user can have no first and last names
            displayname = userDirectoryService.getUser(userId).getDisplayId();
        } else {
            displayname = dispLastName + ", " + dispFirstName;
        }

        return displayname;
    } catch (UserNotDefinedException e) {
        log.warn("Cannot get user displayname for id: " + userId);
        return "--------";
    }
}

From source file:org.sonar.api.config.Category.java

public String key() {
    return StringUtils.lowerCase(originalKey, Locale.ENGLISH);
}

From source file:org.sonar.server.platform.ServerIdChecksum.java

@VisibleForTesting
static String sanitizeJdbcUrl(String jdbcUrl) {
    String result;//w  ww  .j a  v  a  2s  .c  o m
    if (jdbcUrl.startsWith(SQLSERVER_PREFIX)) {
        result = sanitizeSqlServerUrl(jdbcUrl);
    } else {
        // remove query parameters, they don't aim to reference the schema
        result = StringUtils.substringBefore(jdbcUrl, "?");
    }
    return StringUtils.lowerCase(result, Locale.ENGLISH);
}