Example usage for java.util Map values

List of usage examples for java.util Map values

Introduction

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

Prototype

Collection<V> values();

Source Link

Document

Returns a Collection view of the values contained in this map.

Usage

From source file:com.github.stagirs.lingvo.build.MorphStateMachineBuilder.java

private static Collection<RuleMapping> suf2mapping() throws IOException {
    Set<String> suffixes = getSuffixes();
    Map<String, Struct> sufs = new HashMap<String, Struct>();
    for (Map.Entry<String, List<WordForm[]>> raw2WordForms : getRaw2WordForms().entrySet()) {
        String raw = raw2WordForms.getKey();
        int[] index = getCommon(suffixes, raw, raw2WordForms.getValue());
        String common = index[0] < index[1] ? raw.substring(index[0], index[1]) : "";
        String rawPref = raw.substring(0, Math.min(index[0], index[1]));
        String rawSuf = raw.substring(index[1]);
        Map<String, List<RuleItem>> map = new HashMap();
        for (WordForm[] wordForm : raw2WordForms.getValue()) {
            String normSuf = wordForm[1].getWord().substring(common.length());
            if (!map.containsKey(normSuf)) {
                map.put(normSuf, new ArrayList<RuleItem>());
            }/*from   w  w  w.  j a  va  2 s  .com*/
            map.get(normSuf).add(new RuleItem(normSuf, wordForm[1].getForm(), wordForm[0].getForm()));
        }
        RuleItem[][] items = new RuleItem[map.size()][];
        int i = 0;
        for (List<RuleItem> item : map.values()) {
            items[i++] = item.toArray(new RuleItem[item.size()]);
        }
        Rule rule = new Rule(rawPref, rawSuf, items);
        String ruleId = Rule.serialize(rule);
        if (!sufs.containsKey(rawSuf)) {
            sufs.put(rawSuf, new Struct());
        }
        Struct struct = sufs.get(rawSuf);
        if (!struct.rule2id.containsKey(ruleId)) {
            struct.rule2id.put(ruleId, struct.rule2id.size());
            struct.rules.add(rule);
        }
        struct.prefcommons.put(rawPref + common, struct.rule2id.get(ruleId));
    }
    List<RuleMapping> list = new ArrayList<RuleMapping>();
    for (Map.Entry<String, Struct> entrySet : sufs.entrySet()) {
        list.add(new RuleMapping(entrySet.getKey(), entrySet.getValue().prefcommons,
                entrySet.getValue().rules.toArray(new Rule[entrySet.getValue().rules.size()])));
    }
    return list;
}

From source file:io.github.moosbusch.lumpi.util.LumpiUtil.java

public static Collection<Type> getParameterTypesForCollection(Class<?> type) {
    if (isCollectionOrSequence(type)) {
        Map<TypeVariable<?>, Type> m = TypeUtils
                .getTypeArguments((ParameterizedType) type.getGenericSuperclass());
        return m.values();
    }//from  w w  w  . j  a  v  a  2s  .  co  m

    return null;
}

From source file:com.netflix.ice.basic.BasicWeeklyCostEmailService.java

private static Map<String, List<ApplicationGroup>> collectEmails(Map<String, ApplicationGroup> appgroups) {

    Map<String, List<ApplicationGroup>> result = Maps.newTreeMap();
    for (ApplicationGroup appgroup : appgroups.values()) {
        if (StringUtils.isEmpty(appgroup.owner))
            continue;

        String email = appgroup.owner.trim().toLowerCase();
        List<ApplicationGroup> list = result.get(email);
        if (list == null) {
            list = Lists.newArrayList();
            result.put(email, list);//from w w  w  .  j  av  a  2 s  . c o m
        }
        list.add(appgroup);
    }

    return result;
}

From source file:jp.go.nict.langrid.bpel.ProcessAnalyzer.java

/**
 * /*  w w  w . j  a  v a 2s  .  com*/
 * 
 */
