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:net.kamhon.ieagle.dao.Jpa2Dao.java

private QueryParams translateExampleToQueryParams(Object example, String... orderBy) {
    Object newObj = example;//from  w w  w  .j a va  2s .  c o  m
    Entity entity = ((Entity) newObj.getClass().getAnnotation(Entity.class));
    if (entity == null)
        throw new DataException(newObj.getClass().getSimpleName() + " class is not valid JPA annotated bean");

    String entityName = StringUtils.isBlank(entity.name()) ? example.getClass().getSimpleName() : entity.name();
    String aliasName = StringUtils.isBlank(entity.name()) ? "obj" : entity.name();

    String hql = "SELECT " + aliasName + " FROM ";
    List<Object> params = new ArrayList<Object>();

    BeanWrapper beanO1 = new BeanWrapperImpl(newObj);
    PropertyDescriptor[] proDescriptorsO1 = beanO1.getPropertyDescriptors();
    int propertyLength = proDescriptorsO1.length;

    if (newObj != null) {
        hql += entityName + " " + aliasName;
    }

    if (example instanceof VoBase) {
        VoBase voBase = (VoBase) example;
        for (String key : voBase.getJoinTables().keySet()) {
            if (StringUtils.isNotBlank(key)) {
                hql += " JOIN " + key + " " + voBase.getJoinTables().get(key);
            }
        }
    }

    hql += " WHERE 1=1";

    int paramCount = 0;
    for (int i = 0; i < propertyLength; i++) {
        try {
            Object propertyValueO1 = beanO1.getPropertyValue(proDescriptorsO1[i].getName());

            if ((propertyValueO1 instanceof String && StringUtils.isNotBlank((String) propertyValueO1))
                    || propertyValueO1 instanceof Long || propertyValueO1 instanceof Double
                    || propertyValueO1 instanceof Integer || propertyValueO1 instanceof Boolean
                    || propertyValueO1 instanceof Date || propertyValueO1.getClass().isPrimitive()) {

                Field field = null;
                try {
                    field = example.getClass().getDeclaredField(proDescriptorsO1[i].getName());
                } catch (NoSuchFieldException e) {
                    if (propertyValueO1 instanceof Boolean || propertyValueO1.getClass().isPrimitive()) {
                        String fieldName = "is"
                                + StringUtils.upperCase(proDescriptorsO1[i].getName().substring(0, 1))
                                + proDescriptorsO1[i].getName().substring(1);
                        field = example.getClass().getDeclaredField(fieldName);
                    }
                }

                if (proDescriptorsO1[i].getName() != null && field != null
                        && !field.isAnnotationPresent(Transient.class)) {
                    if (!Arrays.asList(VoBase.propertiesVer).contains(proDescriptorsO1[i].getName())) {
                        hql += " AND " + aliasName + "." + field.getName() + " = ?" + (++paramCount);
                        params.add(propertyValueO1);
                    }
                }
            } else if (propertyValueO1 != null) {
                Field field = example.getClass().getDeclaredField(proDescriptorsO1[i].getName());
                if (field.isAnnotationPresent(javax.persistence.Id.class)
                        || field.isAnnotationPresent(javax.persistence.EmbeddedId.class)) {

                    BeanWrapper bean = new BeanWrapperImpl(propertyValueO1);
                    PropertyDescriptor[] proDescriptors = bean.getPropertyDescriptors();

                    for (PropertyDescriptor propertyDescriptor : proDescriptors) {
                        Object propertyValueId = bean.getPropertyValue(propertyDescriptor.getName());

                        if (propertyValueId != null && ReflectionUtil.isJavaDataType(propertyValueId)) {
                            hql += " AND " + aliasName + "." + proDescriptorsO1[i].getName() + "."
                                    + propertyDescriptor.getName() + " = ?" + (++paramCount);
                            params.add(bean.getPropertyValue(propertyDescriptor.getName()));
                        }
                    }
                }
            }

        } catch (Exception e) {
        }
    }

    // not condition
    if (example instanceof VoBase) {
        VoBase voBase = (VoBase) example;
        for (String key : voBase.getNotConditions().keySet()) {
            if (StringUtils.isNotBlank(key)) {
                hql += " AND " + aliasName + "." + key + "!= ?" + (++paramCount);
                params.add(voBase.getNotConditions().get(key));
            }
        }
    }

    // like condition
    if (example instanceof VoBase) {
        VoBase voBase = (VoBase) example;
        for (String key : voBase.getLikeConditions().keySet()) {
            if (StringUtils.isNotBlank(key)) {
                hql += " AND " + aliasName + "." + key + " LIKE ?" + (++paramCount);
                params.add(voBase.getLikeConditions().get(key));
            }
        }
    }

    if (orderBy != null && orderBy.length != 0) {
        hql += " ORDER BY ";
        long count = 1;
        for (String orderByStr : orderBy) {
            if (count != 1)
                hql += ",";
            hql += aliasName + "." + orderByStr;
            count += 1;
        }
    }

    log.debug("hql = " + hql);

    return new QueryParams(hql, params);
}

