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

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

Introduction

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

Prototype

public static String upperCase(final String str) 

Source Link

Document

Converts a String to upper case as per String#toUpperCase() .

A null input String returns null .

 StringUtils.upperCase(null)  = null StringUtils.upperCase("")    = "" StringUtils.upperCase("aBc") = "ABC" 

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

Usage

From source file:com.adobe.acs.commons.adobeio.service.impl.EndpointServiceImpl.java

private JsonObject performio(@NotNull String actionUrl, @NotNull Map<String, String> queryParameters) {
    try {/* ww w.ja  va  2  s .  c  om*/
        return process(actionUrl, queryParameters, StringUtils.upperCase(method), null, null);
    } catch (Exception e) {
        LOGGER.error("Problem processing action {} in performIO", actionUrl, e);
    }
    return new JsonObject();
}

From source file:com.xpn.xwiki.store.XWikiHibernateBaseStore.java

/**
 * Convert wiki name in database/schema name.
 * /*from   w  w  w.  j a v  a  2  s  .  com*/
 * @param wikiName the wiki name to convert.
 * @param databaseProduct the database engine type.
 * @param context the XWiki context.
 * @return the database/schema name.
 * @since XWiki Core 1.1.2, XWiki Core 1.2M2
 */
protected String getSchemaFromWikiName(String wikiName, DatabaseProduct databaseProduct, XWikiContext context) {
    if (wikiName == null) {
        return null;
    }

    XWiki wiki = context.getWiki();

    String schema;
    if (context.isMainWiki(wikiName)) {
        schema = wiki.Param("xwiki.db");
        if (schema == null) {
            if (databaseProduct == DatabaseProduct.DERBY) {
                schema = "APP";
            } else if (databaseProduct == DatabaseProduct.HSQLDB) {
                schema = "PUBLIC";
            } else {
                schema = wikiName.replace('-', '_');
            }
        }
    } else {
        // virtual
        schema = wikiName.replace('-', '_');

        // For HSQLDB we only support uppercase schema names. This is because Hibernate doesn't properly generate
        // quotes around schema names when it qualifies the table name when it generates the update script.
        if (databaseProduct == DatabaseProduct.HSQLDB) {
            schema = StringUtils.upperCase(schema);
        }
    }

    // Apply prefix
    String prefix = wiki.Param("xwiki.db.prefix", "");
    schema = prefix + schema;

    return schema;
}

From source file:ca.on.oicr.pde.workflows.GATK3WorkflowTest.java

private void validateWorkflow(AbstractWorkflowDataModel w) {

    //check for null string
    for (AbstractJob j : w.getWorkflow().getJobs()) {

        String c = Joiner.on(" ").useForNull("null").join(j.getCommand().getArguments());

        //check for null string
        Assert.assertFalse(c.contains("null"), "Warning: command contains \"null\":\n" + c + "\n");

        // check for missing spaces
        Assert.assertFalse(c.matches("(.*)[^ ]--(.*)"));
    }/* w  ww .j  a v a  2s. c o  m*/

    //verify bai is located in the correct provision directory
    Map<String, String> bamFileDirectories = new HashMap<>();
    for (SqwFile f : w.getFiles().values()) {
        if (FilenameUtils.isExtension(f.getProvisionedPath(), "bam")) {
            bamFileDirectories.put(FilenameUtils.removeExtension(f.getSourcePath()),
                    FilenameUtils.getPath(f.getProvisionedPath()));
        }
    }
    for (SqwFile f : w.getFiles().values()) {
        //FIXME: bai.getProvisionedPath != bai.getOutputPath ...
        // at least with seqware 1.1.0, setting output path changes where the output file will be stored,
        // but the commonly used get provisioned path will return the incorrect path to the file
        if (FilenameUtils.isExtension(f.getProvisionedPath(), "bai")) {
            //check bai is in the same provision directory its corresponding bam is in
            Assert.assertEquals(FilenameUtils.getPath(f.getOutputPath()),
                    bamFileDirectories.get(FilenameUtils.removeExtension(f.getSourcePath())));
        }
    }

    //check number of parent nodes
    Set<VariantCaller> vc = new HashSet<>();
    for (String s : StringUtils.split(w.getConfigs().get("variant_caller"), ",")) {
        vc.add(VariantCaller.valueOf(StringUtils.upperCase(s)));
    }
    int parallelism = Math.max(1, StringUtils.split(w.getConfigs().get("chr_sizes"), ",").length);
    int expectedParentNodeCount = parallelism * (vc.contains(HAPLOTYPE_CALLER) ? 1 : 0)
            + parallelism * (vc.contains(UNIFIED_GENOTYPER) ? 2 : 0); //ug indels and ug snvs
    int actualParentNodeCount = 0;
    for (AbstractJob j : w.getWorkflow().getJobs()) {
        if (j.getParents().isEmpty()) {
            actualParentNodeCount++;
        }
    }
    Assert.assertEquals(actualParentNodeCount, expectedParentNodeCount);

    //view output files
    for (AbstractJob j : w.getWorkflow().getJobs()) {
        for (SqwFile f : j.getFiles()) {
            if (f.isOutput()) {
                System.out.println(f.getProvisionedPath());
            }
        }
    }
}

