List of usage examples for java.lang String compareTo
public int compareTo(String anotherString)
From source file:com.kdgregory.pomutil.cleaner.TestReplaceExplicitVersionsWithProperties.java
@Test public void testBasicOperation() throws Exception { new ReplaceExplicitVersionsWithProperties(loadPom("cleaner/VersionProps1.xml")).transform(); assertProperty("commons-io.version", "2.1"); assertProperty("junit.version", "4.10"); assertDependencyReference("junit", "junit", "${junit.version}"); assertDependencyReference("commons-io", "commons-io", "${commons-io.version}"); // verify that we removed the previous dependencies assertNoDependencyReference("junit", "junit", "4.10"); assertNoDependencyReference("commons-io", "commons-io", "2.1"); // verify that we didn't damage the existing properties section String existingProp = newXPath("/mvn:project/mvn:properties/mvn:project.build.sourceEncoding") .evaluateAsString(dom());/*from ww w . jav a 2 s .c o m*/ assertEquals("existing property still exists", "UTF-8", existingProp); // finally, verify that the new properties are in sorted order String lastPropValue = ""; for (Element prop : newXPath("/mvn:project/mvn:properties/*").evaluate(dom(), Element.class)) { String value = DomUtil.getLocalName(prop); if (!value.endsWith(".version")) continue; if (value.compareTo(lastPropValue) < 0) fail("found property " + value + " after " + lastPropValue); lastPropValue = value; } }
From source file:com.springinpractice.ch11.model.AbstractCI.java
@Override public int compareTo(T that) { String thisDisplayName = getDisplayName(); String thatDisplayName = that.getDisplayName(); if (thisDisplayName == null) { return (thatDisplayName == null ? 0 : 1); } else if (thatDisplayName == null) { return -1; } else {// w w w . j a va2 s.c o m return thisDisplayName.compareTo(thatDisplayName); } }
From source file:org.geoserver.wps.GetCapabilities.java
public WPSCapabilitiesType run(GetCapabilitiesType request) throws WPSException { // do the version negotiation dance List<String> provided = Collections.singletonList("1.0.0"); List<String> accepted = null; if (request.getAcceptVersions() != null) accepted = request.getAcceptVersions().getVersion(); String version = RequestUtils.getVersionOws11(provided, accepted); if (!"1.0.0".equals(version)) { throw new WPSException("Could not understand version:" + version); }//from ww w . j a va2s . c om // TODO: add update sequence negotiation // encode the response Wps10Factory wpsf = Wps10Factory.eINSTANCE; Ows11Factory owsf = Ows11Factory.eINSTANCE; WPSCapabilitiesType caps = wpsf.createWPSCapabilitiesType(); caps.setVersion("1.0.0"); // TODO: make configurable caps.setLang("en"); // ServiceIdentification ServiceIdentificationType si = owsf.createServiceIdentificationType(); caps.setServiceIdentification(si); si.getTitle().add(Ows11Util.languageString(wps.getTitle())); si.getAbstract().add(Ows11Util.languageString(wps.getAbstract())); KeywordsType kw = Ows11Util.keywords(wps.keywordValues()); ; if (kw != null) { si.getKeywords().add(kw); } si.setServiceType(Ows11Util.code("WPS")); si.getServiceTypeVersion().add("1.0.0"); si.setFees(wps.getFees()); if (wps.getAccessConstraints() != null) { si.getAccessConstraints().add(wps.getAccessConstraints()); } // ServiceProvider ServiceProviderType sp = owsf.createServiceProviderType(); caps.setServiceProvider(sp); // TODO: set provder name from context SettingsInfo settings = wps.getGeoServer().getSettings(); if (settings.getContact().getContactOrganization() != null) { sp.setProviderName(settings.getContact().getContactOrganization()); } else { sp.setProviderName("GeoServer"); } sp.setProviderSite(owsf.createOnlineResourceType()); sp.getProviderSite().setHref(settings.getOnlineResource()); sp.setServiceContact(responsibleParty(settings, owsf)); // OperationsMetadata OperationsMetadataType om = owsf.createOperationsMetadataType(); caps.setOperationsMetadata(om); OperationType gco = owsf.createOperationType(); gco.setName("GetCapabilities"); gco.getDCP().add(Ows11Util.dcp("wps", request)); om.getOperation().add(gco); OperationType dpo = owsf.createOperationType(); dpo.setName("DescribeProcess"); dpo.getDCP().add(Ows11Util.dcp("wps", request)); om.getOperation().add(dpo); OperationType eo = owsf.createOperationType(); eo.setName("Execute"); eo.getDCP().add(Ows11Util.dcp("wps", request)); om.getOperation().add(eo); ProcessOfferingsType po = wpsf.createProcessOfferingsType(); caps.setProcessOfferings(po); // gather the process list for (ProcessFactory pf : GeoServerProcessors.getProcessFactories()) { for (Name name : pf.getNames()) { ProcessBriefType p = wpsf.createProcessBriefType(); p.setProcessVersion(pf.getVersion(name)); po.getProcess().add(p); p.setIdentifier(Ows11Util.code(name)); p.setTitle(Ows11Util.languageString(pf.getTitle(name))); p.setAbstract(Ows11Util.languageString(pf.getDescription(name))); } } // sort it ECollections.sort(po.getProcess(), new Comparator() { public int compare(Object o1, Object o2) { ProcessBriefType pb1 = (ProcessBriefType) o1; ProcessBriefType pb2 = (ProcessBriefType) o2; final String id1 = pb1.getIdentifier().getValue(); final String id2 = pb2.getIdentifier().getValue(); return id1.compareTo(id2); } }); LanguagesType1 languages = wpsf.createLanguagesType1(); caps.setLanguages(languages); DefaultType2 defaultLanguage = wpsf.createDefaultType2(); languages.setDefault(defaultLanguage); defaultLanguage.setLanguage("en-US"); LanguagesType supportedLanguages = wpsf.createLanguagesType(); languages.setSupported(supportedLanguages); supportedLanguages.getLanguage().add("en-US"); return caps; // Version detection and alternative invocation if being implemented. }
From source file:adalid.core.DisplayField.java
@Override public int compareTo(DisplayField o) { DisplayField that;//from www. j av a 2 s . com if (o != null) { that = o; String thisName = StringUtils.trimToEmpty(this.getName()); String thatName = StringUtils.trimToEmpty(that.getName()); return thisName.compareTo(thatName); } return 0; }
From source file:com.sfs.whichdoctor.dao.PhoneDAOImpl.java
/** * If the PhoneBean is primary ensure no other * primary entry exists for the ReferenceGUID. * * @param phone the phone/*from w ww .j a v a 2 s . c o m*/ * @param action the action * @throws WhichDoctorDaoException the which doctor dao exception */ private void updatePrimary(final PhoneBean phone, final String action) throws WhichDoctorDaoException { if (phone.getPrimary()) { if (action.compareTo("delete") != 0) { /* Find old primary address and turn off flag */ this.getJdbcTemplateWriter().update(this.getSQL().getValue("phone/updatePrimary"), new Object[] { false, phone.getReferenceGUID(), phone.getGUID(), true }); } } }
From source file:com.sp.keyword_generator.UnitexParser.java
public KeywordSet parseKeywords(String s, Book ABook) { boolean Normier = Boolean.parseBoolean(conf.getProperty("advance.keyword.generation")); String line;//from w w w . j a v a2 s.c o m if (s.compareTo("") == 0) { return new KeywordSet(); } StringTokenizer st = new StringTokenizer(s, "\n"); KeywordSet KeywordList = new KeywordSet(); for (int i = 0; i < 59 && st.hasMoreElements(); i++, st.hasMoreTokens()) { try { line = st.nextToken(); } catch (java.util.NoSuchElementException e) { LOG.info("No more elements"); break; } String[] temp = line.split("\t"); String keywordLemma = StringEscapeUtils.escapeSql(temp[1].trim()); String weight = temp[0].trim(); String[] ArrayStopWords = { "pre", "livre", "dit", "ISBN", "isbn", "mre", "fille", "fils", "famille", "homme", "femme", "histoire", "an", "anne", "premier", "dernier", "histoire", "vie", "jours", "fin", "jeune", "vieux", "bon", "critique.N", "mai.N", "critiques.N", "critiques.N", "page.N", "pages.N", "critique.A", "critiques.A", "maison d'dition", "tome", "commentaire", "grand", "petit", "premier", "nouveau", "certain", "dition", "tome", "commentaire", "diteur", "babelio", "LiliGalipette", "chose", "choses", "titre", "livre de poche", "BVIALLET", "Vienlivre", "nom", "lecture", "mis", "brigetoun", "brigittelascombe", "Evene", "null", "vincentf", "premire", "br", "diffrent", "monde", "diffrents", "http", "Livr" }; ArrayList<String> Stopwords = new ArrayList<>(Arrays.asList(ArrayStopWords)); temp = keywordLemma.split("\\."); String lemma = null; if (temp.length > 1) { lemma = temp[1]; } String keyword = temp[0]; if ("N".equals(lemma) || "A".equals(lemma) || (keyword.matches("^[A-Z].*") && "".equals(lemma))) { if (/*!Stopwords.contains(keywordLemma) && !Stopwords.contains(keyword) && */keyword != null && keyword.length() > 1) { if (lemma.isEmpty() || "".equals(lemma)) { lemma = "NP"; } Keyword new_kw = new Keyword(keyword, lemma, Double.parseDouble(weight)); if (Normier) { Main.NormierKeywords.put(new_kw); } KeywordList.put(new_kw); } } } return KeywordList; }
From source file:edu.cmu.tetrad.search.TimeSeriesUtils.java
public static IKnowledge getKnowledge(Graph graph) { // System.out.println("Entering getKnowledge ... "); int numLags = 1; // need to fix this! List<Node> variables = graph.getNodes(); List<Integer> laglist = new ArrayList<>(); IKnowledge knowledge = new Knowledge2(); int lag;//from www . j ava 2s . c om for (Node node : variables) { String varName = node.getName(); String tmp; if (varName.indexOf(':') == -1) { lag = 0; laglist.add(lag); } else { tmp = varName.substring(varName.indexOf(':') + 1, varName.length()); lag = Integer.parseInt(tmp); laglist.add(lag); } } numLags = Collections.max(laglist); // System.out.println("Variable list before the sort = " + variables); Collections.sort(variables, new Comparator<Node>() { @Override public int compare(Node o1, Node o2) { String name1 = getNameNoLag(o1); String name2 = getNameNoLag(o2); // System.out.println("name 1 = " + name1); // System.out.println("name 2 = " + name2); String prefix1 = getPrefix(name1); String prefix2 = getPrefix(name2); // System.out.println("prefix 1 = " + prefix1); // System.out.println("prefix 2 = " + prefix2); int index1 = getIndex(name1); int index2 = getIndex(name2); // System.out.println("index 1 = " + index1); // System.out.println("index 2 = " + index2); if (getLag(o1.getName()) == getLag(o2.getName())) { if (prefix1.compareTo(prefix2) == 0) { return Integer.compare(index1, index2); } else { return prefix1.compareTo(prefix2); } } else { return getLag(o1.getName()) - getLag(o2.getName()); } } }); // System.out.println("Variable list after the sort = " + variables); for (Node node : variables) { String varName = node.getName(); String tmp; if (varName.indexOf(':') == -1) { lag = 0; // laglist.add(lag); } else { tmp = varName.substring(varName.indexOf(':') + 1, varName.length()); lag = Integer.parseInt(tmp); // laglist.add(lag); } knowledge.addToTier(numLags - lag, node.getName()); } //System.out.println("Knowledge in graph = " + knowledge); return knowledge; }
From source file:com.aliyun.datahub.flume.sink.DatahubSink.java
private OdpsEventSerializer createSerializer(String serializerType) { if (serializerType.compareToIgnoreCase(OdpsDelimitedTextSerializer.ALIAS) == 0 || serializerType.compareTo(OdpsDelimitedTextSerializer.class.getName()) == 0) { return new OdpsDelimitedTextSerializer(); } else if (serializerType.compareToIgnoreCase(OdpsRegexEventSerializer.ALIAS) == 0 || serializerType.compareTo(OdpsRegexEventSerializer.class.getName()) == 0) { return new OdpsRegexEventSerializer(); }//from w w w . j ava 2 s. c o m try { return (OdpsEventSerializer) Class.forName(serializerType).newInstance(); } catch (Exception e) { throw new IllegalArgumentException( "Unable to instantiate serializer: " + serializerType + " on sink: " + getName(), e); } }
From source file:es.prodevelop.gvsig.mini.json.GeoJSONParser.java
private void encodeGeometry(IGeometry g) throws JSONException { builder.object();/*from w w w . j a v a 2 s .c o m*/ builder.key("type"); String name = getGeometryName(g); if (name != null) { builder.value(name); if (name.compareTo("Point") == 0) { builder.key("coordinates"); encodeCoordinate((Point) g); } else if (name.compareTo("MultiPoint") == 0) { MultiPoint mp = (MultiPoint) g; builder.key("coordinates"); builder.array(); for (int i = 0; i < mp.getNumPoints(); i++) { encodeCoordinate(((MultiPoint) g).getPoint(i)); } builder.endArray(); } } builder.endObject(); }
From source file:com.vtls.opensource.jhove.JHOVEDocumentFactory.java
/** * Private constructor. Initializes the logger and loads modules. *//*from w ww.j av a 2 s. c o m*/ private JHOVEDocumentFactory() { String version = System.getProperty("java.vm.version"); if (version.compareTo("1.4.0") < 0) throw new RuntimeException(EXCEPTION_JAVA_VERSION); m_module_list = new LinkedList(); // Set the log level for the JHOVE package. java.util.logging.Logger.getLogger("edu.harvard.hul.ois.jhove").setLevel(java.util.logging.Level.SEVERE); // Set up a placeholder JhoveBase instance. App m_application = new App(ApplicationName, Release, ApplicationDate, Usage, Rights); try { // Create base JHOVE object, We won't actually use this class but a // quirk of the architecture requires that it be passed to the Modules. m_jhove = new JhoveBase(); m_jhove.setLogLevel("SEVERE"); m_jhove.setChecksumFlag(false); m_jhove.setShowRawFlag(false); m_jhove.setSignatureFlag(false); } catch (JhoveException e) { throw new RuntimeException(e); } // Initialize the collection of Modules. for (int i = 0; i < Modules.length; i++) { try { Class module_class = Class.forName(Modules[i]); Module module = (Module) module_class.newInstance(); module.init(null); module.setDefaultParams(new LinkedList()); m_module_list.add(module); } catch (ClassNotFoundException e) { m_logger.error("Cannot initialize module: " + Modules[i], e); } catch (InstantiationException e) { m_logger.error("Cannot initialize module: " + Modules[i], e); } catch (Exception e) { m_logger.error(e); } } }