List of usage examples for java.lang String compareToIgnoreCase
public int compareToIgnoreCase(String str)
From source file:com.qingstor.sdk.utils.QSJSONUtil.java
public static void sortJSONArray(List array, final String key) { Collections.sort((List<JSONObject>) array, new Comparator<JSONObject>() { @Override/* ww w. ja va 2 s . c o m*/ public int compare(JSONObject o1, JSONObject o2) { String v1 = QSJSONUtil.toString(o1, key); String v2 = QSJSONUtil.toString(o2, key); if (v2 == null) { v2 = ""; } if (v1 == null) { v1 = ""; } return v2.compareToIgnoreCase(v1); } }); }
From source file:com.ibuildapp.romanblack.FanWallPlugin.data.Statics.java
public static List<FanWallMessage> getLikedByMe(List<FanWallMessage> messages) { if (Authorization.getAuthorizedUser(Authorization.AUTHORIZATION_TYPE_FACEBOOK) == null) return messages; List<String> likedList = null; try {//from w w w. j av a 2 s . co m likedList = FacebookAuthorizationActivity.getUserOgLikes(); if (likedList != null && !likedList.isEmpty()) for (String likedLink : likedList) { for (FanWallMessage msg : messages) { if (likedLink.compareToIgnoreCase(msg.getImageUrl()) == 0) { msg.setLikedByMe(true); break; } } } return messages; } catch (FacebookAuthorizationActivity.FacebookNotAuthorizedException e) { return null; } }
From source file:org.eclipse.emf.teneo.util.StoreUtil.java
/** * Based on the eclass and the fieldname returns the structural feature. Caching should be added here. *//*from www . ja v a2 s .c o m*/ public static EStructuralFeature getEStructuralFeature(EClass eclass, String fieldName) { EStructuralFeature reserve = null; for (EStructuralFeature estruct : eclass.getEAllStructuralFeatures()) { String name = estruct.getName(); if (name.compareTo(fieldName) == 0) { return estruct; } if (name.compareToIgnoreCase(fieldName) == 0) { reserve = estruct; // use this if all else fails } else if ((name + "_").compareToIgnoreCase(fieldName) == 0) { // reserved // word reserve = estruct; // use this if all else fails } } if (reserve != null) { return reserve; } return null; // throw new StoreException("The fieldname " + fieldName + " is not // present as a ereference type in the class: " // + eclass.getName()); }
From source file:se.kth.karamel.backend.github.GithubApi.java
public synchronized static void removeRepo(String owner, String repoName) throws KaramelException { try {/*from ww w . j a va 2s .co m*/ GitHub gitHub = GitHub.connectUsingPassword(GithubApi.getUser(), GithubApi.getPassword()); if (!gitHub.isCredentialValid()) { throw new KaramelException("Invalid GitHub credentials"); } GHRepository repo = null; if (owner.compareToIgnoreCase(GithubApi.getUser()) != 0) { GHOrganization org = gitHub.getOrganization(owner); repo = org.getRepository(repoName); } else { repo = gitHub.getRepository(owner + "/" + repoName); } repo.delete(); } catch (IOException ex) { throw new KaramelException("Problem authenticating with gihub-api when trying to remove a repository"); } }
From source file:com.vividsolutions.jump.io.CompressedFile.java
/** * Searches through the .zip file looking for a file with the given extension. * Returns null if it doesn't find one./* w w w . j av a 2 s .c o m*/ * * @deprecated only used by very old data readers which only deliver the first file in zip file [ede 05.2012] */ public static String getInternalZipFnameByExtension(String extension, String compressedFile) throws Exception { // zip file String inside_zip_extension; InputStream IS_low = new FileInputStream(compressedFile); ZipInputStream fr_high = new ZipInputStream(IS_low); // need to find the correct file within the .zip file ZipEntry entry; entry = fr_high.getNextEntry(); while (entry != null) { inside_zip_extension = entry.getName().substring(entry.getName().length() - extension.length()); if (inside_zip_extension.compareToIgnoreCase(extension) == 0) { return (entry.getName()); } entry = fr_high.getNextEntry(); } return null; }
From source file:com.sldeditor.test.unit.tool.vector.VectorToolTest.java
/** * Stream 2 file.//from www . jav a 2 s .c om * * @param in the in * @return the file * @throws IOException Signals that an I/O exception has occurred. */ private static File stream2file(InputStream in) throws IOException { final File tempFile = File.createTempFile(PREFIX, SUFFIX); try (FileOutputStream out = new FileOutputStream(tempFile)) { IOUtils.copy(in, out); } // Update the font for the operating system String newFont = getFontForOS(); if (newFont.compareToIgnoreCase(DEFAULT_FONT) != 0) { BufferedReader br = new BufferedReader(new FileReader(tempFile)); try { StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line.replace(DEFAULT_FONT, newFont)); sb.append("\n"); line = br.readLine(); } try { FileWriter fileWriter = new FileWriter(tempFile); fileWriter.write(sb.toString()); fileWriter.flush(); fileWriter.close(); } catch (IOException e) { e.printStackTrace(); } } finally { br.close(); } } return tempFile; }
From source file:com.openbravo.pos.admin.RolesViewTree.java
public static DefaultMutableTreeNode sortTree(DefaultMutableTreeNode root) { for (int i = 0; i < root.getChildCount() - 1; i++) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) root.getChildAt(i); String nt = node.getUserObject().toString(); for (int j = i + 1; j <= root.getChildCount() - 1; j++) { DefaultMutableTreeNode prevNode = (DefaultMutableTreeNode) root.getChildAt(j); String np = prevNode.getUserObject().toString(); if (nt.compareToIgnoreCase(np) > 0) { root.insert(node, j);/*from w w w .j a v a2s.c o m*/ root.insert(prevNode, i); } } if (node.getChildCount() > 0) { node = sortTree(node); } } return root; }
From source file:com.egt.ejb.toolkit.ToolKitUtils.java
private static Comparator<Pagina> applicationPagesComparator() { return new Comparator<Pagina>() { @Override// w ww .j a va2 s . c om public int compare(Pagina x, Pagina y) { String nx = StringUtils.trimToEmpty(x.getNombrePagina()); String ny = StringUtils.trimToEmpty(y.getNombrePagina()); int c = nx.compareToIgnoreCase(ny); return c == 0 ? x.compareTo(y) : c; } }; }
From source file:org.yccheok.jstock.engine.Utils.java
/** * One of the shortcomings of JStock is that, it is very difficult to get a * complete list of available stocks in a market. Most stock servers do not * provide information on complete list of available stocks. We can overcome * this, by reading the stock list information from a CSV file. * * @param file The CSV file/* w w w . ja v a2 s.c om*/ * @return List of stocks carried by the CSV file. */ public static List<Stock> getStocksFromCSVFile(File file) { List<Stock> stocks = new ArrayList<Stock>(); FileInputStream fileInputStream = null; InputStreamReader inputStreamReader = null; CSVReader csvreader = null; try { fileInputStream = new FileInputStream(file); inputStreamReader = new InputStreamReader(fileInputStream, Charset.forName("UTF-8")); csvreader = new CSVReader(inputStreamReader); final String[] types = csvreader.readNext(); if (types == null) { // Fail. Returns empty stock list. return stocks; } int code_index = -1; int symbol_index = -1; // Name, board and industry information is optional. int name_index = -1; int board_index = -1; int industry_index = -1; boolean success_index = false; // Search for the indecies for code, symbol and name. for (int index = 0; index < types.length; index++) { final String type = types[index]; if (0 == type.compareToIgnoreCase("code")) { code_index = index; } else if (0 == type.compareToIgnoreCase("symbol")) { symbol_index = index; } else if (0 == type.compareToIgnoreCase("name")) { name_index = index; } else if (0 == type.compareToIgnoreCase("board")) { board_index = index; } else if (0 == type.compareToIgnoreCase("industry")) { industry_index = index; } if (code_index != -1 && symbol_index != -1 && name_index != -1 && board_index != -1 && industry_index != -1) { // All found. Early quit. break; } } // Ignore board_index, as it is optional. success_index = (code_index != -1 && symbol_index != -1); // Are we having all the indecies? if (false == success_index) { // Nope. Returns empty stock list. return stocks; } String[] nextLine; while ((nextLine = csvreader.readNext()) != null) { // Shall we continue to ignore, or shall we just return early to // flag an error? if (nextLine.length != types.length) { // Give a warning message. log.error("Incorrect CSV format. There should be exactly " + types.length + " item(s)"); continue; } final String code = nextLine[code_index]; final String symbol = nextLine[symbol_index]; final String name = name_index == -1 ? "" : nextLine[name_index]; final String _board = board_index == -1 ? "Unknown" : nextLine[board_index]; final String _industry = industry_index == -1 ? "Unknown" : nextLine[industry_index]; Board board; Industry industry; try { board = Board.valueOf(_board); } catch (IllegalArgumentException exp) { log.error(null, exp); board = Board.Unknown; } try { industry = Industry.valueOf(_industry); } catch (IllegalArgumentException exp) { log.error(null, exp); industry = Industry.Unknown; } final Stock stock = new Stock.Builder(Code.newInstance(code), Symbol.newInstance(symbol)).name(name) .board(board).industry(industry).build(); stocks.add(stock); } } catch (IOException ex) { log.error(null, ex); } finally { if (csvreader != null) { try { csvreader.close(); } catch (IOException ex) { log.error(null, ex); } } org.yccheok.jstock.gui.Utils.close(inputStreamReader); org.yccheok.jstock.gui.Utils.close(fileInputStream); } return stocks; }
From source file:org.broad.igv.cbio.GeneNetwork.java
/** * The the value of a child node by the key. * If there are multiple matches, the first is returned. * Search is not recursive./* www . ja v a 2 s . c o m*/ * <p/> * <p/> * Example: Say that node has the following XML * "<node id="3725"/> * <data key="label">JUN</data> * <data key="type">Protein</data> * <data key="RELATIONSHIP_XREF">HGNC:JUN;Entrez Gene:3725</data> * <data key="IN_QUERY">false</data> * </node>" * So getNodeKeyData(node, "key", "label") returns "JUN". * * @param node * @param attrName * @param attrValue * @return String value of key found. null if not found */ public static String getNodeAttrValue(Node node, String attrName, String attrValue) { NodeList elements = node.getChildNodes(); for (int ee = 0; ee < elements.getLength(); ee++) { Node el = elements.item(ee); try { NamedNodeMap map = el.getAttributes(); Node label = map.getNamedItem(attrName); String textContent = label.getTextContent(); if (textContent.compareToIgnoreCase(attrValue) == 0) { return el.getTextContent(); } } catch (NullPointerException e) { //In general these get hit due to newlines and such //We simply skip continue; } } return null; }