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.amalto.workbench.actions.XSDSetAnnotationLabelAction.java

@Override
public IStatus doAction() {
    try {/*w ww .j  ava  2 s  .  c  o m*/
        // IStructuredSelection selection = (IStructuredSelection)page.getTreeViewer().getSelection();
        //
        // XSDAnnotationsStructure struc = new XSDAnnotationsStructure((XSDComponent)selection.getFirstElement());
        IStructuredSelection selection = (TreeSelection) page.getTreeViewer().getSelection();
        XSDComponent xSDCom = null;
        if (selection.getFirstElement() instanceof Element) {
            TreePath tPath = ((TreeSelection) selection).getPaths()[0];
            for (int i = 0; i < tPath.getSegmentCount(); i++) {
                if (tPath.getSegment(i) instanceof XSDAnnotation) {
                    xSDCom = (XSDAnnotation) (tPath.getSegment(i));
                }
            }
        } else {
            xSDCom = (XSDComponent) selection.getFirstElement();
        }
        XSDAnnotationsStructure struc = new XSDAnnotationsStructure(xSDCom);
        if (struc.getAnnotation() == null) {
            throw new RuntimeException(Messages.bind(Messages.XSDSetAnnotationLabelAction_ExceptioInfo,
                    xSDCom.getClass().getName()));
        }

        AnnotationLanguageLabelsDialog dlg = new AnnotationLanguageLabelsDialog(struc.getLabels(),
                new AnnotationLabelDialogSelectionListener(page), page.getEditorSite().getShell(),
                Messages.XSDSetAnnotationLabelAction_DialogTitle);
        dlg.setBlockOnOpen(true);
        dlg.open();

        if (dlg.getReturnCode() == Window.OK) {
            // remove existing annotations with labels
            struc.removeAllLabels();
            // add the new ones
            LinkedHashMap<String, String> descriptions = dlg.getDescriptionsMap();
            Set<String> isoCodes = descriptions.keySet();
            for (Iterator iter = isoCodes.iterator(); iter.hasNext();) {
                String isoCode = (String) iter.next();
                struc.setLabel(isoCode, descriptions.get(isoCode));
            }
        } else {
            return Status.CANCEL_STATUS;
        }

        if (struc.hasChanged()) {
            page.markDirty();
            page.refresh();
            page.getTreeViewer().expandToLevel(xSDCom, 2);
        }

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(page.getSite().getShell(), Messages._Error,
                Messages.bind(Messages.XSDSetAnnotationLabelAction_ErrorMsg, e.getLocalizedMessage()));
        return Status.CANCEL_STATUS;
    }

    return Status.OK_STATUS;
}

From source file:com.vikingbrain.nmt.controller.impl.RemoteHttpServiceImpl.java

/**
 * It uses the parameters to build the http arguments with name and value.
 * @param params all the parameters with name and value
 * @return the stringbuffer with the http arguments ready to be added to a http request
 *///  w w  w  . j  a va2s . c  om
private StringBuffer buildEncodedParameters(LinkedHashMap<String, String> params) {
    StringBuffer parametersUrlGet = new StringBuffer("");

    if (null != params) {
        for (String key : params.keySet()) {

            String value = params.get(key);
            String encodedParameter = encodeHttpParameter(value);

            // It builds something like
            // "&param1=file%20name%26blues for entry "param1","file name&blues"
            parametersUrlGet.append("&").append(key).append("=").append(encodedParameter);
        }
    }
    return parametersUrlGet;
}

From source file:com.redhat.topicindex.security.FedoraAccountSystem.java

private boolean checkCLAAgreement(LinkedHashMap groups) {
    for (Object key : groups.keySet()) {
        LinkedHashMap group = (LinkedHashMap) groups.get(key);
        if (group.containsKey("name")) {
            if (group.get("name").equals("cla_done")) {
                return true;
            }//from   w w w  . j a v  a2s .  co m
        }
    }
    return false;
}

From source file:net.big_oh.resourcestats.dao.RequestorDAOIntegrationTest.java

/**
 * Test method for//  w  ww.ja va  2 s.  c  o m
 * {@link net.big_oh.resourcestats.dao.RequestorDAO#getMostFrequentRequestors(int)}
 * .
 */
@Test
public void testGetMostFrequentRequestorsInt() {
    try {
        sf.getCurrentSession().beginTransaction();

        LinkedHashMap<Requestor, Number> requestors = dao.getMostFrequentRequestors(5);

        assertNotNull(requestors);

        for (Object key : requestors.keySet()) {
            assertTrue(key instanceof Requestor);
            Object value = requestors.get(key);
            assertTrue(value instanceof Number);
        }

        // TODO DSW Provide improved assertions

        sf.getCurrentSession().getTransaction().commit();
    } catch (Throwable t) {
        HibernateUtil.rollback(t, sf, log);
        throw new RuntimeException(t);
    }
}

From source file:net.big_oh.resourcestats.dao.RequestorDAOIntegrationTest.java

/**
 * Test method for//from   ww w.ja  v a2 s  .  com
 * {@link net.big_oh.resourcestats.dao.RequestorDAO#getMostFrequentRequestors(int, int)}
 * .
 */
