List of usage examples for java.lang String compareTo
public int compareTo(String anotherString)
From source file:technology.tikal.gae.system.service.imp.SystemAccountServiceImp.java
@Override @RequestMapping(value = "/{user}", method = RequestMethod.POST) public void updateSystemAccount(@PathVariable String user, @Valid @RequestBody final SystemUser systemUser, final BindingResult result) { if (result.hasErrors()) { throw new NotValidException(result); }/*from ww w . jav a2 s. c om*/ if (systemUser.getUsername() != null && user.compareTo(systemUser.getUsername()) != 0) { throw new MessageSourceResolvableException(new DefaultMessageSourceResolvable( new String[] { "NotSame.SystemAccountServiceImp.updateSystemAccount" }, new String[] { systemUser.getUsername(), user }, "Body username dont correspond to path username")); } else { SystemUser account = systemUserDao.consultar(user); account.update(systemUser); systemUserDao.guardar(account); } }
From source file:ca.uqac.info.trace.generation.PetriNetGenerator.java
/** * Defines the Petri net from a structured string. * The string itself is just a succession of "words" separated * by whitespace with the following structure: * <dl>//from ww w .jav a2s . co m * <dt><tt>T label<sub>1</sub> label<sub>2</sub></tt></dt> * <dd>Defines an arrow from a transition named label<sub>1</sub> to a * place named label<sub>2</sub></dd> * <dt><tt>P label<sub>1</sub> label<sub>2</sub></tt></dt> * <dd>Defines an arrow from a place named label<sub>1</sub> to a * transition named label<sub>2</sub></dd> * <dt><tt>M label<sub>1</sub> x</tt></dt> * <dd>Defines an initial marking by putting <i>x</i> tokens into * a place named label<sub>1</sub></dd> * </dl> * For example, Petri net <i>N</i> shown on * <a href="http://en.wikipedia.org/wiki/Petri_net">Wikipedia's entry</a> * would be represented as: * <pre> * T T1 p1 * P p1 T2 * T T2 p2 * P p2 T3 * M p1 0 * M p2 0 * </pre> * Carriage returns are optional, the whole text could have been * put on a single line. The order in which lines are input does not * matter: transitions and places are created the first time their * label is seen by the parser. * <p> * <em>Caveat emptor</em>: the parser assumes the string is well-formed * but does not check it. A malformed string will likely cause a runtime * error of some kind. * @param s The structured string */ protected void parseFromString(String s) throws java.text.ParseException { String[] elements = s.split("\\s+"); int i = 0; while (i < elements.length) { String word = elements[i]; if (word.compareTo("P") == 0) { // Definition of a place -> transition arrow assert i + 2 < elements.length; String place_label = elements[i + 1]; String trans_label = elements[i + 2]; Place p = getAddPlace(new Place(place_label)); Transition t = getAddTransition(new Transition(trans_label)); p.addOutgoingTransition(t); t.addIncomingPlace(p); i += 3; } else if (word.compareTo("T") == 0) { // Definition of a transition -> place arrow assert i + 2 < elements.length; String place_label = elements[i + 2]; String trans_label = elements[i + 1]; Place p = getAddPlace(new Place(place_label)); Transition t = getAddTransition(new Transition(trans_label)); p.addIncomingTransition(t); t.addOutgoingPlace(p); i += 3; } else if (word.compareTo("M") == 0) { // Definition of an initial marking assert i + 2 < elements.length; String place_label = elements[i + 1]; int value = Integer.parseInt(elements[i + 2]); Place p = getAddPlace(new Place(place_label)); p.setMarking(value); i += 3; } else { throw new java.text.ParseException("Unknown word " + word, i); } } }
From source file:eu.stratosphere.pact.test.util.TestBase.java
/** * Compares the expectedResultString and the file(s) in the HDFS linewise. * Both results (expected and computed) are held in memory. Hence, this * method should not be used to compare large results. * /*from ww w .j a va2 s. co m*/ * @param expectedResult * @param hdfsPath */ protected void compareResultsByLinesInMemory(String expectedResultStr, String resultPath) throws Exception { Comparator<String> defaultStrComp = new Comparator<String>() { @Override public int compare(String arg0, String arg1) { return arg0.compareTo(arg1); } }; this.compareResultsByLinesInMemory(expectedResultStr, resultPath, defaultStrComp); }
From source file:com.clevertrail.mobile.Database_SavedTrails.java
public String getJSONString() { String[] columns = new String[] { "json" }; Cursor cursor = sqLiteDatabase.query(MYDATABASE_TABLE, columns, null, null, null, null, null); cursor.moveToFirst();//w w w . j a v a2 s . c o m int index_JSON = cursor.getColumnIndex("json"); //we will create a simple return value of the format: //"[trail1JSON, trail2JSON, ...]" String sReturn = "["; while (!cursor.isAfterLast()) { String sTrailJSON = cursor.getString(index_JSON); sReturn = sReturn.concat(sTrailJSON); cursor.moveToNext(); if (!cursor.isAfterLast()) { if (sTrailJSON.compareTo("") != 0) sReturn = sReturn.concat(","); } else { break; } } sReturn = sReturn.concat("]"); return sReturn; }
From source file:com.prowidesoftware.swift.model.SwiftBlock2.java
/** * Sets the block name. Will cause an exception unless setting block number to "2". * @param blockName the block name to set * @throws IllegalArgumentException if parameter blockName is not the string "2" * @since 5.0/* w w w . jav a 2s . c om*/ */ protected void setBlockName(final String blockName) { // sanity check Validate.notNull(blockName, "parameter 'blockName' cannot be null"); Validate.isTrue(blockName.compareTo("2") == 0, "blockName must be string '2'"); }
From source file:com.pactera.edg.am.metamanager.extractor.dao.impl.DBDictionaryDaoImpl.java
public Map<String, List<Map<String, String>>> getColInfoFromMM(List<String> sqlTables) { // ?,//ww w . j a v a2 s. c o m if (sqlTables == null || sqlTables.size() == 0) { return Collections.emptyMap(); } if (!modelHasCheck) { // ? hasColumnId = checkModel(); modelHasCheck = true; } if (!hasColumnId) { // columnId,???,!! return Collections.emptyMap(); } columnSql = GenSqlUtil.getSql("QUERY_DICTIONARY_COLUMN"); columnSql = columnSql.replaceAll("#COLUMNPOSITION#", columnPosition); // ?? Collections.sort(sqlTables, new Comparator<String>() { public int compare(String o1, String o2) { return o1.compareTo(o2); } }); // ????,???:schema.table <schema,Set<table>> Set<String> schemaTables = verifyTables(sqlTables); if (schemaTables.size() == 0) { return Collections.emptyMap(); } // ?? Map<String, List<Map<String, String>>> returnColumns = new HashMap<String, List<Map<String, String>>>(); // ?SCHEMACODE??? for (Iterator<String> schemaTableNames = schemaTables.iterator(); schemaTableNames.hasNext();) { String schemaTableName = schemaTableNames.next(); if (schemaTablesCache.containsKey(schemaTableName)) { // ,? if (schemaTablesCache.get(schemaTableName) == null) { // null,?,? continue; } returnColumns.put(schemaTableName, schemaTablesCache.get(schemaTableName)); } else { getTable(schemaTableName, returnColumns); } } if (returnColumns.size() > 0) { log.info("???:"); } for (Iterator<String> iter = returnColumns.keySet().iterator(); iter.hasNext();) { log.info(iter.next()); } return returnColumns; }
From source file:uk.org.taverna.platform.report.Invocation.java
@Override public int compareTo(Invocation o) { String id = getId(); String otherId = o.getId();/*from w ww.j a v a 2s . c o m*/ if (id.length() == otherId.length()) return id.compareTo(otherId); // Make "invoc5" be sorted before "invoc49" return id.length() - otherId.length(); }
From source file:WebCrawler.java
public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); if (command.compareTo(SEARCH) == 0) { setStatus("searching..."); // launch a thread to do the search if (searchThread == null) { searchThread = new Thread(this); }/*ww w .j av a 2 s.co m*/ searchThread.start(); } else if (command.compareTo(STOP) == 0) { stop(); } }
From source file:com.fratello.longevity.smooth.object.SpecialFile.java
private boolean testFilterProperty_Hash(SpecialFile other) { String srcHashAlgo = this.filter.getHashString(); String[] possibilties = new String[] { "MD5", "SHA-1", "SHA-256", "SHA-512" }; boolean goodToContinue = false; for (String s : possibilties) if (s.compareTo(srcHashAlgo) == 0) { goodToContinue = true;/* ww w.j a v a 2 s. c o m*/ break; } if (!goodToContinue) return false; try { MessageDigest md1 = MessageDigest.getInstance(srcHashAlgo); MessageDigest md2 = MessageDigest.getInstance(srcHashAlgo); if (!Arrays.equals(md1.digest(Files.readAllBytes(this.PATH)), md2.digest(Files.readAllBytes(other.PATH)))) { return false; } } catch (Exception e) { e.printStackTrace(); } return true; }
From source file:gda.device.enumpositioner.EpicsValve.java
@Override public void configure() { if (!configured) { try {/*from ww w. j a v a 2 s .c om*/ // remove any final : if (templateName.endsWith(":")) { templateName = templateName.substring(0, templateName.lastIndexOf(":")); } // create channel currentPositionChnl = controller.createChannel(templateName + ":CON.VAL"); currentStatusChnl = controller.createChannel(templateName + ":STA.VAL"); // create required channel monitors controller.setMonitor(currentStatusChnl, this, EpicsController.MonitorType.STS); // loop over the pv's in the record for (int i = 0; i < 3; i++) { Channel thisStringChannel = controller .createChannel(templateName + ":CON." + EpicsEnumConstants.CHANNEL_NAMES[i]); String positionName = controller.cagetString(thisStringChannel); thisStringChannel.destroy(); // if the string is not "" then save it to the array if (positionName.compareTo("") != 0) { super.positions.add(positionName); } } } catch (Exception e) { logger.error("Error while trying to configure: " + getName() + " : " + e.getMessage()); } configured = true; } }