From source file:io.apiman.manager.api.es.EsMarshallingTest.java

/**
 * Fabricates a new instance of the given bean type.  Uses reflection to figure
 * out all the fields and assign generated values for each.
 *///from w  w  w.  j  a  va 2  s . c o m
private static <T> T createBean(Class<T> beanClass) throws InstantiationException, IllegalAccessException,
        InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException {
    T bean = beanClass.newInstance();
    Map<String, String> beanProps = BeanUtils.describe(bean);
    for (String key : beanProps.keySet()) {
        try {
            Field declaredField = beanClass.getDeclaredField(key);
            Class<?> fieldType = declaredField.getType();
            if (fieldType == String.class) {
                BeanUtils.setProperty(bean, key, StringUtils.upperCase(key));
            } else if (fieldType == Boolean.class || fieldType == boolean.class) {
                BeanUtils.setProperty(bean, key, Boolean.TRUE);
            } else if (fieldType == Date.class) {
                BeanUtils.setProperty(bean, key, new Date(1));
            } else if (fieldType == Long.class || fieldType == long.class) {
                BeanUtils.setProperty(bean, key, 17L);
            } else if (fieldType == Integer.class || fieldType == long.class) {
                BeanUtils.setProperty(bean, key, 11);
            } else if (fieldType == Set.class) {
                // Initialize to a linked hash set so that order is maintained.
                BeanUtils.setProperty(bean, key, new LinkedHashSet());

                Type genericType = declaredField.getGenericType();
                String typeName = genericType.getTypeName();
                String typeClassName = typeName.substring(14, typeName.length() - 1);
                Class<?> typeClass = Class.forName(typeClassName);
                Set collection = (Set) BeanUtilsBean.getInstance().getPropertyUtils().getProperty(bean, key);
                populateSet(collection, typeClass);
            } else if (fieldType == Map.class) {
                Map<String, String> map = new LinkedHashMap<String, String>();
                map.put("KEY-1", "VALUE-1");
                map.put("KEY-2", "VALUE-2");
                BeanUtils.setProperty(bean, key, map);
            } else if (fieldType.isEnum()) {
                BeanUtils.setProperty(bean, key, fieldType.getEnumConstants()[0]);
            } else if (fieldType.getPackage() != null
                    && fieldType.getPackage().getName().startsWith("io.apiman.manager.api.beans")) {
                Object childBean = createBean(fieldType);
                BeanUtils.setProperty(bean, key, childBean);
            } else {
                throw new IllegalAccessException(
                        "Failed to handle property named [" + key + "] type: " + fieldType.getSimpleName());
            }
            //            String capKey = StringUtils.capitalize(key);
            //            System.out.println(key);;
        } catch (NoSuchFieldException e) {
            // Skip it - there is not really a bean property with this name!
        }
    }
    return bean;
}

From source file:jp.terasoluna.fw.file.dao.standard.AbstractFileLineWriter.java

/**
 * ??getter?????<br>/*from  w  w  w.  ja va2 s  .c  o m*/
 * ??getter????<br>
 * <ul>
 * <li>??????????get?????</li>
 * <li>is()?has()???getter???</li>
 * </ul>
 * getter??????????
 * @throws FileException getter????????
 */
private void buildMethods() {
    Method[] dataColumnGetMethods = new Method[fields.length];
    StringBuilder getterName = new StringBuilder();
    String fieldName = null;

    for (int i = 0; i < fields.length; i++) {
        // JavaBean??????????
        fieldName = fields[i].getName();

        // ????getter??????
        getterName.setLength(0);
        getterName.append("get");
        getterName.append(StringUtils.upperCase(fieldName.substring(0, 1)));
        getterName.append(fieldName.substring(1, fieldName.length()));

        // getter???
        try {
            dataColumnGetMethods[i] = clazz.getMethod(getterName.toString());
        } catch (NoSuchMethodException e) {
            throw new FileException("The getter method of column doesn't exist.", e, fileName);
        }
    }
    this.methods = dataColumnGetMethods;
}

