Example usage for java.util Hashtable toString

List of usage examples for java.util Hashtable toString

Introduction

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

Prototype

public synchronized String toString() 

Source Link

Document

Returns a string representation of this Hashtable object in the form of a set of entries, enclosed in braces and separated by the ASCII characters "" (comma and space).

Usage

From source file:Main.java

public static void main(String args[]) {
    // create hash table 
    Hashtable<Integer, String> htable1 = new Hashtable<Integer, String>();

    // put values in table
    htable1.put(1, "A");
    htable1.put(2, "B");
    htable1.put(3, "C");
    htable1.put(4, "from java2s.com");

    System.out.println("String form of hash table is: " + htable1.toString());
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Hashtable h = new Hashtable();
    h.put("string", "AAA");
    h.put("int", new Integer(26));
    h.put("double", new Double(Math.PI));

    FileOutputStream fileOut = new FileOutputStream("hashtable.ser");
    ObjectOutputStream out = new ObjectOutputStream(fileOut);
    out.writeObject(h);//from www .  ja v a 2s . co m

    FileInputStream fileIn = new FileInputStream("h.ser");
    ObjectInputStream in = new ObjectInputStream(fileIn);
    Hashtable h = (Hashtable) in.readObject();
    System.out.println(h.toString());
}

From source file:org.cocos2dx.plugin.IAPOnlineQH360.java

@Override
public void payForProduct(Hashtable<String, String> info) {
    LogD("payForProduct invoked " + info.toString());
    final Hashtable<String, String> curInfo = info;
    PluginWrapper.runOnMainThread(new Runnable() {

        @Override//from w  w  w  . ja  v a  2s  . co m
        public void run() {
            try {
                Intent intent = getPayIntent(curInfo);
                Matrix.invokeActivity(mContext, intent, new IDispatcherCallback() {
                    @Override
                    public void onFinished(String data) {
                        LogD("mPayCallback, data is " + data);
                        JSONObject jsonRes;
                        try {
                            jsonRes = new JSONObject(data);
                            int errorCode = jsonRes.getInt("error_code");
                            String errorMsg = jsonRes.getString("error_msg");
                            int retCode = IAPWrapper.PAYRESULT_FAIL;
                            switch (errorCode) {
                            case 0:
                                // Success 
                                retCode = IAPWrapper.PAYRESULT_SUCCESS;
                                break;
                            case 1:
                                // Fail 
                                retCode = IAPWrapper.PAYRESULT_FAIL;
                                break;
                            case -1:
                                // cancel 
                                retCode = IAPWrapper.PAYRESULT_CANCEL;
                                break;
                            case -2:
                                // paying 
                                retCode = IAPWrapper.PAYRESULT_SUCCESS;
                                break;
                            default:
                                break;
                            }

                            IAPOnlineQH360.payResult(retCode, errorMsg);
                        } catch (Exception e) {
                            IAPOnlineQH360.payResult(IAPWrapper.PAYRESULT_FAIL, "Unkonw Error");
                            LogE("Error when parse the result data!", e);
                        }
                    }
                });
            } catch (Exception e) {
                IAPOnlineQH360.payResult(IAPWrapper.PAYRESULT_FAIL, "Unkonw Error");
                LogE("Unknow Error!", e);
            }
        }
    });
}

From source file:org.cocos2dx.plugin.AnalyticsUmeng.java

@Override
public void logEvent(String eventId, Hashtable<String, String> paramMap) {
    LogD("logEvent(" + eventId + "," + paramMap.toString() + ") invoked!");
    HashMap<String, String> curParam = changeTableToMap(paramMap);
    MobclickAgent.onEvent(mContext, eventId, curParam);
}

From source file:org.easy.ldap.LdapContextFactory.java

/**
 * @param enviroment//from  www .j av  a  2s . c o  m
 * @return
 * @throws NamingException
 */
public DirContext createContext(Hashtable<String, String> enviroment) throws NamingException {
    if (log.isDebugEnabled()) {
        log.debug("Creating context with enviroment settings of:");
        log.debug(enviroment.toString());
    }

    DirContext ctx = null;
    ctx = new InitialDirContext(enviroment);

    return ctx;
}