@Test
public void testGetMostFrequentRequestorsIntInt() {
    try {
        sf.getCurrentSession().beginTransaction();

        LinkedHashMap<Requestor, Number> requestors = dao.getMostFrequentRequestors(5, 7);

        assertNotNull(requestors);

        for (Object key : requestors.keySet()) {
            assertTrue(key instanceof Requestor);
            Object value = requestors.get(key);
            assertTrue(value instanceof Number);
        }

        // TODO DSW Provide improved assertions

        sf.getCurrentSession().getTransaction().commit();
    } catch (Throwable t) {
        HibernateUtil.rollback(t, sf, log);
        throw new RuntimeException(t);
    }
}

From source file:guru.qas.martini.scope.ScenarioScope.java

protected void runDestructionCallbacks() {
    LinkedHashMap<String, Runnable> index = DESTRUCTION_CALLBACKS.get();
    DESTRUCTION_CALLBACKS.remove();//from   w  ww .ja v  a 2 s .  c o  m
    List<String> names = Lists.reverse(Lists.newArrayList(index.keySet()));
    for (String name : names) {
        Runnable callback = index.remove(name);
        run(name, callback);
    }
}

From source file:org.fcrepo.integration.kernel.utils.LowLevelCacheEntryIT.java

License:asdf

@Test
public void testModifyingCacheStores() throws Exception {

    final EmbeddedCacheManager cm = new DefaultCacheManager("config/infinispan/chained/infinispan.xml");

    final CacheStore ispn = cm.getCache("FedoraRepository").getAdvancedCache().getComponentRegistry()
            .getComponent(CacheLoaderManager.class).getCacheStore();

    assert ispn instanceof ChainingCacheStore;

    final BinaryKey key = new BinaryKey("123");

    final ChainingCacheStore chained_store = (ChainingCacheStore) ispn;

    final LinkedHashMap<CacheStore, CacheStoreConfiguration> stores = chained_store.getStores();

    final LowLevelCacheEntry cs = new CacheStoreEntry((CacheStore) stores.keySet().toArray()[0],
            "FedoraRepository", key);
    final LowLevelCacheEntry cs2 = new CacheStoreEntry((CacheStore) stores.keySet().toArray()[1],
            "FedoraRepository", key);

    cs.storeValue(new ByteArrayInputStream("123456".getBytes()));

    cs2.storeValue(new ByteArrayInputStream("asdfg".getBytes()));

    Thread.sleep(1000);//from   ww w. ja  v  a 2 s  . c  o m

    final String v1 = IOUtils.toString(cs.getInputStream());
    final String v2 = IOUtils.toString(cs2.getInputStream());

    assertEquals("Found the wrong value in our cache store", "123456", v1);
    assertEquals("Found the wrong value in our cache store", "asdfg", v2);

}

From source file:org.skb.lang.dal.DalPass3_Gen.java

public LinkedHashMap<String, String> fixKV(LinkedHashMap<String, List<StringTemplate>> kv) {
    LinkedHashMap<String, String> ret = new LinkedHashMap<String, String>();
    String key;//w  w w  .  j a v a  2  s .co m
    Set<String> o_set = kv.keySet();
    Iterator<String> key_it = o_set.iterator();
    while (key_it.hasNext()) {
        key = key_it.next();
        String value = "";
        List<StringTemplate> list = kv.get(key);
        for (int i = 0; i < list.size(); i++) {
            if (value.length() > 0)
                value += ", ";
            value += StringUtils.removeEnd(StringUtils.removeStart(list.get(i).toString(), "\""), "\"");
        }
        ret.put(key, value);
    }
    return ret;
}

From source file:net.big_oh.resourcestats.dao.ResourceDAOIntegrationTest.java

/**
 * Test method for/* ww  w .  j  av a 2s  .c  om*/
 * {@link net.big_oh.resourcestats.dao.ResourceDAO#getMostPopularResources(int)}
 * .
 */
@Test
public void testGetMostPopularResourcesInt() {
    try {
        sf.getCurrentSession().beginTransaction();

        LinkedHashMap<Resource, Number> resources = dao.getMostPopularResources(5);

        assertNotNull(resources);

        for (Object key : resources.keySet()) {
            assertTrue(key instanceof Resource);
            Object value = resources.get(key);
            assertTrue(value instanceof Number);
        }

        // TODO DSW Provide improved assertions

        sf.getCurrentSession().getTransaction().commit();
    } catch (Throwable t) {
        HibernateUtil.rollback(t, sf, log);
        throw new RuntimeException(t);
    }
}

From source file:com.opengamma.analytics.math.curve.InterpolatedCurveBuildingFunction.java

public InterpolatedCurveBuildingFunction(final LinkedHashMap<String, double[]> knotPoints,
        LinkedHashMap<String, Interpolator1D> interpolators) {
    Validate.notNull(knotPoints, "null knot points");
    Validate.notNull(interpolators, "null interpolators");
    int count = 0;
    Set<String> names = knotPoints.keySet();
    for (String name : names) {
        int size = knotPoints.get(name).length;
        Validate.isTrue(size > 0, "no knot points for " + name);
        count += size;/*from   w w  w.  j  a  v  a 2  s.  com*/
    }
    _knotPoints = knotPoints;
    _interpolators = interpolators;
    _nNodes = count;
}