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.logsniffer.reader.log4j.Log4jTextReader.java

@Override
public LinkedHashMap<String, FieldBaseTypes> getFieldTypes() throws FormatException {
    init();//w w w.  java 2 s . co  m
    final LinkedHashMap<String, FieldBaseTypes> types = super.getFieldTypes();
    if (timeSpecifier != null) {
        types.put(LogEntry.FIELD_TIMESTAMP, FieldBaseTypes.DATE);
    }
    if (levelSpecifier != null) {
        types.put(LogEntry.FIELD_SEVERITY_LEVEL, FieldBaseTypes.SEVERITY);
    }
    return types;
}

From source file:org.jamwiki.servlets.CategoryServlet.java

/**
 *
 *///w  w  w . j a v a  2  s . com
private void viewCategories(HttpServletRequest request, ModelAndView next, WikiPageInfo pageInfo)
        throws Exception {
    String virtualWiki = pageInfo.getVirtualWikiName();
    Pagination pagination = ServletUtil.loadPagination(request, next);
    List<Category> categoryObjects = WikiBase.getDataHandler().getAllCategories(virtualWiki, pagination);
    LinkedHashMap<String, String> categories = new LinkedHashMap<String, String>();
    for (Category category : categoryObjects) {
        String key = category.getName();
        String value = key.substring(Namespace.namespace(Namespace.CATEGORY_ID).getLabel(virtualWiki).length()
                + Namespace.SEPARATOR.length());
        categories.put(key, value);
    }
    next.addObject("categoryCount", categories.size());
    next.addObject("categories", categories);
    if (categories.isEmpty()) {
        pageInfo.addMessage(new WikiMessage("allcategories.message.none"));
    }
    pageInfo.setPageTitle(new WikiMessage("allcategories.title"));
    pageInfo.setContentJsp(JSP_CATEGORIES);
    pageInfo.setSpecial(true);
}

From source file:com.intel.iotkitlib.LibModules.DeviceManagement.DeviceManagement.java

public boolean getInfoOnDevice(String deviceId) {
    //initiating get for device info
    HttpGetTask getDeviceDetails = new HttpGetTask(new HttpTaskHandler() {
        @Override/*ww  w . jav  a 2 s  .c  o  m*/
        public void taskResponse(int responseCode, String response) {
            Log.d(TAG, String.valueOf(responseCode));
            Log.d(TAG, response);
            statusHandler.readResponse(responseCode, response);
        }
    });
    getDeviceDetails.setHeaders(basicHeaderList);
    LinkedHashMap<String, String> linkedHashMap = new LinkedHashMap<String, String>();
    linkedHashMap.put("other_device_id", deviceId);
    String url = objIotKit.prepareUrl(objIotKit.getOneDeviceInfo, linkedHashMap);
    return super.invokeHttpExecuteOnURL(url, getDeviceDetails, "other device info");
}

From source file:com.intel.iotkitlib.LibModules.DeviceManagement.DeviceManagement.java

public boolean deleteADevice(String deviceId) {
    //initiating delete of device
    HttpDeleteTask deleteADevice = new HttpDeleteTask(new HttpTaskHandler() {
        @Override//from  w  ww  .j a v a2  s .  c o m
        public void taskResponse(int responseCode, String response) {
            Log.d(TAG, String.valueOf(responseCode));
            Log.d(TAG, response);
            statusHandler.readResponse(responseCode, response);
        }
    });
    deleteADevice.setHeaders(basicHeaderList);
    LinkedHashMap<String, String> linkedHashMap = new LinkedHashMap<String, String>();
    linkedHashMap.put("other_device_id", deviceId);
    String url = objIotKit.prepareUrl(objIotKit.deleteDevice, linkedHashMap);
    return super.invokeHttpExecuteOnURL(url, deleteADevice, "delete device");
}

From source file:com.intel.iotkitlib.LibModules.DeviceManagement.DeviceManagement.java

