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:de.cosmocode.palava.model.business.AbstractAddress.java

@Override
public void setCountryCode(String code) {
    this.countryCode = StringUtils.upperCase(TrimMode.NULL.apply(code));
    if (countryCode == null)
        return;//from  w  w  w. ja  va 2  s. com
    Preconditions.checkArgument(Patterns.ISO_3166_1_ALPHA_2.matcher(countryCode).matches(),
            "%s does not match %s", countryCode, Patterns.ISO_3166_1_ALPHA_2.pattern());
}

From source file:com.nttdata.sky.mobile.wsc.exception.mapper.UserAgentFilterExceptionMapper.java

private String createOSPropertyMessage(String userAgent) {
    UserAgentInfo uaInfo = new UserAgentBuilder().composeFrom(userAgent).build();
    StringBuilder propertyKey = new StringBuilder("mobile.message.user-agent.denied.version")
            .append(WSCConstants.DOT_CHAR).append(StringUtils.upperCase(uaInfo.getOsType().toString()));
    String message = Config.getInstance().getProperty(propertyKey.toString(),
            MobileUtils.getDefaultJsonMessageKo());
    logger.error("Created property key for Platform Version ACCESS DENIED => '{}'", message);
    return message;
}

From source file:jp.co.tis.gsp.tools.dba.mojo.LoadDataMojo.java

@Override
protected void executeMojoSpec() throws MojoExecutionException, MojoFailureException {
    List<File> files = CollectionsUtil
            .newArrayList(FileUtils.listFiles(dataDirectory, new String[] { "csv" }, true));
    DriverManagerUtil.registerDriver(driver);
    Connection conn = null;/*from w  w w  . j  a  v  a 2  s .c o  m*/
    try {
        conn = DriverManager.getConnection(url, user, password);
        conn.setAutoCommit(false);
    } catch (SQLException e) {
        getLog().error(
                "DB?????????driver??url?????????????");
        throw new MojoExecutionException("", e);
    }

    // ????
    EntityDependencyParser parser = new EntityDependencyParser();
    Dialect dialect = DialectFactory.getDialect(url);
    parser.parse(conn, url, dialect.normalizeSchemaName(schema));
    final List<String> tableList = parser.getTableList();
    Collections.sort(files, new Comparator<File>() {
        @Override
        public int compare(File f1, File f2) {
            return getIndex(FilenameUtils.getBaseName(f1.getName()))
                    - getIndex(FilenameUtils.getBaseName(f2.getName()));
        }

        private int getIndex(String tableName) {
            for (int i = 0; i < tableList.size(); i++) {
                if (StringUtil.equalsIgnoreCase(tableName, tableList.get(i))) {
                    return i;
                }
            }
            return 0;
        }

    });
    try {
        for (File file : files) {
            CsvReader reader = null;
            String fileName = file.getName();
            FileInputStream in = FileInputStreamUtil.create(file);
            try {
                getLog().info("????:" + fileName);
                if (specifiedEncodingFiles != null && specifiedEncodingFiles.containsKey(fileName)) {
                    String encoding = (String) specifiedEncodingFiles.get(fileName);
                    reader = new CsvReader(in, Charset.forName(encoding));
                    getLog().info(" -- encoding:" + encoding);
                } else {
                    reader = new CsvReader(in, SJIS);
                }
                String tableName = StringUtils.upperCase(FilenameUtils.getBaseName(fileName));
                reader.readHeaders();
                String[] headers = reader.getHeaders();
                CsvInsertHandler insertHandler = new CsvInsertHandler(conn, dialect,
                        dialect.normalizeSchemaName(schema), tableName, headers);
                insertHandler.prepare();

                while (reader.readRecord()) {
                    String[] values = reader.getValues();

                    for (int i = 0; i < values.length; i++) {
                        insertHandler.setObject(i + 1, values[i]);
                    }
                    insertHandler.execute();
                }

                insertHandler.close();
            } catch (IOException e) {
                getLog().warn("??????:" + file, e);
            } catch (SQLException e) {
                getLog().warn("SQL??????:" + file, e);
            } finally {
                if (reader != null)
                    reader.close();
            }
        }
    } finally {
        ConnectionUtil.close(conn);
    }
}

