List of usage examples for java.lang String CASE_INSENSITIVE_ORDER
Comparator CASE_INSENSITIVE_ORDER
To view the source code for java.lang String CASE_INSENSITIVE_ORDER.
Click Source Link
From source file:com.nxt.zyl.data.volley.toolbox.BasicNetwork.java
/** * Converts Headers[] to Map<String, String>. *//* w w w.j a va 2 s . c o m*/ protected static Map<String, String> convertHeaders(Header[] headers) { Map<String, String> result = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); for (Header header : headers) { result.put(header.getName(), header.getValue()); } return result; }
From source file:org.apache.directory.fortress.core.impl.HierUtil.java
/** * Recursively traverse the hierarchical graph and return all of the descendants for a given node. * * @param parentName maps to vertex to determine parentage. * @param graph contains a reference to simple digraph {@code org.jgrapht.graph.SimpleDirectedGraph}. * @return Set of names that are children of given parent. *///from w ww . ja v a2 s . c o m static Set<String> getDescendants(String parentName, SimpleDirectedGraph<String, Relationship> graph) { Map<String, String> vx = new HashMap<>(); // TreeSet will return in sorted order: // create Set with case insensitive comparator: Set<String> children = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); vx.put(VERTEX, parentName.toUpperCase()); getDescendants(vx, graph, children); return children; }
From source file:forge.gui.ImportSourceAnalyzer.java
private void analyzeCardPicsSetDir(final File root) { if (null == cardFileNamesBySet) { cardFileNamesBySet = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); for (final CardEdition ce : FModel.getMagicDb().getEditions()) { final Map<String, String> cardFileNames = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); final Predicate<PaperCard> filter = IPaperCard.Predicates.printedInSet(ce.getCode()); addSetCards(cardFileNames, FModel.getMagicDb().getCommonCards().getAllCards(), filter); addSetCards(cardFileNames, FModel.getMagicDb().getVariantCards().getAllCards(), filter); cardFileNamesBySet.put(ce.getCode2(), cardFileNames); }//w w w . j av a2 s.c o m // planar cards now don't have the ".full" part in their filenames nameUpdates = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); final Predicate<PaperCard> predPlanes = new Predicate<PaperCard>() { @Override public boolean apply(final PaperCard arg0) { return arg0.getRules().getType().isPlane() || arg0.getRules().getType().isPhenomenon(); } }; for (final PaperCard c : Iterables.filter(FModel.getMagicDb().getVariantCards().getAllCards(), predPlanes)) { String baseName = ImageUtil.getImageKey(c, false, true); nameUpdates.put(baseName + ".full.jpg", baseName + ".jpg"); if (ImageUtil.hasBackFacePicture(c)) { baseName = ImageUtil.getImageKey(c, true, true); nameUpdates.put(baseName + ".full.jpg", baseName + ".jpg"); } } } final CardEdition.Collection editions = FModel.getMagicDb().getEditions(); final String editionCode = root.getName(); final CardEdition edition = editions.get(editionCode); if (null == edition) { // not a valid set name, skip numFilesAnalyzed += countFiles(root); return; } final String editionCode2 = edition.getCode2(); final Map<String, String> validFilenames = cardFileNamesBySet.get(editionCode2); analyzeListedDir(root, ForgeConstants.CACHE_CARD_PICS_DIR, new ListedAnalyzer() { @Override public String map(String filename) { filename = editionCode2 + "/" + filename; if (nameUpdates.containsKey(filename)) { filename = nameUpdates.get(filename); } if (validFilenames.containsKey(filename)) { return validFilenames.get(filename); } else if (StringUtils.endsWithIgnoreCase(filename, ".jpg") || StringUtils.endsWithIgnoreCase(filename, ".png")) { return filename; } return null; } @Override public OpType getOpType(final String filename) { return validFilenames.containsKey(filename) ? OpType.SET_CARD_PIC : OpType.POSSIBLE_SET_CARD_PIC; } }); }
From source file:gov.nih.nci.caintegrator.application.lists.UserListBeanHelper.java
public void differenceLists(List<String> listNames, String newListName, ListType listType) { //we're only expecting 2 lists here if (listNames.size() != 2) { return;/*from w ww . j a va2 s. c o m*/ } UserList ulist = userListBean.getList(listNames.get(0)); List<String> s1 = ulist.getList(); ulist = userListBean.getList(listNames.get(1)); List<String> s2 = ulist.getList(); //transforms s1 into the (asymmetric) set difference of s1 and s2. //(For example, the set difference of s1 minus s2 is the set containing all //the elements found in s1 but not in s2.) Set<String> difference = new HashSet<String>(s1); difference.removeAll(s2); UserList newList = null; if (difference.size() > 0) { List dList = new ArrayList(); dList.addAll(difference); Collections.sort(dList, String.CASE_INSENSITIVE_ORDER); newList = new UserList(newListName + "_" + listNames.get(0) + "-" + listNames.get(1), listType, dList, new ArrayList<String>(), new Date()); newList.setListOrigin(ListOrigin.Custom); newList.setItemCount(dList.size()); userListBean.addList(newList); } Set<String> difference2 = new HashSet<String>(s2); difference2.removeAll(s1); if (difference2.size() > 0) { List dList2 = new ArrayList(); dList2.addAll(difference2); Collections.sort(dList2, String.CASE_INSENSITIVE_ORDER); newList = null; newList = new UserList(newListName + "_" + listNames.get(1) + "-" + listNames.get(0), listType, dList2, new ArrayList<String>(), new Date()); newList.setListOrigin(ListOrigin.Custom); newList.setItemCount(dList2.size()); userListBean.addList(newList); } }
From source file:org.springframework.jdbc.repo.impl.jdbc.RawPropertiesRepoImplTest.java
private Map<String, Serializable> createEntityProperties(final String seed) { final int unitIndex = RANDOMIZER.nextInt(units.size()); final int classIndex = RANDOMIZER.nextInt(classes.size()); return new TreeMap<String, Serializable>(String.CASE_INSENSITIVE_ORDER) { private static final long serialVersionUID = 1L; {/*w w w.ja v a2s . co m*/ put("testName", seed); put("testHash", Integer.valueOf(seed.hashCode())); put("nowTime", Long.valueOf(System.nanoTime())); put("nowDate", new Date(System.currentTimeMillis())); put("nowCalendar", Calendar.getInstance()); put("randomValue", Double.valueOf(Math.random())); put("enumValue", units.get(unitIndex)); put("periodValue", Period.valueOf(units.get(unitIndex), Math.abs(RANDOMIZER.nextLong()))); put("classValue", classes.get(classIndex)); } }; }
From source file:org.knime.ext.textprocessing.nodes.source.parser.tika.TikaParser.java
/** * @return the list of all supported MIME types in Tika. *//*from w w w . j ava 2s . c om*/ public static String[] getMimeTypes() { Iterator<MediaType> it = TikaParserConfig.VALID_TYPES.iterator(); List<String> list = new ArrayList<String>(); while (it.hasNext()) { list.add(it.next().toString()); } Collections.sort(list, String.CASE_INSENSITIVE_ORDER); return list.toArray(new String[list.size()]); }
From source file:rapture.repo.jdbc.JDBCStructuredStore.java
private ResultSetExtractor<List<Map<String, Object>>> createResultSetExtractor() { return new ResultSetExtractor<List<Map<String, Object>>>() { @Override//from w w w .j av a 2 s . co m public List<Map<String, Object>> extractData(ResultSet rs) throws SQLException, DataAccessException { List<Map<String, Object>> ret = new ArrayList<>(); ResultSetMetaData rsmd = rs.getMetaData(); int numColumns = rsmd.getColumnCount(); while (rs.next()) { Map<String, Object> m = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); for (int i = 1; i <= numColumns; i++) { m.put(rsmd.getColumnLabel(i), rs.getObject(i)); } ret.add(m); } return ret; } }; }
From source file:com.microsoft.tfs.client.common.ui.teamexplorer.internal.pendingchanges.PendingChangesViewModel.java
public Workspace[] getWorkspaces() { if (allWorkspaces == null) { final QueryLocalWorkspacesCommand queryCommand = new QueryLocalWorkspacesCommand( server.getConnection()); final IStatus queryStatus = new CommandExecutor().execute(queryCommand); if (queryStatus.isOK()) { allWorkspaces = queryCommand.getWorkspaces(); Arrays.sort(allWorkspaces, new Comparator<Workspace>() { @Override//from w w w . j a va2 s .co m public int compare(final Workspace workspace0, final Workspace workspace1) { return String.CASE_INSENSITIVE_ORDER.compare(workspace0.getName(), workspace1.getName()); } }); } } return allWorkspaces; }
From source file:jails.http.MediaType.java
/** * Compares this {@link MediaType} to another alphabetically. * @param other media type to compare to * @see #sortBySpecificity(List)/*from ww w . j a v a 2 s . c o m*/ */ public int compareTo(MediaType other) { int comp = this.type.compareToIgnoreCase(other.type); if (comp != 0) { return comp; } comp = this.subtype.compareToIgnoreCase(other.subtype); if (comp != 0) { return comp; } comp = this.parameters.size() - other.parameters.size(); if (comp != 0) { return comp; } TreeSet<String> thisAttributes = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); thisAttributes.addAll(this.parameters.keySet()); TreeSet<String> otherAttributes = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); otherAttributes.addAll(other.parameters.keySet()); Iterator<String> thisAttributesIterator = thisAttributes.iterator(); Iterator<String> otherAttributesIterator = otherAttributes.iterator(); while (thisAttributesIterator.hasNext()) { String thisAttribute = thisAttributesIterator.next(); String otherAttribute = otherAttributesIterator.next(); comp = thisAttribute.compareToIgnoreCase(otherAttribute); if (comp != 0) { return comp; } String thisValue = this.parameters.get(thisAttribute); String otherValue = other.parameters.get(otherAttribute); if (otherValue == null) { otherValue = ""; } comp = thisValue.compareTo(otherValue); if (comp != 0) { return comp; } } return 0; }
From source file:org.sakaiproject.tool.assessment.facade.QuestionPoolFacadeQueries.java
public List getAllItemFacadesOrderByItemText(final Long questionPoolId, final String orderBy, final String ascending) { // Fixed for bug 3559 log.debug("QuestionPoolFacadeQueries: getAllItemFacadesOrderByItemText:: orderBy=" + orderBy); List list = getAllItems(questionPoolId); log.debug("QuestionPoolFacadeQueries: getAllItemFacadesOrderByItemText:: size = " + list.size()); HashMap hp = new HashMap(); Vector origValueV;//from www . ja v a 2 s . c o m ItemData itemData; ItemFacade itemFacade; Vector facadeVector = new Vector(); String text; for (int i = 0; i < list.size(); i++) { log.debug("QuestionPoolFacadeQueries: getAllItemFacadesOrderByItemText:: i = " + i); itemData = (ItemData) list.get(i); itemFacade = new ItemFacade(itemData); facadeVector.add(itemFacade); log.debug("QuestionPoolFacadeQueries: getAllItemFacadesOrderByItemText:: getItemId = " + itemData.getItemId()); log.debug("QuestionPoolFacadeQueries: getAllItemFacadesOrderByItemText:: getText = " + itemData.getText()); // SAM-2499 text = formattedText.stripHtmlFromText(itemFacade.getText(), false, true).trim(); log.debug("QuestionPoolFacadeQueries: getAllItemFacadesOrderByItemText:: getTextHtmlStrippedAll = '" + text + "'"); origValueV = (Vector) hp.get(text); if (origValueV == null) { log.debug("QuestionPoolFacadeQueries: getAllItemFacadesOrderByItemText:: origValueV is null "); origValueV = new Vector(); } origValueV.add(Integer.valueOf(i)); hp.put(text, origValueV); } Vector v = new Vector(hp.keySet()); Collections.sort(v, String.CASE_INSENSITIVE_ORDER); ArrayList itemList = new ArrayList(); Iterator it = v.iterator(); Vector orderdValueV; Integer value; String key; if ((ascending != null) && ("false").equals(ascending)) {//sort descending for (int l = v.size() - 1; l >= 0; l--) { key = (String) v.get(l); orderdValueV = (Vector) hp.get(key); Iterator iter = orderdValueV.iterator(); while (iter.hasNext()) { value = (Integer) iter.next(); ItemData itemdata = (ItemData) list.get(value.intValue()); ItemFacade f = new ItemFacade(itemdata); itemList.add(f); } } } else {//sort ascending while (it.hasNext()) { key = (String) it.next(); orderdValueV = (Vector) hp.get(key); Iterator iter = orderdValueV.iterator(); while (iter.hasNext()) { value = (Integer) iter.next(); log.debug("QuestionPoolFacadeQueries: getAllItemFacadesOrderByItemText:: sorted (value) = " + value); itemFacade = (ItemFacade) facadeVector.get(value.intValue()); itemList.add(itemFacade); } } } return itemList; }