Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.util.SparseArray;

import java.util.Map;

public class Main {
    public static String mergeUri(String uri, Object[] args, SparseArray<String> paramKeys,
            Map<String, String> methodStaticUri, Map<String, String> globalParamKeys) {

        if (paramKeys != null && paramKeys.size() > 0 && args != null && args.length > 0) {
            for (int i = 0, key = paramKeys.keyAt(i); i < paramKeys.size(); key = paramKeys.keyAt(++i)) {
                uri = uri.replaceFirst(":" + paramKeys.get(key), String.valueOf(args[key]));
            }
        }
        if (methodStaticUri != null && methodStaticUri.size() > 0) {
            for (Map.Entry<String, String> e : methodStaticUri.entrySet()) {
                uri = uri.replaceFirst(":" + e.getKey(), e.getValue());
            }
        }
        if (globalParamKeys != null && globalParamKeys.size() > 0) {
            for (Map.Entry<String, String> e : globalParamKeys.entrySet()) {
                uri = uri.replaceFirst(":" + e.getKey(), e.getValue());
            }
        }

        return uri;
    }
}