config-prettyfaces/src/main/java/com/ocpsoft/pretty/faces/url/URLPatternParser.java
public List<PathParameter> parse(final URL url)
   {
      List<PathParameter> result = new ArrayList<PathParameter>();

      String inboundUrl = url.toURL();
      if (this.matches(url))
      {
         Iterator<Segment> iter = pathSegments.iterator();
         while (iter.hasNext())
         {
            Segment segment = iter.next();

            String regex = "";
            if (url.hasLeadingSlash() && !"/".equals(url.toURL()))
            {
               regex += "/";
            }

            regex += segment.getRegex();
            if (iter.hasNext() || url.hasTrailingSlash())
            {
               regex += "/";
            }

            Matcher segmentMatcher = Pattern.compile(regex).matcher(inboundUrl);
            if (segmentMatcher.find())
            {
               for (int j = 0; j < segment.numParameters(); j++)
               {
                  String value = segmentMatcher.group(j + 1);
                  PathParameter param = segment.getParameter(j).copy();
                  param.setValue(value);
                  result.add(param);
               }

               int regionEnd = segmentMatcher.end();

               inboundUrl = inboundUrl.substring(regionEnd - 1);
            }
            else
            {
               throw new PrettyException("Error parsing url: <" + url
                        + ">, a parameter did not match compiled segment in pattern: " + originalPattern);
            }
         }
      }
      else
      {
         throw new IllegalArgumentException("The given URL: " + url + ", cannot be parsed by the pattern: "
                  + originalPattern);
      }
      return result;
   }
public List<PathParameter> parse(final URL url)
   {
      List<PathParameter> result = new ArrayList<PathParameter>();

      String inboundUrl = url.toURL();
      if (this.matches(url))
      {
         Iterator<Segment> iter = pathSegments.iterator();
         while (iter.hasNext())
         {
            Segment segment = iter.next();

            String regex = "";
            if (url.hasLeadingSlash() && !"/".equals(url.toURL()))
            {
               regex += "/";
            }

            regex += segment.getRegex();
            if (iter.hasNext() || url.hasTrailingSlash())
            {
               regex += "/";
            }

            Matcher segmentMatcher = Pattern.compile(regex).matcher(inboundUrl);
            if (segmentMatcher.find())
            {
               for (int j = 0; j < segment.numParameters(); j++)
               {
                  String value = segmentMatcher.group(j + 1);
                  PathParameter param = segment.getParameter(j).copy();
                  param.setValue(value);
                  result.add(param);
               }

               int regionEnd = segmentMatcher.end();

               inboundUrl = inboundUrl.substring(regionEnd - 1);
            }
            else
            {
               throw new PrettyException("Error parsing url: <" + url
                        + ">, a parameter did not match compiled segment in pattern: " + originalPattern);
            }
         }
      }
      else
      {
         throw new IllegalArgumentException("The given URL: " + url + ", cannot be parsed by the pattern: "
                  + originalPattern);
      }
      return result;
   }
public List < PathParameter > parse ( final URL url ) { List < PathParameter > result = new ArrayList < PathParameter > ( ) ; String inboundUrl = url . toURL ( ) ; if ( this . matches ( url ) ) { Iterator < Segment > iter = pathSegments . iterator ( ) ; while ( iter . hasNext ( ) ) { Segment segment = iter . next ( ) ; String regex = "" ; if ( url . hasLeadingSlash ( ) && ! "/" . equals ( url . toURL ( ) ) ) { regex += "/" ; } regex += segment . getRegex ( ) ; if ( iter . hasNext ( ) || url . hasTrailingSlash ( ) ) { regex += "/" ; } Matcher segmentMatcher = Pattern . compile ( regex ) . matcher ( inboundUrl ) ; if ( segmentMatcher . find ( ) ) { for ( int j = 0 ; j < segment . numParameters ( ) ; j ++ ) { String value = segmentMatcher . group ( j + 1 ) ; PathParameter param = segment . getParameter ( j ) . copy ( ) ; param . setValue ( value ) ; result . add ( param ) ; } int regionEnd = segmentMatcher . end ( ) ; inboundUrl = inboundUrl . substring ( regionEnd - 1 ) ; } else { throw new PrettyException ( "Error parsing url: <" + url + ">, a parameter did not match compiled segment in pattern: " + originalPattern ) ; } } } else { throw new IllegalArgumentException ( "The given URL: " + url + ", cannot be parsed by the pattern: " + originalPattern ) ; } return result ; }
Builds a list of PathParameters for this UrlPattern, extracted from the provided URL (assuming a match is found).
This list excludes duplicate named parameters.
Builds a list of PathParameters for this UrlPattern extracted from the provided URL ( assuming a match is found ) . This list excludes duplicate named parameters .