List of usage examples for java.text Collator getInstance
public static synchronized Collator getInstance()
From source file:org.wso2.carbon.esb.scenario.test.common.ScenarioTestBase.java
private List<String> getFilesFromSourceDirectory(String relativePath) { List<String> requestFiles = getListOfFiles(relativePath); java.util.Collections.sort(requestFiles, Collator.getInstance()); return requestFiles; }
From source file:com.marand.thinkmed.medications.business.impl.DefaultMedicationsBo.java
private void sortTherapyTemplateElements(final List<TherapyTemplateDto> templates) { final Collator collator = Collator.getInstance(); for (final TherapyTemplateDto template : templates) { Collections.sort(template.getTemplateElements(), (o1, o2) -> compareTherapiesForSort(o1.getTherapy(), o2.getTherapy(), collator)); }/*from w w w . j av a2 s . c om*/ }
From source file:org.apache.ddlutils.platform.JdbcModelReader.java
/** * Reads the tables from the database metadata. * /*from ww w . ja va2 s. c o m*/ * @param catalog The catalog to acess in the database; use <code>null</code> for the default value * @param schemaPattern The schema(s) to acess in the database; use <code>null</code> for the default value * @param tableTypes The table types to process; use <code>null</code> or an empty list for the default ones * @return The tables */ protected Collection readTables(String catalog, String schemaPattern, String[] tableTypes) throws SQLException { ResultSet tableData = null; try { DatabaseMetaDataWrapper metaData = new DatabaseMetaDataWrapper(); metaData.setMetaData(_connection.getMetaData()); metaData.setCatalog(catalog == null ? getDefaultCatalogPattern() : catalog); metaData.setSchemaPattern(schemaPattern == null ? getDefaultSchemaPattern() : schemaPattern); metaData.setTableTypes( (tableTypes == null) || (tableTypes.length == 0) ? getDefaultTableTypes() : tableTypes); tableData = metaData.getTables(getDefaultTablePattern()); List tables = new ArrayList(); while (tableData.next()) { Map values = readColumns(tableData, getColumnsForTable()); Table table = readTable(metaData, values); if (table != null) { tables.add(table); } } final Collator collator = Collator.getInstance(); Collections.sort(tables, new Comparator() { public int compare(Object obj1, Object obj2) { return collator.compare(((Table) obj1).getName().toUpperCase(), ((Table) obj2).getName().toUpperCase()); } }); return tables; } finally { closeResultSet(tableData); } }
From source file:org.apache.ddlutils.model.Table.java
/** * Sorts the foreign keys alphabetically. * /*from w w w . java 2s . com*/ * @param caseSensitive Whether case matters */ public void sortForeignKeys(final boolean caseSensitive) { if (!_foreignKeys.isEmpty()) { final Collator collator = Collator.getInstance(); Collections.sort(_foreignKeys, new Comparator() { public int compare(Object obj1, Object obj2) { String fk1Name = ((ForeignKey) obj1).getName(); String fk2Name = ((ForeignKey) obj2).getName(); if (!caseSensitive) { fk1Name = (fk1Name != null ? fk1Name.toLowerCase() : null); fk2Name = (fk2Name != null ? fk2Name.toLowerCase() : null); } return collator.compare(fk1Name, fk2Name); } }); } }
From source file:org.jumpmind.db.platform.AbstractJdbcDdlReader.java
protected Collection<Table> readTables(Connection connection, String catalog, String schemaPattern, String[] tableTypes) throws SQLException { ResultSet tableData = null;//from w w w .j av a2 s .c om try { DatabaseMetaDataWrapper metaData = new DatabaseMetaDataWrapper(); metaData.setMetaData(connection.getMetaData()); metaData.setCatalog(catalog == null ? getDefaultCatalogPattern() : catalog); metaData.setSchemaPattern(schemaPattern == null ? getDefaultSchemaPattern() : schemaPattern); metaData.setTableTypes( (tableTypes == null) || (tableTypes.length == 0) ? getDefaultTableTypes() : tableTypes); tableData = metaData.getTables(getDefaultTablePattern()); List<Table> tables = new ArrayList<Table>(); while (tableData.next()) { Map<String, Object> values = readMetaData(tableData, getColumnsForTable()); Table table = readTable(connection, metaData, values); if (table != null) { tables.add(table); } } final Collator collator = Collator.getInstance(); Collections.sort(tables, new Comparator<Table>() { public int compare(Table obj1, Table obj2) { return collator.compare(obj1.getName().toUpperCase(), obj2.getName().toUpperCase()); } }); return tables; } finally { if (tableData != null) { tableData.close(); } } }
From source file:org.locationtech.udig.style.sld.raster.editor.SingleBandEditorPage.java
private void init() { Layer l = getSelectedLayer();/*from w w w. j a va 2s. c o m*/ for (IColorMapTypePanel pnl : stylePanels) { pnl.setFormatter(this.formatter); } try { GridCoverage coverage = l.getGeoResource().resolve(GridCoverage.class, null); if (coverage.getNumSampleDimensions() > 0) { formatter.setRawDataType(coverage.getSampleDimension(0).getSampleDimensionType()); this.noDataValues = coverage.getSampleDimension(0).getNoDataValues(); } } catch (Exception ex) { //eat me } if (colorRules != null) { colorRules.dispose(); colorRules = null; } colorRules = new PredefinedColorRules(getGridCoverageReader(), this.noDataValues); Style style = (Style) l.getStyleBlackboard().get(SLDContent.ID); //set inputs based on brewer and colorRules //do this first so we don't overwrite any custom color rules List<Object> inputs = new ArrayList<Object>(); BrewerPalette[] palettes = getBrewer().getPalettes(ColorBrewer.ALL); Arrays.sort(palettes, 0, palettes.length, new Comparator<BrewerPalette>() { @Override public int compare(BrewerPalette arg0, BrewerPalette arg1) { return Collator.getInstance().compare(brewerLblProvider.getText(arg0), brewerLblProvider.getText(arg1)); } }); for (BrewerPalette p : palettes) { inputs.add(p); } inputs.add(Messages.SingleBandEditorPage_predefinedStyleSeperator); for (PredefinedColorRule key : colorRules.getPredefinedSets()) { inputs.add(key); } cmbPalette.setInput(inputs); /* reselect based on blackboard setting */ String paletteName = (String) l.getStyleBlackboard().get("org.locationtech.udig.style.raster.palette"); //$NON-NLS-1$ if (paletteName != null) { ColorBrewer cb = getBrewer(); BrewerPalette palette = cb.getPalette(paletteName); if (palette != null) { cmbPalette.setSelection(new StructuredSelection(cb.getPalette(paletteName))); } else { PredefinedColorRule cm = colorRules.getPredefinedRule(paletteName); if (cm != null) { cmbPalette.setSelection(new StructuredSelection(cm)); } } } RasterSymbolizer symbolizer = SLD.rasterSymbolizer(style); if (symbolizer == null || symbolizer.getColorMap() == null) { //no symbolizer } else { ColorMap cm = symbolizer.getColorMap(); for (IColorMapTypePanel pnl : stylePanels) { if (pnl.canSupport(cm.getType())) { pnl.init(cm); cmbThemingStyle.setSelection(new StructuredSelection(pnl)); cmbThemingStyle.getControl().notifyListeners(SWT.Selection, new Event()); } } if (formatter.getRawDataType() == DataType.INTEGER) { //if some of the entries are doubles we want to format in double //regardless of the fact that the raster is an integer raster. try { for (ColorMapEntry e : cm.getColorMapEntries()) { Double dvalue = (Double) e.getQuantity().evaluate(null, Double.class); Integer ivalue = (Integer) e.getQuantity().evaluate(null, Integer.class); if (ivalue.doubleValue() != dvalue) { formatter.setDataType(DataType.DOUBLE); } } } catch (Exception ex) { //eatme } } } }
From source file:org.jumpmind.db.model.Table.java
/** * Sorts the foreign keys alphabetically. * //from ww w . j a v a 2 s .co m * @param caseSensitive * Whether case matters */ public void sortForeignKeys(final boolean caseSensitive) { if (!foreignKeys.isEmpty()) { final Collator collator = Collator.getInstance(); Collections.sort(foreignKeys, new Comparator<ForeignKey>() { public int compare(ForeignKey obj1, ForeignKey obj2) { String fk1Name = ((ForeignKey) obj1).getName(); String fk2Name = ((ForeignKey) obj2).getName(); if (!caseSensitive) { fk1Name = (fk1Name != null ? fk1Name.toLowerCase() : null); fk2Name = (fk2Name != null ? fk2Name.toLowerCase() : null); } return collator.compare(fk1Name, fk2Name); } }); } }
From source file:net.refractions.udig.style.sld.editor.raster.SingleBandEditorPage.java
private void init() { Layer l = getSelectedLayer();//from w w w. j av a 2 s .co m for (IColorMapTypePanel pnl : stylePanels) { pnl.setFormatter(this.formatter); } try { GridCoverage coverage = l.getGeoResource().resolve(GridCoverage.class, null); if (coverage.getNumSampleDimensions() > 0) { formatter.setRawDataType(coverage.getSampleDimension(0).getSampleDimensionType()); this.noDataValues = coverage.getSampleDimension(0).getNoDataValues(); } } catch (Exception ex) { //eat me } if (colorRules != null) { colorRules.dispose(); colorRules = null; } colorRules = new PredefinedColorRules(getGridCoverageReader(), this.noDataValues); Style style = (Style) l.getStyleBlackboard().get(SLDContent.ID); RasterSymbolizer symbolizer = SLD.rasterSymbolizer(style); if (symbolizer == null || symbolizer.getColorMap() == null) { //no symbolizer } else { ColorMap cm = symbolizer.getColorMap(); for (IColorMapTypePanel pnl : stylePanels) { if (pnl.canSupport(cm.getType())) { pnl.init(cm); cmbThemingStyle.setSelection(new StructuredSelection(pnl)); cmbThemingStyle.getControl().notifyListeners(SWT.Selection, new Event()); } } if (formatter.getRawDataType() == DataType.INTEGER) { //if some of the entries are doubles we want to format in double //regardless of the fact that the raster is an integer raster. try { for (ColorMapEntry e : cm.getColorMapEntries()) { Double dvalue = (Double) e.getQuantity().evaluate(null, Double.class); Integer ivalue = (Integer) e.getQuantity().evaluate(null, Integer.class); if (ivalue.doubleValue() != dvalue) { formatter.setDataType(DataType.DOUBLE); } } } catch (Exception ex) { //eatme } } } //set inputs based on brewer and colorRules List<Object> inputs = new ArrayList<Object>(); BrewerPalette[] palettes = getBrewer().getPalettes(ColorBrewer.ALL); Arrays.sort(palettes, 0, palettes.length, new Comparator<BrewerPalette>() { @Override public int compare(BrewerPalette arg0, BrewerPalette arg1) { return Collator.getInstance().compare(brewerLblProvider.getText(arg0), brewerLblProvider.getText(arg1)); } }); for (BrewerPalette p : palettes) { inputs.add(p); } inputs.add(Messages.SingleBandEditorPage_predefinedStyleSeperator); for (PredefinedColorRule key : colorRules.getPredefinedSets()) { inputs.add(key); } cmbPalette.setInput(inputs); /* reselect based on blackboard setting */ String paletteName = (String) l.getStyleBlackboard().get("net.refractions.udig.style.raster.palette"); //$NON-NLS-1$ if (paletteName != null) { ColorBrewer cb = getBrewer(); BrewerPalette palette = cb.getPalette(paletteName); if (palette != null) { cmbPalette.setSelection(new StructuredSelection(cb.getPalette(paletteName))); } else { PredefinedColorRule cm = colorRules.getPredefinedRule(paletteName); if (cm != null) { cmbPalette.setSelection(new StructuredSelection(cm)); } } } }
From source file:org.locationtech.udig.style.sld.editor.raster.SingleBandEditorPage.java
private void init() { Layer l = getSelectedLayer();/*w w w.j av a2s. com*/ for (IColorMapTypePanel pnl : stylePanels) { pnl.setFormatter(this.formatter); } try { GridCoverage coverage = l.getGeoResource().resolve(GridCoverage.class, null); if (coverage.getNumSampleDimensions() > 0) { formatter.setRawDataType(coverage.getSampleDimension(0).getSampleDimensionType()); this.noDataValues = coverage.getSampleDimension(0).getNoDataValues(); } } catch (Exception ex) { //eat me } if (colorRules != null) { colorRules.dispose(); colorRules = null; } colorRules = new PredefinedColorRules(getGridCoverageReader(), this.noDataValues); Style style = (Style) l.getStyleBlackboard().get(SLDContent.ID); RasterSymbolizer symbolizer = SLD.rasterSymbolizer(style); if (symbolizer == null || symbolizer.getColorMap() == null) { //no symbolizer } else { ColorMap cm = symbolizer.getColorMap(); for (IColorMapTypePanel pnl : stylePanels) { if (pnl.canSupport(cm.getType())) { pnl.init(cm); cmbThemingStyle.setSelection(new StructuredSelection(pnl)); cmbThemingStyle.getControl().notifyListeners(SWT.Selection, new Event()); } } if (formatter.getRawDataType() == DataType.INTEGER) { //if some of the entries are doubles we want to format in double //regardless of the fact that the raster is an integer raster. try { for (ColorMapEntry e : cm.getColorMapEntries()) { Double dvalue = (Double) e.getQuantity().evaluate(null, Double.class); Integer ivalue = (Integer) e.getQuantity().evaluate(null, Integer.class); if (ivalue.doubleValue() != dvalue) { formatter.setDataType(DataType.DOUBLE); } } } catch (Exception ex) { //eatme } } } //set inputs based on brewer and colorRules List<Object> inputs = new ArrayList<Object>(); BrewerPalette[] palettes = getBrewer().getPalettes(ColorBrewer.ALL); Arrays.sort(palettes, 0, palettes.length, new Comparator<BrewerPalette>() { @Override public int compare(BrewerPalette arg0, BrewerPalette arg1) { return Collator.getInstance().compare(brewerLblProvider.getText(arg0), brewerLblProvider.getText(arg1)); } }); for (BrewerPalette p : palettes) { inputs.add(p); } inputs.add(Messages.SingleBandEditorPage_predefinedStyleSeperator); for (PredefinedColorRule key : colorRules.getPredefinedSets()) { inputs.add(key); } cmbPalette.setInput(inputs); /* reselect based on blackboard setting */ String paletteName = (String) l.getStyleBlackboard().get("org.locationtech.udig.style.raster.palette"); //$NON-NLS-1$ if (paletteName != null) { ColorBrewer cb = getBrewer(); BrewerPalette palette = cb.getPalette(paletteName); if (palette != null) { cmbPalette.setSelection(new StructuredSelection(cb.getPalette(paletteName))); } else { PredefinedColorRule cm = colorRules.getPredefinedRule(paletteName); if (cm != null) { cmbPalette.setSelection(new StructuredSelection(cm)); } } } }
From source file:de.innovationgate.wgpublisher.webtml.Input.java
private List<InputOption> retrieveInputOptions() throws WGAPIException { // Fetch options. Possible sources: 1. directly from item (Attribute optionsitem) 2. comma-separated string (Attribute options) 3. HDBModel relation targets String optionsItem = getOptionsitem(); List<String> rawOptionsList = null; if (!WGUtils.isEmpty(optionsItem)) { rawOptionsList = WGUtils.toString(getTMLContext().itemlist(optionsItem)); } else {//from w ww. j a va 2 s . co m String strOptions = this.getOptions(); if (!WGUtils.isEmpty(strOptions)) { rawOptionsList = WGUtils.deserializeCollection(strOptions, ","); } else { String relType = getRelationtype(); if (!WGUtils.isEmpty(relType)) { String titleExpr = getOptionstitle(); if (titleExpr == null) { titleExpr = "TITLE"; } rawOptionsList = getHdbmodelRelationOptions(titleExpr); } } } if (rawOptionsList == null) { return new ArrayList<InputOption>(); } // Process raw options. Divide up value and text and create InputOption objects by them Iterator<String> rawOptions = rawOptionsList.iterator(); List<InputOption> optionList = new ArrayList<InputOption>(); String optionText; String optionValue; String rawOption; while (rawOptions.hasNext()) { rawOption = rawOptions.next(); if (rawOption == null) { continue; } int divider = rawOption.indexOf("|"); if (divider != -1) { optionText = rawOption.substring(0, divider).trim(); optionValue = rawOption.substring(divider + 1).trim(); } else { optionText = evaluateOptionTitle(rawOption.trim()); optionValue = rawOption.trim(); } optionList.add(new InputOption(optionText, optionValue)); } // Optionally sort options by their title String sort = getSortoptions(); if (sort != null) { boolean byValue = false; boolean desc = false; List<String> sortParams = WGUtils.deserializeCollection(sort, ","); if (sortParams.size() >= 2) { byValue = "value".equalsIgnoreCase(sortParams.get(0)); desc = "desc".equalsIgnoreCase(sortParams.get(1)); } else { desc = "desc".equalsIgnoreCase(sortParams.get(0)); } Comparator<InputOption> comparator; if (byValue) { comparator = new Comparator<InputOption>() { @Override public int compare(InputOption o1, InputOption o2) { return Collator.getInstance().compare(o1.getValue(), o2.getValue()); } }; } else { comparator = new Comparator<InputOption>() { @Override public int compare(InputOption o1, InputOption o2) { return Collator.getInstance().compare(o1.getText(), o2.getText()); } }; } Collections.sort(optionList, comparator); if (desc) { Collections.reverse(optionList); } } return optionList; }