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

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

Introduction

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

Prototype

public static boolean equalsIgnoreCase(final CharSequence str1, final CharSequence str2) 

Source Link

Document

Compares two CharSequences, returning true if they represent equal sequences of characters, ignoring case.

null s are handled without exceptions.

Usage

From source file:edu.umn.se.trap.rule.grantrule.NihNoFoodRule.java

/**
 * @param expense//from w  w w  .java  2 s  .co m
 * @throws TrapException
 */
private void checkNihFood(Expense expense) throws TrapException {

    /*
     * Check to make sure the expense is a food expense.
     */
    if (expense.getType().equals(ExpenseType.BREAKFAST) || expense.getType().equals(ExpenseType.LUNCH)
            || expense.getType().equals(ExpenseType.DINNER)) {

        GrantSet grantSet = expense.getEligibleGrants();

        if (grantSet == null) {
            throw new TrapException("Invalid TrapForm object: grantSet was null.");
        }

        Set<FormGrant> grants = grantSet.getGrants();

        if (grants == null) {
            throw new TrapException("Invalid TrapForm object: grants was null.");
        }

        Iterator<FormGrant> grantIter = grants.iterator();

        while (grantIter.hasNext()) {
            FormGrant grant = grantIter.next();

            if (StringUtils.equalsIgnoreCase(grant.getFundingOrganization(), "NIH")) {
                // Remove the grant if it is a NIH grant.
                grantSet.removeGrant(grant.getAccountName());
            }
        }

    }

}

From source file:edu.umn.se.trap.rule.grantrule.ForeignGrantsForeignTravelOnlyRule.java

/**
 * @param expenses/* w w  w.j  a v  a  2s .  co m*/
 * @param expenses
 * @throws TrapException
 */
protected void checkExpenseGrants(Expense expense, List<Expense> expenses) throws TrapException {

    Location location = expense.getLocation();

    /*
     * If a transportation or other expense has the same date as any other
     * type of expense, then it must have the same location.
     */
    if (location == null && (expense.getType().equals(ExpenseType.TRANSPORTATION)
            || expense.getType().equals(ExpenseType.OTHER))) {
        for (Expense ex : expenses) {
            if (!(ex.getType().equals(ExpenseType.TRANSPORTATION) || ex.getType().equals(ExpenseType.OTHER))) {
                if (expense.getDate().equals(ex.getDate())) {
                    location = ex.getLocation();
                }
            }
        }
    }

    if (location != null) {

        if (StringUtils.equalsIgnoreCase(location.getCountry(), "USA")
                || StringUtils.equalsIgnoreCase(location.getCountry(), "United States")) {
            GrantSet grantSet = expense.getEligibleGrants();

            if (grantSet == null) {
                throw new TrapException("Invalid TrapForm object: grantSet was null.");
            }

            Set<FormGrant> grants = grantSet.getGrants();

            if (grants == null) {
                throw new TrapException("Invalid TrapForm object: grants was null.");
            }

            Set<FormGrant> newGrants = new HashSet<FormGrant>();

            for (FormGrant grant : grants) {

                if (!StringUtils.equalsIgnoreCase(grant.getOrganizationType(), "foreign")) {
                    // Add domestic grants to the newGrants object.
                    newGrants.add(grant);
                }
            }

            // Set the newGrants for the grantSet.
            grantSet.setGrants(newGrants);

        }
    }

}

From source file:edu.umn.se.trap.rule.businessrule.ExportGrantCitizenRule.java

/**
 * @param grants//  w ww  .  j  a  v a 2  s  .  c o  m
 * @param formUser
 * @throws TrapException
 */
protected void checkExportGrantCitizen(Set<FormGrant> grants, FormUser formUser) throws TrapException {

    if (formUser.getCitizenship().equalsIgnoreCase("united states")
            || formUser.getCitizenship().equalsIgnoreCase("usa")) {
        return;
    } else {
        for (FormGrant grant : grants) {
            if (StringUtils.equalsIgnoreCase(grant.getOrganizationType(), "noExport")) {
                throw new TrapException(TrapErrors.NONCITIZEN_EXPORT);
            }
        }

    }

}

From source file:de.dev.eth0.elasticsearch.aem.indexing.ElasticSearchTransportHandler.java

/**
 *
 * @param config/*from w  ww .  j a va 2  s  . c om*/
 * @return only accept if the serializationType is "elastic"
 */
