List of usage examples for java.lang String compareTo
public int compareTo(String anotherString)
From source file:ait.ffma.service.preservation.riskmanagement.api.riskanalysis.risk.RiskUtils.java
/** * This method searches in DBPedia for software that was released after passed date. * //from w w w.ja v a 2 s .co m * @param data * The year of the latest release * @return software names */ public static List<String> searchSoftwareReleasedAfter(String date) { List<String> resultList = new ArrayList<String>(); RepositoryDescription dbpedia = new DBPediaConnector(); RiskProperty riskProperty = RiskUtils.getRiskPropertyById(RiskConstants.GRAPHICS_FILE_FORMATS_PROPERTY_ID); ConnectorImpl connector = new ConnectorImpl(riskProperty); dbpedia.setConnector(connector); List<Map<String, String>> dbpediaList = dbpedia.retrieveAll(); Iterator<Map<String, String>> iter = dbpediaList.iterator(); while (iter.hasNext()) { Map<String, String> dbpediaMap = iter.next(); String value = dbpediaMap.get(RiskConstants.COLUMN_RELEASED); if (value != null && value.compareTo(date) > 0) { if (!resultList.contains(dbpediaMap.get(RiskConstants.COLUMN_NAME))) { resultList.add(dbpediaMap.get(RiskConstants.COLUMN_NAME)); } } } return resultList; }
From source file:com.eufar.asmm.server.UploadFunction.java
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("UploadFunction - the function started"); response.setContentType("text/html;charset=UTF-8"); response.addHeader("Cache-Control", "no-cache,no-store"); FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); try {//w w w. ja v a 2 s . c o m List items = upload.parseRequest(request); Iterator iter = items.iterator(); while (iter.hasNext()) { Object obj = iter.next(); org.apache.commons.fileupload.FileItem item = (org.apache.commons.fileupload.FileItem) obj; if (FilenameUtils.getExtension(item.getName()).matches("(xml|XML)")) { if (item.isFormField()) { String name = item.getName(); String value = ""; if (name.compareTo("textBoxFormElement") == 0) { value = item.getString(); } else { value = item.getString(); } response.getWriter().write(name + "=" + value + "\n"); } else { byte[] fileContents = item.get(); String message = new String(fileContents); response.setCharacterEncoding("UTF-8"); response.setContentType("text/html"); response.getWriter().write(message); System.out.println("UploadFunction - file uploaded"); } } else { System.out.println("UploadFunction - file rejected: wrong format"); response.setCharacterEncoding("UTF-8"); response.setContentType("text/html"); response.getWriter().write("format"); } } } catch (Exception ex) { System.out.println("UploadFunction - a problem occured: " + ex); response.getWriter().write("ERROR:" + ex.getMessage()); } }
From source file:edu.cwru.apo.Contract.java
public void onRestRequestComplete(Methods method, JSONObject result) { if (method == Methods.getContract) { if (result != null) { try { String requestStatus = result.getString("requestStatus"); if (requestStatus.compareTo("success") == 0) { String contract = ""; contract += "Status: " + result.getString("status") + "\n"; contract += "Dues: " + result.getString("dues") + "\n\n"; contract += "Chapter Attendance: \n"; contract += "Attended: " + result.getDouble("chaptersAttended") + "\n"; contract += "Required: " + result.getDouble("chaptersRequired") + "\n\n"; contract += "Pledge Attendance: \n"; contract += "Attended: " + result.getDouble("pledgeAttended") + "\n"; contract += "Required: " + result.getDouble("pledgeRequired") + "\n\n"; contract += "Hours:\n"; contract += "Hours towards contract: " + result.getDouble("contractHours") + "/" + result.getDouble("contractHoursRequired") + "\n"; contract += "Inside Hours: " + result.getDouble("in") + "/" + result.getDouble("inRequired") + "\n"; contract += "Outside Hours: " + result.getDouble("out") + "\n"; contract += "Total semester Hours: " + result.getDouble("totalHours"); text.setText(contract); } else if (requestStatus.compareTo("timestamp invalid") == 0) { Toast msg = Toast.makeText(getApplicationContext(), "Invalid timestamp. Please try again.", Toast.LENGTH_LONG); msg.show();//from ww w . jav a 2s . c o m } else if (requestStatus.compareTo("HMAC invalid") == 0) { Auth.loggedIn = false; Toast msg = Toast.makeText(getApplicationContext(), "You have been logged out by the server. Please log in again.", Toast.LENGTH_LONG); msg.show(); finish(); } else if (requestStatus.compareTo("no contract") == 0) { Toast msg = Toast.makeText(getApplicationContext(), "You have not signed a contract.", 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(); } } } }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.clinicalData.SelectIdentifiersListener.java
@Override public void handleEvent(Event event) { //write in a new file File file = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".columns.tmp"); try {//from w ww. j av a2 s . c o m Vector<String> subjectIds = this.setSubjectsIdUI.getSubjectIds(); for (String s : subjectIds) { if (s.compareTo("") == 0) { this.setSubjectsIdUI.displayMessage("Subjects identifier columns have to be choosen"); return; } } 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"); //subject identifier Vector<File> rawFiles = ((ClinicalData) this.dataType).getRawFiles(); for (int i = 0; i < rawFiles.size(); i++) { int columnNumber = FileHandler.getHeaderNumber(rawFiles.elementAt(i), subjectIds.elementAt(i)); if (columnNumber != -1) { out.write(rawFiles.elementAt(i).getName() + "\t\t" + columnNumber + "\tSUBJ_ID\t\t\n"); } } if (((ClinicalData) this.dataType).getCMF() == null) { out.close(); File fileDest = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".columns"); FileUtils.moveFile(file, fileDest); ((ClinicalData) this.dataType).setCMF(fileDest); WorkPart.updateSteps(); } else { try { BufferedReader br = new BufferedReader(new FileReader(((ClinicalData) this.dataType).getCMF())); String line = br.readLine(); while ((line = br.readLine()) != null) { String[] s = line.split("\t", -1); if (s[3].compareTo("SUBJ_ID") != 0) { out.write(line + "\n"); } } br.close(); } catch (Exception e) { this.setSubjectsIdUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); out.close(); } out.close(); try { String fileName = ((ClinicalData) this.dataType).getCMF().getName(); ((ClinicalData) this.dataType).getCMF().delete(); File fileDest = new File(this.dataType.getPath() + File.separator + fileName); FileUtils.moveFile(file, fileDest); ((ClinicalData) this.dataType).setCMF(fileDest); } catch (IOException ioe) { this.setSubjectsIdUI.displayMessage("File errorrror: " + ioe.getLocalizedMessage()); return; } } } catch (Exception e) { this.setSubjectsIdUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.setSubjectsIdUI.displayMessage("Column mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); UsedFilesPart.sendFilesChanged(dataType); }
From source file:fxts.stations.trader.ui.dialogs.ADatePage.java
/** * Returns begining date//www. j a va 2s.c o m * * @return */ public String getBeginDate() { Calendar instance = Calendar.getInstance(); instance.setTime(mCalendarComboBegin.getDate()); boolean date = instance.get(Calendar.DATE) == Calendar.getInstance().get(Calendar.DATE); boolean month = instance.get(Calendar.MONTH) == Calendar.getInstance().get(Calendar.MONTH); boolean year = instance.get(Calendar.YEAR) == Calendar.getInstance().get(Calendar.YEAR); if (date && month && year) { TradingSessionStatus tss = TradingServerSession.getInstance().getTradingSessionStatus(); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); sdf.setTimeZone(TimeZone.getTimeZone(tss.getFXCMServerTimeZoneName())); String etd = TradingServerSession.getInstance().getParameterValue("END_TRADING_DAY"); String now = sdf.format(new Date()); if (now.compareTo(etd) > 0) { instance.roll(Calendar.DATE, true); } return mDateFormat.format(instance.getTime()); } else { return mDateFormat.format(mCalendarComboBegin.getDate()); } }
From source file:edu.internet2.middleware.subject.provider.LdapComparator.java
public int compare(Object so0, Object so1) { try {//from w w w . j a va 2 s .co m Subject s0 = (Subject) so0; Subject s1 = (Subject) so1; String s0d = s0.getDescription(); String s1d = s1.getDescription(); // log.debug("comparing " + s0d + " to " + s1d); return s0d.compareTo(s1d); } catch (Exception e) { log.debug("exception " + e); } return (1); }
From source file:es.alrocar.map.vector.provider.filesystem.impl.GeoJSONParser.java
/** * Parses a single feature with a Point// w w w . j a v a 2 s . co m * * @param feature * The feature {@link JSONObject} * @return A {@link JTSFeature} * @throws JSONException */ public JTSFeature parseFeature(JSONObject feature) throws JSONException { JTSFeature feat = new JTSFeature(null); JSONObject geometry = (JSONObject) feature.get("geometry"); String geomType = geometry.get("type").toString(); if (geomType.compareTo("Point") == 0) { JSONArray coords = geometry.getJSONArray("coordinates"); double x = coords.getDouble(0); double y = coords.getDouble(1); GeometryFactory factory = new GeometryFactory(); Coordinate c = new Coordinate(); c.x = x; c.y = y; Point p = factory.createPoint(c); feat.setGeometry(new JTSGeometry(p)); } // TODO process other geometry types JSONObject props = feature.getJSONObject("properties"); Iterator it = props.keys(); String key; String val; feat.setText(""); while (it.hasNext()) { key = it.next().toString(); val = props.getString(key); feat.addField(key, val, 0); if (val.indexOf("http") == -1) { feat.setText(feat.getText() + " " + val); } } return feat; }
From source file:annis.model.QueryAnnotation.java
public int compareTo(QueryAnnotation o) { String name1 = getQualifiedName(); String name2 = o.getQualifiedName(); return name1.compareTo(name2); }
From source file:io.stallion.secrets.SecretsVault.java
public List<String> getSecretNames() { List<String> secretNames = new ArrayList<String>(secrets.keySet()); secretNames.sort(new Comparator<String>() { @Override/*from w w w. j a v a2s .com*/ public int compare(String o1, String o2) { return o1.compareTo(o2); } }); return secretNames; }
From source file:com.eufar.emc.server.UploadFunction.java
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("UploadFunction - the function started"); response.setContentType("text/html;charset=UTF-8"); response.addHeader("Cache-Control", "no-cache,no-store"); @SuppressWarnings("unused") boolean isMultipart = ServletFileUpload.isMultipartContent(request); FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); try {/*from ww w . ja va2 s .c om*/ List<?> items = upload.parseRequest(request); Iterator<?> iter = items.iterator(); while (iter.hasNext()) { Object obj = iter.next(); if (obj == null) { continue; } org.apache.commons.fileupload.FileItem item = (org.apache.commons.fileupload.FileItem) obj; if (FilenameUtils.getExtension(item.getName()).matches("(xml|XML)")) { if (item.isFormField()) { String name = item.getName(); String value = ""; if (name.compareTo("textBoxFormElement") == 0) { value = item.getString(); } else { value = item.getString(); } response.getWriter().write(name + "=" + value + "\n"); } else { byte[] fileContents = item.get(); String message = new String(fileContents); response.setCharacterEncoding("UTF-8"); response.setContentType("text/html"); response.getWriter().write(message); System.out.println("UploadFunction - file uploaded"); } } else { System.out.println("UploadFunction - file rejected: wrong format"); response.setCharacterEncoding("UTF-8"); response.setContentType("text/html"); response.getWriter().write("format"); } } } catch (Exception ex) { System.out.println("UploadFunction - a problem occured: " + ex); response.getWriter().write("ERROR:" + ex.getMessage()); } }