Example usage for java.util LinkedHashMap keySet

List of usage examples for java.util LinkedHashMap keySet

Introduction

In this page you can find the example usage for java.util LinkedHashMap keySet.

Prototype

public Set<K> keySet() 

Source Link

Document

Returns a Set view of the keys contained in this map.

Usage

From source file:com.ariht.maven.plugins.config.generator.ConfigGeneratorImpl.java

/**
 * Merge templates with filters to generate config, scripts and property io.
 *//* w  w  w.j a v  a  2 s .co  m*/
private void processTemplatesAndGenerateConfig() throws Exception {
    final DirectoryReader directoryReader = new DirectoryReader(log);
    final List<FileInfo> filters = directoryReader.readFiles(configGeneratorParameters.getFiltersBasePath(),
            configGeneratorParameters.getFiltersToIgnore());
    for (FileInfo fileInfo : filters) {
        fileInfo.lookForExternalFiles(configGeneratorParameters.getExternalFilterBasePaths());
    }
    final List<FileInfo> templates = directoryReader.readFiles(configGeneratorParameters.getTemplatesBasePath(),
            configGeneratorParameters.getTemplatesToIgnore());
    logOutputPath();

    // Get list of all properties in all filter io.
    final Set<String> allProperties = getAllProperties(filters);
    // Collection stores missing properties by file so this can be logged once at the end.
    final Map<String, Set<String>> missingPropertiesByFilename = new LinkedHashMap<String, Set<String>>();

    for (final FileInfo filter : filters) {
        final Properties properties = readFilterIntoProperties(filter);
        final LinkedHashMap<String, String> valueMap = Maps.newLinkedHashMap(Maps.fromProperties(properties));

        // No point checking for missing properties if all were found in the filter file
        boolean missingPropertyFound = false;
        for (String missingProperty : Sets.difference(allProperties, valueMap.keySet()).immutableCopy()) {
            valueMap.put(missingProperty, MISSING_PROPERTY_PREFIX + missingProperty + MISSING_PROPERTY_SUFFIX);
            missingPropertyFound = true;
        }
        final StrSubstitutor strSubstitutor = new StrSubstitutor(valueMap,
                configGeneratorParameters.getPropertyPrefix(), configGeneratorParameters.getPropertySuffix());
        for (final FileInfo template : templates) {
            generateConfig(template, filter, configGeneratorParameters.getOutputBasePath(), strSubstitutor,
                    missingPropertiesByFilename, missingPropertyFound);
        }
    }

    if (!missingPropertiesByFilename.keySet().isEmpty()) {
        final StringBuilder sb = new StringBuilder("Missing properties identified:\n");
        for (String filename : missingPropertiesByFilename.keySet()) {
            sb.append(filename).append(": ");
            sb.append(StringUtils.join(missingPropertiesByFilename.get(filename), ", ")).append("\n");
        }
        log.warn(sb.toString());
        if (configGeneratorParameters.isFailOnMissingProperty()) {
            throw new MojoExecutionException(sb.toString());
        }
    }
}

From source file:com.grarak.kerneladiutor.fragments.tools.BackupFragment.java

private void showBackupFlashingDialog(final File file) {
    final LinkedHashMap<String, Backup.PARTITION> menu = getPartitionMenu();
    mBackupFlashingDialog = new Dialog(getActivity())
            .setItems(menu.keySet().toArray(new String[menu.size()]), new DialogInterface.OnClickListener() {
                @Override/*from w  w  w.j  a  v  a2s. co m*/
                public void onClick(DialogInterface dialogInterface, int i) {
                    Backup.PARTITION partition = menu.values().toArray(new Backup.PARTITION[menu.size()])[i];
                    if (file != null) {
                        restore(partition, file, true);
                    } else {
                        backup(partition);
                    }
                }
            }).setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialogInterface) {
                    mBackupFlashingDialog = null;
                }
            });
    mBackupFlashingDialog.show();
}

