+/*
+ * Svjatoslav Commons - shared library of common functionality.
+ * Copyright ©2012-2014, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 3 of the GNU Lesser General Public License
+ * or later as published by the Free Software Foundation.
+ */
+
package eu.svjatoslav.commons.network.navigation;
import java.net.MalformedURLException;
try {
final String requestPath = new URL(requestUrl).getPath();
- for (final NavigationItem item : rootNavigationItem.subElements)
- if (item.matchesUrl(requestPath))
- return item;
+ final NavigationItem match = rootNavigationItem
+ .getMatchingNavigationItem(requestPath);
+
+ if (match != null)
+ return match;
} catch (final MalformedURLException e) {
System.out.println("Cannot handle URL: " + requestUrl);
e.printStackTrace();