List of usage examples for java.lang String compareToIgnoreCase
public int compareToIgnoreCase(String str)
From source file:org.nuclos.common2.StringUtils.java
public static int compareIgnoreCase(String s1, String s2) { return (s1 == null) ? ((s2 == null) ? 0 : 1) : s1.compareToIgnoreCase(s2); }
From source file:elh.eus.absa.NLPpipelineWrapper.java
/** * Process linguistically input sentence with ixa-pipes (tokenization and PoS tagging). * A tagged file is generated for each sentence in the corpus and stored in the directory * given as argument. Sentence Ids are used as file names. If a tagged file already exists * that sentence is not tagged /* www.j ava 2s. c o m*/ * * @param nafdir : path to the directory were tagged files should be stored * @param posModel : model to be used by the PoS tagger * @throws IOException * @throws JDOMException */ public static String tagSentence(String input, String savePathNoExt, String lang, String posModel, eus.ixa.ixa.pipe.pos.Annotate postagger) throws IOException, JDOMException { KAFDocument kafinst = new KAFDocument("", ""); if (FileUtilsElh.checkFile(savePathNoExt + ".kaf")) { //System.err.println("NLPpipelineWrapper::tagSentence : file already there:"+savePathNoExt+".kaf"); return savePathNoExt + ".kaf"; } // if language is basque 'posModel' argument is used to pass the path to the basque morphological analyzer eustagger else if (lang.compareToIgnoreCase("eu") == 0) { int ok = eustaggerCall(posModel, input, savePathNoExt); } else { kafinst = ixaPipesTokPos(input, lang, posModel, postagger); kafinst.save(savePathNoExt + ".kaf"); } return savePathNoExt + ".kaf"; }
From source file:MyComparator.java
public int compare(String strA, String strB) { return strA.compareToIgnoreCase(strB); }
From source file:org.iavante.sling.searcher.SearcherServiceTestIT.java
@org.junit.BeforeClass static public void initialize() { try {//from w w w. j a v a 2 s. c o m Thread.sleep(3000); } catch (InterruptedException e1) { e1.printStackTrace(); } /* get env params */ Map<String, String> envs = System.getenv(); Set<String> keys = envs.keySet(); Iterator<String> it = keys.iterator(); boolean hashost = false; while (it.hasNext()) { String key = (String) it.next(); if (key.compareToIgnoreCase(HOSTVAR) == 0) { SLING_URL = SLING_URL + (String) envs.get(key); hashost = true; break; } } if (hashost == false) SLING_URL = SLING_URL + HOSTPREDEF; /* make http connection */ client = new HttpClient(); authPrefs.add(AuthPolicy.DIGEST); authPrefs.add(AuthPolicy.BASIC); defaultcreds = new UsernamePasswordCredentials("admin", "admin"); PostMethod post_create_col; /* tests if the collection exists */ GetMethod get_create_col = new GetMethod(SLING_URL + COLLECTIONS_URL + "/" + COLLECTION); get_create_col.setDoAuthentication(true); client.getParams().setAuthenticationPreemptive(true); client.getState().setCredentials(AuthScope.ANY, defaultcreds); client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs); try { client.executeMethod(get_create_col); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } if (get_create_col.getStatusCode() != 404) { deletecontent(); } /* create a collection */ post_create_col = new PostMethod(SLING_URL + COLLECTIONS_URL + "/*"); post_create_col.setDoAuthentication(true); NameValuePair[] data_create_col = { new NameValuePair("sling:resourceType", "gad/collection"), new NameValuePair("title", COLLECTION), new NameValuePair("subtitle", ""), new NameValuePair("schema", SCHEMA), new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""), new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", "") }; post_create_col.setRequestBody(data_create_col); client.getParams().setAuthenticationPreemptive(true); client.getState().setCredentials(AuthScope.ANY, defaultcreds); client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs); try { client.executeMethod(post_create_col); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } assertEquals("Creando la coleccion", 201, post_create_col.getStatusCode()); post_create_col.releaseConnection(); // collection created // Get the content try { Thread.sleep(3000); } catch (InterruptedException e1) { e1.printStackTrace(); } /* create a content */ post_create_col = new PostMethod(SLING_URL + COLLECTIONS_URL + "/" + COLLECTION + "/contents/*"); post_create_col.setDoAuthentication(true); NameValuePair[] data_create_col_content = { new NameValuePair("sling:resourceType", "gad/content"), new NameValuePair("title", TITLE_CONTENT), new NameValuePair("author", "test_autor@tests.com"), new NameValuePair("schema", SCHEMA), new NameValuePair("description", DESCRIPTION), new NameValuePair("origin", "final cut"), new NameValuePair("lang", "es"), new NameValuePair("tags", "recetas equilibradas"), new NameValuePair("tags@TypeHint", "String[]"), new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""), new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", "") }; post_create_col.setRequestBody(data_create_col_content); client.getParams().setAuthenticationPreemptive(true); client.getState().setCredentials(AuthScope.ANY, defaultcreds); client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs); try { client.executeMethod(post_create_col); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } assertEquals("Creando contenido", 201, post_create_col.getStatusCode()); post_create_col.releaseConnection(); // Content created // Get the content try { Thread.sleep(3000); } catch (InterruptedException e1) { e1.printStackTrace(); } /* create a source */ post_create_col = new PostMethod( SLING_URL + COLLECTIONS_URL + "/" + COLLECTION + "/contents/tests_search_title/sources/*"); post_create_col.setDoAuthentication(true); NameValuePair[] data_create_col_source = { new NameValuePair("sling:resourceType", "gad/source"), new NameValuePair("title", SOURCE_TITLE), new NameValuePair("author", "test_autor@tests.com"), new NameValuePair("schema", SCHEMA), new NameValuePair("description", DESCRIPTION), new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""), new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", "") }; post_create_col.setRequestBody(data_create_col_source); // post.setDoAuthentication(true); client.getParams().setAuthenticationPreemptive(true); client.getState().setCredentials(AuthScope.ANY, defaultcreds); client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs); try { client.executeMethod(post_create_col); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } // Get the content assertEquals("Creando fuente", 201, post_create_col.getStatusCode()); post_create_col.releaseConnection(); // Source created /* send to review */ try { Thread.sleep(3000); } catch (InterruptedException e1) { e1.printStackTrace(); } post_create_col = new PostMethod( SLING_URL + COLLECTIONS_URL + "/" + COLLECTION + "/contents/" + TITLE_CONTENT); post_create_col.setDoAuthentication(true); NameValuePair[] data_send_review = { new NameValuePair(":operation", "copy"), new NameValuePair(":dest", "/content/catalogo/pendientes/"), new NameValuePair("replace", "true") }; post_create_col.setRequestBody(data_send_review); // post.setDoAuthentication(true); client.getParams().setAuthenticationPreemptive(true); client.getState().setCredentials(AuthScope.ANY, defaultcreds); client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs); try { client.executeMethod(post_create_col); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } // test if sent assertEquals("Mandando a revision", 201, post_create_col.getStatusCode()); post_create_col.releaseConnection(); // send to review finished }
From source file:com.l2jfree.gameserver.model.entity.events.VIP.java
public static void setTeam(String team) { if (team.compareToIgnoreCase("Human") == 0) { _team = 1;/*from w w w .j a v a2s . co m*/ _teamName = "Human"; } else if (team.compareToIgnoreCase("Elf") == 0) { _team = 2; _teamName = "Elf"; } else if (team.compareToIgnoreCase("Dark") == 0) { _team = 3; _teamName = "Dark Elf"; } else if (team.compareToIgnoreCase("Orc") == 0) { _team = 4; _teamName = "Orc"; } else if (team.compareToIgnoreCase("Dwarf") == 0) { _team = 5; _teamName = "Dwarf"; } setLoc(); }
From source file:mb.impostor.bytearray.RandByteArray.java
public byte[] randDataGen(String type, int count) { byte[] randbuf; if (type.compareToIgnoreCase("NRandom") == 0) { randbuf = RandomUtils.nextBytes(new Random().nextInt(count)); return randbuf; } else if (type.compareToIgnoreCase("Random") == 0) { randbuf = RandomUtils.nextBytes(count); return randbuf; } else if (type.compareToIgnoreCase("RandString") == 0) { String s = RandomStringUtils.randomAlphanumeric(count); return s.getBytes(); } else {/*from w ww . ja v a2 s .c om*/ return null; } }
From source file:com.l2jfree.gameserver.model.entity.events.VIP.java
public static void setTeam(String team, L2Player activeChar) { if (team.compareToIgnoreCase("Human") == 0) { _team = 1;/*from w ww.jav a2 s . c om*/ _teamName = "Human"; } else if (team.compareToIgnoreCase("Elf") == 0) { _team = 2; _teamName = "Elf"; } else if (team.compareToIgnoreCase("Dark") == 0) { _team = 3; _teamName = "Dark Elf"; } else if (team.compareToIgnoreCase("Orc") == 0) { _team = 4; _teamName = "Orc"; } else if (team.compareToIgnoreCase("Dwarf") == 0) { _team = 5; _teamName = "Dwarf"; } else { activeChar.sendMessage("Invalid Team Name: //vip_setteam <human/elf/dark/orc/dwarf>"); return; } setLoc(); }
From source file:org.jasig.portlet.contacts.model.util.ContactComparator.java
private int compareStrings(String s1, String s2) { if (StringUtils.hasLength(s1)) { return s1.compareToIgnoreCase(s2); } else if (StringUtils.hasLength(s2)) { return -1; }/*from w w w .j av a 2s . co m*/ return 0; }
From source file:conceptnet.ConceptBuilder.java
public boolean compareString(String s1, String s2) { if (s1.compareToIgnoreCase(s2) == 0) { return true; }/*w ww . j a v a 2 s . com*/ if (s1.length() > s2.length()) { String t = s1; s1 = s2; s2 = t; } return false; }
From source file:org.theospi.portfolio.help.model.TermComparator.java
/** * Compares its two arguments for order. Returns a negative integer, * zero, or a positive integer as the first argument is less than, equal * to, or greater than the second.<p> * <p/>/*from w ww . j av a 2s.co m*/ * The implementor must ensure that <tt>sgn(compare(x, y)) == * -sgn(compare(y, x))</tt> for all <tt>x</tt> and <tt>y</tt>. (This * implies that <tt>compare(x, y)</tt> must throw an exception if and only * if <tt>compare(y, x)</tt> throws an exception.)<p> * <p/> * The implementor must also ensure that the relation is transitive: * <tt>((compare(x, y)>0) && (compare(y, z)>0))</tt> implies * <tt>compare(x, z)>0</tt>.<p> * <p/> * Finally, the implementer must ensure that <tt>compare(x, y)==0</tt> * implies that <tt>sgn(compare(x, z))==sgn(compare(y, z))</tt> for all * <tt>z</tt>.<p> * <p/> * It is generally the case, but <i>not</i> strictly required that * <tt>(compare(x, y)==0) == (x.equals(y))</tt>. Generally speaking, * any comparator that violates this condition should clearly indicate * this fact. The recommended language is "Note: this comparator * imposes orderings that are inconsistent with equals." * * @param o1 the first object to be compared. * @param o2 the second object to be compared. * @return a negative integer, zero, or a positive integer as the * first argument is less than, equal to, or greater than the * second. * @throws ClassCastException if the arguments' types prevent them from * being compared by this Comparator. */ public int compare(Object o1, Object o2) { String entry1 = o1.toString(); String entry2 = o2.toString(); return entry1.compareToIgnoreCase(entry2); }