Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

import org.w3c.dom.Node;

import java.util.HashMap;
import java.util.Map;

public class Main {
    /**
     * Extracts a {@code Map} of header tag to value from the header node.
     *
     * @param headerNode the header node
     * @return a {@code Map} of header tag to value from the header node.
     */
    public static Map<String, String> extractHeaderMap(Node headerNode) {
        Map<String, String> headerMap = new HashMap<String, String>();
        for (int i = 0; i < headerNode.getChildNodes().getLength(); i++) {
            Node headerChildNode = headerNode.getChildNodes().item(i);
            headerMap.put(headerChildNode.getLocalName(), headerChildNode.getFirstChild().getNodeValue());
        }
        return headerMap;
    }
}