Example usage for java.util LinkedHashMap values

List of usage examples for java.util LinkedHashMap values

Introduction

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

Prototype

public Collection<V> values() 

Source Link

Document

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

Usage

From source file:application.Crawler.java

/**
 * map object from string //w  w w  .j  a  v  a 2 s .com
 * @param res
 * @return the product list 
 * @throws IOException
 */
private ProductLists StringToObject(String res) throws CrawlerException, BadAnswerExp {

    ObjectMapper mapper = new ObjectMapper();
    ProductLists productLists = new ProductLists();
    // very dirty part bad mapping from jackson because the full object is not set
    try {
        LinkedHashMap readValue = (LinkedHashMap) mapper.readValue(res, Object.class);
        Collection values = readValue.values();
        ArrayList<LinkedHashMap> next = (ArrayList) values.iterator().next();

        ArrayList<Products> localProductList = new ArrayList<>();
        Double totalPrize = 0.0;

        for (LinkedHashMap next1 : next) {

            String values1 = (String) next1.values().iterator().next();
            Double extractUnitPrice = this.extractUnitPrice(values1);
            this.extractLinkAndTitle(values1);
            String crawledDescriptionPage = this.crawlDescriptionPage();
            String extractDescription = this.extractDescription(crawledDescriptionPage);
            // calculate the total price
            totalPrize += extractUnitPrice;
            // instance a product 
            localProductList.add(new Products(extractDescription, title, extractUnitPrice, size));
        }

        productLists.setProduct(localProductList);
        productLists.setTotalPrice(totalPrize);

    } catch (IOException e) {
        //            LOG.error(e.getMessage());
        throw new BadAnswerExp("bad answer from server");
    }

    return productLists;
}

From source file:ren.hankai.cordwood.web.breadcrumb.BreadCrumbInterceptor.java

/**
 * //from   w  w  w.ja v  a  2 s. c  o m
 *
 * @param familyMap 
 * @param newLink 
 * @author hankai
 * @since Nov 22, 2018 3:50:12 PM
 */
private void createRelationships(LinkedHashMap<String, BreadCrumbLink> familyMap, BreadCrumbLink newLink) {
    final Collection<BreadCrumbLink> values = familyMap.values();
    for (final BreadCrumbLink breadCrumbLink : values) {
        if (breadCrumbLink.getLabel().equalsIgnoreCase(newLink.getParentKey())) {
            breadCrumbLink.addNext(newLink);
            newLink.setPrevious(breadCrumbLink);
            newLink.setParent(breadCrumbLink);
        }
    }
}

From source file:com.linkedin.haivvreo.AvroSerDe.java

private Properties determineCorrectProperties(Configuration configuration, Properties properties) {
    if ((configuration instanceof JobConf) && HaivvreoUtils.insideMRJob((JobConf) configuration)) {
        LOG.info("In MR job, extracting table-level properties");
        MapredWork mapRedWork = Utilities.getMapRedWork(configuration);
        LinkedHashMap<String, PartitionDesc> a = mapRedWork.getAliasToPartnInfo();
        if (a.size() == 1) {
            LOG.info("Only one PartitionDesc found.  Returning that Properties");
            PartitionDesc p = a.values().iterator().next();
            TableDesc tableDesc = p.getTableDesc();
            return tableDesc.getProperties();
        } else {/*  w  w w .  j  a va 2  s .co  m*/
            String tableName = properties.getProperty("name");
            LOG.info("Multiple PartitionDescs.  Return properties for " + tableName);

            for (Map.Entry<String, PartitionDesc> partitionDescs : a.entrySet()) {
                Properties p = partitionDescs.getValue().getTableDesc().getProperties();
                if (p.get("name").equals(tableName)) {
                    // We've found the matching table partition
                    LOG.info("Matched table name against " + partitionDescs.getKey()
                            + ", return its properties");
                    return p;
                }
            }
            // Didn't find anything in partitions to match on.  WARN, at least.
            LOG.warn("Couldn't find any matching properties for table: " + tableName
                    + ". Returning original properties");
        }

    }
    return properties;
}

From source file:com.jaspersoft.studio.data.xml.XMLDataAdapterDescriptor.java

private void addMainNodeField(LinkedHashMap<String, JRDesignField> fieldsMap, Node item) {
    JRDesignField f = new JRDesignField();
    f.setName(ModelUtils.getNameForField(new ArrayList<JRDesignField>(fieldsMap.values()), item.getNodeName()));
    f.setValueClass(String.class);
    f.setDescription(".");
    fieldsMap.put(".", f);
}

From source file:aldenjava.opticalmapping.data.mappingresult.OptMapResultNode.java

public static LinkedHashMap<String, List<GenomicPosNode>> getPotentiallyMappedRegion(
        LinkedHashMap<String, DataNode> optrefmap,
        LinkedHashMap<String, List<OptMapResultNode>> resultListMap) {

    LinkedHashMap<String, List<GenomicPosNode>> targetRegionMap = new LinkedHashMap<>();
    for (List<OptMapResultNode> resultList : resultListMap.values()) {
        List<GenomicPosNode> targetRegionList = getPotentiallyMappedRegion(optrefmap, resultList);
        targetRegionMap.put(resultList.get(0).parentFrag.name, targetRegionList);
    }//w  w  w.  j  a  v  a 2 s.c om
    return targetRegionMap;
}

From source file:com.vmware.bdd.cli.commands.CommandsUtils.java