From source file:br.com.diegosilva.jsfcomponents.util.Utils.java

public static String upper(String value) {
    return StringUtils.upperCase(value);
}

From source file:com.liferay.cucumber.util.StringUtil.java

public static String toUpperCase(String s) {
    if (s == null) {
        return null;
    }//  w w w  .  j av a 2 s . c o m

    return StringUtils.upperCase(s);
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopSearchField.java

protected void handleSearch(final String newFilter) {
    clearSearchVariants();/* ww w .  ja v a  2s . c  o  m*/

    String filterForDs = newFilter;
    if (mode == Mode.LOWER_CASE) {
        filterForDs = StringUtils.lowerCase(newFilter);
    } else if (mode == Mode.UPPER_CASE) {
        filterForDs = StringUtils.upperCase(newFilter);
    }

    if (escapeValueForLike && StringUtils.isNotEmpty(filterForDs)) {
        filterForDs = QueryUtils.escapeForLike(filterForDs);
    }

    if (!isRequired() && StringUtils.isEmpty(filterForDs)) {
        if (optionsDatasource.getState() == Datasource.State.VALID) {
            optionsDatasource.clear();
        }

        setValue(null);
        updateOptionsDsItem();
        return;
    }

    if (StringUtils.length(filterForDs) >= minSearchStringLength) {
        optionsDatasource
                .refresh(Collections.singletonMap(SearchField.SEARCH_STRING_PARAM, (Object) filterForDs));

        if (optionsDatasource.getState() == Datasource.State.VALID) {
            if (optionsDatasource.size() == 0) {
                if (searchNotifications != null)
                    searchNotifications.notFoundSuggestions(newFilter);
            } else if (optionsDatasource.size() == 1) {
                setValue(optionsDatasource.getItems().iterator().next());
                updateOptionsDsItem();
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        updateComponent(getValue());
                    }
                });
            } else {
                initSearchVariants();
                comboBox.showSearchPopup();
            }
        }
    } else {
        if (optionsDatasource.getState() == Datasource.State.VALID) {
            optionsDatasource.clear();
        }

        if (searchNotifications != null && StringUtils.length(filterForDs) > 0) {
            searchNotifications.needMinSearchStringLength(newFilter, minSearchStringLength);
        }
    }
}

From source file:net.sourceforge.fenixedu.util.UniqueAcronymCreator.java

private static boolean isValidAcception(String string) {
    if (acceptSet.contains(StringUtils.upperCase(string))) {
        if (logger.isDebugEnabled()) {
            logger.info("isValidAcception, true -> " + string);
        }/*from   w w  w.j a  va  2 s  .  c  om*/
        return true;
    }
    if (logger.isDebugEnabled()) {
        logger.info("isValidAcception, false -> " + string);
    }
    return false;
}

From source file:com.adobe.acs.commons.users.impl.EnsureGroup.java

