Example usage for java.util Hashtable get

List of usage examples for java.util Hashtable get

Introduction

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

Prototype

@SuppressWarnings("unchecked")
public synchronized 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:com.flexive.faces.FxJsfUtils.java

/**
 * Gets all faces messages grouped by a equal summary and wrapped as
 * FxFacesMessage (which gives access to the clientId). In case of a grouped message
 * the details of the original FacesMessage can be retrieved by calling getDetails() of
 * the FxFacesMessage.//from   ww  w  . ja  va2s. c  om
 *
 * @return a array holding all (grouped) messages
 */
public static List<FxFacesMessages> getGroupedFxMessages() {
    ArrayList<FxFacesMessage> ffm = getFxMessages();
    Hashtable<String, FxFacesMessages> grouped = new Hashtable<String, FxFacesMessages>(ffm.size());
    for (FxFacesMessage msg : ffm) {
        String key = msg.getSeverity() + ":" + msg.getSummary();
        FxFacesMessages exists = grouped.get(key);
        if (exists != null) {
            exists.addMessage(msg);
        } else {
            grouped.put(key, new FxFacesMessages(msg.getSummary(), msg.getSeverity(), msg));
        }
    }
    return new ArrayList<FxFacesMessages>(grouped.values());
}

From source file:de.betterform.connector.xmlrpc.XMLRPCSubmissionHandler.java

/**
 * Serializes and submits the given instance data to an xmlrpc function protocol.
 *
 * @param submission the submission issuing the request.
 * @param instance   the instance data to be serialized and submitted.
 * @return <code>null</code>.
 * @throws XFormsException if any error occurred during submission.
 *///from  ww  w  .j  a v  a  2  s. c om
public Map submit(Submission submission, Node instance) throws XFormsException {

    if (!submission.getReplace().equals("none")) {
        throw new XFormsException("submission mode '" + submission.getReplace() + "' not supported");
    }

    try {
        SerializerRequestWrapper wrapper = new SerializerRequestWrapper(new ByteArrayOutputStream());
        serialize(submission, instance, wrapper);
        ByteArrayOutputStream stream = (ByteArrayOutputStream) wrapper.getBodyStream();

        URI uri = new URI(getURI());
        log.info("Getting URI: '" + uri + "'");

        Vector v = parseURI(uri);
        String rpcURL = (String) v.get(0);
        String function = (String) v.get(1);
        Hashtable params = (Hashtable) v.get(2);

        params.put("doc", stream.toByteArray());

        de.betterform.connector.xmlrpc.RPCClient rpc = new de.betterform.connector.xmlrpc.RPCClient(rpcURL);

        Hashtable result = rpc.runFunc(function, params);

        if (((String) result.get("status")).equals("error")) {
            throw new XFormsException((String) result.get("error"));
        }
    } catch (Exception e) {
        throw new XFormsException(e);
    }
    return null;
}

From source file:com.modeln.build.ctrl.charts.CMnBuildListChart.java

/**
 * Generate a stacked bar graph representing the total number of tests in
 * in each build. /*from   www. ja v a 2  s.  com*/
 *
 * @param   builds  List of builds 
 * 
 * @return  Stacked graph representing automated tests across all builds 
 */