From source file:eu.hydrologis.jgrass.charting.impl.JGrassXYTimeBarChart.java

/**
 * A line chart creator basing on series made up two values per row. More series, independing
 * one from the other are supported.//  w  w  w  . ja v  a  2 s.  co  m
 * 
 * @param chartValues - a hashmap containing as keys the name of the series and as values the
 *        double[][] representing the data. In this case the x value is assumed to ge a date.
 *        Important: the data matrix has to be passed as two rows (not two columns)
 * @param barWidth TODO
 */
public JGrassXYTimeBarChart(LinkedHashMap<String, double[][]> chartValues, Class<RegularTimePeriod> timeClass,
        double barWidth) {
    try {
        chartSeries = new TimeSeries[chartValues.size()];

        constructor = timeClass.getConstructor(Date.class);

        final Iterator<String> it = chartValues.keySet().iterator();
        int count = 0;
        while (it.hasNext()) {
            final String key = it.next();
            final double[][] values = chartValues.get(key);

            chartSeries[count] = new TimeSeries(key, timeClass);
            for (int i = 0; i < values[0].length; i++) {
                // important: the data matrix has to be passed as two rows (not
                // two columns)
                chartSeries[count].add(constructor.newInstance(new Date((long) values[0][i])), values[1][i]);
            }
            count++;
        }

        lineDataset = new TimeSeriesCollection();
        for (int i = 0; i < chartSeries.length; i++) {
            lineDataset.addSeries(chartSeries[i]);
        }
        lineDataset.setXPosition(TimePeriodAnchor.MIDDLE);

        if (barWidth != -1)
            dataset = new XYBarDataset(lineDataset, barWidth);
    } catch (Exception e) {
        ChartPlugin.log("ChartPlugin", e); //$NON-NLS-1$
    }

}

From source file:org.karndo.graphs.CustomChartFactory.java

/**
 * Creates a chart of the selected PiracyEvent data graphed by event 
 * status. Presently uses a very basic method of graphing this data by 
 * using the static CreateBarChart3D method available in class
 * org.jfree.chart.ChartFactory.    //www. j a v a2 s.c o  m
 * 
 * @param data the selected PiracyEvent data to graph.
 * @return A JFreeChart object representing a graph of the selected 
 * PiracyEvent data against event status.
 */
public JFreeChart createHistogramStatus(LinkedList<PiracyEvent> data) {
    //the data to plot
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    LinkedHashMap<String, MutableInt> freqs_cats = new LinkedHashMap<String, MutableInt>();

    for (PiracyEvent ev : data) {
        if (!freqs_cats.containsKey(ev.getStatus())) {
            freqs_cats.put(ev.getStatus(), new MutableInt(1));
        } else {
            freqs_cats.get(ev.getStatus()).increment();
        }
    }

    Iterator itr = freqs_cats.keySet().iterator();
    while (itr.hasNext()) {
        String category = (String) itr.next();
        Integer i1 = freqs_cats.get(category).getValue();
        dataset.addValue(i1, "Piracy Incidents", category);
    }

    JFreeChart chart = ChartFactory.createBarChart3D("Piracy Incidents " + "by event status", "Event Status",
            "Frequency", dataset, PlotOrientation.VERTICAL, false, true, false);
    return chart;
}

From source file:net.duckling.ddl.service.resource.impl.ResourcePipeAgentServiceImpl.java

/**
 * //from  w  w  w.  j  a  va 2 s  .co m
 * @param metaMap
 * @param uid
 * @param tid
 * @param rootRid
 * @return
 */
private Map<String, Resource> createFolderAll(Map<String, MeePoMeta> metaMap, String uid, int tid, int rootRid,
        String selectedPath) {
    LinkedHashMap<String, MeePoMeta> folderMetaMap = sortMeta(metaMap);
    Map<String, Resource> resourceMap = new HashMap<String, Resource>();

    for (String key : folderMetaMap.keySet()) {
        PathNamePair pair = parsePathName(key);
        Resource parentFolder = resourceMap.get(pair.getPath());
        int bid = parentFolder == null ? rootRid : parentFolder.getRid();
        boolean autoRename = key.equals(selectedPath) ? true : false;
        Resource r = createFolder(uid, tid, bid, pair.getName(), autoRename);
        resourceMap.put(key, r);
    }
    return resourceMap;
}