From source file:gov.nih.nci.caintegrator.data.CaIntegrator2DaoImpl.java

private List<String> toUpperCase(Collection<String> symbols) {
    List<String> symbolsUpper = Lists.newArrayList();
    for (String symbol : symbols) {
        symbolsUpper.add(StringUtils.upperCase(symbol));
    }// w  ww.j av  a2s  . co  m
    return symbolsUpper;
}

From source file:io.bibleget.BibleGetDB.java

public String getMetaData(String dataOption) {
    dataOption = StringUtils.upperCase(dataOption);
    String metaDataStr = "";
    if (dataOption.startsWith("BIBLEBOOKS") || dataOption.equals("LANGUAGES") || dataOption.equals("VERSIONS")
            || dataOption.endsWith("IDX")) {
        System.out.println("getMetaData received a valid request for " + dataOption);
        if (instance.connect()) {
            if (instance.conn == null) {
                System.out.println("What is going on here? Why is connection null?");
            } else {
                System.out.println("getMetaData has connected to the database...");
            }//from  ww  w.j av a 2s . co m
            String sqlexec = "SELECT " + dataOption + " FROM METADATA WHERE ID=0";
            try (Statement stmt = instance.conn.createStatement()) {
                try (ResultSet rsOps = stmt.executeQuery(sqlexec)) {
                    //System.out.println("query seems to have been successful...");
                    //ResultSetMetaData rsMD = rsOps.getMetaData();
                    //int cols = rsMD.getColumnCount();
                    //String colnm = rsMD.getColumnName(cols);
                    //System.out.println("there are "+Integer.toString(cols)+" columns in this resultset and name is: "+colnm+"(requested "+dataOption+")");
                    while (rsOps.next()) {
                        metaDataStr = rsOps.getString(dataOption);
                    }
                    rsOps.close();
                }
                stmt.close();
            } catch (SQLException ex) {
                Logger.getLogger(BibleGetDB.class.getName()).log(Level.SEVERE, null, ex);
            }
            instance.disconnect();
        }
    }
    return metaDataStr;
}

From source file:jp.terasoluna.fw.file.dao.standard.AbstractFileLineIterator.java

/**
 * ??setter?????<br>//  ww  w . ja v a2s  . co  m
 * ??setter????<br>
 * <ul>
 * <li>??????????set?????</li>
 * </ul>
 * setter??????????
 * @throws FileException setter????????
 */
private void buildMethods() {
    Method[] dataColumnSetMethods = new Method[fields.length];
    StringBuilder setterName = new StringBuilder();
    String fieldName = null;

    for (int i = 0; i < fields.length; i++) {
        // JavaBean??????????
        fieldName = fields[i].getName();

        // ????setter??????
        setterName.setLength(0);
        setterName.append("set");
        setterName.append(StringUtils.upperCase(fieldName.substring(0, 1)));
        setterName.append(fieldName.substring(1, fieldName.length()));

        // setter???
        // fields[i].getType()?????
        try {
            dataColumnSetMethods[i] = clazz.getMethod(setterName.toString(),
                    new Class[] { fields[i].getType() });
        } catch (NoSuchMethodException e) {
            throw new FileException("The setter method of column doesn't exist.", e, fileName);
        }
    }
    this.methods = dataColumnSetMethods;
}

From source file:cgeo.geocaching.connector.gc.GCParser.java

/**
 * Parse a trackable HTML description into a Trackable object
 *
 * @param page//w  ww.  j a  v a  2 s .  com
 *            the HTML page to parse, already processed through {@link TextUtils#replaceWhitespace}
 * @return the parsed trackable, or null if none could be parsed
 */