@Activate
protected void activate(final Map<String, Object> config) {
    boolean ensureImmediately = PropertiesUtil.toBoolean(config.get(PROP_ENSURE_IMMEDIATELY),
            DEFAULT_ENSURE_IMMEDIATELY);

    String operationStr = StringUtils
            .upperCase(PropertiesUtil.toString(config.get(PROP_OPERATION), DEFAULT_OPERATION));
    try {/*from w w w.  j  ava2 s  .c o  m*/
        this.operation = Operation.valueOf(operationStr);
        // Parse OSGi Configuration into Group object
        this.group = new Group(config);

        if (ensureImmediately) {
            // Ensure
            ensure(operation, getAuthorizable());
        } else {
            log.info(
                    "This Group is configured to NOT ensure immediately. Please ensure this Group via the JMX MBean.");
        }

    } catch (EnsureAuthorizableException e) {
        log.error("Unable to ensure Group [ {} ]",
                PropertiesUtil.toString(config.get(PROP_PRINCIPAL_NAME), "Undefined Group Principal Name"), e);
    } catch (IllegalArgumentException e) {
        throw new IllegalArgumentException("Unknown Ensure Group operation [ " + operationStr + " ]", e);
    }
}

From source file:gnete.card.web.merch.MerchAction.java

public String showAdd() throws Exception {
    hasRightTodo();/*from www .java 2 s  . c o  m*/
    initPage();
    this.merchInfoReg = new MerchInfoReg();
    merchInfoReg.setOpenFlag(OpenFlag.OPEN.getValue());
    merchInfoReg.setUsePwdFlag(UsePwdFlag.BRANCH.getValue());
    merchInfoReg.setAcctType(AcctType.COMPANY.getValue());
    merchInfoReg.setSingleProduct(Symbol.NO);// ???

    //??
    if (isCardOrCardDeptRoleLogined()) {
        this.branchCode = this.getLoginBranchCode();
    }

    // ???????
    this.showModifyManage = showModifyManageBranch();
    if (showModifyManage) {
        BranchInfo loginBranch = this.branchInfoDAO.findBranchInfo(this.getLoginBranchCode());
        BranchInfo manageBranch = this.branchInfoDAO.findBranchInfo(loginBranch.getParent());
        this.setManageBranch(manageBranch.getBranchName());
        merchInfoReg.setManageBranch(loginBranch.getParent());
    }

    if (StringUtils.isNotEmpty(branchCode)) {
        BranchInfo branchInfo = (BranchInfo) this.branchInfoDAO.findByPk(branchCode);
        BranchInfo manageBranchInfo = (BranchInfo) this.branchInfoDAO.findByPk(branchInfo.getParent());

        this.setManageBranch(manageBranchInfo.getBranchName());

        merchInfoReg.setCardBranch(branchInfo.getBranchCode());// ??
        this.setCardBranchName(branchInfo.getBranchName());
        merchInfoReg.setSingleProduct(branchInfo.getSingleProduct());

        merchInfoReg.setMerchName(branchInfo.getBranchName());
        merchInfoReg.setMerchAbb(branchInfo.getBranchAbbname());
        merchInfoReg.setBankName(branchInfo.getBankName());
        merchInfoReg.setBankNo(branchInfo.getBankNo());
        merchInfoReg.setAccName(branchInfo.getAccName());
        merchInfoReg.setAccNo(branchInfo.getAccNo());
        merchInfoReg.setCurrCode(branchInfo.getCurCode());
        merchInfoReg.setEmail(branchInfo.getEmail());
        merchInfoReg.setFaxNo(branchInfo.getFax());
        merchInfoReg.setLinkMan(branchInfo.getContact());
        merchInfoReg.setManageBranch(branchInfo.getParent());
        merchInfoReg.setMerchAddress(branchInfo.getAddress());
        merchInfoReg.setTelNo(branchInfo.getPhone());
        merchInfoReg.setAcctType(branchInfo.getAcctType());

        merchInfoReg.setLegalPersonIdcard(branchInfo.getLegalPersonIdcard());
        merchInfoReg.setLegalPersonIdcardExpDate(branchInfo.getLicenseExpDate());
        merchInfoReg.setLegalPersonName(branchInfo.getLegalPersonName());
        merchInfoReg.setTaxRegCode(branchInfo.getTaxRegCode());
        merchInfoReg.setMerchCode(branchInfo.getLicense());
        merchInfoReg.setLicenseExpDate(branchInfo.getLicenseExpDate());
        merchInfoReg.setOrganization(branchInfo.getOrganization());
        merchInfoReg.setOrganizationExpireDate(branchInfo.getOrganizationExpireDate());

        // 
        merchInfoReg.setAreaCode(branchInfo.getAreaCode());
        Area area = (Area) this.areaDAO.findByPk(branchInfo.getAreaCode());
        if (area != null) {
            this.setAreaName(area.getAreaName());
        }

        merchInfoReg.setAccAreaCode(branchInfo.getAccAreaCode());
        Area accArea = (Area) this.areaDAO.findByPk(branchInfo.getAccAreaCode());
        if (accArea != null) {
            this.setAccAreaName(accArea.getAreaName());
        }
        // ??
        this.setMerchAdmin(
                StringUtils.upperCase(Cn2PinYinHelper.cn2FirstSpell(merchInfoReg.getMerchAbb())) + "SHAdmin");
    }

    return ADD;
}