From source file:morphy.command.VariablesCommand.java

public void process(String arguments, UserSession userSession) {
    String[] args = arguments.split(" ");
    if (args.length != 1) {
        userSession.send(getContext().getUsage());
        return;/*from   ww w. jav  a  2  s .co  m*/
    }

    // i was wondering if we should have some additional functionality
    // by perhaps having a variable name as a second argument, and then
    // only return that variable's value. i will leave this out of
    // implementation for now, since FICS does not support this.

    String userName = args[0];

    if (userName.equals("")) {
        userName = userSession.getUser().getUserName();
    }

    if (userName.length() < 2) {
        userSession.send("You must provide at least 2 characters of the name.");
        return;
    }

    String[] matches = UserService.getInstance().completeHandle(userName);
    if (matches.length > 1) {
        userSession.send(String.format("Ambiguous handle \"%s\". Matches: %s", userName,
                MorphyStringUtils.toDelimitedString(matches, " ")));
        return;
    } else if (matches.length == 1) {
        userName = matches[0];
    }

    UserSession personQueried = UserService.getInstance().getUserSession(userName);
    if (!UserService.getInstance().isValidUsername(userName)) {
        userSession.send("There is no player matching the name " + userName + ".");
        return;
    }

    java.util.HashMap<String, String> variables = personQueried.getUser().getUserVars().getVariables();

    StringBuilder builder = new StringBuilder(900);

    builder.append("Variable settings of " + personQueried.getUser().getUserName() + ":\n\n");
    builder.append(
            String.format("time=%-4d    private=%-4d    shout=%-4d         pin=%-4d           style=%d\n",
                    toInt(variables.get("time")), toInt(variables.get("private")),
                    toInt(variables.get("shout")), toInt(variables.get("pin")), toInt(variables.get("style"))));
    builder.append(String.format("inc=%-4d     jprivate=%-4d   cshout=%-4d        notifiedby=%-4d    flip=%d\n",
            toInt(variables.get("inc")), toInt(variables.get("jprivate")), toInt(variables.get("cshout")),
            toInt(variables.get("notifiedby")), toInt(variables.get("flip"))));
    builder.append(String.format("rated=%-4d   kibitz=%-4d     availinfo=%-4d     highlight=%-4d\n",
            toInt(variables.get("rated")), toInt(variables.get("kibitz")), toInt(variables.get("availinfo")),
            toInt(variables.get("highlight"))));
    builder.append(String.format("open=%-4d    automail=%-4d   kiblevel=%-4d      availmin=%-4d      bell=%d\n",
            toInt(variables.get("open")), toInt(variables.get("automail")), toInt(variables.get("kiblevel")),
            toInt(variables.get("availmin")), toInt(variables.get("bell"))));
    builder.append(
            String.format("             pgn=%-4d        tell=%-4d          availmax=%-4d      width=%d\n",
                    toInt(variables.get("pgn")), toInt(variables.get("tell")), toInt(variables.get("availmax")),
                    toInt(variables.get("width"))));
    builder.append(
            String.format("bugopen=%-4d                 ctell=%-4d         gin=%-4d           height=%d\n",
                    toInt(variables.get("bugopen")), toInt(variables.get("ctell")), toInt(variables.get("gin")),
                    toInt(variables.get("height"))));
    builder.append(String.format(
            "             mailmess=%-4d                      seek=%-4d          ptime=%d\n",
            toInt(variables.get("mailmess")), toInt(variables.get("seek")), toInt(variables.get("ptime"))));
    builder.append(String.format(
            "tourney=%-4d messreply=%-4d  chanoff=%-4d       showownseek=%-4d   tzone=%s\n",
            toInt(variables.get("tourney")), toInt(variables.get("messreply")), toInt(variables.get("chanoff")),
            toInt(variables.get("showownseek")), variables.get("tzone")));
    builder.append(String.format("provshow=%-4d                silence=%-4d                          Lang=%s\n",
            toInt(variables.get("provshow")), toInt(variables.get("silence")),
            StringUtils.upperCase(variables.get("lang").substring(0, 1)) + variables.get("lang").substring(1)));
    builder.append(String.format("autoflag=%-4dunobserve=%-4d  echo=%-4d          examine=%-4d\n",
            toInt(variables.get("autoflag")), toInt(variables.get("unobserve")), toInt(variables.get("echo")),
            toInt(variables.get("examine"))));
    builder.append(String.format(
            "minmovetime=%-4d             tolerance=%-4d     noescape=%-4d      notakeback=%d\n\n",
            toInt(variables.get("minmovetime")), toInt(variables.get("tolerance")),
            toInt(variables.get("noescape")), toInt(variables.get("notakeback"))));
    builder.append(String.format("Prompt: %s\n", variables.get("prompt")));

    String v = variables.get("interface");
    if (!v.equals("NULL"))
        builder.append(String.format("Interface: \"%s\"", v));

    userSession.send(builder.toString());
}

