Example usage for java.util EnumMap EnumMap

List of usage examples for java.util EnumMap EnumMap

Introduction

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

Prototype

public EnumMap(Map<K, ? extends V> m) 

Source Link

Document

Creates an enum map initialized from the specified map.

Usage

From source file:org.squashtest.tm.service.internal.requirement.VerifiedRequirementsManagerServiceImpl.java

private Map<ExecutionStatus, Long> findResultsForSimpleCoverage(List<Long> testCaseIds, List<Long> iterationIds,
        Map<Long, Long> nbSimpleCoverageByTestCase) {
    List<TestCaseExecutionStatus> testCaseExecutionStatus = iterationDao
            .findExecStatusForIterationsAndTestCases(testCaseIds, iterationIds);
    Map<ExecutionStatus, Long> computedResults = new EnumMap<>(ExecutionStatus.class);
    for (TestCaseExecutionStatus oneTCES : testCaseExecutionStatus) {
        ExecutionStatus status = oneTCES.getStatus();
        Long nbCoverage = nbSimpleCoverageByTestCase.get(oneTCES.getTestCaseId());
        if (computedResults.containsKey(status)) {
            computedResults.put(status, computedResults.get(status) + nbCoverage);
        } else {/*from  ww w  .  j ava  2 s  .c om*/
            computedResults.put(status, nbCoverage);
        }
    }
    return computedResults;
}

From source file:de.hpi.fgis.hdrs.node.Node.java

public SegmentCatalog getLocalSegmentCatalog(long version) {
    Map<Triple.COLLATION, List<SegmentInfo>> lists = new EnumMap<Triple.COLLATION, List<SegmentInfo>>(
            Triple.COLLATION.class);
    for (Index index : indexes.values()) {
        lists.put(index.getOrder(), index.getSegments());
    }//  w  ww. j  a v a  2 s . c om
    return new SegmentCatalog(version, lists);
}

From source file:gov.nih.nci.caarray.web.action.project.ProjectFilesAction.java

/**
 * Computes a file status count for each type of file status.
 *
 * @return Map, map contains key value pair (status, count)
 *///from   ww  w  . j  a  va  2s .  com
public EnumMap<FileStatus, Integer> computeFileStatusCounts() {
    final EnumMap<FileStatus, Integer> countMap = new EnumMap<FileStatus, Integer>(FileStatus.class);

    for (final FileStatus f : FileStatus.values()) {
        countMap.put(f, 0);
    }

    for (final CaArrayFile f : getFiles()) {
        countMap.put(FileStatus.valueOf(f.getStatus()), countMap.get(FileStatus.valueOf(f.getStatus())) + 1);
    }
    return countMap;
}

From source file:net.bashtech.geobot.Channel.java

public void incWarningCount(String name, FilterType type) {
    clearWarnings();/* w  ww  .j av  a2  s.  c  o  m*/
    synchronized (warningCount) {
        if (warningCount.containsKey(name.toLowerCase())) {
            if (warningCount.get(name.toLowerCase()).containsKey(type)) {
                warningCount.get(name.toLowerCase()).put(type,
                        warningCount.get(name.toLowerCase()).get(type) + 1);
                warningTime.put(name.toLowerCase(), getTime());
            } else {
                warningCount.get(name.toLowerCase()).put(type, 1);
                warningTime.put(name.toLowerCase(), getTime());
            }
        } else {
            warningCount.put(name.toLowerCase(), new EnumMap<FilterType, Integer>(FilterType.class));
            warningCount.get(name.toLowerCase()).put(type, 1);
            warningTime.put(name.toLowerCase(), getTime());
        }
    }
}

From source file:ru.orangesoftware.financisto2.db.DatabaseAdapter.java

public EnumMap<SystemAttribute, String> getSystemAttributesForTransaction(long transactionId) {
    Cursor c = db()/*from  w w  w . j a  v  a 2  s .  c o  m*/
            .query(TRANSACTION_ATTRIBUTE_TABLE, TransactionAttributeColumns.NORMAL_PROJECTION,
                    TransactionAttributeColumns.TRANSACTION_ID + "=? AND "
                            + TransactionAttributeColumns.ATTRIBUTE_ID + "<0",
                    new String[] { String.valueOf(transactionId) }, null, null, null);
    try {
        EnumMap<SystemAttribute, String> attributes = new EnumMap<SystemAttribute, String>(
                SystemAttribute.class);
        while (c.moveToNext()) {
            long attributeId = c.getLong(TransactionAttributeColumns.Indicies.ATTRIBUTE_ID);
            String value = c.getString(TransactionAttributeColumns.Indicies.VALUE);
            attributes.put(SystemAttribute.forId(attributeId), value);
        }
        return attributes;
    } finally {
        c.close();
    }
}

