List of usage examples for java.lang String compareToIgnoreCase
public int compareToIgnoreCase(String str)
From source file:org.apache.sysml.validation.ValidateLicAndNotice.java
/** * This will validate all archives from distribution location. * * @return Returns the output code//from w w w .j a v a 2s . co m */ public int validate() throws Exception { int retCode = Constants.SUCCESS, retCodeForAllFileTypes = Constants.SUCCESS, retCodeAll = Constants.SUCCESS; File distroRoot = new File(getDistroDir()); File libDirectory = distroRoot; if (!libDirectory.exists()) { Utility.debugPrint(Constants.DEBUG_ERROR, "Distribution folder '" + libDirectory.getAbsoluteFile().toString() + "' does not exist."); return Constants.NO_ZIP_TGZ; } File outTempDir = File.createTempFile("outTemp", ""); outTempDir.delete(); outTempDir.mkdir(); List<String> zips = getZipsInDistro(libDirectory); if (zips.size() == 0) { Utility.debugPrint(Constants.DEBUG_ERROR, "Can't find archives in folder: " + libDirectory.getAbsoluteFile().toString()); return Constants.NO_ZIP_TGZ; } for (String zipFile : zips) { retCodeForAllFileTypes = Constants.SUCCESS; Utility.debugPrint(Constants.DEBUG_INFO, "======================================================================================"); Utility.debugPrint(Constants.DEBUG_INFO, "Validating archive: " + zipFile + " ..."); for (String fileType : fileTypes) { retCode = Constants.SUCCESS; List<String> filesAll = null; // Extract license/notice only at first time in all filetypes validation for a given zip. if (fileType == Constants.JAR) { if (!ValidateLicAndNotice.extractFile(libDirectory + "/" + zipFile, Constants.LICENSE, outTempDir.getAbsolutePath(), true)) return Constants.FAILED_TO_EXTRACT; if (!ValidateLicAndNotice.extractFile(libDirectory + "/" + zipFile, Constants.NOTICE, outTempDir.getAbsolutePath(), true)) return Constants.FAILED_TO_EXTRACT; } filesAll = getFiles(libDirectory + "/" + zipFile, fileType); File licenseFile = new File(outTempDir, Constants.LICENSE); List<String> files = new ArrayList<String>(); List<String> fileSysml = new ArrayList<String>(); for (String file : filesAll) { int sysmlLen = Constants.SYSTEMML_NAME.length(); String strBegPart = file.substring(0, sysmlLen); if (strBegPart.compareToIgnoreCase(Constants.SYSTEMML_NAME) != 0) files.add(file); else fileSysml.add(file); } List<String> bad2 = getLICENSEFilesNotInList(licenseFile, files, fileType); if (bad2.size() > 0) { Utility.debugPrint(Constants.DEBUG_WARNING, "Files in LICENSE but not in Distribution: " + bad2); retCode += Constants.FILE_NOT_IN_ZIP; } List<String> bad1 = getFilesNotInLICENSE(licenseFile, files, fileType); if (bad1.size() > 0) { Utility.debugPrint(Constants.DEBUG_ERROR, "Files in distribution but not in LICENSE: " + bad1); retCode += Constants.FILE_NOT_IN_LIC; } // Validate shaded jar and notice only one time for each archive. if (fileType == Constants.JAR) { for (String file : fileSysml) retCode += ValidateLicAndNotice.validateShadedLic(libDirectory + "/" + zipFile, file, outTempDir.getAbsolutePath()); if (!validateNotice(outTempDir.getAbsolutePath() + "/" + Constants.NOTICE)) { Utility.debugPrint(Constants.DEBUG_ERROR, "Notice validation failed, please check notice file manually in this archive."); retCode += Constants.INVALID_NOTICE; } if (!validateJSCssLicense(licenseFile, libDirectory + "/" + zipFile)) { Utility.debugPrint(Constants.DEBUG_ERROR, "JS/CSS license validation failed, please check license file manually in this archive."); retCode += Constants.JS_CSS_LIC_NOT_EXIST; } } if (retCode == Constants.SUCCESS) Utility.debugPrint(Constants.DEBUG_INFO3, "Validation of file type '." + fileType + "' in archive " + zipFile + " completed successfully."); else { Utility.debugPrint(Constants.DEBUG_ERROR, "License/Notice validation failed for archive " + zipFile + " with error code " + retCode + ", please validate file manually."); retCodeForAllFileTypes = Constants.FAILURE; } } if (retCodeForAllFileTypes == Constants.SUCCESS) Utility.debugPrint(Constants.DEBUG_INFO, "Validation of archive " + zipFile + " completed successfully."); retCodeAll = retCodeForAllFileTypes != Constants.SUCCESS ? Constants.FAILURE : retCodeAll; } Utility.debugPrint(Constants.DEBUG_INFO, "======================================================================================"); FileUtils.deleteDirectory(outTempDir); return retCodeAll; }
From source file:org.openmrs.module.pmtct.web.controller.PmtctHomeGeneralController.java
/** * @see org.springframework.web.servlet.mvc.ParameterizableViewController#handleRequestInternal(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) *//*from www .j a v a2s. com*/ @Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { StringBuilder parameters = new StringBuilder(); parameters.append("page=1"); String startDate = ""; String endDate = ""; ModelAndView mav = new ModelAndView(); mav.setViewName(getViewName()); PmtctService pmtct; List<Object> result = new ArrayList<Object>(); String pageNumber; int pageSize; List<Object> res; List<Integer> numberOfPages; try { pageNumber = request.getParameter("page"); pageSize = PMTCTConfigurationUtils.getNumberOfRecordPerPage(); // config = PMTCTConfiguration.getInstance(request.getRealPath(PMTCTConstants.CONFIGURATION_FILE_LOC)); // constants = config.getConstants(); // request.getSession().setAttribute("enableModification", "" + config.isModificationEnabled()); request.getSession().setAttribute("pmtctModuleConfigured", "" + PMTCTConfigurationUtils.isConfigured()); if (pageNumber.compareToIgnoreCase("1") == 0 || pageNumber.compareToIgnoreCase("") == 0) { pmtct = Context.getService(PmtctService.class); // pmtct.setPMTCTProgrmaId(constants); res = new ArrayList<Object>(); if (request.getParameter("ckbxPeriod") == null) res = pmtct.getCurrentPatientsInPmtct(); else { parameters.append("&ckbxPeriod=" + request.getParameter("ckbxPeriod")); if (null != request.getParameter("startDate") && "" != request.getParameter("startDate").trim()) { startDate = request.getParameter("startDate").trim(); parameters.append("&startDate=" + startDate); } if (null != request.getParameter("endDate") && "" != request.getParameter("endDate").trim()) { endDate = request.getParameter("endDate").trim(); parameters.append("&endDate=" + endDate); } res = pmtct.getCurrentPatientsInPmtct(startDate, endDate); request.getSession().setAttribute("home_gen_res", res); } //collection for (int i = 0; i < pageSize; i++) { if (res.size() == 0) break; if (i >= res.size() - 1) { result.add(res.get(i)); break; } else result.add(res.get(i)); } //paging int n = (res.size() == ((int) (res.size() / pageSize)) * pageSize) ? (res.size() / pageSize) : ((int) (res.size() / pageSize)) + 1; numberOfPages = new ArrayList<Integer>(); for (int i = 1; i <= n; i++) { numberOfPages.add(i); } request.getSession().setAttribute("home_gen_numberOfPages", numberOfPages); } else { res = (List<Object>) request.getSession().getAttribute("home_gen_res"); numberOfPages = (List<Integer>) request.getSession().getAttribute("home_gen_numberOfPages"); for (int i = (pageSize * (Integer.parseInt(pageNumber) - 1)); i < pageSize * (Integer.parseInt(pageNumber)); i++) { if (i >= res.size()) break; else result.add(res.get(i)); } } //page infos Object[] pagerInfos = new Object[3]; pagerInfos[0] = (res.size() == 0) ? 0 : (pageSize * (Integer.parseInt(pageNumber) - 1)) + 1; pagerInfos[1] = (pageSize * (Integer.parseInt(pageNumber)) <= res.size()) ? pageSize * (Integer.parseInt(pageNumber)) : res.size(); pagerInfos[2] = res.size(); ApplicationContext appContext = ContextProvider.getApplicationContext(); mav.addObject("pageInfos", appContext.getMessage("pmtct.pagingInfo.showingResults", pagerInfos, Context.getUserContext().getLocale())); mav.addObject("numberOfPages", numberOfPages); mav.addObject("patientList", result); mav.addObject("pageSize", pageSize); mav.addObject("parameters", parameters.toString()); mav.addObject("positiveId", PMTCTConstants.POSITIVE); mav.addObject("hivTestResultId", PMTCTConstants.RESULT_OF_HIV_TEST); FileExporter fexp = new FileExporter(); if (request.getParameter("export") != null && request.getParameter("export").compareToIgnoreCase("csv") == 0) { fexp.exportToCSVFile(request, response, res, "list_of_patients_in_pmtct_program.csv", "List of Patient in PMTCT Program"); } } catch (Exception ex) { request.getSession().setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "An error occured when trying to load data. Find the error in the log file."); log.error("An error occured when trying to load data from database: \n" + ex.getMessage()); ex.printStackTrace(); } return mav; }
From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.UploadField.java
/** * @return list valid values for this field's picklist, * or null if no picklist is defined for this field. */// w w w . ja v a2 s . co m protected Map<String, PickListItemIFace> buildValidValues() { if (getIndex() != -1 && getField().getFieldInfo() != null) { PickListDBAdapterIFace pickList = null; if (!StringUtils.isEmpty(getField().getFieldInfo().getPickListName())) { pickList = PickListDBAdapterFactory.getInstance() .create(getField().getFieldInfo().getPickListName(), false); } else if (RecordTypeCodeBuilder.isTypeCodeField(getField().getFieldInfo())) { pickList = RecordTypeCodeBuilder.getTypeCode(getField().getFieldInfo()); } else { pickList = checkForSpecialCasePicklist(); } if (pickList != null) { readOnlyValidValues = pickList.isReadOnly() && !(pickList instanceof PickListTableAdapter); picklistWarn = !readOnlyValidValues && pickList instanceof PickListTableAdapter; // TreeMap<String, PickListItemIFace> pickListItems = picklistWarn ? // new TreeMap<String, PickListItemIFace>(new Comparator<String>(){ // // /* (non-Javadoc) // * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) // */ // @Override // public int compare(String arg0, String arg1) { // if (arg0 == null && arg1 == null) return 0; // if (arg0 == null) return 1; // if (arg1 == null) return -1; // return arg0.compareToIgnoreCase(arg1); // } // // }) // : new TreeMap<String, PickListItemIFace>(); TreeMap<String, PickListItemIFace> pickListItems = new TreeMap<String, PickListItemIFace>( new Comparator<String>() { /* * (non-Javadoc) * * @see * java.util.Comparator#compare(java.lang.Object, * java.lang.Object) */ @Override public int compare(String arg0, String arg1) { if (arg0 == null && arg1 == null) return 0; if (arg0 == null) return 1; if (arg1 == null) return -1; return arg0.compareToIgnoreCase(arg1); } }); for (PickListItemIFace item : pickList.getList()) { pickListItems.put(item.getTitle(), item); } return pickListItems; } } return null; }
From source file:com.sfs.whichdoctor.dao.WhichDoctorDAOImpl.java
/** * Load sibling beans.//from w ww. j a v a 2s . c om * * @param guid the guid * @param type the type * * @return the tree map< integer, collection< which doctor bean>> * * @throws WhichDoctorDaoException the whichdoctor dao exception */ @SuppressWarnings("unchecked") private TreeMap<Integer, Collection<WhichDoctorBean>> loadSiblingBeans(final int guid, final String type) throws WhichDoctorDaoException { dataLogger.info("Sibling history of GUID: " + guid + " requested"); String loadSQL = getSQL().getValue("whichdoctor/load/memo"); if (type.compareToIgnoreCase("membership") == 0) { loadSQL = getSQL().getValue("whichdoctor/load/membership"); } if (type.compareToIgnoreCase("address") == 0) { loadSQL = getSQL().getValue("whichdoctor/load/address"); } if (type.compareToIgnoreCase("phone") == 0) { loadSQL = getSQL().getValue("whichdoctor/load/phone"); } if (type.compareToIgnoreCase("email") == 0) { loadSQL = getSQL().getValue("whichdoctor/load/email"); } if (type.compareToIgnoreCase("specialty") == 0) { loadSQL = getSQL().getValue("whichdoctor/load/specialty"); } if (type.compareToIgnoreCase("workshop") == 0) { loadSQL = getSQL().getValue("whichdoctor/load/workshop"); } if (type.compareToIgnoreCase("rotation") == 0) { loadSQL = getSQL().getValue("whichdoctor/load/rotationSibling"); } if (type.compareToIgnoreCase("project") == 0) { loadSQL = getSQL().getValue("whichdoctor/load/project"); } if (type.compareToIgnoreCase("exam") == 0) { loadSQL = getSQL().getValue("whichdoctor/load/exam"); } if (type.compareToIgnoreCase("qualification") == 0) { loadSQL = getSQL().getValue("whichdoctor/load/qualification"); } if (type.compareToIgnoreCase("accreditation") == 0) { loadSQL = getSQL().getValue("whichdoctor/load/accreditation"); } if (type.compareToIgnoreCase("assessment") == 0) { loadSQL = getSQL().getValue("whichdoctor/load/assessment"); } if (type.compareToIgnoreCase("report") == 0) { loadSQL = getSQL().getValue("whichdoctor/load/report"); } if (type.compareToIgnoreCase("expenseclaim") == 0) { loadSQL = getSQL().getValue("whichdoctor/load/expenseClaim"); } if (type.compareToIgnoreCase("payment") == 0) { loadSQL = getSQL().getValue("whichdoctor/load/payment"); } TreeMap<Integer, Collection<WhichDoctorBean>> siblings = new TreeMap<Integer, Collection<WhichDoctorBean>>(); try { Collection<WhichDoctorBean> siblingCollection = this.getJdbcTemplateReader().query(loadSQL, new Object[] { guid }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { WhichDoctorBean whichdoctorBean = loadHistory(rs); whichdoctorBean.setObjectType(type); return whichdoctorBean; } }); for (WhichDoctorBean whichdoctorBean : siblingCollection) { Collection<WhichDoctorBean> history = new ArrayList<WhichDoctorBean>(); if (siblings.containsKey(whichdoctorBean.getGUID())) { history = siblings.get(whichdoctorBean.getGUID()); } history.add(whichdoctorBean); siblings.put(whichdoctorBean.getGUID(), history); } } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for this search: " + ie.getMessage()); } return siblings; }
From source file:edu.du.penrose.systems.fedoraProxy.web.bus.OaiAggregator.java
@RequestMapping(method = RequestMethod.GET) public final void handleGet(@PathVariable String institution, // must be adr, see below @RequestParam(required = true, value = "verb") String oaiVerb, @RequestParam(required = false, value = "set") String set, @RequestParam(required = false, value = "metadataPrefix") String metadataPrefix, HttpServletRequest request, HttpServletResponse response) throws Exception { // MUST BE type EXCETION for annotation's to work! try {// ww w. j av a2 s . c o m if (institution.compareToIgnoreCase("adr") != 0) { response.setStatus(404); return; } if (oaiCommands.ListMetadataFormats.toString().compareToIgnoreCase(oaiVerb) == 0) { this.performListMetadataFormats(response, oaiVerb); } if (oaiCommands.ListSets.toString().compareToIgnoreCase(oaiVerb) == 0) { this.performListSets(response, oaiVerb); } if (oaiCommands.ListRecords.toString().compareToIgnoreCase(oaiVerb) == 0) { if (set == null || metadataPrefix == null || set.length() == 0 || metadataPrefix.length() == 0) { throw new Exception("Invalid list set command, missing set or metadataPrefix "); } this.performListRecords(response, oaiVerb, set, metadataPrefix, FORCE_NEW_DATE); } } catch (Exception e) { response.sendError(404); // need to send correct status here? TBD } }
From source file:com.orange.oidc.tim.service.Service.java
String sortScope(String scope) { // sort scope in alphabetical order if (scope != null) { scope = scope.toLowerCase(Locale.getDefault()); // offline_access is mandatory if (!scope.contains("offline_access")) { scope += " offline_access"; }/*from www.j a v a2 s.c o m*/ /* // and tim too for php oidc if ( !scope.contains("tim") ) { scope += " tim"; } */ String scopes[] = scope.split("\\ "); if (scopes != null) { Arrays.sort(scopes, new Comparator<String>() { @Override public int compare(String s1, String s2) { return s1.compareToIgnoreCase(s2); } }); scope = null; // filter null or empty strings for (int i = 0; i < scopes.length; i++) { if (scopes[i] != null && scopes[i].length() > 0) { if (scope == null) scope = scopes[i]; else scope += (" " + scopes[i]); } } } } return scope; }
From source file:com.t3.model.MacroButtonProperties.java
@Override public int compareTo(MacroButtonProperties b2) throws ClassCastException { if (b2 != this) { String b1group = getGroup(); if (b1group == null) b1group = ""; String b1sortby = getSortby(); if (b1sortby == null) b1sortby = ""; String b1label = getLabel(); if (b1label == null) b1label = ""; String b2group = b2.getGroup(); if (b2group == null) b2group = ""; String b2sortby = b2.getSortby(); if (b2sortby == null) b2sortby = ""; String b2label = b2.getLabel(); if (b2label == null) b2label = ""; // now parse the sort strings to help dice codes sort properly, use space as a separator String b1string = modifySortString(" " + b1group + " " + b1sortby + " " + b1label); String b2string = modifySortString(" " + b2group + " " + b2sortby + " " + b2label); return b1string.compareToIgnoreCase(b2string); }// www. j av a 2s.c o m return 0; }
From source file:org.msec.sink.es.ESSink.java
String getCurrentIndexName(String serviceName) { Calendar cal = Calendar.getInstance(); if (lastIndexRollingMinute.get(serviceName) != null && lastIndexRollingMinute.get(serviceName) .intValue() == (int) (System.currentTimeMillis() / 60000)) { //udpate indexType every minute return lastIndexRollingName.get(serviceName); }// w w w.j av a2 s .co m String currentIndexPrefix = "msec_" + serviceName; int splitNum = 1; String splitUnit = "day"; int pos = 0; while (pos < indexRollingTime.length() && Character.isDigit(indexRollingTime.charAt(pos))) ++pos; if (pos == 0) { splitNum = 1; } else if (pos < indexRollingTime.length()) { splitNum = Integer.valueOf(indexRollingTime.substring(0, pos).trim()); splitUnit = indexRollingTime.substring(pos).trim(); } else { splitNum = Integer.valueOf(indexRollingTime.trim()); } if (splitNum == 0) splitNum = 1; int month = cal.get(Calendar.MONTH) + 1; if (splitUnit.compareToIgnoreCase("day") == 0) { int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH); if (dayOfMonth % splitNum == 0 || currentIndexName.isEmpty()) currentIndexName = currentIndexPrefix + String.format("%02d%02d", month, dayOfMonth); } else if (splitUnit.compareToIgnoreCase("hour") == 0) { int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH); int hourOfDay = cal.get(Calendar.HOUR_OF_DAY); if (hourOfDay % splitNum == 0 || currentIndexName.isEmpty()) currentIndexName = currentIndexPrefix + String.format("%02d%02d%02d", month, dayOfMonth, hourOfDay); } else if (splitUnit.compareToIgnoreCase("min") == 0) { int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH); int hourOfDay = cal.get(Calendar.HOUR_OF_DAY); int minute = cal.get(Calendar.MINUTE); if (hourOfDay % splitNum == 0 || currentIndexName.isEmpty()) currentIndexName = currentIndexPrefix + String.format("%02d%02d%02d%02d", month, dayOfMonth, hourOfDay, minute); } lastIndexRollingMinute.put(serviceName, (int) (System.currentTimeMillis() / 60000)); lastIndexRollingName.put(serviceName, currentIndexName); return currentIndexName; }
From source file:org.sipfoundry.sipxconfig.rest.RestUtilities.java
public static int compareIgnoreCaseNullSafe(String left, String right) { String leftString = left; String rightString = right;//from ww w. j av a2s . com if (leftString == null) { leftString = EMPTY_STRING; } if (rightString == null) { rightString = EMPTY_STRING; } return leftString.compareToIgnoreCase(rightString); }
From source file:gov.nih.nci.evs.browser.utils.MappingSearchUtils.java
private String replaceAssociationNameByRela(AssociatedConcept ac, String associationName) { if (ac.getAssociationQualifiers() == null) return associationName; if (ac.getAssociationQualifiers().getNameAndValue() == null) return associationName; for (NameAndValue qual : ac.getAssociationQualifiers().getNameAndValue()) { String qualifier_name = qual.getName(); String qualifier_value = qual.getContent(); if (qualifier_name.compareToIgnoreCase("rela") == 0) { return qualifier_value; // replace associationName by Rela value }// ww w . j av a 2 s. c o m } return associationName; }