List of usage examples for java.lang String compareToIgnoreCase
public int compareToIgnoreCase(String str)
From source file:playground.dgrether.analysis.CountsAnalyser.java
/** * Writes the results of the comparison to a file * * @param filename//from w ww . ja v a2s.c om * the path to the kml file * @param format * the format kml or txt */ public void writeCountsComparisonList(final String filename, final String format) { if (format.compareToIgnoreCase("kml") == 0) { CountSimComparisonKMLWriter kmlWriter = new CountSimComparisonKMLWriter(countsComparisonList, this.network, TransformationFactory.getCoordinateTransformation(this.coordinateSystem, TransformationFactory.WGS84)); kmlWriter.writeFile(filename); } else if (format.compareToIgnoreCase("txt") == 0) { CountSimComparisonTableWriter writer = new CountSimComparisonTableWriter(countsComparisonList, Locale.US); writer.writeFile(filename); } else { throw new IllegalArgumentException("Output format must be txt or kml"); } ComparisonErrorStatsCalculator errorStats = new ComparisonErrorStatsCalculator(countsComparisonList); double[] hours = new double[24]; for (int i = 1; i < 25; i++) { hours[i - 1] = i; } DoubleArrayTableWriter tableWriter = new DoubleArrayTableWriter(); tableWriter.addColumn(hours); tableWriter.addColumn(errorStats.getMeanRelError()); tableWriter.writeFile(filename + "errortable.txt"); }
From source file:com.github.braully.graph.UtilResultMerge.java
static List<String> getOperationsSorted() { List<String> opers = new ArrayList<>(operations); Collections.sort(opers, new Comparator<String>() { public int compare(String t, String t1) { try { if (t != null && t1 != null) { t = t.toLowerCase(); t1 = t.toLowerCase(); if (t.contains(OPERACAO_REFERENCIA.toLowerCase()) || t.contains(OPERACAO_REFERENCIA_2.toLowerCase())) { t = "a" + t; }/*w w w . j av a 2s. c o m*/ if (t1.contains(OPERACAO_REFERENCIA.toLowerCase()) || t1.contains(OPERACAO_REFERENCIA_2.toLowerCase())) { t1 = "a" + t1; } return t.compareToIgnoreCase(t1); } } catch (Exception e) { } return 0; } }); return opers; }
From source file:org.openmrs.module.chica.rule.ChicaAgeRule.java
/** * //from w w w. j av a 2s . c o m * @see org.openmrs.logic.Rule#eval(org.openmrs.logic.LogicContext, org.openmrs.Patient, java.util.Map) */ public Result eval(LogicContext context, Integer patientId, Map<String, Object> parameters) throws LogicException { Date birthdate = context.read(patientId, context.getLogicDataSource("person"), "BIRTHDATE").toDatetime(); if (birthdate == null) { return Result.emptyResult(); } int age = 0; Calendar bdate = Calendar.getInstance(); bdate.setTime(birthdate); Calendar now = Calendar.getInstance(); now.setTime(context.getIndexDate()); Date ageEndDate = now.getTime(); // calculate age as the difference in what the parameter says. if (parameters != null) { //if the ChicaAgeRule was called by the PWS, then use the printed timestamp //not the current time FormInstance formInstance = (FormInstance) parameters.get("formInstance"); Integer formId = null; if (formInstance != null) { formId = formInstance.getFormId(); } String formType = null; Integer locationTagId = (Integer) parameters.get(ChirdlUtilConstants.PARAMETER_LOCATION_TAG_ID); if (formId != null && locationTagId != null) { formType = org.openmrs.module.chirdlutil.util.Util.getFormType(formId, locationTagId, formInstance.getLocationId()); } if (ChirdlUtilConstants.PHYSICIAN_FORM_TYPE.equalsIgnoreCase(formType)) { PatientState patientState = org.openmrs.module.atd.util.Util .getProducePatientStateByFormInstanceAction(formInstance); if (patientState != null) { Date formPrintedTime = patientState.getStartTime(); if (formPrintedTime != null) { ageEndDate = formPrintedTime; } } } String units = null; String param = (String) parameters.get("param1"); if (param.compareToIgnoreCase("years") == 0) { units = Util.YEAR_ABBR; } else if (param.compareToIgnoreCase("months") == 0) { units = Util.MONTH_ABBR; } else if (param.compareToIgnoreCase("days") == 0) { units = Util.DAY_ABBR; } else if (param.compareToIgnoreCase("weeks") == 0) { units = Util.WEEK_ABBR; } if (units != null) { age = org.openmrs.module.chirdlutil.util.Util.getAgeInUnits(birthdate, ageEndDate, units); } } else { return Result.emptyResult(); } return new Result(age); }
From source file:interactivespaces.network.client.internal.ros.RosNetworkInformationClient.java
public RosNetworkInformationClient() { lowerCaseStringComparator = new Comparator<String>() { @Override/*from w w w . j a v a2s. com*/ public int compare(String o1, String o2) { return o1.compareToIgnoreCase(o2); } }; networkTopicInformationComparator = new Comparator<NetworkTopicInformation>() { @Override public int compare(NetworkTopicInformation o1, NetworkTopicInformation o2) { return o1.getTopicName().compareToIgnoreCase(o2.getTopicName()); } }; networkNodeInformationComparator = new Comparator<NetworkNodeInformation>() { @Override public int compare(NetworkNodeInformation o1, NetworkNodeInformation o2) { return o1.getNodeName().compareToIgnoreCase(o2.getNodeName()); } }; }
From source file:org.apache.hadoop.io.crypto.bee.RestClient.java
private InputStream httpsWithCertificate(final URL url) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, KeyManagementException { KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); trustStore.load(null);// Make an empty store CertificateFactory cf = CertificateFactory.getInstance("X.509"); FileInputStream fis = new FileInputStream(BeeConstants.BEE_HTTPS_CERTIFICATE_DEFAULT_PATH); BufferedInputStream bis = new BufferedInputStream(fis); while (bis.available() > 0) { Certificate cert = cf.generateCertificate(bis); // System.out.println(cert.getPublicKey().toString()); trustStore.setCertificateEntry("jetty" + bis.available(), cert); }/* w ww. j av a 2 s.c om*/ TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmf.init(trustStore); SSLContext ctx = SSLContext.getInstance("TLS"); ctx.init(null, tmf.getTrustManagers(), null); SSLSocketFactory sslFactory = ctx.getSocketFactory(); // Create all-trusting host name verifier HostnameVerifier allHostsValid = new HostnameVerifier() { @Override public boolean verify(String hostname, SSLSession session) { if (0 == hostname.compareToIgnoreCase(url.getHost())) { return true; } return false; } }; // Install the all-trusting host verifier HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid); HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection(); urlConnection.setSSLSocketFactory(sslFactory); return urlConnection.getInputStream(); }
From source file:org.kuali.rice.shareddata.framework.country.AbstractCountryValuesFinderBase.java
@Override public List<KeyValue> getKeyValues() { List<Country> boList = new ArrayList<Country>(retrieveCountriesForValuesFinder()); List<KeyValue> labels = new ArrayList<KeyValue>(boList.size() + 1); labels.add(new ConcreteKeyValue("", "")); Collections.sort(boList, new Comparator<Country>() { @Override/* w ww . j ava 2 s . com*/ public int compare(Country o1, Country o2) { // some institutions may prefix the country name with an asterisk if the country no longer exists // the country names will be compared without the asterisk String sortValue1 = StringUtils.trim(StringUtils.removeStart(o1.getName(), "*")); String sortValue2 = StringUtils.trim(StringUtils.removeStart(o2.getName(), "*")); return sortValue1.compareToIgnoreCase(sortValue2); } }); for (Country country : boList) { if (country.isActive()) { labels.add(new ConcreteKeyValue(country.getCode(), country.getName())); } } return labels; }
From source file:pl.edu.icm.comac.vis.server.service.GraphToolkit.java
/** * Method to choose appropriate not-favourite nodes of the graph. It takes * all nodes outside the normal and large sets, and chooses only those, who * are not overflowing the normal nodes over 'itemLinkLimit'. Note, that if * at most one normal node is not overflown by item, others may be. * * @param normal list of normal favaourite nodes. * @param large list of favourite nodes which are overflown, i.e. we have limited * knowledge of their links/*from w ww . ja va 2s. com*/ * @param links map of all links for all items, normal and external * @param itemLinkLimit recommended size od the links * @return set of the items choosen for the graphs as not favourite nodes. */ public Set<String> calculateAdditions(Set<String> normal, Set<String> large, Map<String, Set<String>> links, long itemLinkLimit) { Map<String, Long> outgoingLinks = new HashMap<>(); normal.stream().forEach(x -> outgoingLinks.put(x, 0l)); List<String> leftovers = links.keySet().stream().filter(x -> !(normal.contains(x) || large.contains(x))) .collect(Collectors.toList()); //now order list by the link count in each of each element: Collections.sort(leftovers, new Comparator<String>() { @Override public int compare(String o1, String o2) { int res = -((Integer) links.get(o1).size()).compareTo(((Integer) links.get(o2).size())); if (res == 0) { return o1.compareToIgnoreCase(o2); } else { return res; } } }); Set<String> approved = new HashSet<String>(); for (String item : leftovers) { final Set<String> itemLinks = links.get(item); if (itemLinks.stream().anyMatch(x -> { return outgoingLinks.containsKey(x) && outgoingLinks.get(x) < itemLinkLimit; })) { approved.add(item); itemLinks.stream().filter(x -> outgoingLinks.containsKey(x)) .forEach(x -> outgoingLinks.put(x, outgoingLinks.get(x) + 1)); } } return approved; }
From source file:org.webcat.core.git.PrettyDiffFormatter.java
public NSArray<String> modifiedPaths() { if (sortedPaths == null) { try {//www .ja v a 2 s.c o m sortedPaths = prettyDiffs.allKeys().sortedArrayUsingComparator(new NSComparator() { @Override public int compare(Object _lhs, Object _rhs) { String lhs = (String) _lhs; String rhs = (String) _rhs; return lhs.compareToIgnoreCase(rhs); } }); } catch (ComparisonException e) { sortedPaths = prettyDiffs.allKeys(); } } return sortedPaths; }
From source file:io.smartspaces.network.client.internal.ros.RosNetworkInformationClient.java
/** * Construct a new client./*www . j a va 2s. co m*/ */ public RosNetworkInformationClient() { lowerCaseStringComparator = new Comparator<String>() { @Override public int compare(String o1, String o2) { return o1.compareToIgnoreCase(o2); } }; networkTopicInformationComparator = new Comparator<NetworkTopicInformation>() { @Override public int compare(NetworkTopicInformation o1, NetworkTopicInformation o2) { return o1.getTopicName().compareToIgnoreCase(o2.getTopicName()); } }; networkNodeInformationComparator = new Comparator<NetworkNodeInformation>() { @Override public int compare(NetworkNodeInformation o1, NetworkNodeInformation o2) { return o1.getNodeName().compareToIgnoreCase(o2.getNodeName()); } }; }