From source file:org.wso2.developerstudio.eclipse.artifact.dataservice.ui.wizard.DataServiceCreationWizard.java

/**
 * Adds the template// w ww.j a v  a  2s.co  m
 * 
 * @param project
 *            project
 * @return .dbs file
 * @throws Exception
 */
private File addDSTemplate(IProject project) throws Exception {
    String eol = System.getProperty(LINE_SEPERATOR);
    ITemporaryFileTag dsTempTag = FileUtils.createNewTempTag();
    StringBuffer sb = new StringBuffer();
    File dsTemplateFile = new DataServiceTemplateUtils().getResourceFile(DATASERVICE_TEMPLATE);
    String templateContent = FileUtils.getContentAsString(dsTemplateFile);
    templateContent = templateContent.replaceAll("\\{", "<");
    templateContent = templateContent.replaceAll("\\}", ">");
    templateContent = templateContent.replaceAll("<service.name>", dsModel.getServiceName());
    templateContent = templateContent.replaceAll("<service.group>", dsModel.getServiceGroup());
    templateContent = templateContent.replaceAll("<service.NS>", dsModel.getServiceNS());
    templateContent = templateContent.replaceAll("<service.description>", dsModel.getServiceDescription());
    templateContent = templateContent.replaceAll("<config.id>", dsModel.getDataSourceId());
    LinkedHashMap<String, String> config = dsModel.getDataSourceConfig().getConfig();
    Iterator<String> iterator = config.keySet().iterator();
    while (iterator.hasNext()) {
        String key = (String) iterator.next();
        sb.append("<property name=\"").append(key).append("\">").append(config.get(key))
                .append("</property>\n");
    }
    templateContent = templateContent.replaceAll("<config.properties>", sb.toString());

    IFolder dsfolder = project.getFolder(DataServiceArtifactConstants.DS_PROJECT_DATASERVICE_FOLDER);
    File template = new File(dsfolder.getLocation().toFile(), dsModel.getServiceName() + DBS_EXTENSION);
    templateContent = XMLUtil.prettify(templateContent);
    templateContent = templateContent.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "");
    templateContent = templateContent.replaceAll("^" + eol, "");
    FileUtils.createFile(template, templateContent);
    dsTempTag.clearAndEnd();
    return template;
}

From source file:com.concursive.connect.web.modules.wiki.utils.WikiToHTMLUtils.java

