cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1063207 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
Date Tue, 25 Jan 2011 10:22:11 GMT
Author: sergeyb
Date: Tue Jan 25 10:22:11 2011
New Revision: 1063207

URL: http://svn.apache.org/viewvc?rev=1063207&view=rev
Log:
Merged revisions 1063205 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1063205 | sergeyb | 2011-01-25 10:19:18 +0000 (Tue, 25 Jan 2011) | 1 line
  
  [CXF-3262] Applying a patch on behalf of Jason Downey, thanks
........

Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 25 10:22:11 2011
@@ -1 +1 @@
-/cxf/trunk:1063042
+/cxf/trunk:1063042,1063205

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java?rev=1063207&r1=1063206&r2=1063207&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
Tue Jan 25 10:22:11 2011
@@ -26,7 +26,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
 
 import javax.ws.rs.Path;
 import javax.ws.rs.core.MultivaluedMap;
@@ -351,11 +350,11 @@ public final class URITemplate {
             if (uriChunk == null || "".equals(uriChunk)) {
                 throw new IllegalArgumentException("uriChunk is empty");
             }
-            try {
-                return new Variable(uriChunk);
-            } catch (IllegalArgumentException e) {
-                return new Literal(uriChunk);
+            UriChunk uriChunkRepresentation = Variable.create(uriChunk);
+            if (uriChunkRepresentation == null) {
+                uriChunkRepresentation = Literal.create(uriChunk);
             }
+            return uriChunkRepresentation;
         }
 
         public abstract String getValue();
@@ -369,11 +368,17 @@ public final class URITemplate {
     private static final class Literal extends UriChunk {
         private String value;
 
-        public Literal(String uriChunk) {
+        private Literal() {
+            // empty constructor
+        }
+
+        public static Literal create(String uriChunk) {
             if (uriChunk == null || "".equals(uriChunk)) {
                 throw new IllegalArgumentException("uriChunk is empty");
             }
-            value = uriChunk;
+            Literal literal = new Literal();
+            literal.value = uriChunk;
+            return literal;
         }
 
         @Override
@@ -391,30 +396,34 @@ public final class URITemplate {
         private String name;
         private Pattern pattern;
 
+        private Variable() {
+            // empty constructor
+        }
+
         /**
          * Creates variable from stringified part of URI.
-         * 
-         * @param uriChunk chunk that depicts variable
-         * @throws IllegalArgumentException when param is null, empty or does not have variable
syntax.
-         * @throws PatternSyntaxException when pattern of variable has wrong syntax.
+         *
+         * @param uriChunk uriChunk chunk that depicts variable
+         * @return Variable if variable was successfully created; null if uriChunk was not
a variable
          */
-        public Variable(String uriChunk) throws IllegalArgumentException, PatternSyntaxException
{
+        public static Variable create(String uriChunk) {
+            Variable newVariable = new Variable();
             if (uriChunk == null || "".equals(uriChunk)) {
-                throw new IllegalArgumentException("uriChunk is empty");
+                return null;
             }
             if (CurlyBraceTokenizer.insideBraces(uriChunk)) {
                 uriChunk = CurlyBraceTokenizer.stripBraces(uriChunk).trim();
                 Matcher matcher = VARIABLE_PATTERN.matcher(uriChunk);
                 if (matcher.matches()) {
-                    name = matcher.group(1).trim();
+                    newVariable.name = matcher.group(1).trim();
                     if (matcher.group(2) != null && matcher.group(3) != null) {
                         String patternExpression = matcher.group(3).trim();
-                        pattern = Pattern.compile(patternExpression);
+                        newVariable.pattern = Pattern.compile(patternExpression);
                     }
-                    return;
+                    return newVariable;
                 }
             }
-            throw new IllegalArgumentException("not a variable syntax");
+            return null;
         }
 
         public String getName() {



Mime
View raw message