Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.Map;
import java.util.Map.Entry;

public class Main {
    public static String serializeNamespaces(Map<String, String> namespaces) {
        String serialization = "";
        for (Entry<String, String> entry : namespaces.entrySet()) {
            String localPart = entry.getKey();
            String namespace = localPart.isEmpty() ? "xmlns" : ("xmlns:" + localPart);
            serialization = concatKeyValue(serialization, namespace, entry.getValue());
        }
        return serialization;
    }

    public static String concatKeyValue(String baseString, String key, String value) {
        return baseString + " " + serializeKeyValue(key, value);
    }

    private static String serializeKeyValue(String key, String value) {
        return key + "=\"" + value + "\"";
    }
}