@Override
public boolean canHandle(AgentConfig config) {
    return StringUtils.equalsIgnoreCase(config.getSerializationType(), ElasticSearchIndexContentBuilder.NAME);
}

From source file:edu.umn.se.trap.rule.businessrule.USCarrierRule.java

/**
 * @param carrier/*from w ww .  ja v a  2s .  c  o  m*/
 */
protected boolean checkCarrierString(String carrier) {

    // Return false if the carrier is not one of the US carriers.

    for (int i = 0; i < TrapUtil.USCARRIERS.length; i++) {
        if (StringUtils.equalsIgnoreCase(carrier, TrapUtil.USCARRIERS[i])) {
            return true;
        }
    }

    return false;
}

From source file:eu.openanalytics.rsb.message.MultiFilesJob.java

private void addJobFile(final String name, final InputStream is) throws FileNotFoundException, IOException {
    final File jobFile = new File(temporaryDirectory, name);

    if (StringUtils.equalsIgnoreCase(FilenameUtils.getExtension(name), Constants.R_SCRIPT_FILE_EXTENSION)) {
        if (rScriptFile != null) {
            throw new IllegalArgumentException("Only one R script is allowed per job");
        }/*from  w  ww. j  a  va2s. c o  m*/
        rScriptFile = jobFile;
    }

    final FileOutputStream fos = new FileOutputStream(jobFile);
    IOUtils.copy(is, fos);
    IOUtils.closeQuietly(fos);
}

From source file:com.nike.cerberus.service.S3StoreService.java

public Optional<String> get(String path) {
    GetObjectRequest request = new GetObjectRequest(s3Bucket, getFullPath(path));

    try {//from w  w w  .  j a  v a  2 s .c  om
        S3Object s3Object = s3Client.getObject(request);
        InputStream object = s3Object.getObjectContent();
        return Optional.of(IOUtils.toString(object, ConfigConstants.DEFAULT_ENCODING));
    } catch (AmazonServiceException ase) {
        if (StringUtils.equalsIgnoreCase(ase.getErrorCode(), "NoSuchKey")) {
            logger.debug(String.format("The S3 object doesn't exist. Bucket: %s, Key: %s", s3Bucket,
                    request.getKey()));
            return Optional.empty();
        } else {
            logger.error("Unexpected error communicating with AWS.", ase);
            throw ase;
        }
    } catch (IOException e) {
        String errorMessage = String.format(
                "Unable to read contents of S3 object. Bucket: %s, Key: %s, Expected Encoding: %s", s3Bucket,
                request.getKey(), ConfigConstants.DEFAULT_ENCODING);
        logger.error(errorMessage);
        throw new UnexpectedDataEncodingException(errorMessage, e);
    }
}

From source file:de.dfki.mmf.planner.modalityplanner.score.UserInfoScorer.java

@Override
public Score calculateScore(ModalityRepresentation modalityRepresentation) {
    int softScore = 0;
    //some examples about what to retrieve of the user model
    WorldModel.getUserModels().toString();
    for (UserModel userModel : WorldModel.getUserModels()) {
        for (String talkedUser : Controller.getTalkingToUserList()) {
            if (StringUtils.equalsIgnoreCase(talkedUser, userModel.getUserId())) {
                //retrieve from user model whether user has a preferred modality
                if (userModel.getUserProperties().has("preferredmodality")) {
                    String preferredModalityType = userModel.getUserProperties().get("preferredmodality")
                            .getAsString().toUpperCase();
                    useSpecificModality(ModalityType.valueOf(preferredModalityType), modalityRepresentation);
                }/* w w w .ja va 2s .c  o m*/
                //does the user have any impairments -> certain modalities should be avoided
                if (userModel.getUserProperties().has("impairment")) {
                    String impairment = userModel.getUserProperties().get("impairment").getAsString();
                    if (impairment.equals("seeing")) {
                        avoidCertainModalityUsage(new ArrayList<ModalityType>(
                                Arrays.asList(ModalityType.valueOf("POINTING"), ModalityType.valueOf("GAZE"))),
                                modalityRepresentation);
                    } else if (impairment.equals("hearing")) {
                        avoidCertainModalityUsage(
                                new ArrayList<ModalityType>(Arrays.asList(ModalityType.valueOf("SPEECH"))),
                                modalityRepresentation);
                    }
                }
                //does the user have not very good language skills in the language used for communication with him -> avoid using speech only
                if (userModel.getUserProperties().has("languageskills")) {
                    String languageskills = userModel.getUserProperties().get("languageskills").getAsString();
                    if (languageskills.equals("low")) {
                        avoidSpeechOnlyOutput(modalityRepresentation);
                    }
                } else if (userModel.getUserProperties().has("verbose")) {
                    if (userModel.getUserProperties().get("verbose").getAsBoolean()) {
                        verboseSpeechOutput(modalityRepresentation);
                    }
                }
                break;
            }
        }
    }
    //calculate softScore by summing up individuals scores
    softScore += specificModUsedScore;
    softScore += avoidSpecificModScore;
    //speech is very difficult to understand for user, other modalities very important -> score * 2
    softScore += avoidSpeechOnlyOutputScore * 2;
    //since for the verbose speech output the attributive object identifier is very important -> score * 2
    softScore += verboseSpeechOutputScore * 2;

    setMaximalReducedScore(maxReducedScore);
    //reset individual scores for next round
    clearScores();

    return HardSoftScore.valueOf(0, softScore);
}