public static final JFreeChart getTestCountChart(Vector<CMnDbBuildData> builds) {
    JFreeChart chart = null;

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    if ((builds != null) && (builds.size() > 0)) {

        // Collect build test numbers for each of the builds in the list 
        Collections.sort(builds, new CMnBuildIdComparator());
        Enumeration buildList = builds.elements();
        while (buildList.hasMoreElements()) {

            // Process the test summary for the current build
            CMnDbBuildData build = (CMnDbBuildData) buildList.nextElement();
            Hashtable testSummary = build.getTestSummary();
            if ((testSummary != null) && (testSummary.size() > 0)) {
                Enumeration keys = testSummary.keys();
                while (keys.hasMoreElements()) {
                    String testType = (String) keys.nextElement();
                    Integer buildId = new Integer(build.getId());
                    CMnDbTestSummaryData tests = (CMnDbTestSummaryData) testSummary.get(testType);
                    // Record the total number of tests
                    dataset.addValue(tests.getTotalCount(), testType, buildId);
                }
            }

        } // while list has elements

    } // if list has elements

    // API: ChartFactory.createStackedBarChart(title, domainAxisLabel, rangeAxisLabel, dataset, orientation, legend, tooltips, urls)
    chart = ChartFactory.createStackedBarChart("Automated Tests by Type", "Builds", "Test Count", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    // get a reference to the plot for further customization...
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    chartFormatter.formatTypeChart(plot, dataset);

    return chart;
}

From source file:edu.csun.ecs.cs.multitouchj.ui.graphic.WindowManagerCalibratorDefault.java

protected void onSourcePositionCaptured(Position position) {
    super.onSourcePositionCaptured(position);

    Hashtable<String, TexturedControl> targetControls = controls.get(position);
    targetControls.get(URI_IMAGE_WAITING).setVisible(false);
    targetControls.get(URI_IMAGE_OK).setVisible(true);

    log.info("Hmm: " + targetControls.get(URI_IMAGE_OK).getPosition().toString());
}

From source file:eionet.gdem.web.struts.hosts.ListHostsAction.java

@Override
public ActionForward execute(ActionMapping map, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse httpServletResponse) {
    ActionErrors errors = new ActionErrors();
    List result = new ArrayList();

    try {/*from   w  w  w.  ja v a  2 s  .  c  o  m*/
        if (checkPermission(request, Names.ACL_HOST_PATH, "v")) {
            Vector list = hostDao.getHosts(null);
            for (int i = 0; i < list.size(); i++) {
                Hashtable host = (Hashtable) list.get(i);
                HostDto h = new HostDto();
                h.setId((String) host.get("host_id"));
                h.setHostname((String) host.get("host_name"));
                h.setUsername((String) host.get("user_name"));
                result.add(h);
            }
        } else {
            errors.add(ActionMessages.GLOBAL_MESSAGE,
                    new ActionMessage("error.vnoperm", translate(map, request, "label.hosts")));
        }
    } catch (Exception e) {
        LOGGER.error("", e);
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("label.exception.unknown"));
    }

    if (errors.size() > 0) {
        request.getSession().setAttribute("dcm.errors", errors);
    }
    request.setAttribute("hosts.list", result);

    return map.findForward("success");

}

From source file:kidozen.client.crash.HttpSender.java

@Override
public void send(CrashReportData report) throws ReportSenderException {
    try {//from  w w  w. j a  v  a2s  .  c om
        final CountDownLatch cdl = new CountDownLatch(1);
        IdentityManager.getInstance().GetRawToken(mApplicationKey, new ServiceEventListener() {
            @Override
            public void onFinish(ServiceEvent e) {
                mEvent = e;
                cdl.countDown();
            }
        });
        cdl.await(DEFAULT_TIMEOUT, TimeUnit.MINUTES);
        if (mEvent.Exception != null || mEvent.StatusCode >= HttpStatus.SC_BAD_REQUEST)
            throw new ReportSenderException(mEvent.Body);
        mToken = ((KidoZenUser) mEvent.Response).Token;

        String authHeaderValue = String.format("WRAP access_token=\"%s\"", mToken);

        Log.d(LOG_TAG, String.format("About to send log to Log V3 service: %s ", mCrashEndpoint));
        JSONObject reportAsJson = report.toJSON();

        String bc = new JSONArray(mBreadCrumbs).toString();
        reportAsJson.put(APPLICATION_BREADCRUMB, bc);

        Hashtable<String, String> headers = new Hashtable<String, String>();
        headers.put(Constants.AUTHORIZATION_HEADER, authHeaderValue);
        headers.put(Constants.CONTENT_TYPE, Constants.APPLICATION_JSON);
        headers.put(Constants.ACCEPT, Constants.APPLICATION_JSON);

        mSniManager = new SNIConnectionManager(mCrashEndpoint, reportAsJson.toString(), headers, null, true);
        Hashtable<String, String> response = mSniManager.ExecuteHttp(KZHttpMethod.POST);
        String body = response.get("responseBody");
        Integer statusCode = Integer.parseInt(response.get("statusCode"));
        if (statusCode >= HttpStatus.SC_MULTIPLE_CHOICES) {
            String exceptionMessage = (body != null ? body : "Unexpected HTTP Status Code: " + statusCode);
            throw new Exception(exceptionMessage);
        }
    } catch (InterruptedException e) {
        throw new ReportSenderException("Timeout trying to send report to KidoZen services.", e);
    } catch (ReportSenderException e) {
        throw e;
    } catch (Exception e) {
        throw new ReportSenderException("Error while sending  report to KidoZen services.", e);
    }
}

