List of usage examples for java.lang String compareToIgnoreCase
public int compareToIgnoreCase(String str)
From source file:com.cisco.ctao.sparkapi.webhookserver.HttpEventProcessor.java
@Override public void handle(String target, Request baseRequest, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException, ServletException { response = null;/* w ww.ja v a2 s.com*/ httpRSC = HttpServletResponse.SC_OK; final String method = baseRequest.getMethod().toLowerCase(); final String uri = baseRequest.getRequestURI().trim(); final String payload = IOUtils.toString(baseRequest.getInputStream()).trim(); LOG.debug(">>>> handle: received http message: start"); LOG.debug("Method: {}, URI: '{}', RemoteAddr: {}", method, uri, baseRequest.getRemoteAddr()); if (method.compareToIgnoreCase("POST") == 0 || method.compareToIgnoreCase("PUT") == 0) { processHttpMessage(baseRequest, uri, payload); } sendHttpResponse(httpResponse); baseRequest.setHandled(true); LOG.debug("<<<< handle: received http message: end"); }
From source file:org.mrgeo.cmd.ingest.IngestImage.java
private double parseNoData(String fromArg) throws NumberFormatException { String arg = fromArg.trim(); if (arg.compareToIgnoreCase("nan") != 0) { return Double.parseDouble(arg); } else {//from ww w .j a v a 2 s. co m return Double.NaN; } }
From source file:com.sfs.whichdoctor.xml.event.PersonXmlEventImpl.java
/** * Gets the financial url./*from ww w . java 2 s .c o m*/ * * @param type the type * @param guid the guid * @param preferences the preferences * * @return the financial url */ private String getFinancialUrl(final String type, final int guid, final PreferencesBean preferences) { String url = ""; if (type != null) { if (type.compareToIgnoreCase("Credit") == 0) { url = preferences.buildUrl("read", "credits", "guid", guid); } if (type.compareToIgnoreCase("Debit") == 0) { url = preferences.buildUrl("read", "debits", "guid", guid); } if (type.compareToIgnoreCase("Receipt") == 0) { url = preferences.buildUrl("read", "receipts", "guid", guid); } } return url; }
From source file:org.openmrs.module.pmtct.web.view.chart.MaternityPieChartView.java
/** * @see org.openmrs.module.pmtct.web.view.chart.AbstractChartView#createChart(java.util.Map, * javax.servlet.http.HttpServletRequest) */// w ww . j ava2 s . c om @Override protected JFreeChart createChart(Map<String, Object> model, HttpServletRequest request) { UserContext userContext = Context.getUserContext(); ApplicationContext appContext = ContextProvider.getApplicationContext(); PMTCTModuleTag tag = new PMTCTModuleTag(); List<Object> res = new ArrayList<Object>(); PmtctService pmtct; pmtct = Context.getService(PmtctService.class); String startDate = ""; String endDate = ""; DefaultPieDataset pieDataset = new DefaultPieDataset(); String title = "", descriptionTitle = "", dateInterval = ""; Concept concept = null; Encounter enc = null; SimpleDateFormat df = MohTracUtil.getMySQLDateFormat();//new SimpleDateFormat("dd/MM/yyyy"); if (request.getParameter("type").compareTo("1") == 0) { try { // Date myDate = new Date("1/1/" + ((new Date()).getYear() + 1900)); // startDate = df.format(myDate); Date today = new Date(); Date oneYearFromNow = new Date(new Date().getTime() - PMTCTConstants.YEAR_IN_MILLISECONDS); endDate = df.format(today); startDate = df.format(oneYearFromNow); dateInterval = "(" + new SimpleDateFormat("dd-MMM-yyyy").format(oneYearFromNow) + " - " + new SimpleDateFormat("dd-MMM-yyyy").format(today) + ")"; res = pmtct.getGeneralStatsForPatientsInMaternity(startDate, endDate); List<String> childBornOptions = new ArrayList<String>(); List<Integer> childBornStatusValues = new ArrayList<Integer>(); Collection<ConceptAnswer> answers = Context.getConceptService() .getConcept(PMTCTConfigurationUtils.getBornStatusConceptId()).getAnswers(); for (ConceptAnswer str : answers) { childBornOptions.add(str.getAnswerConcept().getName().getName()); childBornStatusValues.add(0); } childBornOptions.add("Others"); childBornStatusValues.add(0); for (Object ob : res) { int patientId = (Integer) ((Object[]) ob)[0]; Encounter matEnc = tag.getMaternityEncounterInfo(patientId); String childResult = tag.observationValueByConcept(matEnc, PMTCTConfigurationUtils.getBornStatusConceptId()); int i = 0; boolean found = false; for (String s : childBornOptions) { if ((s.compareToIgnoreCase(childResult)) == 0) { childBornStatusValues.set(i, childBornStatusValues.get(i) + 1); found = true; } i++; } if (!found) { childBornStatusValues.set(childBornStatusValues.size() - 1, childBornStatusValues.get(childBornStatusValues.size() - 1) + 1); } } int i = 0; for (String s : childBornOptions) { if (childBornStatusValues.get(i) > 0) { Float percentage = new Float(100 * childBornStatusValues.get(i) / res.size()); pieDataset.setValue(s + " (" + childBornStatusValues.get(i) + " , " + percentage + "%)", percentage); } i++; } concept = Context.getConceptService().getConcept(PMTCTConfigurationUtils.getBornStatusConceptId()); } catch (Exception ex) { ex.printStackTrace(); } title = MohTracUtil.getMessage("pmtct.menu.maternity", null); } else if (request.getParameter("type").compareTo("2") == 0) { try { res = pmtct.getExpectedPatientsInMaternity(); String patientHivStatus = "", partnerHivStatus = ""; int allPositive = 0, allNegative = 0, negPos = 0, posNeg = 0, other = 0; for (Object ob : res) { int patientId = (Integer) ((Object[]) ob)[0]; enc = tag.getCPNEncounterInfo(patientId); patientHivStatus = tag.observationValueByConcept(enc, PMTCTConstants.RESULT_OF_HIV_TEST); partnerHivStatus = tag.observationValueByConcept(enc, PMTCTConstants.TESTING_STATUS_OF_PARTNER); if (patientHivStatus.compareTo(partnerHivStatus) == 0 && patientHivStatus.compareTo(Context .getConceptService().getConcept(PMTCTConstants.POSITIVE).getName().getName()) == 0) allPositive += 1; else if (patientHivStatus.compareTo(partnerHivStatus) == 0 && patientHivStatus.compareTo(Context .getConceptService().getConcept(PMTCTConstants.NEGATIVE).getName().getName()) == 0) allNegative += 1; else if (patientHivStatus .compareTo(Context.getConceptService().getConcept(PMTCTConstants.NEGATIVE).getName() .getName()) == 0 && partnerHivStatus.compareTo(Context.getConceptService() .getConcept(PMTCTConstants.POSITIVE).getName().getName()) == 0) negPos += 1; else if (patientHivStatus .compareTo(Context.getConceptService().getConcept(PMTCTConstants.POSITIVE).getName() .getName()) == 0 && partnerHivStatus.compareTo(Context.getConceptService() .getConcept(PMTCTConstants.NEGATIVE).getName().getName()) == 0) posNeg += 1; else other += 1; } Float percentage = 0f; if (allPositive > 0) { percentage = new Float(100 * allPositive / res.size()); title = MohTracUtil.getMessage("pmtct.menu.allPositive", null); pieDataset.setValue(title + " (" + allPositive + " , " + percentage + "%)", percentage); } if (allNegative > 0) { percentage = new Float(100 * allNegative / res.size()); title = MohTracUtil.getMessage("pmtct.menu.allNegative", null); pieDataset.setValue(title + " (" + allNegative + " , " + percentage + "%)", percentage); } if (posNeg > 0) { percentage = new Float(100 * posNeg / res.size()); title = MohTracUtil.getMessage("pmtct.menu.posNeg", null); pieDataset.setValue(title + " (" + posNeg + " , " + percentage + "%)", percentage); } if (negPos > 0) { percentage = new Float(100 * negPos / res.size()); title = MohTracUtil.getMessage("pmtct.menu.negPos", null); pieDataset.setValue(title + " (" + negPos + " , " + percentage + "%)", percentage); } if (other > 0) { percentage = new Float(100 * other / res.size()); title = MohTracUtil.getMessage("pmtct.menu.otherStatus", null); pieDataset.setValue(title + " (" + other + " , " + percentage + "%)", percentage); } title = MohTracUtil.getMessage("pmtct.menu.expectedMaternityPatient", null); descriptionTitle = MohTracUtil.getMessage("pmtct.menu.partnerStatus", null); concept = null; } catch (Exception e) { e.printStackTrace(); } } else if (request.getParameter("type").compareTo("3") == 0) { log.info(">>>>>>>>>>>>>>GRAPHICS>>patientsTestedInDeliveryRoom>>>Starting..."); try { // Date myDate = new Date("1/1/" + ((new Date()).getYear() + 1900)); // startDate = df.format(myDate); Date today = new Date(); Date oneYearFromNow = new Date(new Date().getTime() - PMTCTConstants.YEAR_IN_MILLISECONDS); endDate = df.format(today); startDate = df.format(oneYearFromNow); log.info(">>>>>>>>>>>>>>GRAPHICS>>patientsTestedInDeliveryRoom>>>startdate=" + startDate + " - endDate" + endDate); dateInterval = "(" + new SimpleDateFormat("dd-MMM-yyyy").format(oneYearFromNow) + " - " + new SimpleDateFormat("dd-MMM-yyyy").format(today) + ")"; res = pmtct.getpatientsTestedInDeliveryRoom(startDate, endDate); log.info(">>>>>>>>>>>>>>GRAPHICS>>patientsTestedInDeliveryRoom>>>Result=" + res.size()); // log.info(">>>>>>>>>>>>>>MaternityPieChartView>> startdate=" + startDate + "----- enddate=" + endDate // + "<<=====>>" + res.size()); List<String> resultOfHIVTestOptions = new ArrayList<String>(); List<Integer> resultOfHIVTestValues = new ArrayList<Integer>(); Collection<ConceptAnswer> answers = Context.getConceptService() .getConcept(PMTCTConstants.RESULT_HIV_TEST_IN_DELIVERY_ROOM).getAnswers(); for (ConceptAnswer str : answers) { resultOfHIVTestOptions.add(str.getAnswerConcept().getName().getName()); resultOfHIVTestValues.add(0); } resultOfHIVTestOptions.add("Others"); resultOfHIVTestValues.add(0); for (Object ob : res) { int patientId = (Integer) ((Object[]) ob)[0]; Encounter matEnc = tag.getMaternityEncounterInfo(patientId); String hivTestResult = tag.observationValueByConcept(matEnc, PMTCTConstants.RESULT_HIV_TEST_IN_DELIVERY_ROOM); int i = 0; boolean found = false; for (String s : resultOfHIVTestOptions) { if ((s.compareToIgnoreCase(hivTestResult)) == 0) { resultOfHIVTestValues.set(i, resultOfHIVTestValues.get(i) + 1); found = true; } i++; } if (!found) { resultOfHIVTestValues.set(resultOfHIVTestValues.size() - 1, resultOfHIVTestValues.get(resultOfHIVTestValues.size() - 1) + 1); } } int i = 0; for (String s : resultOfHIVTestOptions) { if (resultOfHIVTestValues.get(i) > 0) { Float percentage = new Float(100 * resultOfHIVTestValues.get(i) / res.size()); pieDataset.setValue(s + " (" + resultOfHIVTestValues.get(i) + " , " + percentage + "%)", percentage); } i++; } concept = Context.getConceptService() .getConcept(PMTCTConfigurationUtils.getHivTestInDeliveryRoomConceptId()); log.info(">>>>>>>>>>>>>>GRAPHICS>>patientsTestedInDeliveryRoom>>>End"); } catch (Exception ex) { log.error(">>>>>>>>>An error occured when trying to create piechart..."); ex.printStackTrace(); } title = appContext.getMessage("pmtct.menu.maternity", null, userContext.getLocale()); } JFreeChart chart = ChartFactory.createPieChart(title + " : " + ((null != concept) ? concept.getPreferredName(userContext.getLocale()) + dateInterval : descriptionTitle), pieDataset, true, true, false); return chart; }
From source file:com.trendrr.oss.networking.strest.StrestHeaders.java
Set<String> getHeaderNames() { Set<String> names = new TreeSet<String>(new Comparator<String>() { @Override/*www . j av a2 s.c om*/ public int compare(String o1, String o2) { return o1.compareToIgnoreCase(o2); } }); Entry e = head.after; while (e != head) { names.add(e.key); e = e.after; } return names; }
From source file:de.hybris.platform.solrfacetsearch.integration.FacetDrillDownTest.java
private void checkOrderByName(final Collection<ProductModel> products) { String previousName = ""; for (final ProductModel product : products) { assertTrue(String.format("Products not sorted by 'name'. '%s' should come before '%s' ", previousName, product.getName()), previousName.compareToIgnoreCase(product.getName()) <= 0); previousName = product.getName(); }/*w w w. java 2 s. co m*/ }
From source file:org.apache.axis2.deployment.ModuleBuilder.java
/** * Fill in the AxisModule I'm holding from the module.xml configuration. * * @throws DeploymentException if there's a problem with the module.xml */// w w w . j av a2 s. co m public void populateModule() throws DeploymentException { try { OMElement moduleElement = buildOM(); // Setting Module Class , if it is there OMAttribute moduleClassAtt = moduleElement.getAttribute(new QName(TAG_CLASS_NAME)); // processing Parameters // Processing service level parameters Iterator itr = moduleElement.getChildrenWithName(new QName(TAG_PARAMETER)); processParameters(itr, module, module.getParent()); Parameter childFirstClassLoading = module .getParameter(Constants.Configuration.ENABLE_CHILD_FIRST_CLASS_LOADING); if (childFirstClassLoading != null) { DeploymentClassLoader deploymentClassLoader = (DeploymentClassLoader) module.getModuleClassLoader(); if (JavaUtils.isTrueExplicitly(childFirstClassLoading.getValue())) { deploymentClassLoader.setChildFirstClassLoading(true); } else if (JavaUtils.isFalseExplicitly(childFirstClassLoading.getValue())) { deploymentClassLoader.setChildFirstClassLoading(false); } } if (moduleClassAtt != null) { String moduleClass = moduleClassAtt.getAttributeValue(); if ((moduleClass != null) && !"".equals(moduleClass)) { loadModuleClass(module, moduleClass); } } // Get our name and version. If this is NOT present, we'll try to figure it out // from the file name (e.g. "addressing-1.0.mar"). If the attribute is there, we // always respect it. //TODO: Need to check whether ths name is getting overridden by the file name of the MAR OMAttribute nameAtt = moduleElement.getAttribute(new QName("name")); if (nameAtt != null) { String moduleName = nameAtt.getAttributeValue(); if (moduleName != null && !"".equals(moduleName)) { module.setName(moduleName); } } if (log.isDebugEnabled()) { log.debug("populateModule: Building module description for: " + module.getName()); } // Process service description OMElement descriptionElement = moduleElement.getFirstChildWithName(new QName(TAG_DESCRIPTION)); if (descriptionElement != null) { OMElement descriptionValue = descriptionElement.getFirstElement(); if (descriptionValue != null) { StringWriter writer = new StringWriter(); descriptionValue.build(); descriptionValue.serialize(writer); writer.flush(); module.setModuleDescription(writer.toString()); } else { module.setModuleDescription(descriptionElement.getText()); } } else { module.setModuleDescription("module description not found"); } // Processing Dynamic Phase Iterator phaseItr = moduleElement.getChildrenWithName(new QName(TAG_PHASE)); processModulePhase(phaseItr); // setting the PolicyInclude // processing <wsp:Policy> .. </..> elements Iterator policyElements = moduleElement.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY)); if (policyElements != null && policyElements.hasNext()) { processPolicyElements(policyElements, module.getPolicySubject()); } // processing <wsp:PolicyReference> .. </..> elements Iterator policyRefElements = moduleElement .getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_REF)); if (policyRefElements != null && policyRefElements.hasNext()) { processPolicyRefElements(policyRefElements, module.getPolicySubject()); } // process flows (case-insensitive) Iterator flows = moduleElement.getChildElements(); while (flows.hasNext()) { OMElement flowElement = (OMElement) flows.next(); final String flowName = flowElement.getLocalName(); if (flowName.compareToIgnoreCase(TAG_FLOW_IN) == 0) { module.setInFlow(processFlow(flowElement, module)); } else if (flowName.compareToIgnoreCase(TAG_FLOW_OUT) == 0) { module.setOutFlow(processFlow(flowElement, module)); } else if (flowName.compareToIgnoreCase(TAG_FLOW_IN_FAULT) == 0) { module.setFaultInFlow(processFlow(flowElement, module)); } else if (flowName.compareToIgnoreCase(TAG_FLOW_OUT_FAULT) == 0) { module.setFaultOutFlow(processFlow(flowElement, module)); } } OMElement supportedPolicyNamespaces = moduleElement .getFirstChildWithName(new QName(TAG_SUPPORTED_POLICY_NAMESPACES)); if (supportedPolicyNamespaces != null) { module.setSupportedPolicyNamespaces(processSupportedPolicyNamespaces(supportedPolicyNamespaces)); } /* * Module description should contain a list of QName of the assertions that are local to the system. * These assertions are not exposed to the outside. */ OMElement localPolicyAssertionElement = moduleElement .getFirstChildWithName(new QName("local-policy-assertions")); if (localPolicyAssertionElement != null) { module.setLocalPolicyAssertions(getLocalPolicyAssertionNames(localPolicyAssertionElement)); } // processing Operations Iterator op_itr = moduleElement.getChildrenWithName(new QName(TAG_OPERATION)); ArrayList<AxisOperation> operations = processOperations(op_itr); for (AxisOperation op : operations) { module.addOperation(op); } if (log.isDebugEnabled()) { log.debug("populateModule: Done building module description"); } } catch (XMLStreamException e) { throw new DeploymentException(e); } catch (AxisFault e) { throw new DeploymentException(e); } }
From source file:org.gbif.portal.webservices.actions.ResourceAction.java
/** * Gets a Data Resource given some parameters * //from w w w. j a v a 2s. c o m * @param params * @return * @throws GbifWebServiceException */ @SuppressWarnings("unchecked") public Map<String, Object> getResourceRecord(ResourceParameters params) throws GbifWebServiceException { Map<String, String> headerMap; Map<String, String> parameterMap; Map<String, String> summaryMap = null; Map<String, Object> results = new HashMap<String, Object>(); Set<DataResourceDTO> list = new HashSet<DataResourceDTO>(); headerMap = returnHeader(params, true); parameterMap = returnParameters(params.getParameterMap(null)); //Map with the Provider name as the key Map<String, Set<Map<String, Object>>> dataProviderMap = new HashMap<String, Set<Map<String, Object>>>(); try { DataResourceDTO dataResourceDTO = dataResourceManager.getDataResourceFor(params.getKey()); List<DataResourceDTO> set = new ArrayList<DataResourceDTO>(); set.add(dataResourceDTO); summaryMap = returnSummary(params, set, true); Map<ResourceAccessPointDTO, List<PropertyStoreNamespaceDTO>> resourceAccessPointMap = new HashMap<ResourceAccessPointDTO, List<PropertyStoreNamespaceDTO>>(); Map<String, Object> dataResourceMap = new HashMap<String, Object>(); List<ResourceAccessPointDTO> resourceAccessPointDTOList = dataResourceManager .getResourceAccessPointsForDataResource(dataResourceDTO.getKey()); List<ResourceNetworkDTO> resourceNetworkDTOList = dataResourceManager .getResourceNetworksForDataResource(dataResourceDTO.getKey()); //iterate over the ResourceAccessPoints to obtain the PropertyStoreNamespaces for (ResourceAccessPointDTO resourceAccessPointDTO : resourceAccessPointDTOList) { List<PropertyStoreNamespaceDTO> propertyStoreNamespaceDTOList = dataResourceManager .getPropertyStoreNamespacesForResourceAccessPoint(resourceAccessPointDTO.getKey()); //associate each ResourceAccessPointDTO to a list of PropertyStoreNamespace resourceAccessPointMap.put(resourceAccessPointDTO, propertyStoreNamespaceDTOList); } dataResourceMap.put("dataResourceDTO", dataResourceDTO); dataResourceMap.put("resourceNetworkDTOList", resourceNetworkDTOList); dataResourceMap.put("resourceAccessPointMap", resourceAccessPointMap); if (dataProviderMap.get(dataResourceDTO.getDataProviderKey()) != null) { Set<Map<String, Object>> dataResourceMapListForProvider = dataProviderMap .get(dataResourceDTO.getDataProviderKey()); dataResourceMapListForProvider.add(dataResourceMap); dataProviderMap.put(dataResourceDTO.getDataProviderKey(), dataResourceMapListForProvider); } else { Set<Map<String, Object>> dataResourceMapListForProvider = new HashSet<Map<String, Object>>(); dataResourceMapListForProvider.add(dataResourceMap); dataProviderMap.put(dataResourceDTO.getDataProviderKey(), dataResourceMapListForProvider); } //creates the set of TaxonConcept maps Set<Map<String, Object>> taxonConceptMapSet = new TreeSet<Map<String, Object>>(new Comparator() { public int compare(Object a, Object b) { TaxonConceptDTO taxonConcept1 = (TaxonConceptDTO) ((Map) a).get("taxonConceptDTO"); TaxonConceptDTO taxonConcept2 = (TaxonConceptDTO) ((Map) b).get("taxonConceptDTO"); String key1 = taxonConcept1.getTaxonName(); String key2 = taxonConcept2.getTaxonName(); return key1.compareToIgnoreCase(key2); } }); //get taxon concepts List<BriefTaxonConceptDTO> rootConcepts = taxonomyManager.getRootTaxonConceptsForTaxonomy(null, dataResourceDTO.getKey()); if (rootConcepts != null && rootConcepts.size() > 0) { //TaxonConcepts taxonConcepts = resource.addNewTaxonConcepts(); for (BriefTaxonConceptDTO rootConcept : rootConcepts) { TaxonConceptDTO rootDto = taxonomyManager.getTaxonConceptFor(rootConcept.getKey()); Map<String, Object> taxonConceptMap = new HashMap<String, Object>(); //add a new taxon concept map taxonConceptMap.put("taxonConceptDTO", rootDto); taxonConceptMapSet.add(taxonConceptMap); } } results.put("count", 1); results.put("results", dataProviderMap); results.put("taxonConceptMapSet", taxonConceptMapSet); results.put("headerMap", headerMap); results.put("parameterMap", parameterMap); results.put("summaryMap", summaryMap); } catch (ServiceException se) { log.error("Data service error: " + se.getMessage(), se); throw new GbifWebServiceException("Data service problems - " + se.getMessage()); } catch (Exception se) { log.error("Data service error: " + se.getMessage(), se); throw new GbifWebServiceException("Data service problems - " + se.toString()); } return results; }
From source file:org.owasp.dependencycheck.dependency.Evidence.java
/** * Wrapper around {@link java.lang.String#compareToIgnoreCase(java.lang.String) String.compareToIgnoreCase} with an * exhaustive, possibly duplicative, check against nulls. * * @param me the value to be compared * @param other the other value to be compared * @return true if the values are equal; otherwise false *//*from w w w . j a v a 2 s. c o m*/ private int compareToIgnoreCaseWithNullCheck(String me, String other) { if (me == null && other == null) { return 0; } else if (me == null) { return -1; //the other string is greater then me } else if (other == null) { return 1; //me is greater then the other string } return me.compareToIgnoreCase(other); }
From source file:org.openmrs.module.logmanager.impl.LogManagerServiceImpl.java
/** * @see org.openmrs.module.logmanager.LogManagerService#getAppenders() *///from w ww . j a va 2 s . com public Collection<AppenderProxy> getAppenders(boolean sorted) { Set<AppenderProxy> appenders = ManagerProxy.getAppenders(); // Optionally sort into a list if (sorted) { List<AppenderProxy> appenderList = new ArrayList<AppenderProxy>(appenders); Collections.sort(appenderList, new Comparator<AppenderProxy>() { public int compare(AppenderProxy ap1, AppenderProxy ap2) { String s1 = ap1.getName() != null ? ap1.getName() : ""; String s2 = ap2.getName() != null ? ap2.getName() : ""; return s1.compareToIgnoreCase(s2); } }); return appenderList; } else return appenders; }