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

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

Introduction

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

Prototype

public static String upperCase(String str) 

Source Link

Document

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

Usage

From source file:org.apache.click.servlet.MockRequest.java

/**
 * Get the method.//from   w w w.  j  a v a  2  s. c  o  m
 * <p/>
 * The returned string will be in upper case eg. <tt>POST</tt>.
 *
 * @return The method
 */
public String getMethod() {
    return StringUtils.upperCase(method);
}

From source file:org.apache.myfaces.custom.convertStringUtils.StringUtilsConverter.java

private String format(String val, boolean duringOutput) throws ConverterException {

    String str;// w  w w . j a va2 s  .  com
    if (BooleanUtils.isTrue(trim)) {
        str = val.trim();
    } else {
        str = val;
    }
    // Any decorations first
    if (StringUtils.isNotEmpty(format)) {
        if ("uppercase".equalsIgnoreCase(format)) {
            str = StringUtils.upperCase(str);
        } else if ("lowercase".equalsIgnoreCase(format)) {
            str = StringUtils.lowerCase(str);
        } else if ("capitalize".equalsIgnoreCase(format)) {
            str = WordUtils.capitalizeFully(str);
        } else {
            throw new ConverterException("Invalid format '" + format + "'");
        }
    }

    boolean appendEllipses = ((duringOutput)
            && ((null != appendEllipsesDuringOutput) && (appendEllipsesDuringOutput.booleanValue())))
            || ((false == duringOutput)
                    && ((null != appendEllipsesDuringInput) && (appendEllipsesDuringInput.booleanValue())));

    if (appendEllipses) {
        // See if we need to abbreviate/truncate this string
        if (null != maxLength && maxLength.intValue() > 4) {
            str = StringUtils.abbreviate(str, maxLength.intValue());
        }
    } else {
        // See if we need to truncate this string
        if (null != maxLength) {
            str = str.substring(0, maxLength.intValue());
        }
    }
    return str;
}

From source file:org.apache.samza.job.yarn.LocalizerResourceConfig.java

public LocalResourceType getResourceLocalType(final String resourceName) {
    String typeStr = config.get(String.format(RESOURCE_LOCAL_TYPE, resourceName), DEFAULT_RESOURCE_LOCAL_TYPE);
    return LocalResourceType.valueOf(StringUtils.upperCase(typeStr));
}

From source file:org.apache.samza.job.yarn.LocalizerResourceConfig.java

public LocalResourceVisibility getResourceLocalVisibility(final String resourceName) {
    String visibilityStr = config.get(String.format(RESOURCE_LOCAL_VISIBILITY, resourceName),
            DEFAULT_RESOURCE_LOCAL_VISIBILITY);
    return LocalResourceVisibility.valueOf(StringUtils.upperCase(visibilityStr));
}

From source file:org.apache.sling.scripting.jsp.taglib.helpers.XSSSupport.java

/**
 * Retrieves the encoding mode associated with the specified string. Will
 * throw an IllegalArgumentException if the mode string is not a valid mode
 * and will throw a NullPointerException if the mode string is null.
 * /*from w  w  w. ja v a2 s. c  om*/
 * @param modeStr
 *            the mode string
 * @return the encoding mode
 */
public static ENCODING_MODE getEncodingMode(String modeStr) {
    return ENCODING_MODE.valueOf(StringUtils.upperCase(modeStr));
}

From source file:org.apereo.lap.model.Output.java

/**
 * @return SQL to run for this output to retrieve the columns
 *///from w w  w  .ja v  a  2  s  .  c o m
public String makeTempDBSelectSQL() {
    List<String> columns = makeSourceColumns();
    for (int i = 0; i < columns.size(); i++) {
        String column = columns.get(i);
        columns.set(i, column + " AS " + StringUtils.upperCase(column));
    }
    String columnsSQL = StringUtils.join(columns, ",");
    return "SELECT " + columnsSQL + " FROM " + this.from;
}

From source file:org.apereo.lap.model.Output.java

/**
 * @return the ordered map of source -> target (e.g. source column name to target header name),
 *      the source name is uppercase to match with the select template
 *//*from  www .j av a 2s . com*/
public Map<String, String> makeSourceTargetMap() {
    LinkedHashMap<String, String> sourceTarget = new LinkedHashMap<>();
    for (OutputField field : fields) {
        sourceTarget.put(StringUtils.upperCase(field.source), field.getTarget());
    }
    return sourceTarget;
}

From source file:org.codehaus.foo.ExternalDeps.java

public void hello(String str) {
    System.out.println(StringUtils.upperCase(str));
}

From source file:org.dspace.storage.rdbms.DatabaseUtils.java