From source file:eionet.gdem.qa.XQueryService.java

/**
 * Checks if the job is ready (or error) and returns the result (or error message).
 *
 * @param jobId//from   w w  w.j av a  2s . com
 * @return Hash including code and result
 */
public Hashtable getResult(String jobId) throws GDEMException {

    LOGGER.info("XML/RPC call for getting result with JOB ID: " + jobId);

    String[] jobData = null;
    HashMap scriptData = null;
    int status = 0;
    try {
        jobData = xqJobDao.getXQJobData(jobId);

        if (jobData == null) { // no such job
            // throw new GDEMException("** No such job with ID=" + jobId + " in the queue.");
            status = Constants.XQ_JOBNOTFOUND_ERR;
        } else {
            scriptData = queryDao.getQueryInfo(jobData[5]);

            status = Integer.valueOf(jobData[3]).intValue();
        }
    } catch (SQLException sqle) {
        throw new GDEMException("Error gettign XQJob data from DB: " + sqle.toString());
    }

    LOGGER.info("XQueryService found status for job (" + jobId + "):" + String.valueOf(status));

    Hashtable ret = result(status, jobData, scriptData, jobId);
    if (LOGGER.isInfoEnabled()) {
        String result = ret.toString();
        if (result.length() > 100) {
            result = result.substring(0, 100).concat("....");
        }
        LOGGER.info("result: " + result);
    }
    return ret;
}

From source file:org.cocos2dx.plugin.ShareFacebook.java

@Override
public void share(final Hashtable<String, String> cpInfo) {
    LogD("share invoked " + cpInfo.toString());
    if (networkReachable()) {
        PluginWrapper.runOnMainThread(new Runnable() {
            @Override//from   w  ww  . j ava  2s  .  com
            public void run() {
                String caption = cpInfo.get("title");
                String url = cpInfo.get("link");
                String text = cpInfo.get("description");
                String picture = cpInfo.get("imageUrl");
                FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(mContext).setCaption(caption)
                        .setPicture(picture).setLink(url).setDescription(text).build();

                FacebookWrapper.track(shareDialog.present());
            }
        });
    }
}

From source file:org.oscarehr.decisionSupport.model.DSGuidelineFactory.java

