Example usage for java.util SortedMap get

List of usage examples for java.util SortedMap get

Introduction

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

Prototype

V get(Object key);

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:business.ImageManager.java

private void doLoadFeaturesAll() {
    final SortedMap<String, String> featuresImage = localFacade.getTerrainLandmarksImage();
    for (String cdFeature : featuresImage.keySet()) {
        //todo: link feature to image vector
        landmarks.put(cdFeature, new ImageIcon(getClass().getResource(featuresImage.get(cdFeature))));
    }// w w  w . j  a  v  a 2  s.  c  om
}

From source file:fr.aliasource.webmail.proxy.impl.ResponderImpl.java

public void sendSummary(SortedMap<IFolder, Integer> summary) {
    try {/*from  w  ww. j  ava 2  s  .  c o  m*/
        Document doc = DOMUtils.createDoc("http://obm.aliasource.fr/xsd/folder_list", "folderList");
        Element root = doc.getDocumentElement();
        for (IFolder f : summary.keySet()) {
            Element fe = DOMUtils.createElement(root, "folder");
            fe.setAttribute("displayName", f.getDisplayName());
            fe.setAttribute("name", f.getName());
            fe.setAttribute("unread", summary.get(f).toString());
        }

        sendDom(doc);
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}

From source file:de.blizzy.documentr.web.system.SystemController.java

private SortedMap<String, SortedMap<String, String>> getMacroSettingsFromRequest(WebRequest webRequest) {
    Map<String, String[]> params = webRequest.getParameterMap();
    SortedMap<String, SortedMap<String, String>> allMacroSettings = Maps.newTreeMap();
    for (Map.Entry<String, String[]> entry : params.entrySet()) {
        String key = entry.getKey();
        if (key.startsWith(MACRO_KEY_PREFIX)) {
            String[] values = entry.getValue();
            if (values.length == 0) {
                values = new String[] { StringUtils.EMPTY };
            }//  www . ja  v a  2s .  c  o m
            key = key.substring(MACRO_KEY_PREFIX.length());
            String macroName = StringUtils.substringBefore(key, "."); //$NON-NLS-1$
            key = StringUtils.substringAfter(key, "."); //$NON-NLS-1$
            SortedMap<String, String> macroSettings = allMacroSettings.get(macroName);
            if (macroSettings == null) {
                macroSettings = Maps.newTreeMap();
                allMacroSettings.put(macroName, macroSettings);
            }
            macroSettings.put(key, values[0]);
        }
    }
    return allMacroSettings;
}

From source file:net.sourceforge.seqware.pipeline.plugins.checkdb.plugins.WorkflowRunConventionsPlugin.java

@Override
public void check(SelectQueryRunner qRunner, SortedMap<Level, Set<String>> result) throws SQLException {
    try {//w ww . ja  v  a 2  s .  c om
        /**
         * May not be true for downsteam workflow runs
        * List<Integer> executeQuery = qRunner.executeQuery("select sw_accession from workflow_run WHERE workflow_run_id NOT IN (select workflow_run_id FROM ius_workflow_runs);", new ColumnListHandler<Integer>());
        * CheckDB.processOutput(result, Level.TRIVIAL,  "Workflow runs not connected to an IUS via ius_workflow_runs: " , executeQuery);
        **/
        // workflow runs not connected to a study
        String query = IOUtils.toString(
                AttributePlugin.class.getResourceAsStream("workflow_runs_not_connected_to_study.sql"));
        List<Object[]> workflow_run_study_pairs = qRunner.executeQuery(query, new ArrayListHandler());

        List<Integer> unreachableByStudy = new ArrayList<>();
        // number studies -> workflow runs
        SortedMap<Integer, SortedSet<Integer>> reachableByMultipleStudies = new TreeMap<>();

        for (Object[] pair : workflow_run_study_pairs) {
            int studyCount = Integer.valueOf(pair[1].toString());
            if (pair[0] == null) {
                continue;
            }
            int sw_accession = Integer.valueOf(pair[0].toString());
            if (studyCount == 0) {
                unreachableByStudy.add(sw_accession);
            } else if (studyCount > 1) {
                if (!reachableByMultipleStudies.containsKey(studyCount)) {
                    reachableByMultipleStudies.put(studyCount, new TreeSet<Integer>());
                }
                reachableByMultipleStudies.get(studyCount).add(sw_accession);
            }
        }
        CheckDB.processOutput(result, Level.SEVERE, "'Completed' Workflow runs not reachable by studies: ",
                unreachableByStudy);
        // workflow runs connected to more than one study
        if (reachableByMultipleStudies.size() > 0) {
            for (Entry<Integer, SortedSet<Integer>> e : reachableByMultipleStudies.entrySet()) {
                CheckDB.processOutput(result, Level.WARNING,
                        "'Completed' Workflow runs reachable by " + e.getKey() + " studies: ",
                        new ArrayList<>(e.getValue()));
            }
        }
        query = IOUtils.toString(
                AttributePlugin.class.getResourceAsStream("workflow_runs_not_connected_in_hierarchy.sql"));
        List<Integer> executeQuery = qRunner.executeQuery(query, new ColumnListHandler<Integer>());
        CheckDB.processOutput(result, Level.SEVERE,
                "'Completed' Workflow runs reachable by ius_workflow_runs but not via the processing_hierarchy: ",
                executeQuery);

        query = IOUtils.toString(AttributePlugin.class.getResourceAsStream("new_input_files_versus_old.sql"));
        executeQuery = qRunner.executeQuery(query, new ColumnListHandler<Integer>());
        CheckDB.processOutput(result, Level.TRIVIAL,
                "Workflow runs with input files via workflow_run_input_files but not via the processing hierarchy: ",
                executeQuery);

        query = IOUtils.toString(AttributePlugin.class.getResourceAsStream("old_input_files_versus_new.sql"));
        executeQuery = qRunner.executeQuery(query, new ColumnListHandler<Integer>());
        CheckDB.processOutput(result, Level.TRIVIAL,
                "Workflow runs with input files via the processing hierarchy but not via workflow_run_input_files: ",
                executeQuery);

    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }

}

From source file:org.opencms.workplace.CmsWidgetDialogParameter.java

/**
 * "Commits" (writes) the value of this widget back to the underlying base object.<p> 
 * /*  w ww  . j a va  2  s.c o m*/
 * @param dialog the widget dialog where the parameter is used on
 * 
 * @throws CmsException in case the String value of the widget is invalid for the base Object
 */
@SuppressWarnings("unchecked")
public void commitValue(CmsWidgetDialog dialog) throws CmsException {

    if (m_baseCollection == null) {
        PropertyUtilsBean bean = new PropertyUtilsBean();
        ConvertUtilsBean converter = new ConvertUtilsBean();
        Object value = null;
        try {
            Class<?> type = bean.getPropertyType(m_baseObject, m_baseObjectProperty);
            value = converter.convert(m_value, type);
            bean.setNestedProperty(m_baseObject, m_baseObjectProperty, value);
            setError(null);
        } catch (InvocationTargetException e) {
            setError(e.getTargetException());
            throw new CmsWidgetException(Messages.get().container(Messages.ERR_PROPERTY_WRITE_3, value,
                    dialog.keyDefault(A_CmsWidget.getLabelKey(this), getKey()),
                    m_baseObject.getClass().getName()), e.getTargetException(), this);
        } catch (Exception e) {
            setError(e);
            throw new CmsWidgetException(Messages.get().container(Messages.ERR_PROPERTY_WRITE_3, value,
                    dialog.keyDefault(A_CmsWidget.getLabelKey(this), getKey()),
                    m_baseObject.getClass().getName()), e, this);
        }
    } else if (m_baseCollection instanceof SortedMap) {
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_value)) {
            int pos = m_value.indexOf('=');
            if ((pos > 0) && (pos < (m_value.length() - 1))) {
                String key = m_value.substring(0, pos);
                String value = m_value.substring(pos + 1);
                @SuppressWarnings("rawtypes")
                SortedMap map = (SortedMap) m_baseCollection;
                if (map.containsKey(key)) {
                    Object val = map.get(key);
                    CmsWidgetException error = new CmsWidgetException(
                            Messages.get().container(Messages.ERR_MAP_DUPLICATE_KEY_3,
                                    dialog.keyDefault(A_CmsWidget.getLabelKey(this), getKey()), key, val),
                            this);
                    setError(error);
                    throw error;
                }
                map.put(key, value);
            } else {
                CmsWidgetException error = new CmsWidgetException(
                        Messages.get().container(Messages.ERR_MAP_PARAMETER_FORM_1,
                                dialog.keyDefault(A_CmsWidget.getLabelKey(this), getKey())),
                        this);
                setError(error);
                throw error;
            }
        }
    } else if (m_baseCollection instanceof List) {
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_value)) {
            @SuppressWarnings("rawtypes")
            List list = (List) m_baseCollection;
            list.add(m_value);
        }
    }
}