public static String getHTML(WikiToHTMLContext context, Connection db) {
    String content = context.getWiki().getContent();
    if (content == null) {
        return null;
    }/*from w w  w .j  av a 2  s.c  om*/
    // Chunk the content into manageable pieces
    LinkedHashMap<String, String> chunks = chunkContent(content, context.isEditMode());
    StringBuffer sb = new StringBuffer();
    for (String type : chunks.keySet()) {
        String chunk = chunks.get(type);
        LOG.trace("========= CHUNK [" + type + "] =========");
        if (type.endsWith(CONTENT_PREFORMATTED)) {
            if (!context.canAppend()) {
                continue;
            }
            LOG.trace(chunk);
            if (type.endsWith(CONTENT_CODE + "remove-test")) {
                sb.append("<code>");
            } else {
                sb.append("<pre>");
            }
            sb.append(chunk);
            if (type.endsWith(CONTENT_CODE + "remove-test")) {
                sb.append("</code>");
            } else {
                sb.append("</pre>");
            }
            sb.append(CRLF);
        } else if (type.endsWith(CONTENT_NEEDS_FORMATTING)) {
            String formatted = getHTML(context, db, chunk);
            LOG.trace(formatted);
            sb.append(formatted);
        }
    }
    return sb.toString();

    // Tables (With linewraps)
    // Header ||
    // Cell |

    // Ordered List
    // *
    // **

    // Unordered List
    // #
    // ##

    // Links
    // [[Wiki link]]
    // [[Wiki Link|Renamed]]
    // [[http://external]]

    // Images
    // [[Image:Filename.jpg]]
    // [[Image:Filename.jpg|A caption]]
    // [[Image:Filename.jpg|link=wiki]]
    // [[Image:Filename.jpg|thumb]]
    // [[Image:Filename.jpg|right]]
    // [[Image:Filename.jpg|left]]

    // Videos
    // [[Video:http://www.youtube.com/watch?v=3LkNlTNHZzE]]
    // [[Video:http://www.ustream.tv/flash/live/1/371673]]
    // [[Video:http://www.justin.tv/vasalini]]
    // [[Video:http://www.livestream.com/spaceflightnow]]
    // [[Video:http://qik.com/zeroio]]

    // Forms
    // [{form name="wikiForm"}]
    // ---
    // [{group value="New Group" display="false"}]
    // ---
    // [{label value="This is a text field" display="false"}]
    // [{field type="text" name="cf10" maxlength="30" size="30" value="" required="false"}]
    // [{description value="This is the text to display after"}]
    // +++
}

From source file:org.wso2.das.integration.tests.clustering.MinimumHAClusterTestCase.java

/**
 * @param instanceNames instances/* www  .  j  a v a2s.c  o m*/
 * @return first instance's carbon home
 */
private String initializeServerManagersAndStubs(String groupName, LinkedHashMap<String, Integer> instanceNames,
        TestUserMode testUserMode)
        throws XPathExpressionException, IOException, AutomationFrameworkException, AutomationUtilException {
    String firstCarbonHome = "";

    int i = 0;
    for (String instanceName : instanceNames.keySet()) {
        int portOffset = instanceNames.get(instanceName);
        AutomationContext context = new AutomationContext(groupName, instanceName, testUserMode);
        DASClusteredTestServerManager serverManager = new DASClusteredTestServerManager(context, portOffset,
                createFileReplacementInformationList(firstCarbonHome, portOffset));
        this.dasServerManagers.put(instanceName, serverManager);

        if (i == 0) {
            firstCarbonHome = this.startServer(instanceName);
        }
        i++;
    }
    return firstCarbonHome;
}

From source file:org.karndo.graphs.CustomChartFactory.java

/**
 * Creates a chart of the selected PiracyEvent data graphed by vessel
 * type. Presently uses a very basic method of graphing this data by 
 * using the static CreateBarChart3D method available in class
 * org.jfree.chart.ChartFactory.     /*from  ww  w.j  a v a2 s .  c  o  m*/
 * 
 * @param data the selected PiracyEvent data to graph.
 * @return A JFreeChart object representing a graph of the selected 
 * PiracyEvent data against vessel type.
 */
public JFreeChart createHistogramVesselType(LinkedList<PiracyEvent> data) {
    //the data to plot
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    LinkedHashMap<String, MutableInt> freqs_cats = new LinkedHashMap<String, MutableInt>();

    for (PiracyEvent ev : data) {
        if (!freqs_cats.containsKey(ev.getVesselType())) {
            freqs_cats.put(ev.getVesselType(), new MutableInt(1));
        } else {
            freqs_cats.get(ev.getVesselType()).increment();
        }
    }

    Iterator itr = freqs_cats.keySet().iterator();
    while (itr.hasNext()) {
        String category = (String) itr.next();
        Integer i1 = freqs_cats.get(category).getValue();
        dataset.addValue(i1, "Piracy Incidents", category);
    }

    JFreeChart chart = ChartFactory.createBarChart3D("Piracy Incidents " + "by vessel type", "Vessel Type",
            "Frequency", dataset, PlotOrientation.VERTICAL, false, true, false);
    return chart;
}