List of usage examples for java.lang String compareTo
public int compareTo(String anotherString)
From source file:net.firejack.platform.service.registry.broker.package_.GenerateUpgradeXmlBroker.java
private Map<String, IElementDiffInfoContainer> splitElementDiffInfoContainer( UpgradeDiffTransformer upgradeDiffTransformer, IElementDiffInfoContainer globalIElementDiffInfoContainer) { Map<String, DialectType> sqlDialectMapping = upgradeDiffTransformer.getSqlDialectMapping(); List<String> lookupList = new ArrayList<String>(sqlDialectMapping.keySet()); Collections.sort(lookupList, new Comparator<String>() { @Override/*from w w w. ja v a2s .com*/ public int compare(String s1, String s2) { return s2.compareTo(s1); } }); String packageLookup = lookupList.get(lookupList.size() - 1); lookupList.remove(packageLookup); Map<String, IElementDiffInfoContainer> elementDiffInfoContainers = new LinkedHashMap<String, IElementDiffInfoContainer>(); elementDiffInfoContainers.put(packageLookup, globalIElementDiffInfoContainer); EntityElementManager newEntitiesManager = globalIElementDiffInfoContainer.getNewEntitiesManager(); EntityElementManager oldEntitiesManager = globalIElementDiffInfoContainer.getOldEntitiesManager(); for (String lookup : lookupList) { ElementDiffInfoContainer elementDiffInfoContainer = new ElementDiffInfoContainer(); elementDiffInfoContainer.setTypesRegistry(newEntitiesManager); elementDiffInfoContainer.setOldTypesRegistry(oldEntitiesManager); elementDiffInfoContainer.setEntityDiffList(new ArrayList<EntitiesDiff>()); List<EntitiesDiff> entityDiffs = globalIElementDiffInfoContainer.getEntityDiffs(); for (EntitiesDiff entityDiff : entityDiffs) { IEntityElement diffTarget = entityDiff.getDiffTarget(); if (diffTarget.getPath().contains(lookup)) { elementDiffInfoContainer.getEntityDiffs().add(entityDiff); } } globalIElementDiffInfoContainer.getEntityDiffs().removeAll(elementDiffInfoContainer.getEntityDiffs()); elementDiffInfoContainer.setFieldDiffList(new ArrayList<FieldsDiff>()); List<FieldsDiff> fieldsDiffs = globalIElementDiffInfoContainer.getFieldDiffs(); for (FieldsDiff fieldDiff : fieldsDiffs) { IEntityElement targetParent = fieldDiff.getTargetParent(); if (targetParent.getPath().contains(lookup)) { elementDiffInfoContainer.getFieldDiffs().add(fieldDiff); } } globalIElementDiffInfoContainer.getFieldDiffs().removeAll(elementDiffInfoContainer.getFieldDiffs()); elementDiffInfoContainer.setRelationshipDiffList(new ArrayList<RelationshipsDiff>()); List<RelationshipsDiff> relationshipDiffs = globalIElementDiffInfoContainer.getRelationshipDiffs(); for (RelationshipsDiff relationshipDiff : relationshipDiffs) { IRelationshipElement relationshipElement = relationshipDiff.getDiffTarget(); Reference source = relationshipElement.getSource(); if (source.getRefPath().contains(lookup)) { elementDiffInfoContainer.getRelationshipDiffs().add(relationshipDiff); } } globalIElementDiffInfoContainer.getRelationshipDiffs() .removeAll(elementDiffInfoContainer.getRelationshipDiffs()); elementDiffInfoContainer.setIndexesDiffList(new ArrayList<IndexesDiff>()); List<IndexesDiff> indexesDiffs = globalIElementDiffInfoContainer.getIndexesDiffs(); for (IndexesDiff indexDiff : indexesDiffs) { IEntityElement targetParent = indexDiff.getTargetParent(); if (targetParent.getPath().contains(lookup)) { elementDiffInfoContainer.getIndexesDiffs().add(indexDiff); } } globalIElementDiffInfoContainer.getIndexesDiffs().removeAll(elementDiffInfoContainer.getIndexesDiffs()); elementDiffInfoContainers.put(lookup, elementDiffInfoContainer); } return elementDiffInfoContainers; }
From source file:me.crime.loader.DataBaseLoader.java
@Override public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException { if (name.compareTo(XmlTags.ELEMENT) == 0) { current_ = attributes.getValue(XmlTags.NAME); } else if (name.compareTo(XmlTags.CLASS) == 0) { String className = attributes.getValue(XmlTags.NAME).trim(); if (this.classMap_.containsKey(className)) { className = classMap_.get(className); }// w w w . jav a 2 s . com try { Class<?> cls = this.getClass().getClassLoader().loadClass(className); Object obj = cls.newInstance(); XmlReadable reader = XmlReadable.class.cast(obj); if (curObject_ != null) { stack_.push(curObject_); } curObject_ = reader; } catch (InstantiationException e) { DataBaseLoader.log_.error("startElement: " + className, e); } catch (IllegalAccessException e) { DataBaseLoader.log_.error("startElement: " + className, e); } catch (ClassNotFoundException e) { DataBaseLoader.log_.error("startElement: " + className, e); } } }
From source file:edu.cwru.apo.Login.java
public void onRestRequestComplete(Methods method, JSONObject result) { if (method == Methods.login) { if (result != null) { try { String requestStatus = result.getString("requestStatus"); if (requestStatus.compareTo("valid login") == 0) { Auth.loggedIn = true; Auth.Hmac.setCounter(result.getInt("counter")); Auth.Hmac.setIncrement(result.getInt("increment")); PhoneOpenHelper db = new PhoneOpenHelper(this); if (database == null) database = db.getWritableDatabase(); API api = new API(this); if (!api.callMethod(Methods.phone, this, (String[]) null)) { Toast msg = Toast.makeText(this, "Error: Calling phone", Toast.LENGTH_LONG); msg.show();/*from w w w .ja v a 2 s .c o m*/ } } else if (requestStatus.compareTo("invalid username") == 0) { Toast msg = Toast.makeText(getApplicationContext(), "Invalid username", Toast.LENGTH_LONG); msg.show(); } else if (requestStatus.compareTo("invalid login") == 0) { Toast msg = Toast.makeText(getApplicationContext(), "Invalid username and/or password", Toast.LENGTH_LONG); msg.show(); } else if (requestStatus.compareTo("no user") == 0) { Toast msg = Toast.makeText(getApplicationContext(), "No username was provided", Toast.LENGTH_LONG); msg.show(); } else { Toast msg = Toast.makeText(getApplicationContext(), "Invalid requestStatus", Toast.LENGTH_LONG); msg.show(); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { Toast msg = Toast.makeText(getApplicationContext(), "Could not contact web server. Please check your connection", Toast.LENGTH_LONG); msg.show(); } } else if (method == Methods.phone) { if (result != null) { try { String requestStatus = result.getString("requestStatus"); if (requestStatus.compareTo("success") == 0) { SharedPreferences.Editor editor = getSharedPreferences(APO.PREF_FILE_NAME, MODE_PRIVATE) .edit(); editor.putLong("updateTime", result.getLong("updateTime")); editor.commit(); int numbros = result.getInt("numBros"); if (numbros > 0) { JSONArray caseID = result.getJSONArray("caseID"); JSONArray first = result.getJSONArray("first"); JSONArray last = result.getJSONArray("last"); JSONArray phone = result.getJSONArray("phone"); JSONArray family = result.getJSONArray("family"); ContentValues values; for (int i = 0; i < numbros; i++) { values = new ContentValues(); values.put("_id", caseID.getString(i)); values.put("first", first.getString(i)); values.put("last", last.getString(i)); values.put("phone", phone.getString(i)); values.put("family", family.getString(i)); database.replace("phoneDB", null, values); } } Intent homeIntent = new Intent(Login.this, Home.class); Login.this.startActivity(homeIntent); finish(); } else if (requestStatus.compareTo("timestamp invalid") == 0) { Toast msg = Toast.makeText(this, "Invalid timestamp. Please try again.", Toast.LENGTH_LONG); msg.show(); } else if (requestStatus.compareTo("HMAC invalid") == 0) { Toast msg = Toast.makeText(this, "You have been logged out by the server. Please log in again.", Toast.LENGTH_LONG); msg.show(); } else { Toast msg = Toast.makeText(this, "Invalid requestStatus", Toast.LENGTH_LONG); msg.show(); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } else { Toast msg = Toast.makeText(getApplicationContext(), "Invalid method callback", Toast.LENGTH_LONG); msg.show(); } }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.clinicalData.SetUnitsListener.java
@Override public void handleEvent(Event event) { Vector<String> columns = this.setUnitsUI.getColumns(); Vector<String> units = this.setUnitsUI.getUnits(); if (columns.size() == 1) { if (columns.get(0).compareTo("") == 0 && columns.get(0).compareTo("") == 0) { columns = new Vector<String>(); units = new Vector<String>(); }//from ww w. j ava 2 s .co m } for (int i = 0; i < columns.size(); i++) { if (columns.get(i).compareTo("") == 0 || units.get(i).compareTo("") == 0) { this.setUnitsUI.displayMessage("Some values are not set"); return; } String columnFileName = columns.get(i).split(" - ", 2)[0]; String unitFileName = units.get(i).split(" - ", 2)[0]; if (columnFileName.compareTo(unitFileName) != 0) { this.setUnitsUI.displayMessage("Columns for value and unit have to been from the same file"); } } if (((ClinicalData) this.dataType).getCMF() == null) { this.setUnitsUI.displayMessage("Error: no column mapping file"); return; } if (!this.checkValues(columns, units)) return; File file = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".columns.tmp"); try { FileWriter fw = new FileWriter(file); BufferedWriter out = new BufferedWriter(fw); out.write( "Filename\tCategory Code\tColumn Number\tData Label\tData Label Source\tControlled Vocab Code\n"); try { BufferedReader br = new BufferedReader(new FileReader(((ClinicalData) this.dataType).getCMF())); String line = br.readLine(); while ((line = br.readLine()) != null) { if (line.split("\t", -1)[3].compareTo("UNITS") != 0) { out.write(line + "\n"); } } br.close(); } catch (Exception e) { this.setUnitsUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); out.close(); } for (int i = 0; i < columns.size(); i++) { String fileName = columns.get(i).split(" - ", 2)[0]; int columnColumnNumber = -1; for (File rawFile : ((ClinicalData) this.dataType).getRawFiles()) { if (rawFile.getName().compareTo(fileName) == 0) { columnColumnNumber = FileHandler.getHeaderNumber(rawFile, columns.get(i).split(" - ", 2)[1]); } } int unitColumnNumber = -1; for (File rawFile : ((ClinicalData) this.dataType).getRawFiles()) { if (rawFile.getName().compareTo(fileName) == 0) { unitColumnNumber = FileHandler.getHeaderNumber(rawFile, units.get(i).split(" - ", 2)[1]); } } if (columnColumnNumber != -1 && unitColumnNumber != -1) { out.write(fileName + "\t\t" + String.valueOf(unitColumnNumber) + "\tUNITS\t" + String.valueOf(columnColumnNumber) + "\t\t\n"); } } out.close(); String fileName = ((ClinicalData) this.dataType).getCMF().getName(); FileUtils.deleteQuietly(((ClinicalData) this.dataType).getCMF()); try { File fileDest = new File(this.dataType.getPath() + File.separator + fileName); FileUtils.moveFile(file, fileDest); ((ClinicalData) this.dataType).setCMF(fileDest); } catch (Exception ioe) { this.setUnitsUI.displayMessage("File error: " + ioe.getLocalizedMessage()); return; } } catch (Exception e) { this.setUnitsUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.setUnitsUI.displayMessage("Column mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); }
From source file:ldap.Entry.java
public int compareTo(Object o) { Entry compareMe = (Entry) o;//www. j av a2 s.co m try { //String name1 = getValue(Config.USER_NAMING_ATT); //String name2 = compareMe.getValue(Config.USER_NAMING_ATT); String name1 = getValue(LdapConstants.ldapAttrUid); String name2 = compareMe.getValue(LdapConstants.ldapAttrUid); return name1.compareTo(name2); } catch (NamingException e) { logger.info("Unexpected Exception while sorting users: " + e.getMessage()); return 0; } }
From source file:com.ebay.nest.io.sede.lazy.LazyTimestamp.java
/** * Initilizes LazyTimestamp object by interpreting the input bytes * as a JDBC timestamp string//from w w w .ja v a 2s .co m * * @param bytes * @param start * @param length */ @Override public void init(ByteArrayRef bytes, int start, int length) { String s = null; try { s = new String(bytes.getData(), start, length, "US-ASCII"); } catch (UnsupportedEncodingException e) { LOG.error(e); s = ""; } Timestamp t = null; if (s.compareTo("NULL") == 0) { isNull = true; logExceptionMessage(bytes, start, length, "TIMESTAMP"); } else { try { t = Timestamp.valueOf(s); isNull = false; } catch (IllegalArgumentException e) { isNull = true; logExceptionMessage(bytes, start, length, "TIMESTAMP"); } } data.set(t); }
From source file:org.arrow.runtime.message.EventMessageEventBus.java
/** * {@inheritDoc}/*ww w.ja v a 2s. c o m*/ */ @Override public int compareClassifiers(String classifier1, String classifier2) { if (classifier1 == null && classifier2 == null) { return 0; } if (classifier1 == null) { return 1; } if (classifier2 == null) { return -1; } return classifier1.compareTo(classifier2); }
From source file:com.sldeditor.test.unit.tool.ysld.YSLDToolTest.java
/** * Test get tool name//www. jav a 2 s. com */ @Test public void testGetToolName() { YSLDTool tool = new YSLDTool(); String toolName = tool.getToolName(); assertTrue(toolName.compareTo("com.sldeditor.tool.ysld.YSLDTool") == 0); }
From source file:com.library.essay.tinymce.spellchecker.GoogleSpellChekerServlet.java
private void connect(String language) throws IOException { URL url = new URL(SPELLCHECK_PROTOCOL, SPELLCHECK_HOST, SPELLCHECK_PORT, SPELLCHECK_PATH + QUERY[0] + ((language.compareTo("") == 0) ? QUERY[1] : language) + QUERY[2]); uc = url.openConnection();/*www . j a v a2 s. com*/ }
From source file:StringArray.java
/** * Find index of a particular string in the array. This does * a binary search through the array values, using a pair of * index bounds to track the subarray of possible matches at * each iteration./*w w w . ja v a 2 s . com*/ * * @param value string to be found in list * @return index of string in array, or <code>-1</code> if * not present */ public int indexOf(String value) { int base = 0; int limit = m_list.length - 1; while (base <= limit) { int cur = (base + limit) >> 1; int diff = value.compareTo(m_list[cur]); if (diff < 0) { limit = cur - 1; } else if (diff > 0) { base = cur + 1; } else { return cur; } } return -1; }