public boolean deleteAComponent(final String componentName) {
    //initiating delete of component
    HttpDeleteTask deleteComponent = new HttpDeleteTask(new HttpTaskHandler() {
        @Override// ww w.  java 2s .c  o m
        public void taskResponse(int responseCode, String response) {
            Log.d(TAG, String.valueOf(responseCode));
            Log.d(TAG, response);
            DeviceToken.deleteTheComponentFromStorage(componentName, responseCode);
            statusHandler.readResponse(responseCode, response);
        }
    });
    deleteComponent.setHeaders(basicHeaderList);
    LinkedHashMap<String, String> linkedHashMap = new LinkedHashMap<String, String>();
    linkedHashMap.put("cname", componentName);
    String url = objIotKit.prepareUrl(objIotKit.deleteComponent, linkedHashMap);
    return super.invokeHttpExecuteOnURL(url, deleteComponent, "delete  a component");
}

From source file:com.opengamma.analytics.financial.provider.sensitivity.multicurve.MultipleCurrencyParameterSensitivity.java

/**
 * Create a copy of the sensitivity and add a given named sensitivity to it. If the name / currency pair is in the map, the two sensitivity matrices are added.
 * Otherwise, a new entry is put into the map
 * @param nameCcy The name and the currency, not null
 * @param sensitivity The sensitivity to add, not null
 * @return The total sensitivity.//from  w ww.j a va2  s.c o m
 */
public MultipleCurrencyParameterSensitivity plus(final Pair<String, Currency> nameCcy,
        final DoubleMatrix1D sensitivity) {
    ArgumentChecker.notNull(nameCcy, "Name/currency");
    ArgumentChecker.notNull(sensitivity, "Matrix");
    final MatrixAlgebra algebra = MatrixAlgebraFactory.COMMONS_ALGEBRA;
    final LinkedHashMap<Pair<String, Currency>, DoubleMatrix1D> result = new LinkedHashMap<>();
    result.putAll(_sensitivity);
    if (result.containsKey(nameCcy)) {
        result.put(nameCcy, (DoubleMatrix1D) algebra.add(result.get(nameCcy), sensitivity));
    } else {
        result.put(nameCcy, sensitivity);
    }
    return new MultipleCurrencyParameterSensitivity(result);
}

From source file:de.qucosa.dissemination.epicur.servlet.EpicurDisseminationServlet.java

private Map<String, String> decodeSubstitutions(String parameterValue) {
    LinkedHashMap<String, String> result = new LinkedHashMap<>();
    if (parameterValue != null && !parameterValue.isEmpty()) {
        for (String substitution : parameterValue.split(";")) {
            String[] s = substitution.split("=");
            result.put(s[0].trim(), s[1].trim());
        }/*from   w  ww.  j a  v a 2 s . com*/
    }
    return result;
}

From source file:com.epam.dlab.core.parser.CommonFormat.java

/**
 * Creates and returns the line of billing report from the list of values.
 *
 * @param row the list of values./* w w w. j ava 2s.  co m*/
 * @return the line of billing report.
 * @throws ParseException
 */
public ReportLine toReportLine(List<String> row) throws ParseException {
    if (row.size() < ColumnMeta.TAG_COLUMN_INDEX || row.size() > columnMeta.getTargetColumnNames().size()) {
        throw new ParseException(
                "Invalid the number of columns in list: expected from " + ColumnMeta.TAG_COLUMN_INDEX + " to "
                        + columnMeta.getTargetColumnNames().size() + ", actual " + row.size());
    }
    ReportLine line = new ReportLine();
    int i = 0;

    line.setDlabId(row.get(i));
    line.setUser(row.get(++i));
    line.setUsageDate(row.get(++i));
    line.setProduct(row.get(++i));
    line.setUsageType(row.get(++i));
    line.setUsage(parseDouble("usage", row.get(++i)));
    line.setCost(parseDouble("cost", row.get(++i)));
    line.setCurrencyCode(row.get(++i));
    line.setResourceTypeId(row.get(++i));

    if (row.size() >= ColumnMeta.TAG_COLUMN_INDEX) {
        LinkedHashMap<String, String> tags = new LinkedHashMap<>();
        i++;
        while (i < row.size()) {
            tags.put(columnMeta.getTargetColumnNames().get(i), row.get(i++));
        }
        line.setTags(tags);
    }

    return line;
}

From source file:com.exalttech.trex.util.PacketUtil.java

/**
 * Create vm instruction/*www  .  j  ava  2 s  .  c o m*/
 *
 * @param packetData
 * @return vm instruction
 */