From source file:com.vmware.appfactory.config.ConfigParam.java

/**
 * Create a new parameter instance./*from w  ww  .  ja  v a  2 s .  c  o  m*/
 *
 *
 * @param group Configuration group (for UI display).
 * @param ord Ordinal (for UI display).
 * @param key Unique key for this parameter.
 * @param units
 */
private ConfigParam(String group, int ord, String key, ConfigParam.Type type, boolean userEditable,
        String units) {
    _group = group;
    _ordinal = ord;
    _key = key;
    _type = type;
    _units = units;
    _userEditable = userEditable;
    _translateKey = "T.CONFIG." + StringUtils.upperCase(key);
}

From source file:com.egt.core.db.util.InterpreteSqlOracle.java

@Override
public String getNombreTabla(String tabla) {
    return StringUtils.upperCase(StringUtils.stripToNull(tabla));
}

From source file:de.torstenwalter.maven.plugins.AbstractDBMojo.java

/**
 * @see http://docs.oracle.com/cd/B19306_01/server.102/b14357/toc.htm
 *      (SQL*Plus User's Guide and Reference)
 * //w ww.  ja  v  a 2s.  c  o m
 * @param credentials
 * @return
 */
protected String getConnectionIdentifier(Credentials credentials) {
    StringBuilder connectionIdentifier = new StringBuilder();
    // fist add the username
    connectionIdentifier.append(credentials.getUsername());
    // then add the password if given
    if (!StringUtils.isEmpty(credentials.getPassword())) {
        connectionIdentifier.append("/").append(credentials.getPassword());
    }

    // now add the connect_identifier:
    if (!useEasyConnect) {
        // To make it more robust and to not to rely on TNSNAMES we specify the
        // full connect identifier like:
        // (DESCRIPTION=
        // (ADDRESS=(PROTOCOL=tcp)(HOST=host)(PORT=port) )
        // (CONNECT_DATA=
        // (SERVICE_NAME=service_name) ) )
        connectionIdentifier.append("@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=")
                .append(hostname).append(")(PORT=").append(port).append(")))(CONNECT_DATA=(SERVICE_NAME=")
                .append(serviceName).append(")");
        if (!StringUtils.isEmpty(instanceName)) {
            connectionIdentifier.append("(INSTANCE_NAME=").append(instanceName).append(")");
        }
        connectionIdentifier.append("))");
    } else {
        // "[//]Host[:Port]/<service_name>"
        connectionIdentifier.append("@//").append(hostname).append(":").append(port).append("/")
                .append(serviceName);
    }
    // add as clause if necessary
    if (StringUtils.equalsIgnoreCase(asClause, "SYSDBA") || StringUtils.equalsIgnoreCase(asClause, "SYSOPER")) {
        connectionIdentifier.append(" AS ").append(StringUtils.upperCase(asClause));
    }

    return connectionIdentifier.toString();
}

From source file:info.magnolia.cms.beans.runtime.FileProperties.java

