/** Converts the portion of ViewParameters that will be rendered into URL * attributes into name/value pairs as a Map. * @param vsh The ViewStateHandler encoding URL information * @param viewparams The ViewParameters object to be encoded * @return A map of String to String holding the key/value pairs. */ public static Map viewParamsToMap(ViewStateHandler vsh, ViewParameters viewparams) { String fullURL = vsh.getFullURL(viewparams); int qpos = fullURL.indexOf('?'); HashMap togo = new HashMap(); return URLUtil.paramsToMap(fullURL.substring(qpos + 1), togo); }
/** Parse a "reduced URL" (as often seen in serialized component trees and * the like) into a full ViewParameters object. */ public static ViewParameters parse(ViewParametersParser parser, String reducedURL) { int qpos = reducedURL.indexOf('?'); String pathinfo = qpos == -1? reducedURL : reducedURL.substring(0, qpos); HashMap params = new HashMap(); if (qpos != -1) { URLUtil.paramsToMap(reducedURL.substring(qpos + 1), params); } String[] paths = URLUtil.splitPathInfo(pathinfo); return parser.parse(paths, params); }