From source file:com.prowidesoftware.swift.io.parser.MxParser.java

/**
 * Distinguished Name structure: cn=name,ou=payment,o=bank,o=swift
 * <br />//  www  . j a  va2s  .  c  om
 * Example: o=spxainjj,o=swift
 * 
 * @param dn the DN element content
 * @return returns capitalized "bank", in the example SPXAINJJ
 */
public static String getBICFromDN(final String dn) {
    for (String s : StringUtils.split(dn, ",")) {
        if (StringUtils.startsWith(s, "o=") && !StringUtils.equals(s, "o=swift")) {
            return StringUtils.upperCase(StringUtils.substringAfter(s, "o="));
        }
        /*
        else if (StringUtils.startsWith(s, "ou=") && !StringUtils.equals(s, "ou=swift")) {
           return StringUtils.upperCase(StringUtils.substringAfter(s, "ou="));
        }
        */
    }
    return null;
}

From source file:com.evolveum.icf.dummy.connector.DummyConnector.java

/**
  * {@inheritDoc}/*w  w  w . j ava  2 s.  co m*/
  */
public Uid update(ObjectClass objectClass, Uid uid, Set<Attribute> replaceAttributes,
        OperationOptions options) {
    log.info("update::begin");
    validate(objectClass);

    try {

        if (ObjectClass.ACCOUNT.is(objectClass.getObjectClassValue())) {

            final DummyAccount account;
            if (configuration.getUidMode().equals(DummyConfiguration.UID_MODE_NAME)) {
                account = resource.getAccountByUsername(uid.getUidValue());
            } else if (configuration.getUidMode().equals(DummyConfiguration.UID_MODE_UUID)) {
                account = resource.getAccountById(uid.getUidValue());
            } else {
                throw new IllegalStateException("Unknown UID mode " + configuration.getUidMode());
            }
            if (account == null) {
                throw new UnknownUidException("Account with UID " + uid + " does not exist on resource");
            }

            // we do this before setting attribute values, in case when description itself would be changed
            resource.changeDescriptionIfNeeded(account);

            for (Attribute attr : replaceAttributes) {
                if (attr.is(Name.NAME)) {
                    String newName = (String) attr.getValue().get(0);
                    try {
                        resource.renameAccount(account.getId(), account.getName(), newName);
                    } catch (ObjectDoesNotExistException e) {
                        throw new org.identityconnectors.framework.common.exceptions.UnknownUidException(
                                e.getMessage(), e);
                    } catch (ObjectAlreadyExistsException e) {
                        throw new org.identityconnectors.framework.common.exceptions.AlreadyExistsException(
                                e.getMessage(), e);
                    } catch (SchemaViolationException e) {
                        throw new org.identityconnectors.framework.common.exceptions.ConnectorException(
                                "Schema exception: " + e.getMessage(), e);
                    }
                    // We need to change the returned uid here (only if the mode is not set to UUID)
                    if (!(configuration.getUidMode().equals(DummyConfiguration.UID_MODE_UUID))) {
                        uid = new Uid(newName);
                    }
                } else if (attr.is(OperationalAttributes.PASSWORD_NAME)) {
                    changePassword(account, attr);

                } else if (attr.is(OperationalAttributes.ENABLE_NAME)) {
                    account.setEnabled(getBoolean(attr));

                } else if (attr.is(OperationalAttributes.ENABLE_DATE_NAME)) {
                    account.setValidFrom(getDate(attr));

                } else if (attr.is(OperationalAttributes.DISABLE_DATE_NAME)) {
                    account.setValidTo(getDate(attr));

                } else if (attr.is(OperationalAttributes.LOCK_OUT_NAME)) {
                    account.setLockout(getBoolean(attr));

                } else {
                    String name = attr.getName();
                    try {
                        account.replaceAttributeValues(name, attr.getValue());
                    } catch (SchemaViolationException e) {
                        // we cannot throw checked exceptions. But this one looks suitable.
                        // Note: let's do the bad thing and add exception loaded by this classloader as inner exception here
                        // The framework should deal with it ... somehow
                        throw new IllegalArgumentException(e.getMessage(), e);
                    }
                }
            }

        } else if (ObjectClass.GROUP.is(objectClass.getObjectClassValue())) {

            final DummyGroup group;
            if (configuration.getUidMode().equals(DummyConfiguration.UID_MODE_NAME)) {
                group = resource.getGroupByName(uid.getUidValue());
            } else if (configuration.getUidMode().equals(DummyConfiguration.UID_MODE_UUID)) {
                group = resource.getGroupById(uid.getUidValue());
            } else {
                throw new IllegalStateException("Unknown UID mode " + configuration.getUidMode());
            }
            if (group == null) {
                throw new UnknownUidException("Group with UID " + uid + " does not exist on resource");
            }

            for (Attribute attr : replaceAttributes) {
                if (attr.is(Name.NAME)) {
                    String newName = (String) attr.getValue().get(0);
                    try {
                        resource.renameGroup(group.getId(), group.getName(), newName);
                    } catch (ObjectDoesNotExistException e) {
                        throw new org.identityconnectors.framework.common.exceptions.UnknownUidException(
                                e.getMessage(), e);
                    } catch (ObjectAlreadyExistsException e) {
                        throw new org.identityconnectors.framework.common.exceptions.AlreadyExistsException(
                                e.getMessage(), e);
                    }
                    // We need to change the returned uid here
                    uid = new Uid(newName);
                } else if (attr.is(OperationalAttributes.PASSWORD_NAME)) {
                    throw new IllegalArgumentException("Attempt to change password on group");

                } else if (attr.is(OperationalAttributes.ENABLE_NAME)) {
                    group.setEnabled(getBoolean(attr));

                } else {
                    String name = attr.getName();
                    List<Object> values = attr.getValue();
                    if (attr.is(DummyGroup.ATTR_MEMBERS_NAME) && values != null
                            && configuration.getUpCaseName()) {
                        List<Object> newValues = new ArrayList<Object>(values.size());
                        for (Object val : values) {
                            newValues.add(StringUtils.upperCase((String) val));
                        }
                        values = newValues;
                    }
                    try {
                        group.replaceAttributeValues(name, values);
                    } catch (SchemaViolationException e) {
                        throw new IllegalArgumentException(e.getMessage(), e);
                    }
                }
            }

        } else if (objectClass.is(OBJECTCLASS_PRIVILEGE_NAME)) {

            final DummyPrivilege priv;
            if (configuration.getUidMode().equals(DummyConfiguration.UID_MODE_NAME)) {
                priv = resource.getPrivilegeByName(uid.getUidValue());
            } else if (configuration.getUidMode().equals(DummyConfiguration.UID_MODE_UUID)) {
                priv = resource.getPrivilegeById(uid.getUidValue());
            } else {
                throw new IllegalStateException("Unknown UID mode " + configuration.getUidMode());
            }
            if (priv == null) {
                throw new UnknownUidException("Privilege with UID " + uid + " does not exist on resource");
            }

            for (Attribute attr : replaceAttributes) {
                if (attr.is(Name.NAME)) {
                    String newName = (String) attr.getValue().get(0);
                    try {
                        resource.renamePrivilege(priv.getId(), priv.getName(), newName);
                    } catch (ObjectDoesNotExistException e) {
                        throw new org.identityconnectors.framework.common.exceptions.UnknownUidException(
                                e.getMessage(), e);
                    } catch (ObjectAlreadyExistsException e) {
                        throw new org.identityconnectors.framework.common.exceptions.AlreadyExistsException(
                                e.getMessage(), e);
                    }
                    // We need to change the returned uid here
                    uid = new Uid(newName);
                } else if (attr.is(OperationalAttributes.PASSWORD_NAME)) {
                    throw new IllegalArgumentException("Attempt to change password on privilege");

                } else if (attr.is(OperationalAttributes.ENABLE_NAME)) {
                    throw new IllegalArgumentException("Attempt to change enable on privilege");

                } else {
                    String name = attr.getName();
                    try {
                        priv.replaceAttributeValues(name, attr.getValue());
                    } catch (SchemaViolationException e) {
                        throw new IllegalArgumentException(e.getMessage(), e);
                    }
                }
            }

        } else {
            throw new ConnectorException("Unknown object class " + objectClass);
        }

    } catch (ConnectException e) {
        log.info("update::exception " + e);
        throw new ConnectionFailedException(e.getMessage(), e);
    } catch (FileNotFoundException e) {
        log.info("update::exception " + e);
        throw new ConnectorIOException(e.getMessage(), e);
    }

    log.info("update::end");
    return uid;
}