public String getProperty(String property) {
    String value = StringUtils.EMPTY;

    if (this.getContent() == null) {
        return null;
    }/*from w ww  .  j  ava 2 s .  c om*/

    NodeData props = this.getContent().getNodeData(this.nodeDataName);
    if (props.getType() != PropertyType.BINARY) {
        return null;
    }

    String filename = props.getAttribute(PROPERTY_FILENAME);
    String ext = props.getAttribute(PROPERTY_EXTENSION);
    String fullName = filename;
    String fullExt = StringUtils.EMPTY;
    if (StringUtils.isNotEmpty(ext)) {
        fullExt = "." + ext; //$NON-NLS-1$
        fullName += fullExt;
    }
    if (property.equals(EXTENSION)) {
        value = ext;
    } else if (property.equals(EXTENSION_LOWER_CASE)) {
        value = StringUtils.lowerCase(ext);
    } else if (property.equals(EXTENSION_UPPER_CASE)) {
        value = StringUtils.upperCase(ext);
    } else if (property.equals(NAME_WITHOUT_EXTENSION)) {
        value = filename;
    } else if (property.equals(CONTENT_TYPE)) {
        value = props.getAttribute(PROPERTY_CONTENTTYPE);
    } else if (property.equals(TEMPLATE)) {
        value = props.getAttribute(PROPERTY_TEMPLATE);
    } else if (property.equals(HANDLE)) {
        value = this.getContent().getHandle() + "/" + this.getNodeDataName(); //$NON-NLS-1$
    } else if (property.equals(NAME)) {
        value = fullName;
    } else if (property.equals(PATH_WITHOUT_NAME)) {
        value = this.getContent().getHandle() + "/" + this.getNodeDataName() + fullExt; //$NON-NLS-1$
    } else if (property.equals(ICON) && ext != null) {
        value = MIMEMapping.getMIMETypeIcon(ext);
    } else if (property.equals(SIZE_BYTES)) {
        value = props.getAttribute(PROPERTY_SIZE);
    } else if (property.equals(SIZE_KB)) {
        String sizestring = props.getAttribute(PROPERTY_SIZE);
        if (!NumberUtils.isNumber(sizestring)) {
            return null;
        }
        double size = Long.parseLong(sizestring);
        String sizeStr;
        size = size / 1024;
        sizeStr = Double.toString(size);
        sizeStr = sizeStr.substring(0, sizeStr.indexOf(".") + 2); //$NON-NLS-1$
        value = sizeStr;
    } else if (property.equals(SIZE_MB)) {
        String sizestring = props.getAttribute(PROPERTY_SIZE);
        if (!NumberUtils.isNumber(sizestring)) {
            return null;
        }
        double size = Long.parseLong(sizestring);
        String sizeStr;
        size = size / (1024 * 1024);
        sizeStr = Double.toString(size);
        sizeStr = sizeStr.substring(0, sizeStr.indexOf(".") + 2); //$NON-NLS-1$
        value = sizeStr;
    } else if (property.equals(SIZE)) {
        String sizestring = props.getAttribute(PROPERTY_SIZE);
        if (!NumberUtils.isNumber(sizestring)) {
            return null;
        }
        double size = Long.parseLong(sizestring);
        String unit = "bytes";
        String sizeStr;
        if (size >= 1000) {
            size = size / 1024;
            unit = "KB";
            if (size >= 1000) {
                size = size / 1024;
                unit = "MB";
            }
            sizeStr = Double.toString(size);
            sizeStr = sizeStr.substring(0, sizeStr.indexOf(".") + 2); //$NON-NLS-1$
        } else {
            sizeStr = Double.toString(size);
            sizeStr = sizeStr.substring(0, sizeStr.indexOf(".")); //$NON-NLS-1$
        }
        value = sizeStr + " " + unit; //$NON-NLS-1$
    } else if (property.equals(PROPERTY_WIDTH)) {
        value = props.getAttribute(PROPERTY_WIDTH);
    } else if (property.equals(PROPERTY_HEIGHT)) {
        value = props.getAttribute(PROPERTY_HEIGHT);
    } else { // property.equals(PATH|null|""|any other value)
        value = this.getContent().getHandle() + "/" + this.getNodeDataName() + "/" + fullName; //$NON-NLS-1$ //$NON-NLS-2$
    }
    return value;
}