From source file:com.glaf.core.xml.XmlWriter.java

public Document write(List<ClassDefinition> rows) {
    Document doc = DocumentHelper.createDocument();
    Element root = doc.addElement("mapping");
    for (ClassDefinition classDefinition : rows) {
        Element element = root.addElement("entity");
        element.addAttribute("name", classDefinition.getEntityName());
        element.addAttribute("package", classDefinition.getPackageName());
        element.addAttribute("moduleName", classDefinition.getModuleName());
        element.addAttribute("table", classDefinition.getTableName());
        element.addAttribute("title", classDefinition.getTitle());
        element.addAttribute("englishTitle", classDefinition.getEnglishTitle());
        FieldDefinition idField = classDefinition.getIdField();
        if (idField != null) {
            Element idElement = element.addElement("id");
            idElement.addAttribute("name", idField.getName());
            idElement.addAttribute("column", idField.getColumnName());
            idElement.addAttribute("type", idField.getType());
            idElement.addAttribute("title", idField.getTitle());
            idElement.addAttribute("englishTitle", idField.getEnglishTitle());
            if (idField.getLength() > 0) {
                idElement.addAttribute("length", String.valueOf(idField.getLength()));
            }/*  www .ja v  a 2 s . co  m*/
        }

        Map<String, FieldDefinition> fields = classDefinition.getFields();
        Set<Entry<String, FieldDefinition>> entrySet = fields.entrySet();
        for (Entry<String, FieldDefinition> entry : entrySet) {
            String name = entry.getKey();
            FieldDefinition field = entry.getValue();
            if (idField != null
                    && StringUtils.equalsIgnoreCase(idField.getColumnName(), field.getColumnName())) {
                continue;
            }
            Element elem = element.addElement("property");
            elem.addAttribute("name", name);
            elem.addAttribute("column", field.getColumnName());
            elem.addAttribute("type", field.getType());
            elem.addAttribute("title", field.getTitle());
            elem.addAttribute("englishTitle", field.getEnglishTitle());

            if (StringUtils.equals(field.getType(), "String") && field.getLength() > 0) {
                elem.addAttribute("length", String.valueOf(field.getLength()));
            }
            if (field.isUnique()) {
                elem.addAttribute("unique", String.valueOf(field.isUnique()));
            }
            if (field.isSearchable()) {
                elem.addAttribute("searchable", String.valueOf(field.isSearchable()));
            }
            if (!field.isNullable()) {
                elem.addAttribute("nullable", String.valueOf(field.isNullable()));
            }
            if (field.isEditable()) {
                elem.addAttribute("editable", String.valueOf(field.isEditable()));
            }
            if (field.getDisplayType() > 0) {
                elem.addAttribute("displayType", String.valueOf(field.getDisplayType()));
            }
        }
    }
    return doc;
}

From source file:com.glaf.core.dao.MyBatisEntityDAO.java

public void execute(SqlExecutor sqlExecutor) {
    String statementId = sqlExecutor.getStatementId();
    String operation = sqlExecutor.getOperation();
    Object parameter = sqlExecutor.getParameter();
    if (StringUtils.equalsIgnoreCase("insert", operation)) {
        getSqlSession().insert(statementId, parameter);
    } else if (StringUtils.equalsIgnoreCase("update", operation)) {
        getSqlSession().update(statementId, parameter);
    } else if (StringUtils.equalsIgnoreCase("delete", operation)) {
        getSqlSession().delete(statementId, parameter);
    }/*from   w  ww .  j  a va  2s  . c o  m*/
}