static Trackable parseTrackable(final String page, final String possibleTrackingcode) {
    if (StringUtils.isBlank(page)) {
        Log.e("GCParser.parseTrackable: No page given");
        return null;
    }

    if (page.contains(GCConstants.ERROR_TB_DOES_NOT_EXIST)
            || page.contains(GCConstants.ERROR_TB_ARITHMETIC_OVERFLOW)
            || page.contains(GCConstants.ERROR_TB_ELEMENT_EXCEPTION)) {
        return null;
    }

    final Trackable trackable = new Trackable();

    // trackable geocode
    trackable.setGeocode(TextUtils.getMatch(page, GCConstants.PATTERN_TRACKABLE_GEOCODE, true,
            StringUtils.upperCase(possibleTrackingcode)));
    if (trackable.getGeocode() == null) {
        Log.e("GCParser.parseTrackable: could not figure out trackable geocode");
        return null;
    }

    // trackable id
    trackable.setGuid(TextUtils.getMatch(page, GCConstants.PATTERN_TRACKABLE_GUID, true, trackable.getGuid()));

    // trackable icon
    trackable.setIconUrl(
            TextUtils.getMatch(page, GCConstants.PATTERN_TRACKABLE_ICON, true, trackable.getIconUrl()));

    // trackable name
    trackable.setName(
            Html.fromHtml(TextUtils.getMatch(page, GCConstants.PATTERN_TRACKABLE_NAME, true, "")).toString());

    // trackable type
    if (StringUtils.isNotBlank(trackable.getName())) {
        trackable.setType(
                TextUtils.getMatch(page, GCConstants.PATTERN_TRACKABLE_TYPE, true, trackable.getType()));
    }

    // trackable owner name
    try {
        final MatcherWrapper matcherOwner = new MatcherWrapper(GCConstants.PATTERN_TRACKABLE_OWNER, page);
        if (matcherOwner.find() && matcherOwner.groupCount() > 0) {
            trackable.setOwnerGuid(matcherOwner.group(1));
            trackable.setOwner(matcherOwner.group(2).trim());
        }
    } catch (final RuntimeException e) {
        // failed to parse trackable owner name
        Log.w("GCParser.parseTrackable: Failed to parse trackable owner name");
    }

    // trackable origin
    trackable.setOrigin(
            TextUtils.getMatch(page, GCConstants.PATTERN_TRACKABLE_ORIGIN, true, trackable.getOrigin()));

    // trackable spotted
    try {
        final MatcherWrapper matcherSpottedCache = new MatcherWrapper(
                GCConstants.PATTERN_TRACKABLE_SPOTTEDCACHE, page);
        if (matcherSpottedCache.find() && matcherSpottedCache.groupCount() > 0) {
            trackable.setSpottedGuid(matcherSpottedCache.group(1));
            trackable.setSpottedName(matcherSpottedCache.group(2).trim());
            trackable.setSpottedType(Trackable.SPOTTED_CACHE);
        }

        final MatcherWrapper matcherSpottedUser = new MatcherWrapper(GCConstants.PATTERN_TRACKABLE_SPOTTEDUSER,
                page);
        if (matcherSpottedUser.find() && matcherSpottedUser.groupCount() > 0) {
            trackable.setSpottedGuid(matcherSpottedUser.group(1));
            trackable.setSpottedName(matcherSpottedUser.group(2).trim());
            trackable.setSpottedType(Trackable.SPOTTED_USER);
        }

        if (TextUtils.matches(page, GCConstants.PATTERN_TRACKABLE_SPOTTEDUNKNOWN)) {
            trackable.setSpottedType(Trackable.SPOTTED_UNKNOWN);
        }

        if (TextUtils.matches(page, GCConstants.PATTERN_TRACKABLE_SPOTTEDOWNER)) {
            trackable.setSpottedType(Trackable.SPOTTED_OWNER);
        }
    } catch (final RuntimeException e) {
        // failed to parse trackable last known place
        Log.w("GCParser.parseTrackable: Failed to parse trackable last known place");
    }

    // released date - can be missing on the page
    final String releaseString = TextUtils.getMatch(page, GCConstants.PATTERN_TRACKABLE_RELEASES, false, null);
    if (releaseString != null) {
        try {
            trackable.setReleased(dateTbIn1.parse(releaseString));
        } catch (ParseException e) {
            if (trackable.getReleased() == null) {
                try {
                    trackable.setReleased(dateTbIn2.parse(releaseString));
                } catch (ParseException e1) {
                    Log.e("Could not parse trackable release " + releaseString);
                }
            }
        }
    }

    // trackable distance
    final String distance = TextUtils.getMatch(page, GCConstants.PATTERN_TRACKABLE_DISTANCE, false, null);
    if (null != distance) {
        try {
            trackable.setDistance(DistanceParser.parseDistance(distance, !Settings.isUseImperialUnits()));
        } catch (final NumberFormatException e) {
            Log.e("GCParser.parseTrackable: Failed to parse distance", e);
        }
    }

    // trackable goal
    trackable.setGoal(convertLinks(
            TextUtils.getMatch(page, GCConstants.PATTERN_TRACKABLE_GOAL, true, trackable.getGoal())));

    // trackable details & image
    try {
        final MatcherWrapper matcherDetailsImage = new MatcherWrapper(
                GCConstants.PATTERN_TRACKABLE_DETAILSIMAGE, page);
        if (matcherDetailsImage.find() && matcherDetailsImage.groupCount() > 0) {
            final String image = StringUtils.trim(matcherDetailsImage.group(3));
            final String details = StringUtils.trim(matcherDetailsImage.group(4));

            if (StringUtils.isNotEmpty(image)) {
                trackable.setImage(image);
            }
            if (StringUtils.isNotEmpty(details)
                    && !StringUtils.equals(details, "No additional details available.")) {
                trackable.setDetails(convertLinks(details));
            }
        }
    } catch (final RuntimeException e) {
        // failed to parse trackable details & image
        Log.w("GCParser.parseTrackable: Failed to parse trackable details & image");
    }
    if (StringUtils.isEmpty(trackable.getDetails()) && page.contains(GCConstants.ERROR_TB_NOT_ACTIVATED)) {
        trackable.setDetails(CgeoApplication.getInstance().getString(R.string.trackable_not_activated));
    }

    // trackable logs
    try {
        final MatcherWrapper matcherLogs = new MatcherWrapper(GCConstants.PATTERN_TRACKABLE_LOG, page);
        /*
         * 1. Type (image)
         * 2. Date
         * 3. Author
         * 4. Cache-GUID
         * 5. <ignored> (strike-through property for ancient caches)
         * 6. Cache-name
         * 7. Log text
         */
        while (matcherLogs.find()) {
            long date = 0;
            try {
                date = GCLogin.parseGcCustomDate(matcherLogs.group(2)).getTime();
            } catch (final ParseException e) {
            }

            final LogEntry logDone = new LogEntry(Html.fromHtml(matcherLogs.group(3)).toString().trim(), date,
                    LogType.getByIconName(matcherLogs.group(1)), matcherLogs.group(7).trim());

            if (matcherLogs.group(4) != null && matcherLogs.group(6) != null) {
                logDone.cacheGuid = matcherLogs.group(4);
                logDone.cacheName = matcherLogs.group(6);
            }

            // Apply the pattern for images in a trackable log entry against each full log (group(0))
            final String logEntry = matcherLogs.group(0);
            final MatcherWrapper matcherLogImages = new MatcherWrapper(GCConstants.PATTERN_TRACKABLE_LOG_IMAGES,
                    logEntry);
            /*
             * 1. Image URL
             * 2. Image title
             */
            while (matcherLogImages.find()) {
                final Image logImage = new Image(matcherLogImages.group(1), matcherLogImages.group(2));
                logDone.addLogImage(logImage);
            }

            trackable.getLogs().add(logDone);
        }
    } catch (final Exception e) {
        // failed to parse logs
        Log.w("GCParser.parseCache: Failed to parse cache logs", e);
    }

    // tracking code
    if (!StringUtils.equalsIgnoreCase(trackable.getGeocode(), possibleTrackingcode)) {
        trackable.setTrackingcode(possibleTrackingcode);
    }

    if (CgeoApplication.getInstance() != null) {
        DataStore.saveTrackable(trackable);
    }

    return trackable;
}

From source file:com.sonicle.webtop.core.CoreManager.java

public List<OServiceStoreEntry> listServiceStoreEntriesByQuery(String serviceId, String context, String query,
        int max) {
    ServiceStoreEntryDAO sseDao = ServiceStoreEntryDAO.getInstance();
    UserProfileId targetPid = getTargetProfileId();
    Connection con = null;/* w  w  w.  ja  va2 s  . c  o m*/

    try {
        con = WT.getCoreConnection();
        if (StringUtils.isBlank(query)) {
            return sseDao.selectKeyValueByLimit(con, targetPid.getDomainId(), targetPid.getUserId(), serviceId,
                    context, max);
        } else {
            String newQuery = StringUtils.upperCase(StringUtils.trim(query));
            return sseDao.selectKeyValueByLikeKeyLimit(con, targetPid.getDomainId(), targetPid.getUserId(),
                    serviceId, context, "%" + newQuery + "%", max);
        }

    } catch (SQLException | DAOException ex) {
        logger.error("Error querying servicestore entry [{}, {}, {}, {}]", targetPid, serviceId, context, query,
                ex);
        return new ArrayList<>();
    } finally {
        DbUtils.closeQuietly(con);
    }
}