From source file:gessi.ossecos.graph.GraphModel.java

public static void IStarJsonToGraphFile(String iStarModel, String layout, String typeGraph)
        throws ParseException {
    JSONParser parser = new JSONParser();
    JSONObject jsonObject = (JSONObject) parser.parse(iStarModel);

    JSONArray jsonArrayNodes = (JSONArray) jsonObject.get("nodes");
    JSONArray jsonArrayEdges = (JSONArray) jsonObject.get("edges");
    String modelType = jsonObject.get("modelType").toString();

    // System.out.println(modelType);
    // System.out.println(jsonArrayNodes.toJSONString());
    // System.out.println(jsonArrayEdges.toJSONString());

    System.out.println(jsonObject.toJSONString());

    Hashtable<String, String> nodesHash = new Hashtable<String, String>();
    Hashtable<String, String> boundaryHash = new Hashtable<String, String>();
    Hashtable<String, Integer> countNodes = new Hashtable<String, Integer>();
    ArrayList<String> boundaryItems = new ArrayList<String>();
    ArrayList<String> actorItems = new ArrayList<String>();
    GraphViz gv = new GraphViz();
    gv.addln(gv.start_graph());/*w  w  w.  j a v  a  2 s . co  m*/

    String nodeType;
    String nodeName;
    String nodeBoundary;
    for (int i = 0; i < jsonArrayNodes.size(); i++) {

        jsonObject = (JSONObject) jsonArrayNodes.get(i);
        nodeName = jsonObject.get("name").toString().replace(" ", "_");
        // .replace("(", "").replace(")", "");
        nodeName = nodeName.replaceAll("[\\W]|`[_]", "");
        nodeType = jsonObject.get("elemenType").toString();
        nodeBoundary = jsonObject.get("boundary").toString();
        // TODO: Verify type of diagram
        // if (!nodeType.equals("actor") & !nodeBoundary.equals("boundary"))
        // {
        if (countNodes.get(nodeName) == null) {
            countNodes.put(nodeName, 0);
        } else {
            countNodes.put(nodeName, countNodes.get(nodeName) + 1);
            nodeName += "_" + countNodes.put(nodeName, 0);

        }
        gv.addln(renderNode(nodeName, nodeType));

        // }

        nodesHash.put(jsonObject.get("id").toString(), nodeName);
        boundaryHash.put(jsonObject.get("id").toString(), nodeBoundary);
        if (nodeType.equals("actor")) {
            actorItems.add(nodeName);
        }
    }

    String edgeType = "";
    String source = "";
    String target = "";
    String edgeSubType = "";
    int subgraphCount = 0;
    boolean hasCluster = false;
    nodeBoundary = "na";
    String idSource;
    String idTarget;
    for (int i = 0; i < jsonArrayEdges.size(); i++) {

        jsonObject = (JSONObject) jsonArrayEdges.get(i);
        edgeSubType = jsonObject.get("linksubtype").toString();
        edgeType = renderEdge(edgeSubType, jsonObject.get("linktype").toString());
        idSource = jsonObject.get("source").toString();
        idTarget = jsonObject.get("target").toString();
        source = nodesHash.get(idSource);
        target = nodesHash.get(idTarget);

        if (!boundaryHash.get(idSource).toString().equals("boundary")
                && !boundaryHash.get(idTarget).toString().equals("boundary")) {
            if (!boundaryHash.get(idSource).toString().equals(nodeBoundary)) {
                nodeBoundary = boundaryHash.get(idSource).toString();
                if (hasCluster) {
                    gv.addln(gv.end_subgraph());
                    hasCluster = false;

                } else {
                    hasCluster = true;
                }
                gv.addln(gv.start_subgraph(subgraphCount));
                gv.addln(actorItems.get(subgraphCount++));
                gv.addln("style=filled;");
                gv.addln("color=lightgrey;");

            }
            gv.addln(source + "->" + target + edgeType);

        } else {

            boundaryItems.add(source + "->" + target + edgeType);

        }

    }
    if (subgraphCount > 0) {
        gv.addln(gv.end_subgraph());
    }
    for (String boundaryE : boundaryItems) {
        gv.addln(boundaryE);
    }
    gv.addln(gv.end_graph());

    String type = typeGraph;
    // String type = "dot";
    // String type = "fig"; // open with xfig
    // String type = "pdf";
    // String type = "ps";
    // String type = "svg"; // open with inkscape
    // String type = "png";
    // String type = "plain";

    String repesentationType = layout;
    // String repesentationType= "neato";
    // String repesentationType= "fdp";
    // String repesentationType= "sfdp";
    // String repesentationType= "twopi";
    // String repesentationType= "circo";

    // //File out = new File("/tmp/out"+gv.getImageDpi()+"."+ type); //
    // Linux
    File out = new File("Examples/out." + type); // Windows
    gv.writeGraphToFile(gv.getGraph(gv.getDotSource(), type, repesentationType), out);

}