public DSGuideline createGuidelineFromXml(String xml) throws DecisionSupportParseException {
    if (xml == null || xml.equals(""))
        throw new DecisionSupportParseException("Xml not set");
    SAXBuilder parser = new SAXBuilder();
    Document doc;//w  w w . ja  v a2 s  . c o  m
    try {
        doc = parser.build(new StringReader(xml));
    } catch (JDOMException jdome) {
        throw new DecisionSupportParseException("Failed to read the xml string for parsing", jdome);
    } catch (IOException ioe) {
        throw new DecisionSupportParseException("Failed to read the xml string for parsing", ioe);
    }
    //<guideline evidence="" significance="" title="Plavix Drug DS">
    Element guidelineRoot = doc.getRootElement();

    DSGuideline dsGuideline = this.createBlankGuideline();

    String guidelineTitle = guidelineRoot.getAttributeValue("title");
    dsGuideline.setTitle(guidelineTitle);

    //Load parameters such as classes
    //<parameter identifier="a">
    //  <class>java.util.ArrayList</class>
    //</parameter>
    ArrayList<DSParameter> parameters = new ArrayList<DSParameter>();
    @SuppressWarnings("unchecked")
    List<Element> parameterTags = guidelineRoot.getChildren("parameter");
    for (Element parameterTag : parameterTags) {
        String alias = parameterTag.getAttributeValue("identifier");
        if (alias == null) {
            throw new DecisionSupportParseException(guidelineTitle,
                    "Parameter identifier attribute is mandatory");
        }

        Element Eclass = parameterTag.getChild("class");
        String strClass = Eclass.getText();
        DSParameter dsParameter = new DSParameter();
        dsParameter.setStrAlias(alias);
        dsParameter.setStrClass(strClass);
        parameters.add(dsParameter);
    }

    dsGuideline.setParameters(parameters);

    //Load Conditions
    //<conditions>
    //  <condition type="dxcodes" any="icd9:4439,icd9:4438,icd10:E11,icd10:E12"/>
    //  <condition type="drug" not="atc:34234"/>
    ArrayList<DSCondition> conditions = new ArrayList<DSCondition>();
    @SuppressWarnings("unchecked")
    List<Element> conditionTags = guidelineRoot.getChild("conditions").getChildren("condition");
    for (Element conditionTag : conditionTags) {

        String conditionTypeStr = conditionTag.getAttributeValue("type");
        if (conditionTypeStr == null)
            throw new DecisionSupportParseException(guidelineTitle, "Condition 'type' attribute is mandatory");
        //try to resolve type
        DSDemographicAccess.Module conditionType;
        try {
            conditionType = DSDemographicAccess.Module.valueOf(conditionTypeStr);
        } catch (IllegalArgumentException iae) {
            String knownTypes = StringUtils.join(DSDemographicAccess.Module.values(), ",");
            throw new DecisionSupportParseException(guidelineTitle,
                    "Cannot recognize condition type: '" + conditionTypeStr + "'.  Known types: " + knownTypes,
                    iae);
        }

        String conditionDescStr = conditionTag.getAttributeValue("desc");

        Hashtable<String, String> paramHashtable = new Hashtable<String, String>();
        @SuppressWarnings("unchecked")
        List<Element> paramList = conditionTag.getChildren("param");
        if (paramList != null) {
            for (Element param : paramList) {
                String key = param.getAttributeValue("key");
                String value = param.getAttributeValue("value");
                paramHashtable.put(key, value);
            }
        }

        @SuppressWarnings("unchecked")
        List<Attribute> attributes = conditionTag.getAttributes();
        for (Attribute attribute : attributes) {
            if (attribute.getName().equalsIgnoreCase("type"))
                continue;
            if (attribute.getName().equalsIgnoreCase("desc"))
                continue;
            DSCondition.ListOperator operator;
            try {
                operator = DSCondition.ListOperator.valueOf(attribute.getName().toLowerCase());
            } catch (IllegalArgumentException iae) {
                throw new DecisionSupportParseException(guidelineTitle,
                        "Unknown condition attribute'" + attribute.getName() + "'", iae);
            }
            DSCondition dsCondition = new DSCondition();
            dsCondition.setConditionType(conditionType);
            dsCondition.setDesc(conditionDescStr);
            dsCondition.setListOperator(operator); //i.e. any, all, not
            if (paramHashtable != null && !paramHashtable.isEmpty()) {
                _log.debug("THIS IS THE HASH STRING " + paramHashtable.toString());
                dsCondition.setParam(paramHashtable);
            }

            dsCondition.setValues(DSValue.createDSValues(attribute.getValue())); //i.e. icd9:3020,icd9:3021,icd10:5022
            conditions.add(dsCondition);
        }
    }
    dsGuideline.setConditions(conditions);

    //CONSEQUENCES
    ArrayList<DSConsequence> dsConsequences = new ArrayList<DSConsequence>();
    @SuppressWarnings("unchecked")
    List<Element> consequenceElements = guidelineRoot.getChild("consequence").getChildren();
    for (Element consequenceElement : consequenceElements) {
        DSConsequence dsConsequence = new DSConsequence();

        String consequenceTypeStr = consequenceElement.getName();
        DSConsequence.ConsequenceType consequenceType = null;
        //try to resolve type
        try {
            consequenceType = DSConsequence.ConsequenceType.valueOf(consequenceTypeStr.toLowerCase());
        } catch (IllegalArgumentException iae) {
            String knownTypes = StringUtils.join(DSConsequence.ConsequenceType.values(), ",");
            throw new DecisionSupportParseException(guidelineTitle,
                    "Unknown consequence: " + consequenceTypeStr + ". Allowed: " + knownTypes, iae);
        }
        dsConsequence.setConsequenceType(consequenceType);

        if (consequenceType == DSConsequence.ConsequenceType.warning) {
            String strengthStr = consequenceElement.getAttributeValue("strength");
            if (strengthStr == null) {
                strengthStr = "warning";
            }
            DSConsequence.ConsequenceStrength strength = null;
            //try to resolve strength type
            try {
                strength = DSConsequence.ConsequenceStrength.valueOf(strengthStr.toLowerCase());
                dsConsequence.setConsequenceStrength(strength);
            } catch (IllegalArgumentException iae) {
                String knownStrengths = StringUtils.join(DSConsequence.ConsequenceStrength.values(), ",");
                throw new DecisionSupportParseException(guidelineTitle,
                        "Unknown strength: " + strengthStr + ". Allowed: " + knownStrengths, iae);
            }
        }
        dsConsequence.setText(consequenceElement.getText());
        dsConsequences.add(dsConsequence);
    }
    dsGuideline.setConsequences(dsConsequences);
    dsGuideline.setXml(xml);
    dsGuideline.setParsed(true);
    //populate consequence here
    return dsGuideline;
}

