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:org.wso2.carbon.bpel.core.ode.integration.store.repository.BPELPackageRepository.java
private List<BPELPackageInfo> sortByPackageName(List<BPELPackageInfo> packageList) { List<BPELPackageInfo> sortedPackageList = new ArrayList<BPELPackageInfo>(); Map<String, BPELPackageInfo> packageInfoMap = new HashMap<String, BPELPackageInfo>(); for (BPELPackageInfo packageInfo : packageList) { packageInfoMap.put(packageInfo.getName(), packageInfo); }/*ww w. j av a 2s .c o m*/ SortedSet<String> sortedPackageNames = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); sortedPackageNames.addAll(packageInfoMap.keySet()); for (String packageName : sortedPackageNames) { sortedPackageList.add(packageInfoMap.get(packageName)); } return sortedPackageList; }
From source file:com.comcast.cmb.common.util.AuthUtil.java
protected static String getCanonicalizedHeaderString(Map<String, String> headers) { List<String> sortedHeaders = new ArrayList<String>(); sortedHeaders.addAll(headers.keySet()); Collections.sort(sortedHeaders, String.CASE_INSENSITIVE_ORDER); StringBuilder buffer = new StringBuilder(); for (String header : sortedHeaders) { buffer.append(header.toLowerCase().replaceAll("\\s+", " ") + ":" + headers.get(header).replaceAll("\\s+", " ")); buffer.append("\n"); }//from w w w . j a v a 2s . c om return buffer.toString(); }
From source file:org.opensolaris.opengrok.web.PageConfig.java
/** * Get a list of filenames in the requested path. * * @return an empty list, if the resource does not exist, is not a directory * or an error occurred when reading it, otherwise a list of filenames in * that directory, sorted alphabetically * @see #getResourceFile()/*from www. ja va 2s . co m*/ * @see #isDir() */ public List<String> getResourceFileList() { if (dirFileList == null) { String[] files = null; if (isDir() && getResourcePath().length() > 1) { files = getResourceFile().list(); } if (files == null) { dirFileList = Collections.emptyList(); } else { Arrays.sort(files, String.CASE_INSENSITIVE_ORDER); dirFileList = Collections.unmodifiableList(Arrays.asList(files)); } } return dirFileList; }
From source file:com.microsoft.tfs.core.clients.versioncontrol.localworkspace.LocalWorkspaceScanner.java
public void partialScan(final Iterable<String> changedPaths) throws CoreCancelException { final List<String> itemsToScan = new ArrayList<String>(); boolean fallBackToFullScan = false; for (final String changedPath : changedPaths) { try {/*from w w w. ja v a 2 s .c o m*/ itemsToScan.add(LocalPath.canonicalize(changedPath)); } catch (final Throwable t) { fallBackToFullScan = true; break; } } // If we need to fall back to a full scan, do so. if (fallBackToFullScan) { fullScan(); return; } final List<String> itemsToScanNotOnDisk = new ArrayList<String>(); final Iterable<String> workspaceRoots = WorkingFolder.getWorkspaceRoots(this.wp.getWorkingFolders()); // Otherwise proceed with a partial scan -- only those items which were // invalidated for (final String localItem : itemsToScan) { final WorkspaceLocalItem lvEntry = lv.getByLocalItem(localItem); final File localFile = new File(localItem); final FileSystemAttributes attrs = FileSystemUtils.getInstance().getAttributes(localFile); if (!attrs.exists()) { // Missing on disk, and candidate delete if (null != lvEntry) { markForRemoval.add(lvEntry); } if (null == lvEntry || !lvEntry.isCommitted()) { itemsToScanNotOnDisk.add(localItem); } continue; } final EnumeratedLocalItem fromDisk = new EnumeratedLocalItem(localFile, attrs); if (null != lvEntry) { diffItem(fromDisk, lvEntry); } else if (!fromDisk.isDirectory()) { String workspaceRoot = null; for (final String potentialRoot : workspaceRoots) { if (LocalPath.isChild(potentialRoot, fromDisk.getFullPath())) { workspaceRoot = potentialRoot; break; } } if (null != workspaceRoot) { // Start the ignore file stack's evaluation at the workspace // root of this local item. final LocalItemExclusionEvaluator ignoreFileStack = new LocalItemExclusionEvaluator(this.wp, workspaceRoot); if (!ignoreFileStack.isExcluded(fromDisk.getFullPath())) { fromDisk.setServerItem(WorkingFolder.getServerItemForLocalItem(fromDisk.getFullPath(), wp.getWorkingFolders())); if (null != fromDisk.getServerItem() && ServerPath.isServerPath(fromDisk.getServerItem())) { addCandidateAdd(fromDisk); } } } } } scanPartTwo(); // Remove from the pending changes table those candidates which we don't // have in our list. final Set<String> candidatesToRemove = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); for (final String itemToScan : itemsToScan) { final String targetServerItem = WorkingFolder.getServerItemForLocalItem(itemToScan, wp.getWorkingFolders()); if (null != targetServerItem) { final LocalPendingChange candidateChange = pc.getCandidateByTargetServerItem(targetServerItem); if (null != candidateChange && !candidateChanges.contains(candidateChange.getTargetServerItem())) { // This candidate was in the scoped scan manifest, but we // didn't create a candidate for it. We'll remove this // candidate change. candidatesToRemove.add(candidateChange.getTargetServerItem()); } } } // If we removed any items from disk, we need to check if any candidate // adds beneath it should be removed as well. There is no index by local // item on the candidates, so we have to walk the entire candidates // table. if (itemsToScanNotOnDisk.size() > 0) { for (final LocalPendingChange candidateChange : pc.queryCandidatesByTargetServerItem(ServerPath.ROOT, RecursionType.FULL, null)) { if (candidateChange.isAdd() && !candidateChanges.contains(candidateChange.getTargetServerItem())) { final String localItem = WorkingFolder.getLocalItemForServerItem( candidateChange.getTargetServerItem(), wp.getWorkingFolders(), true /* detectImplicitCloak */); if (null != localItem) { for (final String parent : itemsToScanNotOnDisk) { if (LocalPath.isChild(parent, localItem)) { candidatesToRemove.add(candidateChange.getTargetServerItem()); break; } } } } } } for (final String candidateToRemove : candidatesToRemove) { pc.removeCandidateByTargetServerItem(candidateToRemove); } if (candidatesToRemove.size() > 0) { LocalWorkspaceTransaction.getCurrent().setRaisePendingChangeCandidatesChanged(true); } fireChangedByScanEvent(); }
From source file:com.comcast.cmb.common.util.AuthUtil.java
protected static String getSignedHeadersString(Map<String, String> headers) { List<String> sortedHeaders = new ArrayList<String>(); sortedHeaders.addAll(headers.keySet()); Collections.sort(sortedHeaders, String.CASE_INSENSITIVE_ORDER); StringBuilder buffer = new StringBuilder(); for (String header : sortedHeaders) { if (buffer.length() > 0) buffer.append(";"); buffer.append(header.toLowerCase()); }// w ww. j a v a2s . com return buffer.toString(); }
From source file:org.apache.syncope.core.persistence.jpa.content.XMLContentExporter.java
@Override public void export(final String domain, final OutputStream os, final String uwfPrefix, final String gwfPrefix, final String awfPrefix) throws SAXException, TransformerConfigurationException { if (StringUtils.isNotBlank(uwfPrefix)) { TABLE_PREFIXES_TO_BE_EXCLUDED.add(uwfPrefix); }//from w ww . j av a 2 s .c om if (StringUtils.isNotBlank(gwfPrefix)) { TABLE_PREFIXES_TO_BE_EXCLUDED.add(gwfPrefix); } if (StringUtils.isNotBlank(awfPrefix)) { TABLE_PREFIXES_TO_BE_EXCLUDED.add(awfPrefix); } StreamResult streamResult = new StreamResult(os); final SAXTransformerFactory transformerFactory = (SAXTransformerFactory) SAXTransformerFactory .newInstance(); transformerFactory.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true); TransformerHandler handler = transformerFactory.newTransformerHandler(); Transformer serializer = handler.getTransformer(); serializer.setOutputProperty(OutputKeys.ENCODING, StandardCharsets.UTF_8.name()); serializer.setOutputProperty(OutputKeys.INDENT, "yes"); handler.setResult(streamResult); handler.startDocument(); handler.startElement("", "", ROOT_ELEMENT, new AttributesImpl()); DataSource dataSource = domainsHolder.getDomains().get(domain); if (dataSource == null) { throw new IllegalArgumentException("Could not find DataSource for domain " + domain); } String dbSchema = ApplicationContextProvider.getBeanFactory().getBean(domain + "DatabaseSchema", String.class); Connection conn = null; ResultSet rs = null; try { conn = DataSourceUtils.getConnection(dataSource); final DatabaseMetaData meta = conn.getMetaData(); rs = meta.getTables(null, StringUtils.isBlank(dbSchema) ? null : dbSchema, null, new String[] { "TABLE" }); final Set<String> tableNames = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); while (rs.next()) { String tableName = rs.getString("TABLE_NAME"); LOG.debug("Found table {}", tableName); if (isTableAllowed(tableName)) { tableNames.add(tableName); } } LOG.debug("Tables to be exported {}", tableNames); // then sort tables based on foreign keys and dump for (String tableName : sortByForeignKeys(dbSchema, conn, tableNames)) { try { doExportTable(handler, dbSchema, conn, tableName, TABLES_TO_BE_FILTERED.get(tableName.toUpperCase())); } catch (Exception e) { LOG.error("Failure exporting table {}", tableName, e); } } } catch (SQLException e) { LOG.error("While exporting database content", e); } finally { if (rs != null) { try { rs.close(); } catch (SQLException e) { LOG.error("While closing tables result set", e); } } DataSourceUtils.releaseConnection(conn, dataSource); if (conn != null) { try { if (!conn.isClosed()) { conn.close(); } } catch (SQLException e) { LOG.error("While releasing connection", e); } } } handler.endElement("", "", ROOT_ELEMENT); handler.endDocument(); }
From source file:com.salesforce.ide.ui.views.executeanonymous.ExecuteAnonymousViewComposite.java
private void loadProjects(List<IProject> projects) { if (projectCombo.getItemCount() > 0) projectCombo.removeAll();/*from ww w . j a v a 2 s . c o m*/ projectCombo.setData(projects); Collections.sort(projects, new Comparator<IProject>() { @Override public int compare(IProject o1, IProject o2) { return String.CASE_INSENSITIVE_ORDER.compare(o1.getName(), o2.getName()); } }); for (IProject project : projects) { projectCombo.add(project.getName()); } projectCombo.select(DEFAULT_PROJ_SELECTION); projectCombo.setEnabled(true); // Sets the width of the combo box to the width of the longest string // Layouts everything projectAndLoggingContainerComposite.pack(); projectAndLoggingContainerComposite.layout(true, true); enableComposite(true); }
From source file:com.opengamma.web.server.LiveResultsService.java
private List<String> getAggregatorNames() { List<String> result = new ArrayList<String>(); result.addAll(_aggregatedViewDefinitionManager.getAggregatorNames()); Collections.sort(result, String.CASE_INSENSITIVE_ORDER); return result; }
From source file:org.springframework.jdbc.repo.impl.jdbc.RawPropertiesRepoImpl.java
@Override @Transactional(readOnly = true)//from www . j av a 2s . c om public List<String> findEntities(final String propName, final Predicate<? super Serializable> predicate) { if (StringUtils.isEmpty(propName)) { throw new IllegalArgumentException( "findEntities(" + getEntityClass().getSimpleName() + ") no property specified"); } if (predicate == null) { throw new IllegalArgumentException( "findEntities(" + getEntityClass().getSimpleName() + ")[" + propName + "] no predicate"); } final Set<String> internalIdsSet = new HashSet<String>(); final Set<String> matchingSet = jdbcAccessor.query("SELECT " + PROPS_TABLE_ALIAS + "." + PROP_OWNER_COL + " AS " + PROP_OWNER_COL + " ," + PROPS_TABLE_ALIAS + "." + PROP_NAME_COL + " AS " + PROP_NAME_COL + " ," + PROPS_TABLE_ALIAS + "." + PROP_TYPE_COL + " AS " + PROP_TYPE_COL + " ," + PROPS_TABLE_ALIAS + "." + PROP_VALUE_COL + " AS " + PROP_VALUE_COL + " ," + ENTITIES_TABLE_ALIAS + "." + ENTITY_ID_COL + " AS " + ENTITY_ID_COL + " FROM " + ENTITY_PROPERTIES_TABLE + " AS " + PROPS_TABLE_ALIAS + " INNER JOIN " + IDENTIFIED_ENTITIES_TABLE + " AS " + ENTITIES_TABLE_ALIAS + " ON " + ENTITIES_TABLE_ALIAS + "." + INTERNAL_ID_COL + " = " + PROPS_TABLE_ALIAS + "." + PROP_OWNER_COL + " AND " + ENTITIES_TABLE_ALIAS + "." + ENTITY_TYPE_COL + " = :" + ENTITY_TYPE_COL + " AND " + PROPS_TABLE_ALIAS + "." + PROP_NAME_COL + " = :" + PROP_NAME_COL, new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER) { private static final long serialVersionUID = 1L; { put(ENTITY_TYPE_COL, getEntityClass().getSimpleName()); put(PROP_NAME_COL, propName); } }, new ResultSetExtractor<Set<String>>() { @Override @SuppressWarnings("synthetic-access") public Set<String> extractData(ResultSet rs) throws SQLException, DataAccessException { while (rs.next()) { int rowNum = rs.getRow(); Pair<String, Serializable> rowValue = valueMapper.mapRow(rs, rowNum); String rowName = rowValue.getLeft(); String ownerId = rs.getString(ENTITY_ID_COL); // just for safety if (ExtendedStringUtils.safeCompare(propName, rowName, false) != 0) { logger.warn("findEntities(" + getEntityClass().getSimpleName() + ")[" + propName + "]" + " mismatched property name at row " + rowNum + " for owner=" + ownerId + ": " + rowName); continue; } Serializable propValue = rowValue.getRight(); if (!predicate.evaluate(propValue)) { if (logger.isTraceEnabled()) { logger.trace("findEntities(" + getEntityClass().getSimpleName() + ")[" + propName + "]" + " skip row " + rowNum + " value=" + propValue + " for owner=" + ownerId); } continue; } if (StringUtils.isEmpty(ownerId)) { throw new SQLException("findEntities(" + getEntityClass().getSimpleName() + ")[" + propName + "]" + " no owner for row " + rowNum + " on matching value=" + propValue); } if (logger.isTraceEnabled()) { logger.trace("findEntities(" + getEntityClass().getSimpleName() + ")[" + propName + "]" + " matched row " + rowNum + " value=" + propValue + " for owner=" + ownerId); } if (!internalIdsSet.add(ownerId)) { continue; // debug breakpoint } } return internalIdsSet; } }); if (ExtendedCollectionUtils.isEmpty(matchingSet)) { return Collections.emptyList(); } else { return new ArrayList<String>(matchingSet); } }
From source file:com.evolveum.midpoint.schema.util.AdminGuiConfigTypeUtil.java
public static List<GuiObjectColumnType> orderCustomColumns(List<GuiObjectColumnType> customColumns) { if (customColumns == null || customColumns.size() == 0) { return new ArrayList<>(); }/* w ww .ja v a 2s . c o m*/ List<GuiObjectColumnType> customColumnsList = new ArrayList<>(); customColumnsList.addAll(customColumns); List<String> previousColumnValues = new ArrayList<>(); previousColumnValues.add(null); previousColumnValues.add(""); Map<String, String> columnRefsMap = new HashedMap(); for (GuiObjectColumnType column : customColumns) { columnRefsMap.put(column.getName(), column.getPreviousColumn() == null ? "" : column.getPreviousColumn()); } List<String> temp = new ArrayList<>(); int index = 0; while (index < customColumns.size()) { int sortFrom = index; for (int i = index; i < customColumnsList.size(); i++) { GuiObjectColumnType column = customColumnsList.get(i); if (previousColumnValues.contains(column.getPreviousColumn()) || !columnRefsMap.containsKey(column.getPreviousColumn())) { Collections.swap(customColumnsList, index, i); index++; temp.add(column.getName()); } } if (temp.size() == 0) { temp.add(customColumnsList.get(index).getName()); index++; } if (index - sortFrom > 1) { Collections.sort(customColumnsList.subList(sortFrom, index - 1), new Comparator<GuiObjectColumnType>() { @Override public int compare(GuiObjectColumnType o1, GuiObjectColumnType o2) { return String.CASE_INSENSITIVE_ORDER.compare(o1.getName(), o2.getName()); } }); } previousColumnValues.clear(); previousColumnValues.addAll(temp); temp.clear(); } return customColumnsList; }