/**
 * Show a table(include table column names and table contents) by left
 * justifying. More specifically, the {@code columnNamesWithGetMethodNames}
 * argument is a map struct, the key is table column name and value is method
 * name list which it will be invoked by reflection. The {@code entities}
 * argument is traversed entity array.It is source of table data. In
 * addition,the method name must be each of the {@code entities} argument 's
 * member. The {@code spacesBeforeStart} argument is whitespace in the front
 * of the row.//from   w  w w.j a  v a 2s .c  o  m
 * <p>
 *
 * @param columnNamesWithGetMethodNames
 *           the container of table column name and invoked method name.
 * @param entities
 *           the traversed entity array.
 * @param spacesBeforeStart
 *           the whitespace in the front of the row.
 * @throws Exception
 */
public static void printInTableFormat(LinkedHashMap<String, List<String>> columnNamesWithGetMethodNames,
        Object[] entities, String spacesBeforeStart) throws Exception {
    if (entities != null && entities.length > 0) {
        // get number of columns
        int columnNum = columnNamesWithGetMethodNames.size();

        String[][] table = new String[entities.length + 1][columnNum];

        //build table header: column names
        String[] tableHeader = new String[columnNum];
        Set<String> columnNames = columnNamesWithGetMethodNames.keySet();
        columnNames.toArray(tableHeader);

        //put table column names into the first row
        table[0] = tableHeader;

        //build table contents
        Collection<List<String>> getMethodNamesCollect = columnNamesWithGetMethodNames.values();
        int i = 1;
        for (Object entity : entities) {
            int j = 0;
            for (List<String> getMethodNames : getMethodNamesCollect) {
                Object tempValue = null;
                int k = 0;
                for (String methodName : getMethodNames) {
                    if (tempValue == null)
                        tempValue = entity;
                    Object value = tempValue.getClass().getMethod(methodName).invoke(tempValue);
                    if (k == getMethodNames.size() - 1) {
                        table[i][j] = value == null ? ""
                                : ((value instanceof Double) ? String.valueOf(
                                        round(((Double) value).doubleValue(), 2, BigDecimal.ROUND_FLOOR))
                                        : value.toString());
                        if (isJansiAvailable() && !isBlank(table[i][j])) {
                            table[i][j] = transferEncoding(table[i][j]);
                        }
                        j++;
                    } else {
                        tempValue = value;
                        k++;
                    }
                }
            }
            i++;
        }

        printTable(table, spacesBeforeStart);
    }
}

From source file:com.jaspersoft.studio.data.xml.XMLDataAdapterDescriptor.java

private void addNewField(String nodeName, LinkedHashMap<String, JRDesignField> fieldsMap, Node item,
        String prefix) {//from w  ww. ja  v a 2  s  . co m
    JRDesignField f = new JRDesignField();
    String description = "";
    f.setName(ModelUtils.getNameForField(new ArrayList<JRDesignField>(fieldsMap.values()), nodeName));
    f.setValueClass(String.class);
    if (item.getNodeType() == Node.ATTRIBUTE_NODE) {
        description = prefix + "@" + item.getNodeName();
        f.setDescription(description); //$NON-NLS-1$
    } else {
        description = prefix + item.getNodeName();
        f.setDescription(description);
    }
    // Let's consider the description indicating the XPath query
    // as unique and therefore as map key.
    fieldsMap.put(description, f);
}

From source file:com.perceptive.epm.perkolcentral.bl.EmployeeBL.java

@Cacheable(cacheName = "EmployeeCache", keyGenerator = @KeyGenerator(name = "HashCodeCacheKeyGenerator", properties = @Property(name = "includeMethod", value = "false")))
@Transactional(propagation = Propagation.REQUIRED, readOnly = true, isolation = Isolation.SERIALIZABLE, rollbackFor = ExceptionWrapper.class)
public LinkedHashMap<Long, EmployeeBO> getAllEmployees() throws ExceptionWrapper {
    try {//from w  w  w  .ja  v a  2  s.c om
        LinkedHashMap<Long, EmployeeBO> employeeBOLinkedHashMap = employeeDataAccessor.getAllEmployees();
        luceneUtil.indexUserInfo(employeeBOLinkedHashMap.values());
        return employeeBOLinkedHashMap;
    } catch (Exception ex) {
        throw new ExceptionWrapper(ex);
    }
}

From source file:com.money.manager.ex.currency.recycler.CurrencyRecyclerListFragment.java

@Subscribe
public void onEvent(CurrencyDeletionConfirmedEvent event) {
    CurrencyRepository repo = new CurrencyRepository(getContext());
    boolean success = repo.delete(event.currencyId);
    if (success) {
        Toast.makeText(getContext(), R.string.delete_success, Toast.LENGTH_SHORT).show();

        // remove from data.
        LinkedHashMap<String, Section> sectionMap = getAdapter().getSectionsMap();
        for (Section section : sectionMap.values()) {
            CurrencySection currencySection = (CurrencySection) section;
            currencySection.currencies.remove(event.itemPosition);
        }/*from   www.  j ava 2 s. c  om*/

        // update ui.
        getAdapter().notifyItemRemoved(event.itemPosition);
    }
}

From source file:com.intellij.plugins.haxe.haxelib.HaxeLibrary.java

/**
 * Get all dependent libraries in search order.
 *///from  w w  w . j a va2 s  .c  o m
@NotNull
public HaxeLibraryList collectDependents() {
    LinkedHashMap<String, HaxeLibraryDependency> collection = new LinkedHashMap<String, HaxeLibraryDependency>();
    collectDependentsInternal(collection);
    HaxeLibraryList list = new HaxeLibraryList(myCache.getSdk());
    for (HaxeLibraryDependency dep : collection.values()) {
        list.add(dep);
    }
    return list;
}