Example usage for java.util LinkedHashMap toString

List of usage examples for java.util LinkedHashMap toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:com.saggezza.litetracker.track.PayloadMap.java

public static void main(String[] args) {
    PayloadMap pl = new PayloadMap();
    LinkedHashMap<String, String> configurations = new LinkedHashMap<String, String>();

    System.out.println(pl.toString());
    LinkedHashMap<String, String> params = pl.getParams();
    Set<String> paramsSet = pl.getParams().keySet();
    for (String s : paramsSet) {
        System.out.println(s + ":" + params.get(s));
    }/* ww w. j  a  va  2s . c  o m*/

    System.out.println(configurations.toString().length());
    System.out.println(configurations.toString().equals("{}"));
}

From source file:com.saggezza.jtracker.track.PayloadMapC.java

public static void main(String[] args) {
    PayloadMap pl = new PayloadMapC();
    LinkedHashMap<String, String> configurations = new LinkedHashMap<String, String>();

    System.out.println(pl.toString());
    LinkedHashMap<String, String> params = pl.getParams();
    Set<String> paramsSet = pl.getParams().keySet();
    for (String s : paramsSet) {
        System.out.println(s + ":" + params.get(s));
    }/*from   ww w.j  a  v a 2s . c om*/

    System.out.println(configurations.toString().length());
    System.out.println(configurations.toString().equals("{}"));
}

From source file:com.taobao.datax.plugins.writer.oraclejdbcwriter.OracleJdbcWriter.java

public String buildInsertString() {
    StringBuilder sb = new StringBuilder();
    sb.append("INSERT INTO ").append(this.schema + "." + this.table).append(" ");
    if (!StringUtils.isEmpty(this.colorder)) {
        sb.append("(").append(this.colorder).append(")");
    }/*from  www  .j a v  a  2 s . c  om*/
    sb.append(" VALUES(");
    try {
        ResultSet rs = this.connection.createStatement()
                .executeQuery("SELECT COLUMN_NAME,DATA_TYPE FROM USER_TAB_COLUMNS WHERE TABLE_NAME='"
                        + this.table.toUpperCase() + "'");
        LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
        while (rs.next()) {
            String colName = rs.getString(1);
            String colType = rs.getString(2);
            map.put(colName, colType);
        }
        logger.debug("Column map:size=" + map.size() + ";cols=" + map.toString());
        if (StringUtils.isEmpty(this.colorder)) {
            Iterator<Entry<String, String>> it = map.entrySet().iterator();
            while (it.hasNext()) {
                Entry<String, String> entry = it.next();
                String colType = entry.getValue();
                if (colType.toUpperCase().equals("DATE")) {
                    sb.append("to_date(?,'" + this.dtfmt + "'),");
                } else {
                    sb.append("?,");
                }
            }
            sb.deleteCharAt(sb.length() - 1);// remove last comma
            sb.append(")");
        } else {
            String[] arr = colorder.split(",");
            for (String colName : arr) {
                if (!map.containsKey(colName)) {
                    throw new DataExchangeException("col " + colName + " not in database");
                }
                String colType = map.get(colName);
                if (colType.toUpperCase().equals("DATE")) {
                    sb.append("to_date(?,'" + this.dtfmt + "'),");
                } else {
                    sb.append("?,");
                }
            }
            sb.deleteCharAt(sb.length() - 1);// remove last comma
            sb.append(")");
        }
    } catch (SQLException e) {
        e.printStackTrace();
        throw new DataExchangeException(e.getMessage());
    }

    return sb.toString();
}

From source file:org.kuali.kfs.module.cam.businessobject.AssetPaymentDetail.java

/**
 * Create a key including the//from w ww .  j  a  v a2s. c  o  m
 * <li><b>expenditureFinancialDocumentNumber</b></li>
 * <li><b>expenditureFinancialDocumentTypeCode</b></li>
 * with accounting information for asset payment distribution
 *
 * Make sure the full accounting line information is part of the key
 * chartOfAccount, accountNumber, subAccountNumber, objectCode, subObjectCode, projectCode
 *
 * @return
 */