public static void resolve(BPEL bpel, Map<URI, WSDL> wsdls)
        throws ProcessAnalysisException, URISyntaxException {
    // EndpointReference?
    for (WSDL w : wsdls.values()) {
        for (Service s : w.getServices().values()) {
            for (Port p : s.getPorts().values()) {
                EndpointReference epr = new EndpointReference();
                epr.setServiceName(new QName(w.getTargetNamespace().toString(), s.getName()));
                epr.setServicePortName(p.getName());
                epr.setAddress(p.getAddress());

                QName binding = p.getBinding();
                WSDL bw = wsdls.get(new URI(binding.getNamespaceURI()));
                assert bw != null;
                QName bindingType = bw.getBindingTypes().get(binding.getLocalPart());
                WSDL btw = wsdls.get(new URI(bindingType.getNamespaceURI()));
                assert btw != null;
                Map<String, EndpointReference> map = btw.getPortTypeToEndpointReference();
                if (map == null) {
                    map = new HashMap<String, EndpointReference>();
                    btw.setPortTypeToEndpointReference(map);
                }
                map.put(p.getName(), epr);
            }
        }
    }
    Map<QName, EndpointReference> portTypeQNameToEndpointReference = new HashMap<QName, EndpointReference>();
    Map<QName, PartnerLinkType> qnameToPartnerLinkType = new HashMap<QName, PartnerLinkType>();
    Map<QName, QName> bindingNameToServiceName = new HashMap<QName, QName>();
    for (WSDL w : wsdls.values()) {
        String tns = w.getTargetNamespace().toString();
        for (Map.Entry<String, EndpointReference> e : w.getPortTypeToEndpointReference().entrySet()) {
            portTypeQNameToEndpointReference.put(new QName(tns, e.getKey()), e.getValue());
        }
        for (Map.Entry<String, PartnerLinkType> e : w.getPlinks().entrySet()) {
            qnameToPartnerLinkType.put(new QName(tns, e.getKey()), e.getValue());
        }
        for (Service s : w.getServices().values()) {
            for (Port p : s.getPorts().values()) {
                bindingNameToServiceName.put(p.getBinding(), new QName(tns, s.getName()));
            }
        }
    }
    Map<QName, QName> portTypeNameToServiceName = new HashMap<QName, QName>();
    for (WSDL w : wsdls.values()) {
        String tns = w.getTargetNamespace().toString();
        for (Map.Entry<String, QName> e : w.getBindingTypes().entrySet()) {
            portTypeNameToServiceName.put(e.getValue(),
                    bindingNameToServiceName.get(new QName(tns, e.getKey())));
        }
    }

    // PartnerLink -> ServiceName
    // PartnerLink -> EndpointReference
    // ?
    for (PartnerLink p : bpel.getPartnerLinks()) {
        // PartnerLink -> wsdl?plink:partnerLinkType
        QName pltName = p.getPartnerLinkType();
        PartnerLinkType plt = qnameToPartnerLinkType.get(pltName);
        if (plt == null) {
            throw new ProcessAnalysisException("couldn't find partner link type for: " + pltName);
        }

        // myRole?
        String myRole = p.getMyRole();
        if (myRole != null) {
            Role role = plt.getRoles().get(myRole);
            if (role == null) {
                throw new ProcessAnalysisException("The my role \"" + myRole + "\" for partner link name \""
                        + plt.getName() + "\" is not found.");
            }

            QName portTypeName = role.getPortTypeName();
            QName serviceName = portTypeNameToServiceName.get(portTypeName);
            if (serviceName != null) {
                p.setService(serviceName.getLocalPart());
            } else {
                // ???????
                p.setService(bpel.getProcessName());
            }
        }

        // partnerRole?
        String partnerRole = p.getPartnerRole();
        if (partnerRole != null) {
            Role role = plt.getRoles().get(partnerRole);
            if (role == null) {
                throw new ProcessAnalysisException("The partner role \"" + partnerRole
                        + "\" for partner link name \"" + plt.getName() + "\" is not found.");
            }

            QName portTypeName = role.getPortTypeName();
            EndpointReference epr = portTypeQNameToEndpointReference.get(portTypeName);
            if (epr == null) {
                throw new ProcessAnalysisException(
                        "The EndpointReference for port type \"" + portTypeName + "\" is not found.");
            }
            p.setEndpointReference(epr);
        }
    }
}

From source file:com.clustercontrol.hub.util.CollectStringDataUtil.java

/**
 * /*from ww  w  .ja  va2 s .co  m*/
 * @param sampleList
 */