From source file:org.pentaho.di.repository.pur.PurRepository.java

/**
 * Initialize the shared object assembler map with known assemblers
 *///from   ww w .  j a v  a2  s . co m
private void initSharedObjectAssemblerMap() {
    sharedObjectAssemblerMap = new EnumMap<RepositoryObjectType, SharedObjectAssembler<?>>(
            RepositoryObjectType.class);
    sharedObjectAssemblerMap.put(RepositoryObjectType.DATABASE, databaseMetaTransformer);
    sharedObjectAssemblerMap.put(RepositoryObjectType.CLUSTER_SCHEMA, clusterTransformer);
    sharedObjectAssemblerMap.put(RepositoryObjectType.PARTITION_SCHEMA, partitionSchemaTransformer);
    sharedObjectAssemblerMap.put(RepositoryObjectType.SLAVE_SERVER, slaveTransformer);
}

From source file:org.codice.ddf.spatial.ogc.csw.catalog.common.source.CswFilterDelegate.java

/**
 * Reads the {@link net.opengis.filter.v_1_1_0.FilterCapabilities} in order to determine what types of queries the server
 * can handle.//w w w.j  a v  a2s  .  co  m
 *
 * @param filterCapabilities The {@link net.opengis.filter.v_1_1_0.FilterCapabilities} understood by the Csw service
 */
private final void updateAllowedOperations(FilterCapabilities filterCapabilities) {
    comparisonOps = Collections.newSetFromMap(new ConcurrentHashMap<ComparisonOperatorType, Boolean>(
            new EnumMap<ComparisonOperatorType, Boolean>(ComparisonOperatorType.class)));

    spatialOps = new ConcurrentHashMap<SpatialOperatorNameType, SpatialOperatorType>(
            new EnumMap<SpatialOperatorNameType, SpatialOperatorType>(SpatialOperatorNameType.class));
    logicalOps = true;
    if (null == filterCapabilities) {
        LOGGER.error("CSW Service doesn't support any filters");
        return;
    }

    ScalarCapabilitiesType scalarCapabilities = filterCapabilities.getScalarCapabilities();

    if (null != scalarCapabilities) {
        ComparisonOperatorsType comparisonOperators = scalarCapabilities.getComparisonOperators();
        if (null != comparisonOperators) { // filter out nulls
            for (ComparisonOperatorType comp : comparisonOperators.getComparisonOperator()) {
                if (null != comp) {
                    comparisonOps.add(comp);
                }
            }
        }
        logicalOps = (null != scalarCapabilities.getLogicalOperators());
    }

    SpatialCapabilitiesType spatialCapabilities = filterCapabilities.getSpatialCapabilities();
    if (null != spatialCapabilities && null != spatialCapabilities.getSpatialOperators()) {
        setSpatialOps(spatialCapabilities.getSpatialOperators());
    }

    GeometryOperandsType geometryOperandsType = null;

    if (spatialCapabilities != null) {
        geometryOperandsType = spatialCapabilities.getGeometryOperands();
    }
    if (geometryOperandsType != null) {
        globalGeometryOperands = geometryOperandsType.getGeometryOperand();
        LOGGER.debug("globalGeometryOperands: {}", globalGeometryOperands);
    }
}

From source file:com.att.aro.diagnostics.GraphPanel.java

private static void populateGpsPlot(XYPlot plot, TraceData.Analysis analysis) {
    final XYIntervalSeriesCollection gpsData = new XYIntervalSeriesCollection();
    if (analysis != null) {

        // create the GPS dataset...
        Map<GpsState, XYIntervalSeries> seriesMap = new EnumMap<GpsState, XYIntervalSeries>(GpsState.class);
        for (GpsState eventType : GpsState.values()) {
            XYIntervalSeries series = new XYIntervalSeries(eventType);
            seriesMap.put(eventType, series);
            gpsData.addSeries(series);//from   ww w.  j  av  a 2  s .c o m
        }
        Iterator<GpsInfo> iter = analysis.getGpsInfos().iterator();
        if (iter.hasNext()) {
            while (iter.hasNext()) {
                GpsInfo gpsEvent = iter.next();
                if (gpsEvent.getGpsState() != GpsState.GPS_DISABLED) {
                    seriesMap.get(gpsEvent.getGpsState()).add(gpsEvent.getBeginTimeStamp(),
                            gpsEvent.getBeginTimeStamp(), gpsEvent.getEndTimeStamp(), 0.5, 0, 1);
                }
            }
        }

        XYItemRenderer renderer = plot.getRenderer();
        renderer.setSeriesPaint(gpsData.indexOf(GpsState.GPS_STANDBY), Color.YELLOW);
        renderer.setSeriesPaint(gpsData.indexOf(GpsState.GPS_ACTIVE), new Color(34, 177, 76));

        // Assign ToolTip to renderer
        renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {
            @Override
            public String generateToolTip(XYDataset dataset, int series, int item) {
                GpsState eventType = (GpsState) gpsData.getSeries(series).getKey();
                return MessageFormat.format(rb.getString("gps.tooltip"), dataset.getX(series, item),
                        ResourceBundleManager.getEnumString(eventType));
            }
        });

    }
    plot.setDataset(gpsData);
}