From source file:eu.europeana.corelib.edm.utils.EdmUtils.java

private static void appendAggregation(RDF rdf, List<AggregationImpl> aggregations) {
    List<Aggregation> aggregationList = new ArrayList<Aggregation>();
    for (AggregationImpl aggr : aggregations) {
        Aggregation aggregation = new Aggregation();
        if (isUri(aggr.getAbout())) {
            aggregation.setAbout(aggr.getAbout());
        } else {//from  w ww .ja  v a  2  s .c o m
            aggregation.setAbout(PREFIX + aggr.getAbout());
        }
        if (!addAsObject(aggregation, AggregatedCHO.class, aggr.getAggregatedCHO())) {
            AggregatedCHO cho = new AggregatedCHO();
            if (isUri(rdf.getProvidedCHOList().get(0).getAbout())) {
                cho.setResource(rdf.getProvidedCHOList().get(0).getAbout());
            } else {
                cho.setResource(PREFIX + rdf.getProvidedCHOList().get(0).getAbout());
            }
            aggregation.setAggregatedCHO(cho);
        }
        if (!addAsObject(aggregation, DataProvider.class, aggr.getEdmDataProvider())) {
            addAsObject(aggregation, DataProvider.class, aggr.getEdmProvider());
        }
        addAsObject(aggregation, IsShownAt.class, aggr.getEdmIsShownAt());
        addAsObject(aggregation, IsShownBy.class, aggr.getEdmIsShownBy());
        addAsObject(aggregation, _Object.class, aggr.getEdmObject());
        addAsObject(aggregation, Provider.class, aggr.getEdmProvider());
        addAsObject(aggregation, Rights1.class, aggr.getEdmRights());
        addAsList(aggregation, IntermediateProvider.class, aggr.getEdmIntermediateProvider());

        if (aggr.getEdmUgc() != null && !aggr.getEdmUgc().equalsIgnoreCase("false")) {
            Ugc ugc = new Ugc();

            ugc.setUgc(UGCType.valueOf(StringUtils.upperCase(aggr.getEdmUgc())));
            aggregation.setUgc(ugc);
        }
        addAsList(aggregation, Rights.class, aggr.getDcRights());
        addAsList(aggregation, HasView.class, aggr.getHasView());
        createWebResources(rdf, aggr);
        aggregationList.add(aggregation);
    }
    rdf.setAggregationList(aggregationList);
}