public static void store(List<StringSample> sampleList) {
    m_log.debug("store() start");

    List<CollectStringData> collectdata_entities = new ArrayList<CollectStringData>();
    JpaTransactionManager jtm = new JpaTransactionManager();
    jtm.begin();

    Map<String, MonitorInfo> monitorInfoMap = new HashMap<>();
    Map<String, CollectStringDataParser> parserMap = new HashMap<>();
    for (StringSample sample : sampleList) {
        for (StringSampleData data : sample.getStringSampleList()) {
            // for debug
            if (m_log.isDebugEnabled()) {
                m_log.debug("store() facilityId = " + data.getFacilityId() + ", dateTime = "
                        + sample.getDateTime());
                m_log.debug("store() value = " + data.getValue());
            }

            m_log.debug("persist targetName = " + data.getTargetName());

            String monitorId = sample.getMonitorId();
            String facilityId = data.getFacilityId();
            // ???512 ???
            String targetName = data.getTargetName().length() > 512 ? data.getTargetName().substring(0, 512)
                    : data.getTargetName();

            CollectStringData collectData = null;
            Long collectId = getCollectStringKeyInfoPK(monitorId, facilityId, targetName, jtm);

            Long dataId = StringDataIdGenerator.getNext();
            if (dataId == StringDataIdGenerator.getMax() / 2) {
                AplLogger.put(PriorityConstant.TYPE_WARNING, HinemosModuleConstant.HUB_TRANSFER,
                        MessageConstant.MESSAGE_HUB_COLLECT_NUMBERING_OVER_INTERMEDIATE, new String[] {},
                        String.format("current=%d, max=%d", dataId, StringDataIdGenerator.getMax()));
            }

            CollectStringDataPK pk = new CollectStringDataPK(collectId, dataId);

            String value = data.getValue() != null ? data.getValue() : "";
            collectData = new CollectStringData(pk, HinemosTime.currentTimeMillis(), value);

            if (!data.getTagList().isEmpty()) {
                Map<String, CollectDataTag> tagMap = new HashMap<>();
                for (StringSampleTag tag : data.getTagList()) {
                    tagMap.put(tag.getKey(),
                            new CollectDataTag(new CollectDataTagPK(collectId, dataId, tag.getKey()),
                                    tag.getType(), tag.getValue()));
                }
                collectData.getTagList().addAll(tagMap.values());
            }

            // 
            MonitorSettingControllerBean bean = new MonitorSettingControllerBean();
            try {
                MonitorInfo mi = monitorInfoMap.get(monitorId);
                if (mi == null) {
                    mi = bean.getMonitor(monitorId);
                    monitorInfoMap.put(monitorId, mi);
                }
                if (mi.getLogFormatId() != null) {
                    CollectStringDataParser parser = parserMap.get(mi.getLogFormatId());
                    if (parser == null) {
                        parser = new CollectStringDataParser(
                                new HubControllerBean().getLogFormat(mi.getLogFormatId()));
                        parserMap.put(mi.getLogFormatId(), parser);
                    }
                    parser.parse(collectData);

                    collectData.setLogformatId(mi.getLogFormatId());
                }

                // KEY_TIMESTAMP_IN_LOG ??????????
                CollectDataTag timestamp = null;
                for (CollectDataTag tag : collectData.getTagList()) {
                    if (tag.getKey().equals(CollectStringDataParser.KEY_TIMESTAMP_IN_LOG)) {
                        timestamp = tag;
                        break;
                    }
                }
                if (timestamp != null) {
                    try {
                        Long time = collectData.getTime();
                        collectData.setTime(Long.valueOf(timestamp.getValue()));
                        collectData.getTagList().add(new CollectDataTag(
                                new CollectDataTagPK(collectData.getCollectId(), collectData.getDataId(),
                                        CollectStringDataParser.KEY_TIMESTAMP_RECIEVED),
                                ValueType.number, time.toString()));
                    } catch (Exception e) {
                        m_log.warn("store() : fail to change to timestamp of log. time=" + timestamp.getValue(),
                                e);
                    }
                }
            } catch (MonitorNotFound | HinemosUnknown | InvalidRole e) {
                m_log.warn(String.format("failed to get a MonitorInfo : %s", sample.getMonitorId()));
            }

            collectdata_entities.add(collectData);

            m_log.debug("store() : " + collectData);
        }
    }

    jtm.commit();

    List<JdbcBatchQuery> query = new ArrayList<JdbcBatchQuery>();
    // ()?
    if (!collectdata_entities.isEmpty()) {
        query.add(new CollectStringDataJdbcBatchInsert(collectdata_entities));
        for (CollectStringData data : collectdata_entities) {
            query.add(new CollectStringTagJdbcBatchInsert(data.getTagList()));
        }
    }
    JdbcBatchExecutor.execute(query);
    jtm.close();
    m_log.debug("store() end");
}

