Example usage for java.util LinkedHashMap get

List of usage examples for java.util LinkedHashMap get

Introduction

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

Prototype

public 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:jobs.PodbaseMetadataMigration.java

public Entry parseEntry(LinkedHashMap<String, Object> map) {
    LinkedHashMap<String, Object> entry = (LinkedHashMap<String, Object>) map.get("entry");
    String path = (String) entry.get("path");

    Entry en = new Entry(path);

    ArrayList<ArrayList<String>> tags = (ArrayList<ArrayList<String>>) entry.get("tags");

    for (ArrayList<String> tag : tags) {
        String key = tag.get(0);/*  w ww  . j a  v  a 2  s.  com*/
        String value = tag.get(1);

        en.data.put(key, value);
    }

    return en;
}

From source file:com.espertech.esper.epl.join.plan.NStreamOuterQueryPlanBuilder.java

private static List<LookupInstructionPlan> buildLookupInstructions(int rootStreamNum,
        LinkedHashMap<Integer, int[]> substreamsPerStream, boolean[] requiredPerStream, String[] streamNames,
        QueryGraph queryGraph, QueryPlanIndex[] indexSpecs, EventType[] typesPerStream,
        OuterJoinDesc[] outerJoinDescList, boolean[] isHistorical,
        HistoricalStreamIndexList[] historicalStreamIndexLists, ExprEvaluatorContext exprEvaluatorContext) {
    List<LookupInstructionPlan> result = new LinkedList<LookupInstructionPlan>();

    for (int fromStream : substreamsPerStream.keySet()) {
        int[] substreams = substreamsPerStream.get(fromStream);

        // for streams with no substreams we don't need to look up
        if (substreams.length == 0) {
            continue;
        }/*from w ww  . j av  a  2  s. c o  m*/

        TableLookupPlan plans[] = new TableLookupPlan[substreams.length];
        HistoricalDataPlanNode historicalPlans[] = new HistoricalDataPlanNode[substreams.length];

        for (int i = 0; i < substreams.length; i++) {
            int toStream = substreams[i];

            if (isHistorical[toStream]) {
                // There may not be an outer-join descriptor, use if provided to build the associated expression
                ExprNode outerJoinExpr = null;
                if (outerJoinDescList.length > 0) {
                    OuterJoinDesc outerJoinDesc;
                    if (toStream == 0) {
                        outerJoinDesc = outerJoinDescList[0];
                    } else {
                        outerJoinDesc = outerJoinDescList[toStream - 1];
                    }
                    outerJoinExpr = outerJoinDesc.makeExprNode(exprEvaluatorContext);
                }

                if (historicalStreamIndexLists[toStream] == null) {
                    historicalStreamIndexLists[toStream] = new HistoricalStreamIndexList(toStream,
                            typesPerStream, queryGraph);
                }
                historicalStreamIndexLists[toStream].addIndex(fromStream);
                historicalPlans[i] = new HistoricalDataPlanNode(toStream, rootStreamNum, fromStream,
                        typesPerStream.length, outerJoinExpr);
            } else {
                plans[i] = NStreamQueryPlanBuilder.createLookupPlan(queryGraph, fromStream, toStream,
                        indexSpecs[toStream], typesPerStream);
            }
        }

        String fromStreamName = streamNames[fromStream];
        LookupInstructionPlan instruction = new LookupInstructionPlan(fromStream, fromStreamName, substreams,
                plans, historicalPlans, requiredPerStream);
        result.add(instruction);
    }

    return result;
}

From source file:com.cburch.logisim.gui.main.SelectionAttributes.java

private static LinkedHashMap<Attribute<Object>, Object> computeAttributes(Collection<Component> newSel) {
    LinkedHashMap<Attribute<Object>, Object> attrMap;
    attrMap = new LinkedHashMap<Attribute<Object>, Object>();
    Iterator<Component> sit = newSel.iterator();
    if (sit.hasNext()) {
        AttributeSet first = sit.next().getAttributeSet();
        for (Attribute<?> attr : first.getAttributes()) {
            @SuppressWarnings("unchecked")
            Attribute<Object> attrObj = (Attribute<Object>) attr;
            attrMap.put(attrObj, first.getValue(attr));
        }/*  w ww .  j  a  va  2s  .c  om*/
        while (sit.hasNext()) {
            AttributeSet next = sit.next().getAttributeSet();
            Iterator<Attribute<Object>> ait = attrMap.keySet().iterator();
            while (ait.hasNext()) {
                Attribute<Object> attr = ait.next();
                if (next.containsAttribute(attr)) {
                    Object v = attrMap.get(attr);
                    if (v != null && !v.equals(next.getValue(attr))) {
                        attrMap.put(attr, null);
                    }
                } else {
                    ait.remove();
                }
            }
        }
    }
    return attrMap;
}

From source file:com.devicehive.service.security.jwt.JwtClientService.java