From source file:cec.easyshop.storefront.controllers.pages.CartPageController.java

@RequestMapping(value = "/checkout/select-flow", method = RequestMethod.GET)
@RequireHardLogIn/*from   w ww . j a  v a  2 s  .c o  m*/
public String initCheck(final Model model, final RedirectAttributes redirectModel,
        @RequestParam(value = "flow", required = false) final String flow,
        @RequestParam(value = "pci", required = false) final String pci)
        throws CommerceCartModificationException {
    SessionOverrideCheckoutFlowFacade.resetSessionOverrides();

    if (!getCartFacade().hasEntries()) {
        LOG.info("Missing or empty cart");

        // No session cart or empty session cart. Bounce back to the cart page.
        return REDIRECT_PREFIX + "/cart";
    }

    // Override the Checkout Flow setting in the session
    if (StringUtils.isNotBlank(flow)) {
        final CheckoutFlowEnum checkoutFlow = enumerationService.getEnumerationValue(CheckoutFlowEnum.class,
                StringUtils.upperCase(flow));
        SessionOverrideCheckoutFlowFacade.setSessionOverrideCheckoutFlow(checkoutFlow);
    }

    // Override the Checkout PCI setting in the session
    if (StringUtils.isNotBlank(pci)) {
        final CheckoutPciOptionEnum checkoutPci = enumerationService
                .getEnumerationValue(CheckoutPciOptionEnum.class, StringUtils.upperCase(pci));
        SessionOverrideCheckoutFlowFacade.setSessionOverrideSubscriptionPciOption(checkoutPci);
    }

    // Redirect to the start of the checkout flow to begin the checkout process
    // We just redirect to the generic '/checkout' page which will actually select the checkout flow
    // to use. The customer is not necessarily logged in on this request, but will be forced to login
    // when they arrive on the '/checkout' page.
    return REDIRECT_PREFIX + "/checkout";
}

From source file:com.ctc.storefront.controllers.pages.CartPageController.java

@RequestMapping(value = "/checkout/select-flow", method = RequestMethod.GET)
@RequireHardLogIn/*from  www .  ja v  a2 s . c  om*/
public String initCheck(final Model model, final RedirectAttributes redirectModel,
        @RequestParam(value = "flow", required = false) final String flow,
        @RequestParam(value = "pci", required = false) final String pci)
        throws CommerceCartModificationException {
    SessionOverrideCheckoutFlowFacade.resetSessionOverrides();

    if (!getCartFacade().hasEntries()) {
        LOG.info("Missing or empty cart");

        // No session cart or empty session cart. Bounce back to the cart page.
        return REDIRECT_CART_URL;
    }

    // Override the Checkout Flow setting in the session
    if (StringUtils.isNotBlank(flow)) {
        final CheckoutFlowEnum checkoutFlow = enumerationService.getEnumerationValue(CheckoutFlowEnum.class,
                StringUtils.upperCase(flow));
        SessionOverrideCheckoutFlowFacade.setSessionOverrideCheckoutFlow(checkoutFlow);
    }

    // Override the Checkout PCI setting in the session
    if (StringUtils.isNotBlank(pci)) {
        final CheckoutPciOptionEnum checkoutPci = enumerationService
                .getEnumerationValue(CheckoutPciOptionEnum.class, StringUtils.upperCase(pci));
        SessionOverrideCheckoutFlowFacade.setSessionOverrideSubscriptionPciOption(checkoutPci);
    }

    // Redirect to the start of the checkout flow to begin the checkout process
    // We just redirect to the generic '/checkout' page which will actually select the checkout flow
    // to use. The customer is not necessarily logged in on this request, but will be forced to login
    // when they arrive on the '/checkout' page.
    return REDIRECT_PREFIX + "/checkout";
}