All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.seekay.contract.model.tools.QueryParamTools Maven / Gradle / Ivy

The newest version!
package org.seekay.contract.model.tools;

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

public class QueryParamTools {

  /**
   * Private constructor for utility class
   */
  private QueryParamTools() {
    throw new IllegalStateException("Utility classes should never be constructed");
  }

  public static Map extractParameters(String path) {
    Map result = new HashMap();
    String[] pathChunks = path.split("\\?");
    if(pathChunks.length != 2) {
      return result;
    }
    String[] parameterChunks = pathChunks[1].split("&");
    for(String parameterChunk : parameterChunks) {
      String[] parameters = parameterChunk.split("=");
      if(parameters.length == 2) {
        result.put(parameters[0], parameters[1]);
      }
    }
    return result;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy