cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Homayoun Ashrafzade" <homayoon.ashrafza...@gmail.com>
Subject Re: svn commit: r558317 - in /cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src: main/java/org/apache/cocoon/objectmodel/ObjectModelImpl.java test/java/org/apache/cocoon/objectmodel/ObjectModelImplTestCase.java
Date Sat, 21 Jul 2007 15:01:40 GMT
please unsubscribe me ...thank you

On 7/21/07, gkossakowski@apache.org <gkossakowski@apache.org> wrote:
>
> Author: gkossakowski
> Date: Sat Jul 21 04:44:49 2007
> New Revision: 558317
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=558317
> Log:
> COCOON-2086:
>   * thanks to simplified ObjectModel interface it was possible to simplify
> ObjectModelImpl
>   * added test case for handling null values
>
> Modified:
>
>     cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/objectmodel/ObjectModelImpl.java
>
>     cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/java/org/apache/cocoon/objectmodel/ObjectModelImplTestCase.java
>
> Modified:
> cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/objectmodel/ObjectModelImpl.java
> URL:
> http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/objectmodel/ObjectModelImpl.java?view=diff&rev=558317&r1=558316&r2=558317
>
> ==============================================================================
> ---
> cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/objectmodel/ObjectModelImpl.java
> (original)
> +++
> cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/objectmodel/ObjectModelImpl.java
> Sat Jul 21 04:44:49 2007
> @@ -16,10 +16,8 @@
>   */
> package org.apache.cocoon.objectmodel;
>
> -import java.util.Collection;
> import java.util.HashMap;
> import java.util.Iterator;
> -import java.util.LinkedList;
> import java.util.ListIterator;
> import java.util.Map;
>
> @@ -67,7 +65,7 @@
>
>      public Object put(Object key, Object value) {
>          if (!localContexts.empty())
> -            ((Collection) localContexts.peek()).add(new
> DefaultKeyValue(key, value));
> +            ((ArrayStack) localContexts.peek()).push(new
> DefaultKeyValue(key, value));
>
>          singleValueMap.put(key, value);
>          multiValueMap.put(key, value);
> @@ -77,10 +75,10 @@
>
>      public void putAll(Map mapToCopy) {
>          if (!localContexts.empty()) {
> -            Collection entries = (Collection)localContexts.peek();
> +            ArrayStack entries = (ArrayStack)localContexts.peek();
>              for (Iterator keysIterator = mapToCopy.keySet().iterator();
> keysIterator.hasNext();) {
>                  Object key = keysIterator.next();
> -                entries.add(new DefaultKeyValue(key, mapToCopy.get
> (key)));
> +                entries.push(new DefaultKeyValue(key, mapToCopy.get
> (key)));
>              }
>          }
>
> @@ -91,25 +89,22 @@
>      public void cleanupLocalContext() {
>          if (localContexts.empty())
>              throw new IllegalStateException("Local contexts stack is
> empty");
> -        Collection removeEntries = (Collection)localContexts.pop();
> -        for (Iterator entriesIterator = removeEntries.iterator();
> entriesIterator.hasNext();) {
> -            KeyValue entry = (KeyValue)entriesIterator.next();
> +        ArrayStack removeEntries = (ArrayStack)localContexts.pop();
> +        while (!removeEntries.isEmpty()) {
> +            KeyValue entry = (KeyValue)removeEntries.pop();
>              Object key = entry.getKey();
>              Object value = entry.getValue();
> -            if (!singleValueMap.containsKey(key))
> -                continue;
>
>              multiValueMap.remove(key, value);
> -            if (!multiValueMap.containsKey(key)) {
> -                singleValueMap.remove(key);
> -            }
> -            else if (singleValueMap.get(key).equals(value))
> +            if (multiValueMap.containsKey(key))
>                  singleValueMap.put(key,
> ((StackReversedIteration)multiValueMap.get(key)).peek());
> +            else
> +                singleValueMap.remove(key);
>          }
>      }
>
>      public void markLocalContext() {
> -        localContexts.push(new LinkedList());
> +        localContexts.push(new ArrayStack());
>      }
>
> }
>
> Modified:
> cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/java/org/apache/cocoon/objectmodel/ObjectModelImplTestCase.java
> URL:
> http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/java/org/apache/cocoon/objectmodel/ObjectModelImplTestCase.java?view=diff&rev=558317&r1=558316&r2=558317
>
> ==============================================================================
> ---
> cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/java/org/apache/cocoon/objectmodel/ObjectModelImplTestCase.java
> (original)
> +++
> cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/java/org/apache/cocoon/objectmodel/ObjectModelImplTestCase.java
> Sat Jul 21 04:44:49 2007
> @@ -86,4 +86,23 @@
>          assertEquals(false, objectModel.containsKey("abc"));
>      }
>
> +    public void testNull() {
> +        ObjectModel objectModel = new ObjectModelImpl();
> +
> +        objectModel.markLocalContext();
> +        objectModel.put("foo", "bar");
> +
> +        objectModel.markLocalContext();
> +        objectModel.put("foo", null);
> +        objectModel.put("foo", null);
> +        assertEquals(null, objectModel.get("foo"));
> +        objectModel.cleanupLocalContext();
> +
> +        assertEquals("bar", objectModel.get("foo"));
> +        objectModel.cleanupLocalContext();
> +
> +        assertTrue(objectModel.isEmpty());
> +        assertTrue(objectModel.getAll().isEmpty());
> +    }
> +
> }
>
>
>

Mime
View raw message