From source file:org.cloudata.core.tabletserver.ColumnCollection.java

License:asdf

public void searchAllVersion(Key rowKey, Cell.Key cellKey, List<ColumnValue> result) {
    SortedMap<Cell.Key, ValueCollection> columnValues = null;
    mapLock.readLock().lock();/* ww  w .  jav  a 2 s .  c  om*/
    try {
        columnValues = columnCollectionMap.get(rowKey);
    } finally {
        mapLock.readLock().unlock();
    }

    if (columnValues != null) {
        synchronized (columnValues) {
            ValueCollection vc = columnValues.get(cellKey);
            if (vc != null) {
                for (ColumnValue eachColumnValue : vc.getColumnValues()) {
                    result.add(eachColumnValue.copyColumnValue());
                }
            }
        }
    }
}

From source file:org.eclipse.skalli.core.persistence.XStreamPersistenceTest.java

@Test
public void testGetExtensionsByClassName() throws Exception {
    XStreamPersistence xp = new TestXStreamPersistence();
    Document doc = XMLUtils.documentFromString(XML_WITH_EXTENSIONS);
    Map<String, Class<?>> aliases = getAliases();
    SortedMap<String, Element> extensions = xp.getExtensionsByClassName(doc, aliases);
    assertEquals(2, extensions.size());/*from  ww  w  .jav a2 s. c  o m*/
    for (String alias : aliases.keySet()) {
        String className = aliases.get(alias).getName();
        assertTrue(extensions.containsKey(className));
        assertEquals(alias, extensions.get(className).getNodeName());
    }
}