/**
 * Return the canonical name for a database identifier based on whether this
 * database defaults to storing identifiers in uppercase or lowercase.
 *
 * @param connection //from  w w  w.j a  va 2 s  .c o m
 *     Current Database Connection
 * @param dbIdentifier 
 *     Identifier to canonicalize (may be a table name, column name, etc)
 * @return The canonical name of the identifier.
 * @throws SQLException
 *     An exception that provides information on a database access error or other errors.
 */
public static String canonicalize(Connection connection, String dbIdentifier) throws SQLException {
    // Avoid any null pointers
    if (dbIdentifier == null)
        return null;

    DatabaseMetaData meta = connection.getMetaData();

    // Check how this database stores its identifiers, etc.
    // i.e. lowercase vs uppercase (by default we assume mixed case)
    if (meta.storesLowerCaseIdentifiers()) {
        return StringUtils.lowerCase(dbIdentifier);

    } else if (meta.storesUpperCaseIdentifiers()) {
        return StringUtils.upperCase(dbIdentifier);
    } else // Otherwise DB doesn't care about case
    {
        return dbIdentifier;
    }
}

From source file:org.dspace.storage.rdbms.migration.MigrationUtils.java

/**
 * Drop a given Database Constraint (based on the current database type).
 * Returns a "checksum" for this migration which can be used as part of
 * a Flyway Java migration//  ww  w  .  j  a v  a2  s.c o m
 *
 * @param connection the current Database connection
 * @param tableName the name of the table the constraint applies to
 * @param columnName the name of the column the constraint applies to
 * @param constraintSuffix Only used for PostgreSQL, whose constraint naming convention depends on a suffix (key, fkey, etc)
 * @return migration checksum as an Integer
 * @throws SQLException if a database error occurs
 */
protected static Integer dropDBConstraint(Connection connection, String tableName, String columnName,
        String constraintSuffix) throws SQLException {
    Integer checksum = -1;

    // First, in order to drop the appropriate Database constraint, we
    // must determine the unique name of the constraint. As constraint
    // naming is DB specific, this is dependent on our DB Type
    String dbtype = connection.getMetaData().getDatabaseProductName();
    String constraintName = null;
    String constraintNameSQL = null;
    boolean cascade = false;
    switch (dbtype.toLowerCase()) {
    case "postgres":
    case "postgresql":
        // In Postgres, constraints are always named:
        // {tablename}_{columnname(s)}_{suffix}
        // see: http://stackoverflow.com/a/4108266/3750035
        constraintName = StringUtils.lowerCase(tableName);
        if (!StringUtils.equals(constraintSuffix, "pkey")) {
            constraintName += "_" + StringUtils.lowerCase(columnName);
        }

        constraintName += "_" + StringUtils.lowerCase(constraintSuffix);
        cascade = true;
        break;
    case "oracle":
        // In Oracle, constraints are listed in the USER_CONS_COLUMNS table
        constraintNameSQL = "SELECT CONSTRAINT_NAME " + "FROM USER_CONS_COLUMNS "
                + "WHERE TABLE_NAME = ? AND COLUMN_NAME = ?";
        cascade = true;
        break;
    case "h2":
        // In H2, constraints are listed in the "information_schema.constraints" table
        constraintNameSQL = "SELECT DISTINCT CONSTRAINT_NAME " + "FROM information_schema.constraints "
                + "WHERE table_name = ? AND column_list = ?";
        break;
    default:
        throw new SQLException("DBMS " + dbtype + " is unsupported in this migration.");
    }

    // If we have a SQL query to run for the constraint name, then run it
    if (constraintNameSQL != null) {
        // Run the query to obtain the constraint name, passing it the parameters
        PreparedStatement statement = connection.prepareStatement(constraintNameSQL);
        statement.setString(1, StringUtils.upperCase(tableName));
        statement.setString(2, StringUtils.upperCase(columnName));
        try {
            ResultSet results = statement.executeQuery();
            if (results.next()) {
                constraintName = results.getString("CONSTRAINT_NAME");
            }
            results.close();
        } finally {
            statement.close();
        }
    }

    // As long as we have a constraint name, drop it
    if (constraintName != null && !constraintName.isEmpty()) {
        // This drop constaint SQL should be the same in all databases
        String dropConstraintSQL = "ALTER TABLE " + tableName + " DROP CONSTRAINT " + constraintName;
        if (cascade) {
            dropConstraintSQL += " CASCADE";
        }

        try (PreparedStatement statement = connection.prepareStatement(dropConstraintSQL)) {
            statement.execute();
        }
        // Return the size of the query we just ran
        // This will be our "checksum" for this Flyway migration (see getChecksum())
        checksum = dropConstraintSQL.length();
    }

    return checksum;
}