Example usage for java.util HashMap values

List of usage examples for java.util HashMap values

Introduction

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

Prototype

public Collection<V> values() 

Source Link

Document

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

Usage

From source file:com.juick.android.JuickMessagesAdapter.java

public void recycleView(View view) {
    if (view instanceof ViewGroup) {
        ListRowRuntime lrr = (ListRowRuntime) view.getTag();
        if (lrr != null) {
            if (lrr.userpicListener != null) {
                lrr.removeListenerIfExists();
            }/*  w w w  .  jav  a  2 s .  c o m*/
        }
        ViewGroup vg = (ViewGroup) view;
        if (vg.getChildCount() > 1 && vg.getChildAt(1) instanceof ImageGallery
                && vg instanceof PressableLinearLayout) {
            PressableLinearLayout pll = (PressableLinearLayout) vg;
            // our view
            ImageGallery gallery = (ImageGallery) vg.getChildAt(1);
            Object tag = gallery.getTag();
            if (tag instanceof HashMap) {
                HashMap<Integer, ImageLoaderConfiguration> loaders = (HashMap<Integer, ImageLoaderConfiguration>) tag;
                for (ImageLoaderConfiguration imageLoader : loaders.values()) {
                    imageLoader.loader.terminate();
                }
            }
            pll.blockLayoutRequests = true;
            gallery.cleanup();
            gallery.setTag(null);
            vg.removeViewAt(1);
            vg.measure(View.MeasureSpec.makeMeasureSpec(vg.getRight() - vg.getLeft(), View.MeasureSpec.EXACTLY),
                    View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
            vg.layout(vg.getLeft(), vg.getTop(), vg.getRight(), vg.getTop() + vg.getMeasuredHeight());
            pll.blockLayoutRequests = false;
        }
    }
}

From source file:com.android.calendar.event.EditEventView.java

private void updateAttendees(HashMap<String, Attendee> attendeesList) {
    if (attendeesList == null || attendeesList.isEmpty()) {
        return;//from  w  w w  .jav  a  2  s .  co m
    }
    mAttendeesList.setText(null);
    for (Attendee attendee : attendeesList.values()) {

        // TODO: Please remove separator when Calendar uses the chips MR2
        // project

        // Adding a comma separator between email addresses to prevent a
        // chips MR1.1 bug
        // in which email addresses are concatenated together with no
        // separator.
        mAttendeesList.append(attendee.mEmail + ", ");
    }
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.teacher.onlineTests.ReadDistributedTestMarks.java

protected InfoSiteStudentsTestMarks run(String executionCourseId, String distributedTestId)
        throws FenixServiceException {

    InfoSiteStudentsTestMarks infoSiteStudentsTestMarks = new InfoSiteStudentsTestMarks();

    DistributedTest distributedTest = FenixFramework.getDomainObject(distributedTestId);
    if (distributedTest == null) {
        throw new InvalidArgumentsServiceException();
    }//from w  w w.  j a  v a2 s  .c  o m

    List<StudentTestQuestion> studentTestQuestionList = distributedTest
            .getStudentTestQuestionsSortedByStudentNumberAndTestQuestionOrder();

    HashMap<String, InfoStudentTestQuestionMark> infoStudentTestQuestionMarkList = new HashMap<String, InfoStudentTestQuestionMark>();
    for (StudentTestQuestion studentTestQuestion : studentTestQuestionList) {
        if (infoStudentTestQuestionMarkList.containsKey(studentTestQuestion.getStudent().getExternalId())) {
            InfoStudentTestQuestionMark infoStudentTestQuestionMark = infoStudentTestQuestionMarkList
                    .get(studentTestQuestion.getStudent().getExternalId());
            ParseSubQuestion parse = new ParseSubQuestion();
            Question question = studentTestQuestion.getQuestion();
            try {
                question = parse.parseSubQuestion(studentTestQuestion.getQuestion());
            } catch (Exception e) {
                throw new FenixServiceException(e);
            }
            if (studentTestQuestion.getItemId() != null && !studentTestQuestion.getItemId()
                    .equals(question.getSubQuestions().iterator().next().getItemId())) {
                infoStudentTestQuestionMark.addTestQuestionMark(
                        infoStudentTestQuestionMark.getTestQuestionMarks().size() - 1,
                        studentTestQuestion.getTestQuestionMark());
            } else {
                infoStudentTestQuestionMark.addTestQuestionMark(studentTestQuestion.getTestQuestionMark());
            }
            infoStudentTestQuestionMark.addToMaximumMark(studentTestQuestion.getTestQuestionValue());
        } else {
            infoStudentTestQuestionMarkList.put(studentTestQuestion.getStudent().getExternalId(),
                    InfoStudentTestQuestionMark.newInfoFromDomain(studentTestQuestion));
        }
    }

    List<InfoStudentTestQuestionMark> infoStudentTestQuestionList = new ArrayList<InfoStudentTestQuestionMark>(
            infoStudentTestQuestionMarkList.values());
    Collections.sort(infoStudentTestQuestionList, new BeanComparator("studentNumber"));
    infoSiteStudentsTestMarks.setInfoStudentTestQuestionList(infoStudentTestQuestionList);
    infoSiteStudentsTestMarks.setExecutionCourse(
            InfoExecutionCourse.newInfoFromDomain(distributedTest.getTestScope().getExecutionCourse()));
    infoSiteStudentsTestMarks.setInfoDistributedTest(InfoDistributedTest.newInfoFromDomain(distributedTest));

    return infoSiteStudentsTestMarks;
}

From source file:com.pari.reports.request.handlers.ManageExportHandlerImpl.java

@SuppressWarnings("unchecked")
private ServiceContainer getSetUpWorkflowApprovalDetails(ColumnDefinition[] colDef,
        TableDefinition childTableDef, HashMap<String, Object> paramFilters) {
    ServiceImpl service = null;/*from  w ww.  j av a2 s  . co  m*/
    ServiceContainerImpl serviceContainer = null;
    String customerName = getRequestDetails().getCustomer();
    int customerId = -1;
    if (customerName != null && customerName.trim().length() > 0) {
        try {
            customerId = getRequestDetails().getServerIf().getCustomerIf().getCustomerIdByName(customerName);
        } catch (Exception e) {
            logger.error("Exception while Exporting Setup Workflow", e);
        }
    }
    Map<Integer, ApprovalDefinition> approvalDefMap = null;
    try {
        if (paramFilters != null && paramFilters.size() > 0) {
            approvalDefMap = new HashMap<Integer, ApprovalDefinition>();
            ArrayList<String> grpNames = new ArrayList<String>();
            Object grpIdObj = paramFilters.get("DeviceGroup");
            if (grpIdObj instanceof String) {
                grpNames.add((String) grpIdObj);
            } else if (grpIdObj instanceof ArrayList) {
                grpNames = (ArrayList<String>) grpIdObj;
            }
            for (String grpName : grpNames) {
                int grpId = GroupingService.getInstance().getGroupIdFromName(grpName);
                ApprovalDefinition approvalDef = getRequestDetails().getServerIf().getApprovalIf()
                        .getWorkflowApprovalDefsWithLevels(grpId, customerId);
                approvalDefMap.put(grpId, approvalDef);
            }
        } else {
            approvalDefMap = getRequestDetails().getServerIf().getApprovalIf()
                    .getAllWorkflowApprovalDefsWithLevels(customerId);
        }
    } catch (PariException e) {
        e.printStackTrace();
    }
    if (null == approvalDefMap) {
        return null;
    }
    SimpleDateFormat formatter = new SimpleDateFormat("EEE, MMM dd, yyyy HH:mm:ss Z");
    serviceContainer = new ServiceContainerImpl();

    for (Map.Entry<Integer, ApprovalDefinition> map : approvalDefMap.entrySet()) {
        service = new ServiceImpl();
        ApprovalDefinition approvalDefinition = map.getValue();
        String creationTime = (0 == approvalDefinition.getCreationTime()) ? ""
                : getTimeBasedOnZone(approvalDefinition.getCreationTime());
        String modifierTime = (0 == approvalDefinition.getModifierTime()) ? ""
                : formatter.format(new Date(approvalDefinition.getModifierTime()));

        service.put(colDef[0].getId(), approvalDefinition.getGroupName());
        service.put(colDef[1].getId(), approvalDefinition.getWorkFlowName());
        service.put(colDef[2].getId(), approvalDefinition.getCreatorLogin());
        service.put(colDef[3].getId(), creationTime);
        service.put(colDef[4].getId(), approvalDefinition.getModifierLogin());
        service.put(colDef[5].getId(), modifierTime);

        if (childTableDef != null) {
            ColumnDefinition[] chidlColDef = childTableDef.getColumnDefs();
            Map<Integer, ApprovalLevelDefination> approvalLevels = approvalDefinition.getApprovalLevels();

            if (approvalLevels != null && approvalLevels.size() > 0) {

                ServiceContainerImpl approvalLevelSrvCont = new ServiceContainerImpl();
                for (Integer level : approvalLevels.keySet()) {
                    ApprovalLevelDefination approvalLevel = approvalLevels.get(level);
                    Map<Integer, String> approverLogins = approvalLevel.getApproverLogins();
                    if (approverLogins != null && approverLogins.size() > 0) {
                        for (Integer id : approverLogins.keySet()) {
                            ServiceImpl srvImpl = new ServiceImpl();
                            srvImpl.put(chidlColDef[0].getId(), approvalDefinition.getGroupName());
                            srvImpl.put(chidlColDef[1].getId(), level);
                            srvImpl.put(chidlColDef[2].getId(), approverLogins.get(id));
                            srvImpl.put(chidlColDef[3].getId(),
                                    approvalLevel.getApprovalComplType().getActionString());
                            approvalLevelSrvCont.addManageServices(srvImpl);
                        }
                    }

                    HashMap<Integer, ApprovalGroupDefinition> approvalUsrGrps = approvalLevel
                            .getApprovalUserGrps();
                    if (approvalUsrGrps != null && approvalUsrGrps.size() > 0) {
                        for (ApprovalGroupDefinition approvalUsrGrp : approvalUsrGrps.values()) {
                            approverLogins = approvalUsrGrp.getApproverLogins();
                            if (approverLogins != null && approverLogins.size() > 0) {
                                for (Integer id : approverLogins.keySet()) {
                                    ServiceImpl srvImpl = new ServiceImpl();
                                    srvImpl.put(chidlColDef[0].getId(), approvalDefinition.getGroupName());
                                    srvImpl.put(chidlColDef[1].getId(), level);
                                    srvImpl.put(chidlColDef[2].getId(), approverLogins.get(id));
                                    srvImpl.put(chidlColDef[3].getId(),
                                            approvalLevel.getApprovalComplType().getActionString());
                                    approvalLevelSrvCont.addManageServices(srvImpl);
                                }
                            }
                        }
                    }
                }
                service.put("ApprovalLevelDefs", approvalLevelSrvCont);
            }
        }

        serviceContainer.addManageServices(service);
    }
    return serviceContainer;
}

From source file:org.apache.hadoop.hbase.master.GroupAssignmentManager.java

/**
 * assign regions according to the group information,
 * /*from ww  w. j  av  a  2 s.co  m*/
 * @param regions
 *          regions to assigne
 * @param servers
 *          available servers
 * @return the assignment
 */
private List<Pair<List<HRegionInfo>, List<HServerInfo>>> groupAssignRegions(List<HRegionInfo> regions,
        List<HServerInfo> servers) {
    List<Pair<List<HRegionInfo>, List<HServerInfo>>> ret = new ArrayList<Pair<List<HRegionInfo>, List<HServerInfo>>>();
    HashMap<String, List<HRegionInfo>> groupToRegion = new HashMap<String, List<HRegionInfo>>();
    servers = filterRootServer(servers);
    for (HRegionInfo info : regions) {
        String groups = getGroupString(info.getTableDesc());
        if (!groupExist(groups)) {
            groups = DEFAULT_GROUP;
        }
        if (groupToRegion.get(groups) == null) {
            groupToRegion.put(groups, new ArrayList<HRegionInfo>());
        }
        groupToRegion.get(groups).add(info);
    }

    for (List<HRegionInfo> list : groupToRegion.values()) {
        Pair<List<HRegionInfo>, List<HServerInfo>> p = new Pair<List<HRegionInfo>, List<HServerInfo>>();
        p.setFirst(list);
        p.setSecond(new ArrayList<HServerInfo>());
        for (HServerInfo server : servers) {
            if (this.regionAndServerIsSameGroup(list.get(0), server)) {
                p.getSecond().add(server);
            }
        }
        ret.add(p);
    }
    return ret;
}

From source file:com.h3xstream.findsecbugs.crypto.InsecureSmtpSslDetector.java

private void analyzeMethod(Method m, ClassContext classContext)
        throws CFGBuilderException, DataflowAnalysisException {

    HashMap<Location, String> sslConnMap = new HashMap<Location, String>();
    HashSet<String> sslCertVerSet = new HashSet<String>();
    Location locationWeakness = null;
    String hostName = null;/*from w ww .jav  a2s .co m*/

    ConstantPoolGen cpg = classContext.getConstantPoolGen();
    CFG cfg = classContext.getCFG(m);

    for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
        Location location = i.next();

        Instruction inst = location.getHandle().getInstruction();

        if (inst instanceof INVOKEVIRTUAL) {
            INVOKEVIRTUAL invoke = (INVOKEVIRTUAL) inst;
            if (INSECURE_APIS.contains(invoke.getClassName(cpg))
                    && "setHostName".equals(invoke.getMethodName(cpg))) {
                hostName = ByteCode.getConstantLDC(location.getHandle().getPrev(), cpg, String.class);
            }
            if (INSECURE_APIS.contains(invoke.getClassName(cpg))
                    && "setSSLOnConnect".equals(invoke.getMethodName(cpg))) {
                Integer sslOn = ByteCode.getConstantInt(location.getHandle().getPrev());
                if (sslOn != null && sslOn == 1) {
                    sslConnMap.put(location, invoke.getClassName(cpg) + hostName);
                }
            }
            if (INSECURE_APIS.contains(invoke.getClassName(cpg))
                    && "setSSLCheckServerIdentity".equals(invoke.getMethodName(cpg))) {
                Integer checkOn = ByteCode.getConstantInt(location.getHandle().getPrev());
                if (checkOn != null && checkOn == 1) {
                    sslCertVerSet.add(invoke.getClassName(cpg) + hostName);
                }
            }
        }
    }

    //Both conditions - setSSLOnConnect and setSSLCheckServerIdentity
    //haven't been found in the same instance (verifing instance by class name + host name)
    sslConnMap.values().removeAll(sslCertVerSet);

    if (!sslConnMap.isEmpty()) {
        for (Location key : sslConnMap.keySet()) {
            JavaClass clz = classContext.getJavaClass();
            bugReporter.reportBug(new BugInstance(this, INSECURE_SMTP_SSL, Priorities.HIGH_PRIORITY)
                    .addClass(clz).addMethod(clz, m).addSourceLine(classContext, m, key));
        }
    }
}

From source file:org.gephi.statistics.plugin.Renumbering.java

public void triangles(HierarchicalGraph hgraph) {

    int ProgressCount = 0;
    Progress.start(progress, 7 * hgraph.getNodeCount());

    hgraph.readLock();//from   w  w  w  .  ja v  a  2 s  .c o m

    N = hgraph.getNodeCount();
    nodeClustering = new double[N];

    /** Create network for processing */
    network = new ArrayWrapper[N];

    /**  */
    HashMap<Node, Integer> indicies = new HashMap<Node, Integer>();
    int index = 0;
    for (Node s : hgraph.getNodes()) {
        indicies.put(s, index);
        network[index] = new ArrayWrapper();
        index++;
        Progress.progress(progress, ++ProgressCount);
    }

    index = 0;
    for (Node node : hgraph.getNodes()) {
        HashMap<Node, EdgeWrapper> neighborTable = new HashMap<Node, EdgeWrapper>();

        if (!isDirected) {
            for (Edge edge : hgraph.getEdgesAndMetaEdges(node)) {
                Node neighbor = hgraph.getOpposite(node, edge);
                neighborTable.put(neighbor, new EdgeWrapper(1, network[indicies.get(neighbor)]));
            }
        } else {
            for (Edge in : ((HierarchicalDirectedGraph) hgraph).getInEdgesAndMetaInEdges(node)) {
                Node neighbor = in.getSource().getNodeData().getNode(hgraph.getView().getViewId());
                neighborTable.put(neighbor, new EdgeWrapper(1, network[indicies.get(neighbor)]));
            }

            for (Edge out : ((HierarchicalDirectedGraph) hgraph).getOutEdgesAndMetaOutEdges(node)) {
                Node neighbor = out.getTarget().getNodeData().getNode(hgraph.getView().getViewId());
                EdgeWrapper ew = neighborTable.get(neighbor);
                if (ew == null) {
                    neighborTable.put(neighbor, new EdgeWrapper(1, network[indicies.get(neighbor)]));
                } else {
                    ew.count++;
                }
            }
        }

        EdgeWrapper[] edges = new EdgeWrapper[neighborTable.size()];
        int i = 0;
        for (EdgeWrapper e : neighborTable.values()) {
            edges[i] = e;
            i++;
        }
        network[index].node = node;
        network[index].setArray(edges);
        index++;
        Progress.progress(progress, ++ProgressCount);

        if (isCanceled) {
            hgraph.readUnlockAll();
            return;
        }
    }

    Arrays.sort(network);
    for (int j = 0; j < N; j++) {
        network[j].setID(j);
        Progress.progress(progress, ++ProgressCount);
    }

    for (int j = 0; j < N; j++) {
        Arrays.sort(network[j].getArray(), new Renumbering());
        Progress.progress(progress, ++ProgressCount);
    }

    triangles = new int[N];
    K = (int) Math.sqrt(N);

    for (int v = 0; v < K && v < N; v++) {
        newVertex(v);
        Progress.progress(progress, ++ProgressCount);
    }

    /* remaining links */
    for (int v = N - 1; (v >= 0) && (v >= K); v--) {
        for (int i = closest_in_array(v); i >= 0; i--) {
            int u = network[v].get(i);
            if (u >= K) {
                tr_link_nohigh(u, v, network[v].getCount(i));
            }
        }
        Progress.progress(progress, ++ProgressCount);

        if (isCanceled) {
            hgraph.readUnlockAll();
            return;
        }
    }

    //Results and average
    avgClusteringCoeff = 0;
    totalTriangles = 0;
    int numNodesDegreeGreaterThanOne = 0;
    for (int v = 0; v < N; v++) {
        if (network[v].length() > 1) {
            numNodesDegreeGreaterThanOne++;
            double cc = triangles[v];
            totalTriangles += triangles[v];
            cc /= (network[v].length() * (network[v].length() - 1));
            if (!isDirected) {
                cc *= 2.0f;
            }
            nodeClustering[v] = cc;
            avgClusteringCoeff += cc;
        }
        Progress.progress(progress, ++ProgressCount);

        if (isCanceled) {
            hgraph.readUnlockAll();
            return;
        }
    }
    totalTriangles /= 3;
    avgClusteringCoeff /= numNodesDegreeGreaterThanOne;

    hgraph.readUnlock();
}

From source file:com.sworddance.util.CUtilities.java

/**
 * @param searchRoot// w w  w. java2 s .  com
 * @param fileName
 * @param optional
 * @param searchPaths
 * @return a de-duped Enumeration<URL> never returns null.
 */
private static Collection<URL> getResources(Object searchRoot, String fileName, boolean optional,
        List<String> searchPaths) {
    ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
    ClassLoader searchRootClassLoader = searchRoot != null ? searchRoot.getClass().getClassLoader() : null;
    HashMap<String, URL> results = new HashMap<String, URL>();
    for (String searchPath : searchPaths) {
        Enumeration<URL> resource = null;
        if (searchRootClassLoader != null) {
            try {
                resource = searchRootClassLoader.getResources(searchPath);
                for (URL url : NotNullIterator.<URL>newNotNullIterator(resource)) {
                    results.put(url.toString(), url);
                }
            } catch (IOException e) {
                // TODO what?
            }
        }
        if (contextClassLoader != null) {
            try {
                resource = contextClassLoader.getResources(searchPath);
                for (URL url : NotNullIterator.<URL>newNotNullIterator(resource)) {
                    results.put(url.toString(), url);
                }
            } catch (IOException e) {
                // TODO what?
            }
        }
        if (resource == null) {
            try {
                resource = ClassLoader.getSystemResources(searchPath);
                for (URL url : NotNullIterator.<URL>newNotNullIterator(resource)) {
                    results.put(url.toString(), url);
                }
            } catch (IOException e) {
                // TODO what?
            }
        }
    }
    if (isEmpty(results) && !optional) {
        if (fileName != null) {
            throw new ApplicationNullPointerException(fileName, " not found in ", join(searchPaths, ","),
                    " java.class.path=", System.getProperty("java.class.path"), " java.library.path=",
                    System.getProperty("java.library.path"), " searchRoot =", getClassSafely(searchRoot));
        } else {
            throw new ApplicationNullPointerException("No listed file found ", join(searchPaths, ","),
                    " java.class.path=", System.getProperty("java.class.path"), " java.library.path=",
                    System.getProperty("java.library.path"), " searchRoot =", getClassSafely(searchRoot));
        }
    } else {
        return results.values();
    }
}

From source file:org.apache.stratos.cli.RestCommandLineService.java

/**
 * Initialize the rest client and set username and password of the user
 *
 * @param serverURL server URL//from  w w  w.  jav a  2 s.c o  m
 * @param username  username
 * @param password  password
 * @throws AxisFault
 */
private void initializeRestClient(String serverURL, String username, String password) throws AxisFault {
    HttpTransportProperties.Authenticator authenticator = new HttpTransportProperties.Authenticator();
    authenticator.setUsername(username);
    authenticator.setPassword(password);
    authenticator.setPreemptiveAuthentication(true);

    ConfigurationContext configurationContext;
    try {
        configurationContext = ConfigurationContextFactory.createDefaultConfigurationContext();
    } catch (Exception e) {
        String msg = "Backend error occurred. Please contact the service admins!";
        throw new AxisFault(msg, e);
    }
    HashMap<String, TransportOutDescription> transportsOut = configurationContext.getAxisConfiguration()
            .getTransportsOut();
    for (TransportOutDescription transportOutDescription : transportsOut.values()) {
        transportOutDescription.getSender().init(configurationContext, transportOutDescription);
    }

    this.restClient = new RestClient(serverURL, username, password);
}

From source file:org.archone.ad.domain.LdapActions.java

@RPCAction(name = "user.list", required = { "domain" })
@SecuredMethod(constraints = "administrator.by_domain")
public HashMap<String, Object> listUsers(OperationContext opContext) throws NamingException {

    String domain = (String) opContext.getParams().get("domain");

    List<String> groups = (List<String>) opContext.getParams().get("groups");
    List<String> retAttrs = (List<String>) opContext.getParams().get("attrs");

    DirContextAdapter userDirContext = (DirContextAdapter) SecurityUtils.getSubject().getPrincipal();
    CommonDao commonDao = new CommonDao(userDirContext, new NameConvertor());

    DomainDn domainDn = nameHelper.newDomainDnFromDomain(domain);

    HashMap<String, HashMap<String, Object>> users = new HashMap<String, HashMap<String, Object>>();

    List<ShoadUser> shoadUsers = null;

    if (groups == null || groups.isEmpty()) {
        shoadUsers = commonDao.listUsers(domain);
    } else {/*from www .  j a  v  a 2 s .  com*/
        HashMap<String, ShoadUser> usersMap = new HashMap<String, ShoadUser>();
        for (String groupId : groups) {
            ShoadGroup shoadGroup = commonDao.lookupGroup(groupId);

            shoadUsers = commonDao.listMembers(shoadGroup);
        }
    }

    //TODO: review
    if (shoadUsers != null) {
        for (ShoadUser shoadUser : shoadUsers) {
            if (!users.containsKey(shoadUser.getEntityId())) {
                HashMap<String, Object> user = new HashMap<String, Object>();
                user.put("userId", shoadUser.getEntityId());

                if (retAttrs != null) {
                    for (String attr : retAttrs) {
                        if (displayAttributeHelper.hasApiName(attr)) {
                            user.put(attr,
                                    shoadUser.getObjectAttribute(displayAttributeHelper.getLdapName(attr)));
                        }
                    }
                }
                users.put(shoadUser.getEntityId(), user);
            }
        }
    }

    HashMap<String, Object> response = new HashMap<String, Object>();

    response.put("users", users.values());

    return response;
}