From source file:com.silverpeas.jobDomainPeas.control.JobDomainPeasSessionController.java

public List<UserDetail> searchUsers(Hashtable<String, String> query) throws JobDomainPeasException {
    SilverTrace.info("jobDomainPeas", "JobDomainPeasSessionController.searchUsers()",
            "root.MSG_GEN_ENTER_METHOD", "query=" + query.toString());
    queryToImport = query;/*  w  w w  . j a va2 s  . c  om*/
    usersToImport = m_AdminCtrl.searchUsers(targetDomainId, query);
    return usersToImport;
}

From source file:com.alfaariss.oa.authentication.remote.AbstractRemoteMethod.java

/**
 * Sends a CGI request message.//from   ww  w .  ja  va 2  s . c om
 * 
 * @param sURL The target URL
 * @param htMessage Hashtable containing the message parameters
 * @return A Hashtable containing the CGI response
 * @throws OAException if sending fails
 * @throws IOException if the connection can't be made
 */
protected Hashtable<String, String> sendRequest(String sURL, Hashtable<String, String> htMessage)
        throws OAException, IOException {
    Hashtable<String, String> htResult = null;
    GetMethod method = null;
    try {
        if (_httpClient == null) {
            _logger.error("No http client initialized");
            throw new OAException(SystemErrors.ERROR_INTERNAL);
        }

        String sMessage = convertHashtable(htMessage);
        if (sMessage == null) {
            _logger.error("Can't send empty message to URL: " + sURL);
            throw new OAException(SystemErrors.ERROR_INTERNAL);
        }

        StringBuffer sbMessage = new StringBuffer(sURL);
        sbMessage.append("?");
        sbMessage.append(sMessage);

        method = new GetMethod(sbMessage.toString());

        _logger.debug("Sending message: " + sbMessage.toString());
        int statusCode = _httpClient.executeMethod(method);
        if (statusCode != HttpStatus.SC_OK) {
            StringBuffer sbWarn = new StringBuffer("Received invalid http status '");
            sbWarn.append(method.getStatusLine());
            sbWarn.append("' while sending: ");
            sbWarn.append(sbMessage.toString());

            _logger.warn(sbWarn.toString());
            throw new OAException(SystemErrors.ERROR_RESOURCE_CONNECT);
        }

        // Read the response body.
        byte[] responseBody = method.getResponseBody();
        if (responseBody != null) {
            String sResponseMessage = new String(responseBody).trim();
            _logger.debug("Received response: " + sResponseMessage);
            htResult = convertCGI(sResponseMessage);
        }
    } catch (IOException e) {
        throw e;
    } catch (OAException e) {
        throw e;
    } catch (Exception e) {
        StringBuffer sbError = new StringBuffer("Internal error while sending message (");
        sbError.append(htMessage.toString());
        sbError.append(") to URL: ");
        sbError.append(sURL);
        _logger.error(sbError.toString(), e);
        throw new OAException(SystemErrors.ERROR_INTERNAL);
    } finally {
        try {
            // Release the connection.
            if (method != null)
                method.releaseConnection();
        } catch (Exception e) {
            _logger.error("Could not close the connection reader", e);
        }
    }
    return htResult;
}