From source file:net.sf.ehcache.distribution.MockContextFactory.java

/**
 * @see javax.naming.spi.InitialContextFactory#getInitialContext(java.util.Hashtable)
 *//* ww w . j a v  a 2  s  . c om*/
public Context getInitialContext(Hashtable environment) throws NamingException {
    LOG.debug("getInitialContext " + environment);
    String jndiProviderUrl = (String) environment.get(Context.PROVIDER_URL);
    synchronized (JNDI_PROVIDER_URL_TO_CONTEXT_MAP) {
        if (jndiProviderUrl == null) {
            throw new NamingException("getInitialContext: " + Context.PROVIDER_URL + " is null " + environment);
        }
        Context context = null;
        context = (Context) JNDI_PROVIDER_URL_TO_CONTEXT_MAP.get(jndiProviderUrl);
        if (context == null) {
            context = new MockContext(jndiProviderUrl);
            JNDI_PROVIDER_URL_TO_CONTEXT_MAP.put(jndiProviderUrl, context);
        }
        return context;
    }
}

From source file:com.ziaconsulting.zoho.RemoteAdapterImpl.java

@SuppressWarnings("rawtypes")
private String saveImpl(Hashtable info, byte[] content) {
    logger.info("Saved file from remote agent");
    InputStream in = new ByteArrayInputStream(content);
    String id = info.get("id").toString();
    String nodeRefStr = id.substring(0, id.indexOf("#"));
    String ticket = id.substring(id.indexOf("#") + 1);

    boolean saved = SaveHelper.doSave(id, nodeRefStr, ticket, in, instance.serviceRegistry);

    return saved ? "Document saved to Alfresco" : "Document DID NOT save!";
}

From source file:com.claytablet.service.event.stubs.MockStub.java

/**
 * Prints out the connection params and mappings that were injected.
 * /*from w ww  .jav  a 2  s. co  m*/
 * @throws IOException
 */
public void logConfig() throws IOException {

    log.debug("** Connection parameters **");
    Hashtable<String, String> parms = context.getConnectionParms();
    for (String key : parms.keySet()) {
        log.debug(key + ": " + parms.get(key));
    }

    log.debug("** Language mappings **");
    for (String key : languageMap.keys()) {
        log.debug(key + ": " + languageMap.get(key));
    }

    log.debug("** Asset Task mappings **");
    for (String key : assetTaskMap.keys()) {
        log.debug("Connector Asset Task ID -- " + key + " --");
        AssetTaskMapping mapping = assetTaskMap.get(key);
        log.debug("CTT Asset Task ID: " + mapping.getCttAssetTaskId());
        log.debug("CTT Project ID: " + mapping.getCttProjectId());
        log.debug("Connector Project ID: " + mapping.getConnectorProjectId());
        log.debug("Source language: " + mapping.getSourceLanguageCode());
        log.debug("Target language: " + mapping.getTargetLanguageCode());

    }

}