List of usage examples for java.lang String compareTo
public int compareTo(String anotherString)
From source file:com.yanzhenjie.nohttp.HttpHeaders.java
public HttpHeaders() { super(new Comparator<String>() { @Override//from w w w . ja v a2 s . c o m public int compare(String o1, String o2) { return o1.compareTo(o2); } }); }
From source file:freedots.web.MusicXML2BrailleServlet.java
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { String uri = req.getParameter("uri"); if (uri != null && uri.length() > 0) { URL url = new URL(uri); String extension = "xml"; BrailleEncoding brailleEncoding = BrailleEncoding.UnicodeBraille; int width = 40, height = 25; String ext = uri.substring(uri.length() - 3); if (ext.compareTo("mxl") == 0) { extension = ext;/* www. ja v a 2 s . c om*/ } String encodingParam = req.getParameter("encoding"); if (encodingParam != null && !encodingParam.isEmpty()) { try { brailleEncoding = Enum.valueOf(BrailleEncoding.class, encodingParam); } catch (IllegalArgumentException e) { LOG.info("Unknown encoding " + encodingParam + ", falling back to default"); } } String widthParam = req.getParameter("width"); if (widthParam != null && !widthParam.isEmpty()) { try { final int value = Integer.parseInt(widthParam); if (value >= MIN_COLUMNS_PER_LINE && value <= MAX_COLUMNS_PER_LINE) width = value; } catch (NumberFormatException e) { } } String heightParam = req.getParameter("height"); if (heightParam != null && !heightParam.isEmpty()) { try { final int value = Integer.parseInt(heightParam); if (value >= MIN_LINES_PER_PAGE && value <= MAX_LINES_PER_PAGE) height = value; } catch (NumberFormatException e) { } } Score score = parseMusicXML(url.openStream(), extension); if (score != null) writeResult(score, width, height, Method.SectionBySection, brailleEncoding, resp); else resp.sendError(500); } else { LOG.info("Bad URI error"); resp.sendError(500); } }
From source file:com.android.deskclock.worldclock.CityAndTimeZoneLocator.java
private TZ parseTimeZoneResponse(BufferedReader br) { try {/* w w w.java 2s .c o m*/ boolean status = false; String tzId = null; int rawOffset = 0; XmlPullParser parser = Xml.newPullParser(); parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); parser.setInput(br); parser.nextTag(); parser.require(XmlPullParser.START_TAG, null, TIMEZONE_ROOT); while (parser.next() != XmlPullParser.END_TAG) { if (parser.getEventType() != XmlPullParser.START_TAG) { continue; } String name = parser.getName(); if (name.compareTo(TIMEZONE_STATUS_FLD) == 0) { status = parser.nextText().compareTo(TIMEZONE_VALID_STATUS) == 0; } else if (status && name.compareTo(TIMEZONE_RAW_OFFSET_FLD) == 0) { rawOffset = (int) Double.parseDouble(parser.nextText()); } else if (status && name.compareTo(TIMEZONE_TZ_ID_FLD) == 0) { tzId = parser.nextText(); } else { parser.nextText(); } } // Have a valid response? if (status) { return new TZ(tzId, rawOffset); } } catch (IOException e) { Log.e(TAG, "Failed to parse timezone response", e); } catch (XmlPullParserException e) { Log.e(TAG, "Failed to parse timezone response", e); } return null; }
From source file:io.wcm.caconfig.editor.impl.ConfigNamesServlet.java
private JSONArray getConfigNames(Resource contextResource) throws JSONException { JSONArray output = new JSONArray(); SortedSet<String> configNames = configManager.getConfigurationNames(); SortedSet<JSONObject> sortedResult = new TreeSet<>(new Comparator<JSONObject>() { @Override/*from w w w . j a v a 2 s. c o m*/ public int compare(JSONObject o1, JSONObject o2) { String label1 = o1.optString("label"); String label2 = o2.optString("label"); if (StringUtils.equals(label1, label2)) { String configName1 = o1.optString("configName"); String configName2 = o2.optString("configName"); return configName1.compareTo(configName2); } return label1.compareTo(label2); } }); for (String configName : configNames) { ConfigurationMetadata metadata = configManager.getConfigurationMetadata(configName); if (metadata != null) { JSONObject item = new JSONObject(); item.put("configName", configName); item.putOpt("label", metadata.getLabel()); item.putOpt("description", metadata.getDescription()); item.put("collection", metadata.isCollection()); item.put("exists", hasConfig(contextResource, configName, metadata.isCollection())); item.put("allowAdd", allowAdd(contextResource, configName)); sortedResult.add(item); } } sortedResult.forEach(output::put); return output; }
From source file:com.sfs.beans.BuilderBean.java
/** * Sets the value./*www. java2 s. com*/ * * @param parameter the parameter * @param value the value */ private void setValue(final String parameter, final String value) { if (parameter != null) { if (parameter.compareTo("") != 0) { if (value != null) { if (this.parameters == null) { this.parameters = new HashMap<String, String>(); } if (this.ordering == null) { this.ordering = new ArrayList<String>(); } this.parameters.put(parameter, value); this.ordering.add(parameter); } } } }
From source file:gridool.construct.GridTaskAdapter.java
public int compareTo(GridLocatable other) { String otherKey = other.getKey(); String selfKey = getKey(); return selfKey.compareTo(otherKey); }
From source file:org.nuxeo.apidoc.introspection.OperationInfoImpl.java
@Override public int compareTo(OperationInfo o) { String s1 = getLabel() == null ? getId() : getLabel(); String s2 = o.getLabel() == null ? o.getId() : o.getLabel(); return s1.compareTo(s2); }
From source file:ch.mlutz.plugins.t4e.tapestry.element.TapestryHtmlElement.java
@Override public int compareTo(TapestryHtmlElement o) { String thisName = getPath(); String anotherString = o.getPath(); return thisName.compareTo(anotherString); }
From source file:com.francetelecom.clara.cloud.logicalmodel.LogicalModelItem.java
/** * {@link LogicalModelItem#equals(Object)} depends on this * @param o// w ww. jav a 2 s . c o m * @return */ @Override public int compareTo(LogicalModelItem o) { //Sorting based on class names, and labels among class names which are supposed to be unique. //Note: we expect labels to be set, however if one is null, this should be OK, order will always be consistent //and labels are tested in equals. String name1 = this.getClass().getSimpleName() + getLabel(); String name2 = o.getClass().getSimpleName() + o.getLabel(); return name1.compareTo(name2); }
From source file:com.demonwav.mcdev.platform.forge.version.ForgeVersion.java
@Nullable public String getRecommended(List<String> versions) { String recommended = "1.7"; for (String version : versions) { Double promo = getPromo(version); if (promo == null) { continue; }// w ww. j av a 2 s . c om if (recommended.compareTo(version) < 0) { recommended = version; } } return recommended; }