public Map<String, Object> getVm(PacketData packetData) {
    VMInstructionBuilder vmInstructionBuilder = new VMInstructionBuilder(packetData.isTaggedVlan(),
            packetData.getUdpData().isEnable());
    ArrayList<Object> instructionsList = new ArrayList<>();

    // add VM instructions
    EthernetData ethernetData = packetData.getEthernetData();
    instructionsList.addAll(vmInstructionBuilder.addVmInstruction(VMInstructionBuilder.InstructionType.MAC_DST,
            ethernetData.getDstAddress().getType(), ethernetData.getDstAddress().getCount(),
            ethernetData.getDstAddress().getStep(), ethernetData.getDstAddress().getAddress()));
    instructionsList.addAll(vmInstructionBuilder.addVmInstruction(VMInstructionBuilder.InstructionType.MAC_SRC,
            ethernetData.getSrcAddress().getType(), ethernetData.getSrcAddress().getCount(),
            ethernetData.getSrcAddress().getStep(), ethernetData.getSrcAddress().getAddress()));

    IPV4Data ipv4Data = packetData.getIpv4Data();
    instructionsList.addAll(vmInstructionBuilder.addVmInstruction(VMInstructionBuilder.InstructionType.IP_DST,
            ipv4Data.getDstAddress().getType(), ipv4Data.getDstAddress().getCount(), "1",
            ipv4Data.getDstAddress().getAddress()));
    instructionsList.addAll(vmInstructionBuilder.addVmInstruction(VMInstructionBuilder.InstructionType.IP_SRC,
            ipv4Data.getSrcAddress().getType(), ipv4Data.getSrcAddress().getCount(), "1",
            ipv4Data.getSrcAddress().getAddress()));
    // add ipv4 checksum instructions
    instructionsList.addAll(vmInstructionBuilder.addChecksumInstruction());
    // add packet length instruction
    PacketLength packetLength = packetData.getPacketLength();
    instructionsList.addAll(vmInstructionBuilder.getPacketLenVMInstruction("pkt_len",
            packetLength.getLengthType(), String.valueOf(packetLength.getMinLength()),
            String.valueOf(packetLength.getMaxLength()), packetData.isTaggedVlan()));

    Map<String, Object> additionalProperties = new HashMap<>();

    LinkedHashMap<String, Object> vmBody = new LinkedHashMap<>();
    vmBody.put("split_by_var", vmInstructionBuilder.getSplitByVar());
    vmBody.put("instructions", instructionsList);

    // add cache size
    vmInstructionBuilder.addCacheSize(vmBody);

    additionalProperties.put("vm", vmBody);

    return additionalProperties;
}

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

private Map<String, Object> getDeadLockThreadInformation(ThreadMXBean threadMXBean) {
    LinkedHashMap<String, Object> json = new LinkedHashMap<>();
    long[] deadlockedThreads = threadMXBean.findDeadlockedThreads();

    if (deadlockedThreads != null && deadlockedThreads.length > 0) {
        json.put("Count", deadlockedThreads.length);
        for (long deadlockedThread : deadlockedThreads) {
            LinkedHashMap<String, Object> threadsInfo = new LinkedHashMap<>();
            LinkedHashMap<String, Object> lockedMonitorsInfo = new LinkedHashMap<>();
            LinkedHashMap<String, Object> stackTrackInfo = new LinkedHashMap<>();
            ThreadInfo threadInfo = threadMXBean.getThreadInfo(deadlockedThread);
            LockInfo lockInfo = threadInfo.getLockInfo();
            if (lockInfo != null) {
                threadsInfo.put(threadInfo.getThreadName(), lockInfo);
            } else {
                threadsInfo.put(threadInfo.getThreadName(), "This thread is not waiting for any locks");
            }/* ww  w  . j a  v  a2s  .  c o  m*/
            MonitorInfo[] lockedMonitors = threadInfo.getLockedMonitors();
            for (MonitorInfo lockedMonitor : lockedMonitors) {
                lockedMonitorsInfo.put("Monitor for class " + lockedMonitor.getClassName(),
                        "taken at stack frame " + lockedMonitor.getLockedStackFrame());
            }
            stackTrackInfo.put(Long.toString(deadlockedThread), Arrays.toString(threadInfo.getStackTrace()));
            json.put("Thread Information", threadsInfo);
            json.put("Monitor Information Stack Frame where locks were taken", lockedMonitorsInfo);
            json.put("Stack Trace Of DeadLock Threads", stackTrackInfo);
        }
    }
    return json;
}