- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 06 Aug 2009 12:46:51 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/route In directory hutz:/tmp/cvs-serv2800/src/org/w3c/unicorn/route Added Files: Tag: dev2 RouteParser.java Log Message: w3 => w3c --- NEW FILE: RouteParser.java --- package org.w3c.unicorn.route; import java.net.MalformedURLException; import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; import javax.servlet.http.HttpServletRequest; import org.apache.log4j.Logger; import org.w3.unicorn.route.Route; public class RouteParser { private static Logger logger = Logger.getLogger("RouteParser"); private static List<Route> routeList = new ArrayList<Route>(); private static Route index; private static Route error404; public static Route getRoute(HttpServletRequest request) throws MalformedURLException { logger.debug("Received request: " + request.getPathInfo()); String pathInfo = request.getPathInfo(); if(pathInfo.equals("") || pathInfo.equals("/")) { logger.debug("Found coresponding action: " + index.getAction()); return index; } for(Route route : routeList) { for (String patternString : route.getPatternList()) { Pattern pattern = Pattern.compile(patternString); logger.debug("Trying to match with pattern: " + patternString); if (pattern.matcher(pathInfo).matches()) { logger.debug("> Matched."); logger.debug("Found coresponding action: " + route.getAction()); return route; } } } logger.debug("Found coresponding action: " + error404.getAction()); return error404; } public static List<Route> getRouteList() { return routeList; } public static void setRouteList(List<Route> routeList) { RouteParser.routeList = routeList; } public static Route getIndex() { return index; } public static void setIndex(Route index) { RouteParser.index = index; } public static Route getError404() { return error404; } public static void setError404(Route error404) { RouteParser.error404 = error404; } }
Received on Thursday, 6 August 2009 12:47:01 UTC