public String getAssetPaymentDetailKey() {
    LinkedHashMap<String, String> paymentMap = assetPaymentToStringMapper();
    paymentMap.put("expenditureFinancialDocumentTypeCode", this.getExpenditureFinancialDocumentTypeCode());
    paymentMap.put("expenditureFinancialDocumentNumber", this.getExpenditureFinancialDocumentNumber());

    //use SHORT_PREFIX_STYLE so that memory address is not part of the toString output
    ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
    for (String key : paymentMap.keySet()) {
        builder.append(key, paymentMap.get(key));
    }
    return paymentMap.toString();
}

From source file:com.google.gwt.emultest.java.util.LinkedHashMapTest.java

/**
 * Test method for 'java.util.AbstractMap.toString()'.
 *///from w  ww .  j  a va 2 s .c o m
public void testToString() {
    LinkedHashMap<String, String> hashMap = new LinkedHashMap<String, String>();
    checkEmptyLinkedHashMapAssumptions(hashMap);
    hashMap.put(KEY_KEY, VALUE_VAL);
    String entryString = makeEntryString(KEY_KEY, VALUE_VAL);
    assertTrue(entryString.equals(hashMap.toString()));
}

From source file:hd3gtv.mydmam.auth.AuthenticationBackend.java

public static void refreshConfiguration() throws Exception {
    if (Configuration.global.isElementExists("auth") == false) {
        throw new NullPointerException("Can't found \"auth\" element in configuration");
    }//from   w  ww . j a  va2  s .  c o  m
    if (Configuration.global.isElementKeyExists("auth", "backend") == false) {
        throw new NullPointerException("Can't found \"auth/backend\" element in configuration");
    }

    List<LinkedHashMap<String, ?>> elements = Configuration.global.getListMapValues("auth", "backend");

    if (elements == null) {
        throw new NullPointerException("No items for \"auth/backend\" element in configuration");
    }

    force_select_domain = Configuration.global.getValueBoolean("auth", "force_select_domain");

    authenticators = new ArrayList<Authenticator>(elements.size());
    authenticators_domains = new ArrayList<String>(elements.size());

    LinkedHashMap<String, ?> configuration_element;
    File auth_file;
    for (int pos = 0; pos < elements.size(); pos++) {
        configuration_element = elements.get(pos);
        String element_source = (String) configuration_element.get("source");
        if (element_source.equals("local")) {
            String path = (String) configuration_element.get("path");

            auth_file = new File(path);
            if (auth_file.exists() == false) {
                if (auth_file.isAbsolute() == false) {
                    if (auth_file.getParentFile().getName().equals("conf") & Configuration
                            .getGlobalConfigurationDirectory().getParentFile().getName().equals("conf")) {
                        /**
                         * SQLite file is located in Play conf directory, and Play /app.d/ is also located in conf directory.
                         * We consider that conf directory is the same.
                         */
                        auth_file = new File(Configuration.getGlobalConfigurationDirectory().getParent()
                                + File.separator + auth_file.getName());
                    }
                }
            }
            if (auth_file.exists() == false) {
                throw new FileNotFoundException(path);
            }

            String masterkey = (String) configuration_element.get("masterkey");
            authenticators.add(new AuthenticatorLocalsqlite(auth_file, masterkey));

            String label = (String) configuration_element.get("label");
            authenticators_domains.add(label);
        } else if (element_source.equals("ad")) {
            String domain = (String) configuration_element.get("domain");
            String server = (String) configuration_element.get("server");
            int port = (Integer) configuration_element.get("port");
            authenticators.add(new AuthenticatorActivedirectory(domain, server, port));

            authenticators_domains.add(domain);
        } else {
            Log2.log.error("Can't import \"auth/backend\" " + (pos + 1) + " configuration item", null,
                    new Log2Dump("item", configuration_element.toString()));
        }
    }

    if (authenticators.isEmpty()) {
        throw new NullPointerException("No authentication backend is correctly set");
    }
}

From source file:ch.elexis.core.ui.views.FallDetailBlatt2.java

/**
 * disposes of required and optional fields on the bottom of the page.<br>
 * re-reads the contents for this case for the upper part<br>
 * recreates the required and optional fields on the bottom of the page (call to
 * setExtendedFields)//ww  w . ja  v  a2s.  c om
 * 
 * @param f
 *            caseID
 */
