001
014
015 package com.liferay.portlet;
016
017 import com.liferay.portal.kernel.portlet.Route;
018 import com.liferay.portal.kernel.portlet.Router;
019
020 import java.util.ArrayList;
021 import java.util.List;
022 import java.util.Map;
023
024
028 public class RouterImpl implements Router {
029
030 @Override
031 public Route addRoute(String pattern) {
032 Route route = new RouteImpl(pattern);
033
034 _routes.add(route);
035
036 return route;
037 }
038
039 @Override
040 public String parametersToUrl(Map<String, String> parameters) {
041 for (Route route : _routes) {
042 String url = route.parametersToUrl(parameters);
043
044 if (url != null) {
045 return url;
046 }
047 }
048
049 return null;
050 }
051
052 @Override
053 public boolean urlToParameters(String url, Map<String, String> parameters) {
054 for (Route route : _routes) {
055 if (route.urlToParameters(url, parameters)) {
056 return true;
057 }
058 }
059
060 return false;
061 }
062
063 private List<Route> _routes = new ArrayList<Route>();
064
065 }