public JwtPayload getPayload(String jwtToken) {
    Claims claims = Jwts.parser().setSigningKey(secret).parseClaimsJws(jwtToken).getBody();
    LinkedHashMap payloadMap = (LinkedHashMap) claims.get(JwtPayload.JWT_CLAIM_KEY);

    Optional userId = Optional.ofNullable(payloadMap.get(JwtPayload.USER_ID));
    Optional networkIds = Optional.ofNullable((ArrayList) payloadMap.get(JwtPayload.NETWORK_IDS));
    Optional actions = Optional.ofNullable((ArrayList) payloadMap.get(JwtPayload.ACTIONS));
    Optional deviceGuids = Optional.ofNullable((ArrayList) payloadMap.get(JwtPayload.DEVICE_GUIDS));
    Optional expiration = Optional.ofNullable(payloadMap.get(JwtPayload.EXPIRATION));
    Optional tokenType = Optional.ofNullable(payloadMap.get(JwtPayload.TOKEN_TYPE));

    JwtPayload.Builder builder = new JwtPayload.Builder();
    if (userId.isPresent())
        builder.withUserId(Long.valueOf(userId.get().toString()));
    if (networkIds.isPresent())
        builder.withNetworkIds(new HashSet<>((ArrayList) networkIds.get()));
    if (actions.isPresent())
        builder.withActions(new HashSet<>((ArrayList) actions.get()));
    if (deviceGuids.isPresent())
        builder.withDeviceGuids(new HashSet<>((ArrayList) deviceGuids.get()));
    if (!tokenType.isPresent() && !expiration.isPresent()) {
        throw new MalformedJwtException("Token type and expiration date should be provided in the token");
    } else {//from w  w w.j  a  v  a2  s  . c  om
        if (tokenType.isPresent())
            builder.withTokenType(TokenType.valueOf((String) tokenType.get()));
        else
            throw new MalformedJwtException("Token type should be provided in the token");
        if (expiration.isPresent())
            builder.withExpirationDate(new Date((Long) expiration.get()));
        else
            throw new MalformedJwtException("Expiration date should be provided in the token");
        return builder.buildPayload();
    }
}

From source file:com.google.api.codegen.config.GapicProductConfig.java

private static void createSingleResourceNameConfig(DiagCollector diagCollector, Resource resource,
        ProtoFile file, String pathTemplate, ProtoParser protoParser,
        LinkedHashMap<String, SingleResourceNameConfig> singleResourceNameConfigsMap) {
    SingleResourceNameConfig singleResourceNameConfig = SingleResourceNameConfig
            .createSingleResourceName(resource, pathTemplate, file, diagCollector);
    if (singleResourceNameConfigsMap.containsKey(singleResourceNameConfig.getEntityId())) {
        SingleResourceNameConfig otherConfig = singleResourceNameConfigsMap
                .get(singleResourceNameConfig.getEntityId());
        if (!singleResourceNameConfig.getNamePattern().equals(otherConfig.getNamePattern())) {
            diagCollector.addDiag(Diag.error(SimpleLocation.TOPLEVEL,
                    "Inconsistent collection configs across interfaces. Entity name: "
                            + singleResourceNameConfig.getEntityId()));
        }/*from  w w w.j av  a  2s .  co  m*/
    } else {
        String fullyQualifiedName = singleResourceNameConfig.getEntityId();
        fullyQualifiedName = StringUtils.prependIfMissing(fullyQualifiedName,
                protoParser.getProtoPackage(file) + ".");
        singleResourceNameConfigsMap.put(fullyQualifiedName, singleResourceNameConfig);
    }
}

From source file:com.miserablemind.api.consumer.tradeking.api.impl.response_entities.TKWatchlistItemsResponse.java

@JsonSetter("watchlists")
@SuppressWarnings("unchecked")
public void setWatchLists(LinkedHashMap<String, LinkedHashMap> watchListsResponse) {

    //manually deserialize as we need to un-nest some unnecessary stuff
    if (null == watchListsResponse.get("watchlist"))
        return;//from  w ww  .ja v  a2  s.  c  o  m

    ArrayList<LinkedHashMap> items = new ArrayList<>();

    Object itemsContainer = watchListsResponse.get("watchlist").get("watchlistitem");

    //api does not wrap a single result
    if (itemsContainer.getClass() == ArrayList.class) {
        //we know it's ArrayList because of condition
        items = (ArrayList) itemsContainer;
    } else {
        items.add((LinkedHashMap) watchListsResponse.get("watchlist").get("watchlistitem"));
    }

    ArrayList<WatchlistItem> resultList = new ArrayList<>();

    for (Object item : items) {

        LinkedHashMap itemEntries = (LinkedHashMap) item;
        double costBasis = Double.parseDouble((String) itemEntries.get("costbasis"));
        double quantity = Double.parseDouble((String) itemEntries.get("qty"));
        LinkedHashMap instrument = (LinkedHashMap) itemEntries.get("instrument");
        String ticker = (String) instrument.get("sym");

        WatchlistItem itemObject = new WatchlistItem(costBasis, quantity, ticker);
        resultList.add(itemObject);

    }

    this.watchListsItems = new WatchlistItem[resultList.size()];
    this.watchListsItems = resultList.toArray(this.watchListsItems);

}

