List of usage examples for org.apache.commons.lang StringUtils endsWithIgnoreCase
public static boolean endsWithIgnoreCase(String str, String suffix)
Case insensitive check if a String ends with a specified suffix.
From source file:org.jahia.services.importexport.ImportExportBaseService.java
/** * Helper method to determine which type of the import the uploaded file represents. * * @param declaredContentType the declared content type * @param fileName the uploaded file name * @return type of the import the uploaded file represents *///from w ww . ja v a 2 s . com public static String detectImportContentType(String declaredContentType, String fileName) { String contentType = declaredContentType; if (!KNOWN_IMPORT_CONTENT_TYPES.contains(contentType)) { contentType = JCRContentUtils.getMimeType(fileName); if (!KNOWN_IMPORT_CONTENT_TYPES.contains(contentType)) { if (StringUtils.endsWithIgnoreCase(fileName, ".xml")) { contentType = "application/xml"; } else if (StringUtils.endsWithIgnoreCase(fileName, ".zip")) { contentType = "application/zip"; } else { // no chance to detect it logger.error( "Unable to detect the content type for file {}. It is neither a ZIP file nor an XML. Skipping import.", fileName); } } } return contentType; }
From source file:org.jboss.windup.WindupMetaEngine.java
/** * <p>/*from w w w . j a v a 2s . co m*/ * Generate {@link ArchiveMeta} by processing a single archive. * </p> * * @param archive * Archive to process * @param outputDir * Optional. Directory to save any information generated while * generating the meta information * @param parentMeta * Optional. Parent meta for the {@link ArchiveMeta} generated by * processing the given archive * * @return {@link ArchiveMeta} generated from processing the given archive. * Optionally has a parent of the the optionally given parent meta. * * @throws IOException * This can happen when performing file operations */ private ArchiveMeta processArchive(File archive, File outputDir, ArchiveMeta parentMeta) throws IOException { ArchiveMeta result = null; if (!archive.exists()) { throw new FileNotFoundException("ArchiveMeta not found."); } for (String ext : RPM_EXTENSIONS) { if (StringUtils.endsWithIgnoreCase(archive.getAbsolutePath(), ext)) { try { archive = RPMToZipTransformer.convertRpmToZip(archive); } catch (Exception e) { LOG.error("Exception converting RPM: " + archive.getName() + " to ZIP.", e); return result; } } } if (StringUtils.isNotBlank(settings.getLogLevel())) { LogController.setLogLevel(settings.getLogLevel()); } result = interrogationEngine.process(outputDir, archive, parentMeta); return result; }
From source file:org.kuali.kra.questionnaire.answer.QuestionnaireAnswerServiceImpl.java
protected boolean isAnswerMatched(String condition, String parentAnswer, String conditionValue) { boolean valid = false; if (ConditionType.CONTAINS_TEXT.getCondition().equals(condition)) { valid = StringUtils.containsIgnoreCase(parentAnswer, conditionValue); } else if (ConditionType.BEGINS_WITH_TEXT.getCondition().equals(condition)) { valid = (StringUtils.startsWithIgnoreCase(parentAnswer, conditionValue)); } else if (ConditionType.ENDS_WITH_TEXT.getCondition().equals(condition)) { valid = (StringUtils.endsWithIgnoreCase(parentAnswer, conditionValue)); } else if (ConditionType.MATCH_TEXT.getCondition().equals(condition)) { valid = parentAnswer.equalsIgnoreCase(conditionValue); } else if (Integer.parseInt(condition) >= 5 && Integer.parseInt(condition) <= 10) { valid = (ConditionType.LESS_THAN_NUMBER.getCondition().equals(condition) && (Integer.parseInt(parentAnswer) < Integer.parseInt(conditionValue))) || (ConditionType.LESS_THAN_OR_EQUALS_NUMBER.getCondition().equals(condition) && (Integer.parseInt(parentAnswer) <= Integer.parseInt(conditionValue))) || (ConditionType.EQUALS_NUMBER.getCondition().equals(condition) && (Integer.parseInt(parentAnswer) == Integer.parseInt(conditionValue))) || (ConditionType.NOT_EQUAL_TO_NUMBER.getCondition().equals(condition) && (Integer.parseInt(parentAnswer) != Integer.parseInt(conditionValue))) || (ConditionType.GREATER_THAN_OR_EQUALS_NUMBER.getCondition().equals(condition) && (Integer.parseInt(parentAnswer) >= Integer.parseInt(conditionValue))) || (ConditionType.GREATER_THAN_NUMBER.getCondition().equals(condition) && (Integer.parseInt(parentAnswer) > Integer.parseInt(conditionValue))); } else if (Integer.parseInt(condition) >= 11) { final DateFormat dateFormat = new SimpleDateFormat(Constants.DEFAULT_DATE_FORMAT_PATTERN); try {//ww w .ja v a 2s. com Date date1 = new Date(dateFormat.parse(parentAnswer).getTime()); Date date2 = new Date(dateFormat.parse(conditionValue).getTime()); valid = (ConditionType.BEFORE_DATE.getCondition().equals(condition) && (date1.before(date2))) || (ConditionType.AFTER_DATE.getCondition().equals(condition) && (date1.after(date2))); } catch (Exception e) { } } return valid; }
From source file:org.kuali.kra.questionnaire.QuestionnaireMaintenanceDocumentRule.java
/** * /*from w ww .j a va2 s. c om*/ * This method to check whether if the required fields are ok and whether name exists. * @param maintenanceDocument * @return */ private boolean validateQuestionnaire(MaintenanceDocument maintenanceDocument) { boolean valid = true; Questionnaire newQuestionnaire = (Questionnaire) maintenanceDocument.getNewMaintainableObject() .getBusinessObject(); MessageMap errorMap = GlobalVariables.getErrorMap(); if (StringUtils.isBlank(newQuestionnaire.getName())) { errorMap.putError("document.newMaintainableObject.businessObject.name", RiceKeyConstants.ERROR_REQUIRED, "Questionnaire Name"); valid = false; } if (StringUtils.isBlank(newQuestionnaire.getDescription())) { errorMap.putError("document.newMaintainableObject.businessObject.description", RiceKeyConstants.ERROR_REQUIRED, "Questionnaire Description"); valid = false; } if (getQuestionnaireService().isQuestionnaireNameExist(newQuestionnaire.getQuestionnaireId(), newQuestionnaire.getName())) { errorMap.putError("document.newMaintainableObject.businessObject.name", KeyConstants.ERROR_QUESTIONNAIRE_NAME_EXIST); valid = false; } if (StringUtils.isNotBlank(newQuestionnaire.getFileName()) && !StringUtils.endsWithIgnoreCase(newQuestionnaire.getFileName(), ".xsl")) { errorMap.putError("document.newMaintainableObject.businessObject.fileName", KeyConstants.ERROR_QUESTIONNAIRE_FILENAME_INVALID); valid = false; } for (QuestionnaireQuestion questionnaireQuestion : newQuestionnaire.getQuestionnaireQuestions()) { if ((questionnaireQuestion.getQuestion() != null) && ("I".equals(questionnaireQuestion.getQuestion().getStatus()))) { errorMap.putError( "document.newMaintainableObject.businessObject.question" + newQuestionnaire.getQuestionnaireQuestions().indexOf(questionnaireQuestion), KeyConstants.ERROR_QUESTIONNAIRE_QUESTION_INACTIVE, questionnaireQuestion.getQuestion().getQuestion()); valid = false; } } return valid; }
From source file:org.kuali.student.enrollment.class2.courseoffering.service.impl.CourseOfferingCodeGeneratorDBImpl.java
protected String getNextCode(String source) { if (StringUtils.isEmpty(source)) { return "A"; } else if (StringUtils.endsWithIgnoreCase(source, "Z")) { return getNextCode(StringUtils.substringBeforeLast(source, "Z")) + "A"; } else {//from w w w.j a v a 2s. co m char lastLetter = source.charAt(source.length() - 1); return StringUtils.substringBeforeLast(source, "" + lastLetter) + ++lastLetter; } }
From source file:org.kuali.student.enrollment.class2.courseoffering.service.impl.CourseOfferingCodeGeneratorImpl.java
/** * Gets the next letter of the alphabet in caps in the form A,B...Z,AA,AB...AZ,BA,BB..BZ,CA,CB....ZZ,AAA,AAB... * * Make sure it's public as it's needed for Test class * * @param source source code string//w w w . j a v a2s. c o m * @return next code */ public String getNextCode(String source) { if (StringUtils.isEmpty(source)) { return "A"; } else if (StringUtils.endsWithIgnoreCase(source, "Z")) { return getNextCode(StringUtils.substringBeforeLast(source, "Z")) + "A"; } else { char lastLetter = source.charAt(source.length() - 1); return StringUtils.substringBeforeLast(source, "" + lastLetter) + ++lastLetter; } }
From source file:org.kuali.student.enrollment.class2.courseoffering.service.impl.TestCourseOfferingCodeGeneratorImpl.java
public String getNextCode(String source) { if (StringUtils.isEmpty(source)) { return "A"; } else if (StringUtils.endsWithIgnoreCase(source, "Z")) { return getNextCode(StringUtils.substringBeforeLast(source, "Z")) + "A"; } else {//from www. j av a 2s . c o m char lastLetter = source.charAt(source.length() - 1); return StringUtils.substringBeforeLast(source, "" + lastLetter) + ++lastLetter; } }
From source file:org.mifos.platform.questionnaire.matchers.EventSourceMatcher.java
@Override public boolean matchesSafely(EventSourceDto eventSourceDto) { return StringUtils.endsWithIgnoreCase(this.eventSourceDto.getDescription(), eventSourceDto.getDescription()) && StringUtils.endsWithIgnoreCase(this.eventSourceDto.getSource(), eventSourceDto.getSource()) && StringUtils.endsWithIgnoreCase(this.eventSourceDto.getEvent(), eventSourceDto.getEvent()); }
From source file:org.ngrinder.agent.service.AgentManagerService.java
@Override public Map<String, MutableInt> getAvailableAgentCountMap(User user) { int availableShareAgents = 0; int availableUserOwnAgent = 0; String myAgentSuffix = "owned_" + user.getUserId(); for (AgentInfo agentInfo : getAllActive()) { // Skip all agents which are disapproved, inactive or // have no region prefix. if (!agentInfo.isApproved()) { continue; }/* w w w . j a va2 s . c o m*/ String fullRegion = agentInfo.getRegion(); // It's this controller's agent if (StringUtils.endsWithIgnoreCase(fullRegion, myAgentSuffix)) { availableUserOwnAgent++; } else if (!StringUtils.containsIgnoreCase(fullRegion, "owned_")) { availableShareAgents++; } } int maxAgentSizePerConsole = getMaxAgentSizePerConsole(); availableShareAgents = (Math.min(availableShareAgents, maxAgentSizePerConsole)); Map<String, MutableInt> result = new HashMap<String, MutableInt>(1); result.put(Config.NONE_REGION, new MutableInt(availableShareAgents + availableUserOwnAgent)); return result; }
From source file:org.openhab.io.neeo.internal.models.NeeoSensorNotification.java
/** * Instantiates a new neeo notification from the sensor type, key, item name and data. * * @param overrideType the sensor notification type * @param deviceKey the non-null, non-empty device key * @param itemName the non-null, non-empty item name * @param data the possibly null, possibly empty (if a string) data *//*ww w. j a va2 s .com*/ public NeeoSensorNotification(@Nullable String overrideType, String deviceKey, String itemName, @Nullable Object data) { NeeoUtil.requireNotEmpty(deviceKey, "deviceKey cannot be empty"); NeeoUtil.requireNotEmpty(itemName, "itemName cannot be empty"); this.type = overrideType == null || StringUtils.isEmpty(overrideType) ? NeeoConstants.NEEO_SENSOR_NOTIFICATION_TYPE : overrideType; this.data = new SensorNotificationData( deviceKey + ":" + itemName + (StringUtils.endsWithIgnoreCase(itemName, NeeoConstants.NEEO_SENSOR_SUFFIX) ? "" : NeeoConstants.NEEO_SENSOR_SUFFIX), data == null || (data instanceof String && StringUtils.isEmpty(data.toString())) ? "-" : data); }