upayavira    2004/04/14 02:39:45

  Modified:    src/java/org/apache/cocoon/components/treeprocessor/variables
                        PreparedVariableResolver.java
               src/test/org/apache/cocoon/components/treeprocessor/variables
                        PreparedVariableResolverTestCase.java
  Log:
  Fixing case were a colon occurs as a single text character, not a token, e.g: 
{1}:{1}
  As reported by Christian Mayrhuber on user list
  
  Revision  Changes    Path
  1.8       +3 -12     
cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolver.java
  
  Index: PreparedVariableResolver.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolver.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PreparedVariableResolver.java     4 Apr 2004 06:38:16 -0000       1.7
  +++ PreparedVariableResolver.java     14 Apr 2004 09:39:45 -0000      1.8
  @@ -418,17 +418,8 @@
           }
   
           public Token(String value) {
  -            this.value = null;
  -            if (value.equals("{")) {
  -                this.type = OPEN;
  -            } else if (value.equals("}")) {
  -                this.type = CLOSE;
  -            } else if (value.equals(":")) {
  -                this.type = COLON;
  -            } else {
  -                this.type = TEXT;
  -                this.value = value;
  -            }
  +            this.type = TEXT;
  +            this.value = value;
           }
         
           public int getType() {
  
  
  
  1.4       +17 -1     
cocoon-2.1/src/test/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolverTestCase.java
  
  Index: PreparedVariableResolverTestCase.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/test/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolverTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PreparedVariableResolverTestCase.java     4 Apr 2004 06:38:16 -0000       
1.3
  +++ PreparedVariableResolverTestCase.java     14 Apr 2004 09:39:45 -0000      
1.4
  @@ -187,6 +187,21 @@
           assertEquals(":colon-starts-this", resolver.resolve(context, 
getObjectModel()));
       }
       
  +    public void testEmbeddedColon() throws PatternException {
  +        String expr = "{1}:{1}";
  +        
  +        InvokeContext context = new InvokeContext(true);
  +        context.enableLogging(new LogKitLogger(getLogger()));
  +
  +        Map sitemapElements;
  +        sitemapElements = new HashMap();
  +        sitemapElements.put("1", "abc");
  +        context.pushMap("label", sitemapElements);
  +        
  +        PreparedVariableResolver resolver = new 
PreparedVariableResolver(expr, manager);
  +        assertEquals("abc:abc", resolver.resolve(context, getObjectModel()));
  +    }
  +
       public void testEscapedBraces() throws PatternException {
           String expr = "This is a \\{brace\\}";
           
  @@ -200,4 +215,5 @@
           PreparedVariableResolver resolver = new 
PreparedVariableResolver(expr, manager);
           assertEquals("This is a {brace}", resolver.resolve(context, 
getObjectModel()));
       }
  +
   }
  
  
  

Reply via email to