From source file:com.cyphermessenger.client.SyncRequest.java

public static HttpURLConnection doRequest(String endpoint, CypherSession session, Map<String, String> m)
        throws IOException {
    String[] keys = null;/*  ww  w .  ja v  a 2 s . co m*/
    String[] vals = null;
    if (m != null) {
        keys = (String[]) m.keySet().toArray(new String[] {});
        vals = (String[]) m.values().toArray(new String[] {});
    }
    return doRequest(endpoint, session, keys, vals);
}

From source file:eu.scape_project.pt.mapred.input.ControlFileInputFormat.java

/**
 * Finds input file references in the control line by looking 
 * into its toolspec.//ww w.jav  a 2  s . c o  m
 *
 * @param fs Hadoop filesystem handle
 * @param parser for parsing the control line
 * @param repo Toolspec repository
 * @return array of paths to input file references
 */
public static Path[] getInputFiles(FileSystem fs, CmdLineParser parser, Repository repo, String controlLine)
        throws IOException {
    parser.parse(controlLine);

    Command command = parser.getCommands()[0];
    String strStdinFile = parser.getStdinFile();
    // parse it, read input file parameters
    Tool tool = repo.getTool(command.getTool());

    ToolProcessor proc = new ToolProcessor(tool);
    Operation operation = proc.findOperation(command.getAction());
    if (operation == null)
        throw new IOException("operation " + command.getAction() + " not found");

    proc.setOperation(operation);
    proc.setParameters(command.getPairs());
    Map<String, String> mapInputFileParameters = proc.getInputFileParameters();
    ArrayList<Path> inFiles = new ArrayList<Path>();
    if (strStdinFile != null) {
        Path p = new Path(strStdinFile);
        if (fs.exists(p)) {
            inFiles.add(p);
        }
    }

    for (String fileRef : mapInputFileParameters.values()) {
        Path p = new Path(fileRef);
        if (fs.exists(p)) {
            if (fs.isDirectory(p)) {
                inFiles.addAll(getFilesInDir(fs, p));
            } else {
                inFiles.add(p);
            }
        }
    }
    return inFiles.toArray(new Path[0]);
}

From source file:com.acc.fulfilmentprocess.test.PaymentIntegrationTest.java

@AfterClass
public static void removeProcessDefinitions() {
    LOG.debug("cleanup...");

    final ApplicationContext appCtx = Registry.getGlobalApplicationContext();

    assertTrue("Application context of type " + appCtx.getClass() + " is not a subclass of "
            + ConfigurableApplicationContext.class, appCtx instanceof ConfigurableApplicationContext);

    final ConfigurableApplicationContext applicationContext = (ConfigurableApplicationContext) appCtx;
    final ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory();
    assertTrue("Bean Factory of type " + beanFactory.getClass() + " is not of type "
            + BeanDefinitionRegistry.class, beanFactory instanceof BeanDefinitionRegistry);
    final XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory);
    xmlReader.loadBeanDefinitions(/*from w ww. j a  va 2  s .c om*/
            new ClassPathResource("/bncfulfilmentprocess/test/bncfulfilmentprocess-spring-testcleanup.xml"));

    //cleanup command factory
    final Map<String, CommandFactory> commandFactoryList = applicationContext
            .getBeansOfType(CommandFactory.class);
    commandFactoryList.remove("mockupCommandFactory");
    final DefaultCommandFactoryRegistryImpl commandFactoryReg = appCtx
            .getBean(DefaultCommandFactoryRegistryImpl.class);
    commandFactoryReg.setCommandFactoryList(commandFactoryList.values());

    //      if (definitonFactory != null)
    //      {
    // TODO this test seems to let processes run after method completion - therefore we cannot
    // remove definitions !!!
    //         definitonFactory.remove("testPlaceorder");
    //         definitonFactory.remove("testConsignmentFulfilmentSubprocess");
    //      }
    processService.setTaskService(appCtx.getBean(DefaultTaskService.class));
    definitonFactory = null;
    processService = null;
}