From source file:org.mule.devkit.doclet.Doclava.java

public static PackageInfo[] choosePackages() {
    if (sVisiblePackages != null) {
        return sVisiblePackages;
    }/*w w  w  .j  ava 2  s  .com*/

    ClassInfo[] classes = Converter.rootClasses();
    SortedMap<String, PackageInfo> sorted = new TreeMap<String, PackageInfo>();
    for (ClassInfo cl : classes) {
        PackageInfo pkg = cl.containingPackage();
        String name;
        if (pkg == null) {
            name = "";
        } else {
            name = pkg.name();
        }
        sorted.put(name, pkg);
    }

    ArrayList<PackageInfo> result = new ArrayList<PackageInfo>();

    for (String s : sorted.keySet()) {
        PackageInfo pkg = sorted.get(s);

        if (pkg.isHidden()) {
            continue;
        }
        Boolean allHidden = true;
        int pass = 0;
        ClassInfo[] classesToCheck = null;
        while (pass < 5) {
            switch (pass) {
            case 0:
                classesToCheck = pkg.ordinaryClasses();
                break;
            case 1:
                classesToCheck = pkg.enums();
                break;
            case 2:
                classesToCheck = pkg.errors();
                break;
            case 3:
                classesToCheck = pkg.exceptions();
                break;
            case 4:
                classesToCheck = pkg.getInterfaces();
                break;
            default:
                System.err.println("Error reading package: " + pkg.name());
                break;
            }
            for (ClassInfo cl : classesToCheck) {
                if (!cl.isHidden()) {
                    allHidden = false;
                    break;
                }
            }
            if (!allHidden) {
                break;
            }
            pass++;
        }
        if (allHidden) {
            continue;
        }

        result.add(pkg);
    }

    sVisiblePackages = result.toArray(new PackageInfo[result.size()]);
    return sVisiblePackages;
}

From source file:edu.brown.benchmark.BenchmarkResults.java

public BenchmarkResults addPollResponseInfo(String clientName, int pollIndex, long time, TransactionCounter tc,
        String errMsg) {/*from w  w  w.  j  av  a 2 s  .c  o  m*/
    long benchmarkTime = pollIndex * m_pollIntervalInMillis;
    long offsetTime = time - benchmarkTime;

    if (errMsg != null) {
        Error err = new Error(clientName, errMsg, pollIndex);
        m_errors.add(err);
        return (null);
    }

    if (debug.get())
        LOG.debug(String.format("Setting Poll Response Info for '%s' [%d]:\n%s", clientName, pollIndex,
                tc.transactions));

    // Update Touched Histograms
    // This doesn't need to be synchronized
    this.m_basePartitions.putHistogram(tc.basePartitions);

    BenchmarkResults finishedIntervalClone = null;
    synchronized (this) {
        // put the transactions names:
        if (m_transactionNames.isEmpty()) {
            for (String txnName : tc.transactions.values())
                m_transactionNames.add(txnName);
        }

        // ensure there is an entry for the client
        SortedMap<String, List<Result>> txnResults = m_data.get(clientName);
        if (txnResults == null) {
            txnResults = new TreeMap<String, List<Result>>();
            m_data.put(clientName, txnResults);
        }

        for (String txnName : m_transactionNames) {
            List<Result> results = txnResults.get(txnName);
            if (results == null) {
                results = new ArrayList<Result>();
                txnResults.put(txnName, results);
            }
            assert (results != null);
            Result r = new Result(offsetTime, tc.transactions.get(txnName));
            results.add(r);
        } // FOR
        this.clientResultCount.put(clientName);
        if (debug.get())
            LOG.debug(String.format("New Result for '%s' => %d [minCount=%d]", clientName,
                    this.clientResultCount.get(clientName), this.clientResultCount.getMinCount()));
        if (this.clientResultCount.getMinCount() > this.completedIntervals && m_data.size() == m_clientCount) {
            this.completedIntervals = (int) this.clientResultCount.getMinCount();
            finishedIntervalClone = this.copy();
        }
    } // SYNCH

    return (finishedIntervalClone);
}

From source file:org.cloudata.core.tabletserver.ColumnCollection.java

License:asdf

public ColumnValue get(Row.Key rowKey, Cell.Key columnKey) {
    SortedMap<Cell.Key, ValueCollection> columnValues = null;
    mapLock.readLock().lock();/*from   w  w w. ja va2s. c o m*/
    try {
        columnValues = columnCollectionMap.get(rowKey);
    } finally {
        mapLock.readLock().unlock();
    }

    if (columnValues == null)
        return null;

    synchronized (columnValues) {
        ValueCollection value = columnValues.get(columnKey);
        if (value == null)
            return null;
        return value.get();
    }
}