From source file:io.curly.commons.github.GitHubAuthenticationMethodHandler.java

@SuppressWarnings("unchecked")
private User from(OAuth2Authentication auth) {
    Authentication userAuthentication = auth.getUserAuthentication();
    if (userAuthentication != null) {
        try {/*from   w w w  .  j  av  a  2s  .c om*/
            LinkedHashMap<String, Object> map = (LinkedHashMap<String, Object>) userAuthentication.getDetails();
            return User.builder().id(String.valueOf(map.get("id")))
                    .avatarUrl(String.valueOf(map.get("avatar_url"))).email(String.valueOf(map.get("email")))
                    .name(String.valueOf(map.get("name"))).type(String.valueOf(map.get("type")))
                    .username(String.valueOf(map.get("login"))).build();

        } catch (ClassCastException e) {
            log.error("Cannot build User due to a ClassCastException {}", e);
        }
    }
    log.debug("Returning no user due to previous errors or no UserAuthentication detected");
    return null;
}

From source file:curly.commons.github.GitHubAuthenticationMethodHandler.java

@SuppressWarnings("unchecked")
private OctoUser from(OAuth2Authentication auth) {
    Authentication userAuthentication = auth.getUserAuthentication();
    if (userAuthentication != null) {
        try {/*from  ww w  . j  a  v a2 s  .  co  m*/
            LinkedHashMap<String, Object> map = (LinkedHashMap<String, Object>) userAuthentication.getDetails();
            return new OctoUser(String.valueOf(map.get("email")),
                    Boolean.valueOf(String.valueOf(map.get("hireable"))),
                    Long.valueOf(String.valueOf(map.get("id"))),
                    Integer.valueOf(String.valueOf(map.get("followers"))),
                    Integer.valueOf(String.valueOf(map.get("following"))),
                    Integer.valueOf(String.valueOf(map.get("public_repos"))),
                    String.valueOf(map.get("avatar_url")), String.valueOf(map.get("blog")),
                    String.valueOf(map.get("company")), null, String.valueOf(map.get("html_url")), null,
                    String.valueOf(map.get("login")), String.valueOf(map.get("name")),
                    String.valueOf(map.get("type")), String.valueOf(map.get("url")));

        } catch (ClassCastException e) {
            log.error("Cannot build OctoUser due to a ClassCastException {}", e);
        }
    }
    log.debug("Returning no user due to previous errors or no UserAuthentication detected");
    return null;
}

From source file:runtheshow.resource.webservice.InvitationService.java

/**
 * //from  w  w w  .  j av  a  2  s. c o m
 * @param o
 * @param response
 * @param user
 * @return
 * @throws JSONException 
 */
@RequestMapping(value = "/add", method = RequestMethod.POST, consumes = "application/json; charset=UTF-8", produces = "application/json; charset=UTF-8")
public JSONObject addInvitation(@RequestBody Object o, HttpServletResponse response, Principal user)
        throws JSONException {
    LinkedHashMap lhm = (LinkedHashMap) o;
    Set<Long> set = new HashSet<>((Collection<Long>) lhm.get("id_art"));
    String msgPerso = null;
    long idSousEvent = (long) (int) lhm.get("idSousEvent");
    if (lhm.get("message_perso") != null)
        msgPerso = (String) lhm.get("message_perso");
    Set<Long> setLong = new HashSet<>();

    Iterator i = set.iterator(); // on cre un Iterator pour parcourir notre HashSet
    while (i.hasNext()) {
        setLong.add(Long.parseLong(i.next().toString()));
    }
    List<User> lstArtiste = userMetier.getUsersArtisteByListId(setLong);
    System.out.println(idSousEvent);
    SousEvenement ssEvent = sousEventMetier.findSousEventById(idSousEvent);
    User exp = userMetier.getUserByName(user.getName());

    for (User u : lstArtiste) {
        Invitation newInvit = new Invitation();
        if (msgPerso != null)
            newInvit.setCommentaire(msgPerso);
        newInvit.setDestinataire(u);
        newInvit.setExpediteur(exp);
        newInvit.setSousEvenement(ssEvent);
        newInvit.setStatut(STATUT_CREEE);
        invitationMetier.addInvitation(newInvit);
    }

    return null;
}

From source file:ai.susi.json.JsonTray.java

public JSONObject toJSON() {
    JSONObject j = new JSONObject();
    for (String key : this.per.keySet()) {
        j.put(key, this.per.get(key));
    }//from   w  w w.  ja v  a  2  s .  com
    synchronized (this.vol) {
        LinkedHashMap<String, JSONObject> map = this.vol.getMap();
        for (String key : map.keySet()) {
            j.put(key, map.get(key));
        }
    }
    return j;
}