@SuppressWarnings("unchecked")
public void setFall(final IFall f) {
    if (actFall != null) {
        save();
    }
    // *** dispose of currently displayed fields
    actFall = f;
    for (Control c : lReqs) {
        c.dispose();
    }
    lReqs.clear();
    keepEditable.clear();

    // *** fill billing systems into combo, set current system
    cAbrechnung.setItems(Abrechnungstypen);
    if (f == null) {
        form.setText(Messages.FallDetailBlatt2_NoCaseSelected); //$NON-NLS-1$
        tBezeichnung.setText("");
        tBezeichnung.setMessage(Messages.FallDetailBlatt2_29);
        cReason.select(0);
        return;
    }

    String billingSystem = f.getAbrechnungsSystem();
    // auto select accident if uvg is selected
    if ("UVG".equals(billingSystem)) {
        int idx = ArrayUtils.indexOf(Reasons, FallConstants.TYPE_ACCIDENT);
        if (idx > -1) {
            f.setGrund(Reasons[idx]);
        }
    }

    form.setText(f.getLabel());

    // *** set Fallbezeichnung
    tBezeichnung.setText(f.getBezeichnung());

    // *** set Grund (Krankheit/Unfall/...)
    String grund = f.getGrund();
    int ix = cReason.indexOf(grund);
    if (ix == -1) {
        ix = 0;
    }
    cReason.select(ix);

    cAbrechnung.setText(billingSystem);

    // *** set startDate/EndDate
    TimeTool tt = new TimeTool();
    if (tt.set(f.getBeginnDatum()) == true) {
        dpVon.setDate(tt.getTime());
    } else {
        dpVon.setDate(null);
    }
    if (tt.set(f.getEndDatum()) == true) {
        dpBis.setDate(tt.getTime());
    } else {
        dpBis.setDate(null);
    }

    // *** set copy for patient
    btnCopyForPatient.setSelection(f.getCopyForPatient());

    // *** set Garant
    tGarant.setBackground(null);
    tGarant.setToolTipText(null);
    Kontakt garant = f.getGarant();
    String garantLabel = garant.getLabel();
    if (garant.isDeleted()) {
        tGarant.setBackground(UiDesk.getColor(UiDesk.COL_RED));
        garantLabel = "*** " + garantLabel;
        tGarant.setToolTipText(Messages.Contact_is_marked_deleted);
    }
    tGarant.setText(garantLabel);

    // *** set cost bearer (if enabled for billing system)
    boolean costBearerDisabled = BillingSystem.isCostBearerDisabled(billingSystem);
    tCostBearer.setVisible(!costBearerDisabled);
    hlCostBearer.setVisible(!costBearerDisabled);

    tCostBearer.setBackground(null);
    tCostBearer.setToolTipText(null);
    if (!costBearerDisabled) {
        Kontakt costBearer = f.getCostBearer();
        String label = (costBearer != null) ? costBearer.getLabel() : f.getPatient().getLabel();
        if (costBearer != null && costBearer.isDeleted()) {
            tCostBearer.setBackground(UiDesk.getColor(UiDesk.COL_RED));
            label = "*** " + label;
            tCostBearer.setToolTipText(Messages.Contact_is_marked_deleted);
        }
        tCostBearer.setText(label);
    } else {
        tCostBearer.setText(StringConstants.EMPTY);
    }

    // *** adding required fields defined in prefs
    String reqs = BillingSystem.getRequirementsBySystem(billingSystem);
    if ((reqs != null) && (reqs.length() > 0)) {
        // *** do not display a title bar since this is already displayed
        // above Rechnungsempfnger!
        setExtendedFields(f, reqs, StringTool.leer, false, false, false);
    }
    // *** adding optional fields defined in prefs
    String optionals = f.getOptionals();
    if ((optionals != null) && (optionals.length() > 0)) {
        setExtendedFields(f, optionals, Messages.FallDetailBlatt2_optionalData, false, false, true); //$NON-NLS-1$
    }

    // ****** show any other fields from extinfo - ONLY FOR ADMINS, NOT
    // INTENDED FOR NORMAL USERS !!!
    // first part fields with definition, second part without definition

    // *** display all unused field having a display specification
    String[] reqsArray = BillingSystem.getRequirementsBySystem(billingSystem).split(DEFINITIONSDELIMITER);
    for (int reqI = 0; reqI < reqsArray.length; reqI++) {
        reqsArray[reqI] = reqsArray[reqI].split(ARGUMENTSSDELIMITER)[0];
    }
    String[] optsArray = f.getOptionals().split(DEFINITIONSDELIMITER);
    for (int reqI = 0; reqI < optsArray.length; reqI++) {
        optsArray[reqI] = optsArray[reqI].split(ARGUMENTSSDELIMITER)[0];
    }
    // *** read field definitions for unused fields (previously required or
    // optional)
    List<String> unused = new ArrayList<String>();
    LinkedHashMap<String, String> unusedHash = new LinkedHashMap<String, String>();
    String strUnused = f.getUnused();
    if ((strUnused != null) && (!strUnused.isEmpty())) {
        String[] allUnused = strUnused.split(DEFINITIONSDELIMITER); //$NON-NLS-1$
        Arrays.sort(allUnused, String.CASE_INSENSITIVE_ORDER); // *** sort
        // alphabetically
        for (String unusedPart : allUnused) {
            int posColon = unusedPart.indexOf(ARGUMENTSSDELIMITER);
            String key = unusedPart.substring(0, posColon);
            // *** do not show if already displayed in required or optional
            // fields
            boolean alreadyDisplayed = false;
            for (int reqI = 0; reqI < reqsArray.length; reqI++) {
                if (key.equalsIgnoreCase(reqsArray[reqI])) {
                    alreadyDisplayed = true;
                }
            }
            for (int reqI = 0; reqI < optsArray.length; reqI++) {
                if (key.equalsIgnoreCase(optsArray[reqI])) {
                    alreadyDisplayed = true;
                }
            }
            if (!alreadyDisplayed) {
                String value = unusedPart.substring(posColon + 1);
                unusedHash.put(key, value);
                unused.add(unusedPart);
            }
        }
    }

    Map<String, String> httmp = getSelectedFall().getMap(PersistentObject.FLD_EXTINFO);

    HashMap<String, String> ht = new HashMap<String, String>(httmp);

    String[] unusedHashStringArray = {};
    if (unusedHash.size() > 0) {
        String unusedHashString = unusedHash.toString();
        unusedHashString = unusedHashString.substring(1);
        unusedHashString = unusedHashString.substring(0, unusedHashString.length() - 1);
        unusedHashStringArray = unusedHashString.split(", "); //$NON-NLS-1$
    }
    String otherFieldsList_2 = StringTool.leer;
    String delim = StringTool.leer;
    for (int uhi = 0; uhi < unusedHashStringArray.length; uhi++) {
        String unusedItem = unusedHashStringArray[uhi];
        String[] itemParts = unusedItem.split("="); //$NON-NLS-1$
        String controlName = itemParts[0];
        String[] controlDefParts = itemParts[1].split(ARGUMENTSSDELIMITER);
        String controlType = controlDefParts[0];

        String[] itemList = { StringTool.leer };
        if (controlType.equalsIgnoreCase("X")) { //$NON-NLS-1$
            if (controlDefParts.length > 1) {
                itemList = controlDefParts[1].split(ITEMDELIMITER);
            }
        }
        boolean isAdded = false;
        // *** special handling if multiple items
        for (int ili = 0; ili < itemList.length; ili++) {
            String item = itemList[ili];
            if (!item.isEmpty()) {
                item = "_" + item; //$NON-NLS-1$
            }
            String combControlName = controlName + item;
            if (ht.containsKey(combControlName)) {
                ht.remove(combControlName);
                String values = StringTool.leer;
                if (controlDefParts.length > 1) {
                    values = controlDefParts[1];
                }
                if (!isAdded) {
                    otherFieldsList_2 = otherFieldsList_2 + delim + controlName + ARGUMENTSSDELIMITER
                            + controlType + ARGUMENTSSDELIMITER + values;
                }
                delim = DEFINITIONSDELIMITER;
                isAdded = true;
            }
        }
    }
    // *** only for admins!
    if (otherFieldsList_2.length() > 0) {
        if (CoreHub.acl.request(AccessControlDefaults.CASE_MODIFY_SPECIALS) == true) {
            setExtendedFields(f, otherFieldsList_2, Messages.FallDetailBlatt2_unusedFieldsWithDefinition, true,
                    true, false); //$NON-NLS-1$
        }
    }

    // *** collect all other fields that are not yet shown anywhere else,
    // display as text
    String otherFieldsList = otherFieldsList_2;
    otherFieldsList = StringTool.leer;
    Set<String> keySet = ht.keySet();
    Object[] arr = keySet.toArray();
    for (int i = 0; i < arr.length; i++) {
        String subkey = (String) arr[i];
        String abrSystem = getSelectedFall().getAbrechnungsSystem();
        String key = Preferences.LEISTUNGSCODES_CFG_KEY + "/" + abrSystem; //$NON-NLS-1$
        String bed = CoreHub.globalCfg.get(key + "/bedingungen", StringTool.leer); //$NON-NLS-1$
        boolean isAlreadyShown = false;
        if (subkey.equalsIgnoreCase(FallConstants.FLD_EXTINFO_BILLING))
            isAlreadyShown = true;
        // if (subkey.equalsIgnoreCase("payment")) isAlreadyShown = true;
        // if (subkey.equalsIgnoreCase("Fallnummer")) isAlreadyShown = true;
        // if (subkey.equalsIgnoreCase("Gesetz")) isAlreadyShown = true;
        String[] bedArr = bed.split(DEFINITIONSDELIMITER);
        if (!bed.isEmpty()) {
            for (int ii = 0; ii < bedArr.length; ii++) {
                String fldParts = bedArr[ii];
                String[] flds = fldParts.split(ARGUMENTSSDELIMITER);
                String fld = flds[0];
                if ((flds[1].equalsIgnoreCase("X")) && ((flds.length > 2)) //$NON-NLS-1$
                        && (!flds[2].isEmpty())) {
                    String checkBoxes = flds[2];
                    String[] checkBoxArray = checkBoxes.split(ITEMDELIMITER);
                    for (int cb_i = 0; cb_i < checkBoxArray.length; cb_i++) {
                        if ((fld + "_" + checkBoxArray[cb_i]).equalsIgnoreCase(subkey)) { //$NON-NLS-1$
                            isAlreadyShown = true;
                            break;
                        }
                    }
                } else {
                    if (fld.equalsIgnoreCase(subkey)) {
                        isAlreadyShown = true;
                        break;
                    }
                }
            }
        }
        String opt = CoreHub.globalCfg.get(key + "/fakultativ", StringTool.leer); //$NON-NLS-1$
        if (!isAlreadyShown) {
            String[] optArr = opt.split(DEFINITIONSDELIMITER);
            if (!opt.isEmpty()) {
                for (int ii = 0; ii < optArr.length; ii++) {
                    String fld = optArr[ii].split(ARGUMENTSSDELIMITER)[0];
                    if (fld.equalsIgnoreCase(subkey)) {
                        isAlreadyShown = true;
                        break;
                    }
                }
            }
        }
        if (!isAlreadyShown) {
            if (unusedHash.containsKey(subkey)) {
                // *** try to find def
                String theVal = (String) unusedHash.get(subkey);
                String[] vals = theVal.split(ARGUMENTSSDELIMITER);
                otherFieldsList = otherFieldsList + delim + subkey + ARGUMENTSSDELIMITER + vals[0];
                if (vals.length > 1) {
                    otherFieldsList = otherFieldsList + ARGUMENTSSDELIMITER + vals[1];
                }
            } else {
                // *** if no spec found, then show as text
                otherFieldsList = otherFieldsList + delim + subkey + ":T"; //$NON-NLS-1$
            }
            delim = DEFINITIONSDELIMITER;
        }
    }

    if (otherFieldsList.length() > 0) {
        // *** want to sort alphabetically here
        String[] tmpArr = otherFieldsList.split(DEFINITIONSDELIMITER);
        Arrays.sort(tmpArr, String.CASE_INSENSITIVE_ORDER);
        otherFieldsList = StringTool.leer;
        String tmpDel = StringTool.leer;
        for (int i = 0; i < tmpArr.length; i++) {
            otherFieldsList = otherFieldsList + tmpDel + tmpArr[i];
            tmpDel = DEFINITIONSDELIMITER;
        }
        // *** only for admins!
        if (CoreHub.acl.request(AccessControlDefaults.CASE_MODIFY_SPECIALS) == true) {
            setExtendedFields(f, otherFieldsList, Messages.FallDetailBlatt2_unusedFieldsWithoutDefinition, true,
                    true, false); //$NON-NLS-1$
        }
    }

    if (lockUpdate) {
        setUnlocked(CoreHub.getLocalLockService().isLockedLocal(actFall));
    }
}