Example usage for java.util LinkedHashMap put

List of usage examples for java.util LinkedHashMap put

Introduction

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

Prototype

V put(K key, V value);

Source Link

Document

Associates the specified value with the specified key in this map (optional operation).

Usage

From source file:com.gst.template.domain.Template.java

public LinkedHashMap<String, String> getMappersAsMap() {
    final LinkedHashMap<String, String> map = new LinkedHashMap<>();
    for (final TemplateMapper mapper : getMappers()) {
        map.put(mapper.getMapperkey(), mapper.getMappervalue());
    }/* ww w.  j  a v a  2  s.  c  om*/
    return map;
}

From source file:org.eda.fpsrv.FPParams.java

public String toJSONString() throws JsonProcessingException {
    LinkedHashMap<String, String> h_map = new LinkedHashMap<>();
    for (String key : properties.keySet())
        h_map.put(key, properties.get(key).stringValue());
    //        return new Gson().toJson(h_map, h_map.getClass());
    return new ObjectMapper().writeValueAsString(h_map);
}

From source file:edu.cornell.kfs.coa.businessobject.AccountReversionGlobalDetail.java

/**
 * @see org.kuali.kfs.kns.bo.BusinessObjectBase#toStringMapper()
 *///from  w  w  w .  j  a  v a2s . co m
protected LinkedHashMap toStringMapperr_RICE20_REFACTORME() {
    LinkedHashMap stringMapper = new LinkedHashMap();
    stringMapper.put(KFSPropertyConstants.DOCUMENT_NUMBER, this.documentNumber);
    stringMapper.put("AccountReversionCategoryCode", this.accountReversionCategoryCode);
    return stringMapper;
}

From source file:com.thoughtworks.go.server.service.support.ThreadInformationProvider.java

private Map<String, Object> getThreadCount(ThreadMXBean threadMXBean) {
    LinkedHashMap<String, Object> count = new LinkedHashMap<>();
    count.put("Current", threadMXBean.getThreadCount());
    count.put("Total", threadMXBean.getTotalStartedThreadCount());
    count.put("Daemon", threadMXBean.getDaemonThreadCount());
    count.put("Peak", threadMXBean.getPeakThreadCount());
    return count;
}

From source file:com.thoughtworks.go.server.service.support.ThreadInformationProvider.java

@Override
public Map<String, Object> asJson() {
    ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
    LinkedHashMap<String, Object> json = new LinkedHashMap<>();
    json.put("Thread Count", getThreadCount(threadMXBean));
    json.put("DeadLock Threads", getDeadLockThreadInformation(threadMXBean));
    json.put("Stack Trace", getStackTraceInformation(threadMXBean));
    return json;//  w  w w.ja  v  a 2 s. c o  m
}

From source file:hydrograph.ui.propertywindow.widgets.customwidgets.JDBCDriverClassWidget.java

@Override
public LinkedHashMap<String, Object> getProperties() {
    LinkedHashMap<String, Object> propertymap = new LinkedHashMap<>();
    propertymap.put(this.propertyName, jdbcDriverClassTextBox.getText());
    return propertymap;
}

From source file:org.openmeetings.app.rss.LoadAtomRssFeed.java

public LinkedHashMap<String, LinkedHashMap<String, LinkedHashMap<String, Object>>> parseRssFeed(
        String urlEndPoint) {/*from w w w.j  av  a  2 s .c om*/
    try {
        LinkedHashMap<String, LinkedHashMap<String, LinkedHashMap<String, Object>>> lMap = new LinkedHashMap<String, LinkedHashMap<String, LinkedHashMap<String, Object>>>();

        URL url = new URL(urlEndPoint);

        HttpURLConnection conn = (HttpURLConnection) url.openConnection();

        conn.setDoOutput(true);
        conn.setDoInput(true);
        conn.setRequestProperty("user-agent",
                "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)");
        conn.setRequestProperty("Referer", "http://incubator.apache.org/openmeetings/");
        conn.connect();

        SAXReader reader = new SAXReader();
        Document document = reader.read(conn.getInputStream());

        Element root = document.getRootElement();
        int l = 0;

        for (@SuppressWarnings("unchecked")
        Iterator<Element> i = root.elementIterator(); i.hasNext();) {
            Element item = i.next();
            LinkedHashMap<String, LinkedHashMap<String, Object>> items = new LinkedHashMap<String, LinkedHashMap<String, Object>>();
            boolean isSubElement = false;

            for (@SuppressWarnings("unchecked")
            Iterator<Element> it2 = item.elementIterator(); it2.hasNext();) {
                Element subItem = it2.next();

                LinkedHashMap<String, Object> itemObj = new LinkedHashMap<String, Object>();

                itemObj.put("name", subItem.getName());
                itemObj.put("text", subItem.getText());

                LinkedHashMap<String, String> attributes = new LinkedHashMap<String, String>();

                for (@SuppressWarnings("unchecked")
                Iterator<Attribute> attr = subItem.attributeIterator(); attr.hasNext();) {
                    Attribute at = attr.next();
                    attributes.put(at.getName(), at.getText());
                }
                itemObj.put("attributes", attributes);

                // log.error(subItem.getName()+ ": " +subItem.getText());
                items.put(subItem.getName(), itemObj);
                isSubElement = true;
            }

            if (isSubElement) {
                l++;
                lMap.put("item" + l, items);
            }

        }

        return lMap;

    } catch (Exception err) {
        log.error("[parseRssFeed]", err);
    }
    return null;

}

From source file:uk.ac.kcl.itemProcessors.WebserviceDocumentItemProcessor.java