From source file:org.codice.ddf.spatial.ogc.csw.catalog.common.source.CswFilterDelegate.java

public void setSpatialOps(SpatialOperatorsType spatialOperators) {
    spatialOps = new ConcurrentHashMap<SpatialOperatorNameType, SpatialOperatorType>(
            new EnumMap<SpatialOperatorNameType, SpatialOperatorType>(SpatialOperatorNameType.class));

    for (SpatialOperatorType spatialOp : spatialOperators.getSpatialOperator()) {
        LOGGER.debug("Adding key [spatialOp Name: {}]", spatialOp.getName());
        spatialOps.put(spatialOp.getName(), spatialOp);
        LOGGER.debug("spatialOps Map: {}", spatialOps.toString());
    }//from   ww w  .  jav a  2  s .c o m
}

From source file:com.att.aro.diagnostics.GraphPanel.java

private static void populateWifiPlot(XYPlot plot, TraceData.Analysis analysis) {

    // create the dataset...
    final XYIntervalSeriesCollection wifiData = new XYIntervalSeriesCollection();
    if (analysis != null) {

        Map<WifiState, XYIntervalSeries> seriesMap = new EnumMap<WifiState, XYIntervalSeries>(WifiState.class);
        for (WifiState eventType : WifiState.values()) {
            XYIntervalSeries series = new XYIntervalSeries(eventType);
            seriesMap.put(eventType, series);
            switch (eventType) {
            case WIFI_UNKNOWN:
            case WIFI_DISABLED:
                // Don't chart these
                break;
            default:
                wifiData.addSeries(series);
                break;
            }//from  w w  w  . j  a v  a 2 s  .com
        }

        // Populate the data set
        List<WifiInfo> wifiInfos = analysis.getWifiInfos();
        final Map<Double, WifiInfo> eventMap = new HashMap<Double, WifiInfo>(wifiInfos.size());
        Iterator<WifiInfo> iter = wifiInfos.iterator();
        if (iter.hasNext()) {
            while (iter.hasNext()) {
                WifiInfo wifiEvent = iter.next();
                seriesMap.get(wifiEvent.getWifiState()).add(wifiEvent.getBeginTimeStamp(),
                        wifiEvent.getBeginTimeStamp(), wifiEvent.getEndTimeStamp(), 0.5, 0, 1);
                eventMap.put(wifiEvent.getBeginTimeStamp(), wifiEvent);
            }
        }

        XYItemRenderer renderer = plot.getRenderer();
        for (WifiState eventType : WifiState.values()) {
            Color paint;
            switch (eventType) {
            case WIFI_CONNECTED:
            case WIFI_CONNECTING:
            case WIFI_DISCONNECTING:
                paint = new Color(34, 177, 76);
                break;
            case WIFI_DISCONNECTED:
            case WIFI_SUSPENDED:
                paint = Color.YELLOW;
                break;
            default:
                paint = Color.WHITE;
                break;
            }

            int index = wifiData.indexOf(eventType);
            if (index >= 0) {
                renderer.setSeriesPaint(index, paint);
            }
        }

        // Assign ToolTip to renderer
        renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {
            @Override
            public String generateToolTip(XYDataset dataset, int series, int item) {
                WifiState eventType = (WifiState) wifiData.getSeries(series).getKey();

                StringBuffer message = new StringBuffer(rb.getString("wifi.tooltip.prefix"));
                message.append(MessageFormat.format(rb.getString("wifi.tooltip"), dataset.getX(series, item),
                        ResourceBundleManager.getEnumString(eventType)));
                switch (eventType) {
                case WIFI_CONNECTED:
                    WifiInfo info = eventMap.get(dataset.getX(series, item));
                    if (info != null && info.getWifiState() == WifiState.WIFI_CONNECTED) {
                        message.append(MessageFormat.format(rb.getString("wifi.connTooltip"),
                                info.getWifiMacAddress(), info.getWifiRSSI(), info.getWifiSSID()));
                    }
                    break;
                default:
                    break;
                }
                message.append(rb.getString("wifi.tooltip.suffix"));
                return message.toString();
            }
        });

    }

    plot.setDataset(wifiData);
}