From source file:com.exxonmobile.ace.hybris.fulfilmentprocess.test.PaymentIntegrationTest.java

@AfterClass
public static void removeProcessDefinitions() {
    LOG.debug("cleanup...");

    final ApplicationContext appCtx = Registry.getGlobalApplicationContext();

    assertTrue("Application context of type " + appCtx.getClass() + " is not a subclass of "
            + ConfigurableApplicationContext.class, appCtx instanceof ConfigurableApplicationContext);

    final ConfigurableApplicationContext applicationContext = (ConfigurableApplicationContext) appCtx;
    final ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory();
    assertTrue("Bean Factory of type " + beanFactory.getClass() + " is not of type "
            + BeanDefinitionRegistry.class, beanFactory instanceof BeanDefinitionRegistry);
    final XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory);
    xmlReader.loadBeanDefinitions(new ClassPathResource(
            "/exxonmobilfulfilmentprocess/test/exxonmobilfulfilmentprocess-spring-testcleanup.xml"));

    //cleanup command factory
    final Map<String, CommandFactory> commandFactoryList = applicationContext
            .getBeansOfType(CommandFactory.class);
    commandFactoryList.remove("mockupCommandFactory");
    final DefaultCommandFactoryRegistryImpl commandFactoryReg = appCtx
            .getBean(DefaultCommandFactoryRegistryImpl.class);
    commandFactoryReg.setCommandFactoryList(commandFactoryList.values());

    //      if (definitonFactory != null)
    //      {//from w  w  w. jav  a 2  s  .co m
    // TODO this test seems to let processes run after method completion - therefore we cannot
    // remove definitions !!!
    //         definitonFactory.remove("testPlaceorder");
    //         definitonFactory.remove("testConsignmentFulfilmentSubprocess");
    //      }
    processService.setTaskService(appCtx.getBean(DefaultTaskService.class));
    definitonFactory = null;
    processService = null;
}

From source file:org.vinmonopolet.fulfilmentprocess.test.PaymentIntegrationTest.java

@AfterClass
public static void removeProcessDefinitions() {
    LOG.debug("cleanup...");

    final ApplicationContext appCtx = Registry.getGlobalApplicationContext();

    assertTrue("Application context of type " + appCtx.getClass() + " is not a subclass of "
            + ConfigurableApplicationContext.class, appCtx instanceof ConfigurableApplicationContext);

    final ConfigurableApplicationContext applicationContext = (ConfigurableApplicationContext) appCtx;
    final ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory();
    assertTrue("Bean Factory of type " + beanFactory.getClass() + " is not of type "
            + BeanDefinitionRegistry.class, beanFactory instanceof BeanDefinitionRegistry);
    final XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory);
    xmlReader.loadBeanDefinitions(new ClassPathResource(
            "/vinmonopoletfulfilmentprocess/test/vinmonopoletfulfilmentprocess-spring-testcleanup.xml"));

    //cleanup command factory
    final Map<String, CommandFactory> commandFactoryList = applicationContext
            .getBeansOfType(CommandFactory.class);
    commandFactoryList.remove("mockupCommandFactory");
    final DefaultCommandFactoryRegistryImpl commandFactoryReg = appCtx
            .getBean(DefaultCommandFactoryRegistryImpl.class);
    commandFactoryReg.setCommandFactoryList(commandFactoryList.values());

    //      if (definitonFactory != null)
    //      {//from   ww w .j a  va2  s .  com
    // TODO this test seems to let processes run after method completion - therefore we cannot
    // remove definitions !!!
    //         definitonFactory.remove("testPlaceorder");
    //         definitonFactory.remove("testConsignmentFulfilmentSubprocess");
    //      }
    processService.setTaskService(appCtx.getBean(DefaultTaskService.class));
    definitonFactory = null;
    processService = null;
}