private Document executeWithRetryIgnoringExceptions(Document doc) {
    HashMap<String, Object> newMap = new HashMap<>();
    newMap.putAll(doc.getAssociativeArray());
    doc.getAssociativeArray().forEach((k, v) -> {
        if (fieldsToSendToWebservice.contains(k.toLowerCase())) {
            Object json = retryTemplate
                    .execute(new RetryCallback<Object, WebserviceProcessingFailedException>() {
                        public Object doWithRetry(RetryContext context) {
                            // business logic here
                            Object ob = restTemplate.postForObject(endPoint, v, Object.class);

                            return ob;
                        }/*  w w w. j  a  va 2  s .  c o  m*/
                    }, new RecoveryCallback() {
                        @Override
                        public Object recover(RetryContext context) throws WebserviceProcessingFailedException {
                            LOG.warn(webserviceName + " failed on document " + doc.getDocName());
                            ArrayList<LinkedHashMap<Object, Object>> al = new ArrayList<LinkedHashMap<Object, Object>>();
                            LinkedHashMap<Object, Object> hm = new LinkedHashMap<Object, Object>();
                            hm.put(fieldName, webserviceName + " failed");
                            al.add(hm);
                            doc.getExceptions().add(new WebserviceProcessingFailedException(
                                    webserviceName + " failed on document " + doc.getDocName()));
                            return al;
                        }
                    });
            newMap.put(fieldName, json);
        }
    });
    doc.getAssociativeArray().clear();
    doc.getAssociativeArray().putAll(newMap);
    return doc;
}

From source file:com.yyl.common.utils.excel.ExcelTools.java

/**
 * ?ApachePOIAPI??Excel???List?ListJson??LinkedExcel???
 * @param inputStream ?urlurlinput?//from  www  . ja  v a 2  s . co m
 * @param FileName ???????excel
 * @return Map  HashMapExcelsheet?sheetkeysheet?json?value
 * @throws IOException
 */
public static Map<String, String> excel2jsonWithHeaders(InputStream inputStream, String FileName)
        throws IOException {

    System.out.println("excel2json....");

    // map
    Map<String, String> excelMap = new LinkedHashMap<>();

    // Excel??Excel
    CellStyle cellStyle;
    // ?Excel?
    Workbook wb;
    // 2007??Workbook?CellStyle
    if (FileName.endsWith("xlsx")) {
        System.out.println("2007?  xlsx");
        wb = new XSSFWorkbook(inputStream);
        XSSFDataFormat dataFormat = (XSSFDataFormat) wb.createDataFormat();
        cellStyle = wb.createCellStyle();
        // Excel?
        cellStyle.setDataFormat(dataFormat.getFormat("@"));
    } else {
        System.out.println("2007  xls");
        POIFSFileSystem fs = new POIFSFileSystem(inputStream);
        wb = new HSSFWorkbook(fs);
        HSSFDataFormat dataFormat = (HSSFDataFormat) wb.createDataFormat();
        cellStyle = wb.createCellStyle();
        // Excel?
        cellStyle.setDataFormat(dataFormat.getFormat("@"));
    }

    // sheet
    int sheetsCounts = wb.getNumberOfSheets();
    // ???sheet
    for (int i = 0; i < sheetsCounts; i++) {
        Sheet sheet = wb.getSheetAt(i);
        System.out.println("" + i + "sheet:" + sheet.toString());

        // sheetList
        List list = new LinkedList();

        // jsonkey
        String[] cellNames;
        // ?key
        Row fisrtRow = sheet.getRow(0);
        // sheet
        if (null == fisrtRow) {
            continue;
        }
        // 
        int curCellNum = fisrtRow.getLastCellNum();
        System.out.println("" + curCellNum);
        // ???
        cellNames = new String[curCellNum];
        // ????JSONkey
        for (int m = 0; m < curCellNum; m++) {
            Cell cell = fisrtRow.getCell(m);
            // ?
            cell.setCellStyle(cellStyle);
            cell.setCellType(Cell.CELL_TYPE_STRING);
            // ?
            cellNames[m] = getCellValue(cell);
        }
        for (String s : cellNames) {
            System.out.print("" + i + " sheet " + s + ",");
        }
        System.out.println();

        // ???
        int rowNum = sheet.getLastRowNum();
        System.out.println(" " + rowNum + " ");
        for (int j = 1; j < rowNum; j++) {
            // ?Map
            LinkedHashMap rowMap = new LinkedHashMap();
            // ??
            Row row = sheet.getRow(j);
            int cellNum = row.getLastCellNum();
            // ???
            for (int k = 0; k < cellNum; k++) {
                Cell cell = row.getCell(k);

                cell.setCellStyle(cellStyle);
                cell.setCellType(Cell.CELL_TYPE_STRING);
                // ???
                rowMap.put(cellNames[k], getCellValue(cell));
            }
            // ??List
            list.add(rowMap);
        }
        // sheet??keyListjson?Value
        excelMap.put(sheet.getSheetName(), JacksonUtil.bean2Json(list));
    }

    System.out.println("excel2json?....");

    return excelMap;
}

From source file:com.grarak.kerneladiutor.database.tools.profiles.ImportProfile.java

public LinkedHashMap<String, String> getResults() {
    LinkedHashMap<String, String> results = new LinkedHashMap<>();
    for (int i = 0; i < mCommands.length(); i++) {
        try {/*from w w  w  .  j  a  v  a  2  s .  c  om*/
            JSONObject command = mCommands.getJSONObject(i);
            results.put(command.getString("path"), command.getString("command"));
        } catch (JSONException ignored) {
        }
    }
    return results;
}