abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1220676 - in /abdera/abdera2: activities/src/main/java/org/apache/abdera2/activities/model/objects/ activities/src/main/java/org/apache/abdera2/activities/protocol/ activities/src/main/java/org/apache/abdera2/activities/protocol/managed/ c...
Date Mon, 19 Dec 2011 10:03:10 GMT
Author: jmsnell
Date: Mon Dec 19 10:03:09 2011
New Revision: 1220676

URL: http://svn.apache.org/viewvc?rev=1220676&view=rev
Log:
code quality, efficiency and consistency updates...

Added:
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/ArrayBuilder.java   (with props)
Modified:
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TaskObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/VersionObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesCollectionAdapter.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesProvider.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesWorkspaceProvider.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/ProtocolException.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/managed/AbstractServerConfiguration.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/geo/Point.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/CacheControl.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/io/CharsetSniffingInputStream.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/lang/Lang.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/lang/SubtagSet.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractBaseRequestContext.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractCollectionAdapter.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractMessage.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BasicCollectionInfo.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BasicWorkspaceInfo.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/MethodOverrideFilter.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ProviderHelper.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RegexTargetResolver.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestProcessor.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestTemplateContext.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/AbderaAsyncService.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/Route.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMCollection.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMDocument.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/AbstractParseFilter.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/AbstractSetParseFilter.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/CompoundParseFilter.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/WhiteListParseFilter.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractEntityCollectionAdapter.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/SimpleCategoriesInfo.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/SimpleCategoryInfo.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/SimpleCollectionInfo.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/ServiceRequestProcessor.java

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TaskObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TaskObject.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TaskObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TaskObject.java Mon Dec 19 10:03:09 2011
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
 package org.apache.abdera2.activities.model.objects;
 
 import java.util.Map;

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/VersionObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/VersionObject.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/VersionObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/VersionObject.java Mon Dec 19 10:03:09 2011
@@ -57,7 +57,7 @@ public class VersionObject 
   public static VersionObject makeVersion(Version version) {
     return makeVersion()
       .of(
-        ASObject.makeObject()
+        makeObject()
           .displayName(version.name())
           .url(version.uri())
           .get())

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesCollectionAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesCollectionAdapter.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesCollectionAdapter.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesCollectionAdapter.java Mon Dec 19 10:03:09 2011
@@ -24,7 +24,6 @@ import org.apache.abdera2.activities.mod
 import org.apache.abdera2.activities.model.ASObject;
 import org.apache.abdera2.activities.model.Collection;
 import org.apache.abdera2.activities.model.Collection.CollectionBuilder;
-import org.apache.abdera2.activities.model.objects.PersonObject;
 import org.apache.abdera2.activities.model.objects.ServiceObject;
 import org.apache.abdera2.common.misc.ExceptionHelper;
 import org.apache.abdera2.common.protocol.AbstractCollectionAdapter;
@@ -35,6 +34,9 @@ import org.apache.abdera2.common.protoco
 import org.apache.abdera2.common.protocol.ResponseContextException;
 
 import static org.apache.abdera2.activities.protocol.AbstractActivitiesProvider.*;
+import static org.apache.abdera2.activities.model.objects.PersonObject.makePerson;
+import static org.apache.abdera2.activities.model.objects.ServiceObject.makeService;
+import static org.apache.abdera2.activities.model.Collection.makeCollection;
 
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
@@ -84,15 +86,12 @@ public abstract class AbstractActivities
     RequestContext request) 
       throws ResponseContextException {
     return 
-      ServiceObject
-        .makeService()
+      makeService()
         .displayName(getTitle(request))
         .id(getId(request))
         .author(
-          PersonObject
-            .makePerson()
-            .displayName(getAuthor(request))
-            .get())
+          makePerson()
+            .displayName(getAuthor(request)))
         .get();
   }
   
@@ -103,15 +102,12 @@ public abstract class AbstractActivities
     RequestContext request) 
       throws ResponseContextException {
     return 
-      Collection
-        .makeCollection()
+      makeCollection()
         .id(getId(request))
         .updatedNow()
         .author( 
-          PersonObject
-            .makePerson()
-            .displayName(getAuthor(request))
-            .get())
+          makePerson()
+            .displayName(getAuthor(request)))
         .displayName(getTitle(request))
         .get();
   }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesProvider.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesProvider.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesProvider.java Mon Dec 19 10:03:09 2011
@@ -32,8 +32,8 @@ import org.apache.abdera2.activities.mod
 import org.apache.abdera2.activities.model.IO;
 import org.apache.abdera2.activities.model.TypeAdapter;
 import org.apache.abdera2.activities.model.objects.ErrorObject;
-import org.apache.abdera2.common.date.DateTimes;
 import org.apache.abdera2.common.http.EntityTag;
+import org.apache.abdera2.common.misc.ArrayBuilder;
 import org.apache.abdera2.common.misc.ExceptionHelper;
 import org.apache.abdera2.common.protocol.AbstractProvider;
 import org.apache.abdera2.common.protocol.CollectionRequestProcessor;
@@ -44,6 +44,11 @@ import org.apache.abdera2.common.protoco
 import org.apache.abdera2.common.protocol.WorkspaceManager;
 import org.apache.abdera2.common.protocol.RequestContext.Scope;
 import org.joda.time.DateTime;
+import static org.apache.abdera2.activities.model.objects.ErrorObject.makeError;
+import static org.apache.abdera2.common.date.DateTimes.format;
+import static org.apache.abdera2.common.date.DateTimes.formatNow;
+import static org.apache.abdera2.common.http.EntityTag.generate;
+import static java.util.UUID.randomUUID;
 
 public abstract class AbstractActivitiesProvider 
   extends AbstractProvider
@@ -86,8 +91,7 @@ public abstract class AbstractActivities
     Throwable t) {
       return
         new ActivitiesResponseContext<ErrorObject>(
-            ErrorObject
-            .makeError()
+          makeError()
             .code(code)
             .displayName(message))
         .setStatus(code)
@@ -100,25 +104,25 @@ public abstract class AbstractActivities
     if (base instanceof Activity) {
         Activity ac = (Activity)base;
         id = ac.getId();
-        modified = DateTimes.format(
+        modified = format(
           ac.getUpdated() != null ? 
             ac.getUpdated() : 
             ac.getPublished());
     } else if (base instanceof Collection) {
         Collection<?> col = (Collection<?>)base;
         id = col.getProperty("id");
-        if (id == null) id = java.util.UUID.randomUUID().toString();
+        if (id == null) id = randomUUID().toString();
         modified = col.getProperty("updated");
     } else if (base instanceof ASObject) {
         ASObject as = (ASObject)base;
         id = as.getId().toString();
-        modified = DateTimes.format(
+        modified = format(
           as.getUpdated() != null ? 
             as.getUpdated() : 
             as.getPublished());
     }
-    if (modified == null) modified = DateTimes.formatNow();
-    return EntityTag.generate(id, modified);
+    if (modified == null) modified = formatNow();
+    return generate(id, modified);
   }
   
   public static String getEditUriFromEntry(ASObject object) {
@@ -126,16 +130,14 @@ public abstract class AbstractActivities
     return editLink;
   }
   
-  
-  
   public static IO getIO(
     ActivitiesProvider provider, 
     TypeAdapter<?>... adapters) {
-    Set<TypeAdapter<?>> as = 
-      new HashSet<TypeAdapter<?>>(provider.getTypeAdapters());
-    for (TypeAdapter<?> ta : adapters)
-      as.add(ta);
-    return IO.get(as.toArray(new TypeAdapter[as.size()]));
+    return IO.get(
+      ArrayBuilder.<TypeAdapter<?>>set(TypeAdapter.class)
+        .addAll(provider.getTypeAdapters())
+        .add(adapters)
+        .build());
   }
   
   @SuppressWarnings("unchecked")
@@ -143,7 +145,7 @@ public abstract class AbstractActivities
     RequestContext context) 
       throws IOException {
     ASBase entity = context.getAttribute(Scope.REQUEST, ASBase.class.getName());
-      try {
+    try {
       if (entity == null) {
         Reader reader = context.getReader();
         IO io = getIO(context.<ActivitiesProvider>getProvider());
@@ -152,9 +154,9 @@ public abstract class AbstractActivities
         else // try input stream, but this should've worked
           entity = io.read(context.getInputStream(), "UTF-8");
       }
-      } catch (Throwable t) {
-        throw ExceptionHelper.propogate(t);
-      }
+    } catch (Throwable t) {
+      throw ExceptionHelper.propogate(t);
+    }
     if (entity != null)
       context.setAttribute(ASBase.class.getName(), getDoc(entity,context));
     return (T)entity;
@@ -165,19 +167,19 @@ public abstract class AbstractActivities
       ASDocument.make(base);
     String etag = context.getHeader("ETag");
     if (etag != null)
-        builder.entityTag(etag);
+      builder.entityTag(etag);
     DateTime lm = context.getDateHeader("Last-Modified");
     if (lm != null)
-        builder.lastModified(lm);
+      builder.lastModified(lm);
     MimeType mt = context.getContentType();
     if (mt != null)
-        builder.contentType(mt.toString());
+      builder.contentType(mt.toString());
     String language = context.getContentLanguage();
     if (language != null)
-        builder.language(language);
+      builder.language(language);
     String slug = context.getSlug();
     if (slug != null)
-        builder.slug(slug);
+      builder.slug(slug);
     return builder.get();
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesWorkspaceProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesWorkspaceProvider.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesWorkspaceProvider.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesWorkspaceProvider.java Mon Dec 19 10:03:09 2011
@@ -33,6 +33,7 @@ import org.apache.abdera2.common.protoco
 import org.apache.abdera2.common.protocol.ResponseContext;
 import org.apache.abdera2.common.protocol.TargetType;
 import org.apache.abdera2.common.protocol.WorkspaceManager;
+import static org.apache.abdera2.activities.model.objects.ErrorObject.makeError;
 
 import com.google.common.base.Predicate;
 
@@ -85,8 +86,7 @@ public abstract class AbstractActivities
     Throwable t) {
       return 
         new ActivitiesResponseContext<ErrorObject>(
-          ErrorObject
-            .makeError()
+          makeError()
             .code(code)
             .displayName(message))
         .setStatus(code)

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/ProtocolException.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/ProtocolException.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/ProtocolException.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/ProtocolException.java Mon Dec 19 10:03:09 2011
@@ -20,6 +20,8 @@ package org.apache.abdera2.activities.pr
 import org.apache.abdera2.activities.model.objects.ErrorObject;
 import org.apache.abdera2.common.misc.MoreFunctions;
 
+import static org.apache.abdera2.activities.model.objects.ErrorObject.makeError;
+
 public class ProtocolException extends RuntimeException {
 
     private static final long serialVersionUID = 1017447143200419489L;
@@ -32,8 +34,8 @@ public class ProtocolException extends R
 
     public ProtocolException(int code, String message) {
         super(String.format("%d::%s",code,message));
-        this.error = ErrorObject
-          .makeError()
+        this.error = 
+          makeError()
             .code(code)
             .displayName(message)
           .get();
@@ -64,12 +66,12 @@ public class ProtocolException extends R
         String omessage = other.error != null ? other.error.getDisplayName() : null;
         int ocode = other.error != null ? other.error.getCode() : 0;
         if (message == null) {
-            if (omessage != null)
-                return false;
-        } else if (!message.equals(omessage))
+          if (omessage != null)
             return false;
+        } else if (!message.equals(omessage))
+          return false;
         if (code != ocode)
-            return false;
+          return false;
         return true;
     }
 

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/managed/AbstractServerConfiguration.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/managed/AbstractServerConfiguration.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/managed/AbstractServerConfiguration.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/managed/AbstractServerConfiguration.java Mon Dec 19 10:03:09 2011
@@ -65,10 +65,9 @@ public abstract class AbstractServerConf
         StringBuilder buf = new StringBuilder();
         buf.append(secure ? "https://" : "http://");
         buf.append(host);
-        if (port != 80) {
-            buf.append(":");
-            buf.append(port);
-        }
+        if (port != 80)
+          buf.append(":")
+             .append(port);
         return buf.toString();
     }
 

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/geo/Point.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/geo/Point.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/geo/Point.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/geo/Point.java Mon Dec 19 10:03:09 2011
@@ -59,7 +59,7 @@ public class Point extends Position {
   
     public static class Builder extends Position.Builder<Point> {
 
-      private Coordinate coordinate;
+      Coordinate coordinate;
       
       public Builder at(Coordinate coordinate) {
         this.coordinate = coordinate;
@@ -91,7 +91,7 @@ public class Point extends Position {
 
     private final Coordinate coordinate;
 
-    private Point(Builder builder) {
+    Point(Builder builder) {
       super(builder);
       this.coordinate = builder.coordinate;
     }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/CacheControl.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/CacheControl.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/CacheControl.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/CacheControl.java Mon Dec 19 10:03:09 2011
@@ -280,17 +280,17 @@ public final class CacheControl implemen
                           REVALIDATE = 32,
                           PROXYREVALIDATE = 64,
                           ONLYIFCACHED = 128;
-  private final int flags;
-  private final Iterable<String> 
+  final int flags;
+  final Iterable<String> 
     nocache_headers,
     private_headers;
-  private final long max_age,
+  final long max_age,
                  max_stale,
                  min_fresh,
                  smax_age,
                  staleiferror,
                  stalewhilerevalidate;
-  private final ImmutableMap<String,Object> exts;
+  final ImmutableMap<String,Object> exts;
   
   CacheControl(Builder builder) {
     this.flags = builder.flags;

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/io/CharsetSniffingInputStream.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/io/CharsetSniffingInputStream.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/io/CharsetSniffingInputStream.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/io/CharsetSniffingInputStream.java Mon Dec 19 10:03:09 2011
@@ -108,7 +108,7 @@ public class CharsetSniffingInputStream 
         return (PeekAheadInputStream)in;
     }
 
-    private static boolean equals(byte[] a1, int len, byte[] a2) {
+    static boolean equals(byte[] a1, int len, byte[] a2) {
         for (int n = 0, i = 0; n < len; n++, i++) {
             if (a1[n] != a2[i])
                 return false;

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/lang/Lang.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/lang/Lang.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/lang/Lang.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/lang/Lang.java Mon Dec 19 10:03:09 2011
@@ -27,7 +27,6 @@ import java.util.regex.Pattern;
 import org.apache.abdera2.common.lang.Subtag.Type;
 import org.apache.abdera2.common.misc.MoreFunctions;
 
-import static org.apache.abdera2.common.misc.MoreFunctions.*;
 import static org.apache.abdera2.common.text.CharUtils.*;
 import static com.google.common.base.Preconditions.checkArgument;
 

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/lang/SubtagSet.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/lang/SubtagSet.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/lang/SubtagSet.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/lang/SubtagSet.java Mon Dec 19 10:03:09 2011
@@ -18,12 +18,13 @@
 package org.apache.abdera2.common.lang;
 
 import java.io.Serializable;
-import java.util.Arrays;
 import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
 
 import org.apache.abdera2.common.lang.Subtag.Type;
+import org.apache.abdera2.common.misc.ArrayBuilder;
+
+import com.google.common.collect.ImmutableList;
 
 public abstract class SubtagSet 
   implements Serializable, 
@@ -143,15 +144,14 @@ public abstract class SubtagSet 
     }
 
     public Subtag[] toArray() {
-        List<Subtag> tags = 
-          new LinkedList<Subtag>();
-        for (Subtag tag : this)
-            tags.add(tag);
-        return tags.toArray(new Subtag[tags.size()]);
+      return ArrayBuilder.list(Subtag.class)
+        .addAll(this).build();
     }
 
     public List<Subtag> asList() {
-        return Arrays.asList(toArray());
+      return ImmutableList
+        .<Subtag>builder()
+        .addAll(this).build();
     }
 
     public int compareTo(SubtagSet o) {

Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/ArrayBuilder.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/ArrayBuilder.java?rev=1220676&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/ArrayBuilder.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/ArrayBuilder.java Mon Dec 19 10:03:09 2011
@@ -0,0 +1,87 @@
+package org.apache.abdera2.common.misc;
+import java.lang.reflect.Array;
+import java.util.Comparator;
+import java.util.Iterator;
+
+import com.google.common.collect.ImmutableCollection;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSortedSet;
+
+@SuppressWarnings("unchecked")
+public final class ArrayBuilder<T> {
+  
+  public static <T>ArrayBuilder<T> list(Class<? super T> _class) {
+    return new ArrayBuilder<T>(_class,ImmutableList.<T>builder());
+  }
+  
+  public static <T>ArrayBuilder<T> set(Class<? super T> _class) {
+    return new ArrayBuilder<T>(_class,ImmutableSet.<T>builder());
+  }
+  
+  public static <T>ArrayBuilder<T> sortedSet(Class<? super T> _class, Comparator<T> comp) {
+    return new ArrayBuilder<T>(_class,ImmutableSortedSet.orderedBy(comp));
+  }
+  
+  public static <T extends Comparable<T>>ArrayBuilder<T> sortedSet(Class<? super T> _class) {
+    return new ArrayBuilder<T>(_class,ImmutableSortedSet.<T>naturalOrder());
+  }
+  
+  private final ImmutableCollection.Builder<T> builder;
+  private final Class<? super T> _class;
+
+  ArrayBuilder(Class<? super T> _class, ImmutableCollection.Builder<T> builder) {
+    this.builder = builder;
+    this._class = _class;
+  }
+  public T[] build() {
+    ImmutableCollection<T> list = builder.build();
+    return list.toArray((T[])Array.newInstance(_class, list.size()));
+  }
+  public ArrayBuilder<T> add(T item) {
+    builder.add(item);
+    return this;
+  }
+  public ArrayBuilder<T> add(T... items) {
+    builder.add(items);
+    return this;
+  }
+  public ArrayBuilder<T> addAll(Iterable<T> items) {
+    builder.addAll(items);
+    return this;
+  }
+  public ArrayBuilder<T> addAll(Iterator<T> items) {
+    builder.addAll(items);
+    return this;
+  }
+  @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result + ((_class == null) ? 0 : _class.hashCode());
+    result = prime * result + ((builder == null) ? 0 : builder.hashCode());
+    return result;
+  }
+  @Override
+  public boolean equals(Object obj) {
+    if (this == obj)
+      return true;
+    if (obj == null)
+      return false;
+    if (getClass() != obj.getClass())
+      return false;
+    ArrayBuilder<?> other = (ArrayBuilder<?>) obj;
+    if (_class == null) {
+      if (other._class != null)
+        return false;
+    } else if (!_class.equals(other._class))
+      return false;
+    if (builder == null) {
+      if (other.builder != null)
+        return false;
+    } else if (!builder.equals(other.builder))
+      return false;
+    return true;
+    }
+    
+  }
\ No newline at end of file

Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/ArrayBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractBaseRequestContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractBaseRequestContext.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractBaseRequestContext.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractBaseRequestContext.java Mon Dec 19 10:03:09 2011
@@ -20,11 +20,14 @@ package org.apache.abdera2.common.protoc
 import java.security.Principal;
 import java.util.Arrays;
 import java.util.Iterator;
+import java.util.Set;
 
 import javax.security.auth.Subject;
 
 import org.apache.abdera2.common.iri.IRI;
 
+import com.google.common.collect.ImmutableSet;
+
 @SuppressWarnings("unchecked")
 public abstract class AbstractBaseRequestContext 
   extends AbstractRequest 
@@ -112,7 +115,9 @@ public abstract class AbstractBaseReques
         return getResolvedUri().resolve(urlFor(key, param)).toString();
     }
 
+    private static final Set<Property> properties = 
+      ImmutableSet.copyOf(Property.values());
     public Iterator<Property> iterator() {
-      return Arrays.asList(Property.values()).iterator();
+      return properties.iterator();
     }
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractCollectionAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractCollectionAdapter.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractCollectionAdapter.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractCollectionAdapter.java Mon Dec 19 10:03:09 2011
@@ -53,8 +53,8 @@ public abstract class AbstractCollection
 
     private static class HandlerKey implements Serializable {
       private static final long serialVersionUID = -580349554867112812L;
-      private final TargetType type;
-      private final String method;
+      final TargetType type;
+      final String method;
       HandlerKey(TargetType type, String method) {
         this.type = type;
         this.method = method.toUpperCase();

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractMessage.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractMessage.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractMessage.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractMessage.java Mon Dec 19 10:03:09 2011
@@ -17,9 +17,6 @@
  */
 package org.apache.abdera2.common.protocol;
 
-import java.util.ArrayList;
-import java.util.List;
-
 import javax.activation.MimeType;
 
 import org.apache.abdera2.common.http.CacheControl;
@@ -32,7 +29,7 @@ import org.apache.abdera2.common.text.Ur
 
 import com.google.common.base.Function;
 import com.google.common.base.Functions;
-import com.google.common.collect.Iterables;
+import com.google.common.collect.ImmutableList;
 
 import static com.google.common.base.Preconditions.*;
 /**
@@ -49,10 +46,10 @@ public abstract class AbstractMessage 
     
     public <T>Iterable<T> getHeaders(String name, Function<String,T> transform) {
       Iterable<Object> objs = this.getHeaders(name);
-      List<T> list = new ArrayList<T>();
+      ImmutableList.Builder<T> list = ImmutableList.builder();
       for (Object obj : objs)
         list.add(transform.apply(obj.toString()));
-      return Iterables.unmodifiableIterable(list);
+      return list.build();
     }
   
     public CacheControl getCacheControl() {
@@ -87,29 +84,27 @@ public abstract class AbstractMessage 
     }
 
     public String getSlug() {
-        return getDecodedHeader("Slug");
+      return getDecodedHeader("Slug");
     }
 
     public Iterable<WebLink> getWebLinks() {
-      List<WebLink> links = new ArrayList<WebLink>();
+      ImmutableList.Builder<WebLink> links = ImmutableList.builder();
       Iterable<Object> headers = this.getHeaders("Link");      
-      for (Object obj : headers) {
-        Iterable<WebLink> list = WebLink.parse(obj.toString());
-        for (WebLink link : list)
-          links.add(link);
-      }
-      return links;
+      for (Object obj : headers)
+        links.addAll(
+          WebLink.parse(
+            obj.toString()));
+      return links.build();
     }
     
     public Iterable<Preference> getPrefer() {
-      List<Preference> links = new ArrayList<Preference>();
+      ImmutableList.Builder<Preference> links = ImmutableList.builder();
       Iterable<Object> headers = this.getHeaders("Prefer");
-      for (Object obj : headers) {
-        Iterable<Preference> list = Preference.parse(obj.toString());
-        for (Preference link : list)
-          links.add(link);
-      }
-      return links;
+      for (Object obj : headers)
+        links.addAll(
+          Preference.parse(
+             obj.toString()));
+      return links.build();
     }
 
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BasicCollectionInfo.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BasicCollectionInfo.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BasicCollectionInfo.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BasicCollectionInfo.java Mon Dec 19 10:03:09 2011
@@ -18,12 +18,12 @@
 package org.apache.abdera2.common.protocol;
 
 import java.io.Serializable;
-import java.util.LinkedHashSet;
 import java.util.Set;
 
 import org.apache.abdera2.common.misc.MoreFunctions;
 
 import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableSet;
 
 public class BasicCollectionInfo 
   implements CollectionInfo, 
@@ -34,11 +34,11 @@ public class BasicCollectionInfo 
     }
   
     public static class Generator implements Supplier<CollectionInfo> {
-      private String title;
-      private String href;
-      private final Set<String> accepts = 
-        new LinkedHashSet<String>();
-      public Generator title(String title) {
+      String title;
+      String href;
+      final ImmutableSet.Builder<String> accepts = 
+        ImmutableSet.builder();
+      Generator title(String title) {
         this.title = title;
         return this;
       }
@@ -59,12 +59,12 @@ public class BasicCollectionInfo 
 
     private final String title;
     private final String href;
-    private final Set<String> accepts = new LinkedHashSet<String>();
+    private final Set<String> accepts;
 
     protected BasicCollectionInfo(Generator gen) {
-        this.title = gen.title;
-        this.accepts.addAll(gen.accepts);
-        this.href = gen.href;
+      this.title = gen.title;
+      this.accepts = gen.accepts.build();
+      this.href = gen.href;
     }
 
     public Iterable<String> getAccepts(RequestContext request) {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BasicWorkspaceInfo.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BasicWorkspaceInfo.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BasicWorkspaceInfo.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BasicWorkspaceInfo.java Mon Dec 19 10:03:09 2011
@@ -18,12 +18,12 @@
 package org.apache.abdera2.common.protocol;
 
 import java.io.Serializable;
-import java.util.LinkedHashSet;
 import java.util.Set;
 
 import org.apache.abdera2.common.misc.MoreFunctions;
 
 import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 
 
@@ -34,21 +34,17 @@ public class BasicWorkspaceInfo
     private static final long serialVersionUID = -8459688584319762878L;
     
     public static class Generator implements Supplier<WorkspaceInfo> {
-
-      private String title;
-      private final Set<CollectionInfo> collections = 
-        new LinkedHashSet<CollectionInfo>();
-      
+      String title;
+      final ImmutableSet.Builder<CollectionInfo> collections = 
+        ImmutableSet.builder();
       public Generator title(String title) {
         this.title = title;
         return this;
       }
-      
       public Generator collection(CollectionInfo info) {
         this.collections.add(info);
         return this;
       }
-      
       public WorkspaceInfo get() {
         return new BasicWorkspaceInfo(this);
       }
@@ -56,16 +52,16 @@ public class BasicWorkspaceInfo
     }
     
     protected final String title;
-    protected final Set<CollectionInfo> collections =
-      new LinkedHashSet<CollectionInfo>();
+    protected final Set<CollectionInfo> collections;
 
     protected BasicWorkspaceInfo(Generator generator) {
       this.title = generator.title;
-      this.collections.addAll(generator.collections);
+      this.collections = generator.collections.build();
     }
 
     public BasicWorkspaceInfo(String title) {
         this.title = title;
+        this.collections = ImmutableSet.of();
     }
 
     public String getTitle() {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/MethodOverrideFilter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/MethodOverrideFilter.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/MethodOverrideFilter.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/MethodOverrideFilter.java Mon Dec 19 10:03:09 2011
@@ -18,12 +18,16 @@
 package org.apache.abdera2.common.protocol;
 
 import java.util.HashSet;
+import java.util.Locale;
 import java.util.Set;
 
 import org.apache.abdera2.common.misc.Chain;
 import org.apache.abdera2.common.misc.MoreFunctions;
 import org.apache.abdera2.common.misc.Task;
 
+import com.google.common.collect.ImmutableSet;
+import static com.google.common.base.Preconditions.checkNotNull;
+
 /**
  * Abdera Filter implementation that supports the use of the X-HTTP-Method-Override header used by GData.
  */
@@ -37,18 +41,15 @@ public class MethodOverrideFilter 
     }
 
     public MethodOverrideFilter(String... methods) {
-        setMethods(methods);
+      for (int n = 0; n < checkNotNull(methods).length; n++)
+        methods[n] = methods[n].toUpperCase(Locale.US);
+      this.methods = ImmutableSet.copyOf(methods);
     }
 
     public Iterable<String> getMethods() {
-        return methods;
-    }
-
-    public void setMethods(String... methods) {
-        for (String method : methods)
-          this.methods.add(method);
+      return methods;
     }
-
+    
     public ResponseContext apply(
       RequestContext request, 
       Chain<RequestContext,ResponseContext> chain) {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ProviderHelper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ProviderHelper.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ProviderHelper.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ProviderHelper.java Mon Dec 19 10:03:09 2011
@@ -46,11 +46,11 @@ public class ProviderHelper {
         public Integer apply(RequestContext input) {
           int size = def;
           try {
-              String _ps = input.getParameter(param);
-              size = (_ps != null) ? 
-                Math.min(
-                  Math.max(Integer.parseInt(_ps), 0), def) : 
-                  def;
+            String _ps = input.getParameter(param);
+            size = (_ps != null) ? 
+              Math.min(
+                Math.max(Integer.parseInt(_ps), 0), def) : 
+                def;
           } catch (Exception e) {}
           log.debug(Localizer.sprintf("PAGE.SIZE", size));
           return size;

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RegexTargetResolver.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RegexTargetResolver.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RegexTargetResolver.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RegexTargetResolver.java Mon Dec 19 10:03:09 2011
@@ -85,31 +85,38 @@ public class RegexTargetResolver<R exten
     }
 
     public Target apply(R request) {
-        String uri = request.getTargetPath();
-        for (Pattern pattern : patterns.keySet()) {
-            Matcher matcher = pattern.matcher(uri);
-            if (matcher.matches()) {
-                TargetType type = this.patterns.get(pattern);
-                Iterable<String> fields = this.fields.get(pattern);
-                return getTarget(type, request, matcher, fields);
-            }
-        }
-        return null;
-    }
-
-    protected Target getTarget(TargetType type, RequestContext request, Matcher matcher, Iterable<String> fields) {
+      String uri = request.getTargetPath();
+      for (Pattern pattern : patterns.keySet()) {
+        Matcher matcher = pattern.matcher(uri);
+        if (matcher.matches()) 
+          return getTarget(
+            this.patterns.get(pattern), 
+            request, 
+            matcher, 
+            this.fields.get(pattern));
+      }
+      return null;
+    }
+
+    protected Target getTarget(
+      TargetType type, 
+      RequestContext request, 
+      Matcher matcher, 
+      Iterable<String> fields) {
         return new RegexTarget(type, request, matcher, fields);
     }
 
     public String toString() {
-        StringBuilder buf = new StringBuilder();
-        buf.append("Regex Target Resolver:\n");
-        for (Pattern pattern : patterns.keySet()) {
-            TargetType type = this.patterns.get(pattern);
-            Iterable<String> fields = this.fields.get(pattern);
-            buf.append(pattern.toString() + ", Type: " + type + ", Fields: " + fields);
-        }
-        return buf.toString();
+      StringBuilder buf = new StringBuilder();
+      buf.append("Regex Target Resolver:\n");
+      for (Pattern pattern : patterns.keySet())
+        buf.append(
+          String.format(
+            "%s, Type: %s, Fields: %s",
+            pattern,
+            this.patterns.get(pattern),
+            this.fields.get(pattern)));
+      return buf.toString();
     }
 
     public int hashCode() {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestProcessor.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestProcessor.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestProcessor.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestProcessor.java Mon Dec 19 10:03:09 2011
@@ -17,8 +17,6 @@
  */
 package org.apache.abdera2.common.protocol;
 
-import java.lang.reflect.Constructor;
-
 import org.apache.abdera2.common.misc.ExceptionHelper;
 import org.apache.abdera2.common.misc.MoreFunctions;
 

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestTemplateContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestTemplateContext.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestTemplateContext.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestTemplateContext.java Mon Dec 19 10:03:09 2011
@@ -1,15 +1,15 @@
 package org.apache.abdera2.common.protocol;
 
 import java.security.Principal;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Locale;
-import java.util.Set;
 
 import org.apache.abdera2.common.protocol.RequestContext.Scope;
 import org.apache.abdera2.common.templates.Context;
 import org.apache.abdera2.common.templates.DelegatingContext;
 
+import com.google.common.collect.ImmutableSet;
+
 /**
  * A Template Context implementation based on a RequestContext object.
  * this allows a URI Template to be expanded using properties and 
@@ -92,31 +92,30 @@ public class RequestTemplateContext 
 
   @Override
   public Iterator<String> iterator() {
-      Set<String> vars = new HashSet<String>();
-      for (String var : subcontext)
-          vars.add(var);
-      for (String var : request.getParameterNames())
-          vars.add(toVar(Variable.REQUEST_PARAMETER, var));
-      for (String var : request.getAttributeNames(Scope.SESSION))
-          vars.add(toVar(Variable.SESSION_ATTRIBUTE, var));
-      for (String var : request.getAttributeNames(Scope.REQUEST))
-          vars.add(toVar(Variable.REQUEST_ATTRIBUTE, var));
-      for (String var : request.getHeaderNames())
-          vars.add(toVar(Variable.REQUEST_HEADER, var));
-      Target target = request.getTarget();
-      for (String var : target.getParameterNames())
-          vars.add(toVar(Variable.TARGET_PARAMETER, var));
-      vars.add(Variable.REQUEST_CONTEXT_PATH.name().toLowerCase());
-      vars.add(Variable.REQUEST_CONTENT_TYPE.name().toLowerCase());
-      vars.add(Variable.REQUEST_URI.name().toLowerCase());
-      vars.add(Variable.REQUEST_RESOLVED_URI.name().toLowerCase());
-      vars.add(Variable.REQUEST_LANGUAGE.name().toLowerCase());
-      vars.add(Variable.REQUEST_CHARSET.name().toLowerCase());
-      vars.add(Variable.REQUEST_USER.name().toLowerCase());
-      vars.add(Variable.TARGET_IDENTITY.name().toLowerCase());
-      vars.add(Variable.TARGET_PATH.name().toLowerCase());
-      vars.add(Variable.TARGET_BASE.name().toLowerCase());
-      return vars.iterator();
+    ImmutableSet.Builder<String> vars = ImmutableSet.builder();
+    vars.addAll(subcontext);
+    for (String var : request.getParameterNames())
+        vars.add(toVar(Variable.REQUEST_PARAMETER, var));
+    for (String var : request.getAttributeNames(Scope.SESSION))
+        vars.add(toVar(Variable.SESSION_ATTRIBUTE, var));
+    for (String var : request.getAttributeNames(Scope.REQUEST))
+        vars.add(toVar(Variable.REQUEST_ATTRIBUTE, var));
+    for (String var : request.getHeaderNames())
+        vars.add(toVar(Variable.REQUEST_HEADER, var));
+    Target target = request.getTarget();
+    for (String var : target.getParameterNames())
+        vars.add(toVar(Variable.TARGET_PARAMETER, var));
+    vars.add(Variable.REQUEST_CONTEXT_PATH.name().toLowerCase());
+    vars.add(Variable.REQUEST_CONTENT_TYPE.name().toLowerCase());
+    vars.add(Variable.REQUEST_URI.name().toLowerCase());
+    vars.add(Variable.REQUEST_RESOLVED_URI.name().toLowerCase());
+    vars.add(Variable.REQUEST_LANGUAGE.name().toLowerCase());
+    vars.add(Variable.REQUEST_CHARSET.name().toLowerCase());
+    vars.add(Variable.REQUEST_USER.name().toLowerCase());
+    vars.add(Variable.TARGET_IDENTITY.name().toLowerCase());
+    vars.add(Variable.TARGET_PATH.name().toLowerCase());
+    vars.add(Variable.TARGET_BASE.name().toLowerCase());
+    return vars.build().iterator();
   }
   
   private static String toVar(Variable variable, String label) {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java Mon Dec 19 10:03:09 2011
@@ -17,7 +17,6 @@
  */
 package org.apache.abdera2.common.protocol;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -33,6 +32,8 @@ import org.apache.abdera2.common.templat
 
 import com.google.common.base.Function;
 import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 
 /**
@@ -58,12 +59,12 @@ public class RouteManager<T,X extends Re
     public static class Generator<T, X extends RequestContext,R> 
       implements Supplier<RouteManager<T,X,R>> {
 
-      protected final List<RouteTargetType<R>> targets = 
-        new ArrayList<RouteTargetType<R>>();
-      protected final Map<R, Route<R>> routes = 
-        new HashMap<R, Route<R>>();
-      protected final Map<Route<R>, CollectionAdapter> route2CA = 
-        new HashMap<Route<R>, CollectionAdapter>();
+      protected final ImmutableList.Builder<RouteTargetType<R>> targets = 
+        ImmutableList.builder();
+      protected final ImmutableMap.Builder<R, Route<R>> routes = 
+        ImmutableMap.builder();
+      protected final ImmutableMap.Builder<Route<R>, CollectionAdapter> route2CA = 
+        ImmutableMap.builder();
       public Generator<T,X,R> withAll(RouteManager<T,X,R> other) {
         this.targets.addAll(other.targets);
         this.routes.putAll(other.routes);
@@ -121,17 +122,14 @@ public class RouteManager<T,X extends Re
       }
     }
 
-    protected final List<RouteTargetType<R>> targets = 
-      new ArrayList<RouteTargetType<R>>();
-    protected final Map<R, Route<R>> routes = 
-      new HashMap<R, Route<R>>();
-    protected final Map<Route<R>, CollectionAdapter> route2CA = 
-      new HashMap<Route<R>, CollectionAdapter>();
-
-    private RouteManager(Generator<T,X,R> gen) {
-      this.targets.addAll(gen.targets);
-      this.routes.putAll(gen.routes);
-      this.route2CA.putAll(gen.route2CA);
+    protected final List<RouteTargetType<R>> targets;
+    protected final Map<R, Route<R>> routes;
+    protected final Map<Route<R>, CollectionAdapter> route2CA;;
+
+    RouteManager(Generator<T,X,R> gen) {
+      this.targets = gen.targets.build();
+      this.routes = gen.routes.build();
+      this.route2CA = gen.route2CA.build();
     }
     
     public Target apply(X request) {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/AbderaAsyncService.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/AbderaAsyncService.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/AbderaAsyncService.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/AbderaAsyncService.java Mon Dec 19 10:03:09 2011
@@ -50,7 +50,7 @@ public class AbderaAsyncService 
     public static final String QUEUE = "AbderaProcessorQueue";
     public static final String CM = "AbderaChannelManager";
   
-    private final static Log log = LogFactory.getLog(AbderaAsyncService.class);
+    final static Log log = LogFactory.getLog(AbderaAsyncService.class);
     
     private ServletContext context;
     private TaskExecutor exec;
@@ -87,7 +87,7 @@ public class AbderaAsyncService 
       return c;
     }
     
-    private static boolean getBooleanProperty(Map<String, Object> properties, String name, boolean def) {
+    static boolean getBooleanProperty(Map<String, Object> properties, String name, boolean def) {
       boolean answer = def;
       if (properties.containsKey(name)) {
         Object v = properties.get(name);

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/Route.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/Route.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/Route.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/Route.java Mon Dec 19 10:03:09 2011
@@ -18,16 +18,15 @@
 package org.apache.abdera2.common.templates;
 
 import java.io.Serializable;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.abdera2.common.anno.URIRoute;
+import org.apache.abdera2.common.misc.ArrayBuilder;
 import org.apache.abdera2.common.misc.MoreFunctions;
 
 /**
@@ -69,50 +68,42 @@ public class Route<T> implements Iterabl
     }
 
     private String[] initTokens() {
-        Matcher matcher = VARIABLE.matcher(pattern);
-        List<String> tokens = new ArrayList<String>();
-        while (matcher.find()) {
-            String token = matcher.group();
-            if (!tokens.contains(token))
-                tokens.add(token);
-        }
-        return tokens.toArray(new String[tokens.size()]);
+      Matcher matcher = VARIABLE.matcher(pattern);
+      ArrayBuilder<String> tokens = 
+        ArrayBuilder.set(String.class);
+      while (matcher.find()) 
+        tokens.add(matcher.group());
+      return tokens.build();
     }
 
     private String[] initVariables() {
-        List<String> list = new ArrayList<String>();
-        for (String token : this) {
-            String var = var(token);
-            if (!list.contains(var))
-                list.add(var);
-        }
-        String[] vars = list.toArray(new String[list.size()]);
-        Arrays.sort(vars);
-        return vars;
+      ArrayBuilder<String> list = 
+        ArrayBuilder.sortedSet(String.class);
+      for (String token : this)
+        list.add(var(token));
+      return list.build();
     }
 
     private Pattern initRegexMatch() {
-        StringBuffer match = new StringBuffer();
-        int cnt = 0;
-        for (String part : VARIABLE.split(pattern)) {
-            match.append(Pattern.quote(part));
-            if (cnt++ < tokens.length) {
-                match.append(VARIABLE_CONTENT_MATCH);
-            }
-        }
-        return Pattern.compile(match.toString());
+      StringBuffer match = new StringBuffer();
+      int cnt = 0;
+      for (String part : VARIABLE.split(pattern)) {
+        match.append(Pattern.quote(part));
+        if (cnt++ < tokens.length)
+          match.append(VARIABLE_CONTENT_MATCH);
+      }
+      return Pattern.compile(match.toString());
     }
 
     private Pattern initRegexParse() {
-        StringBuffer parse = new StringBuffer();
-        int cnt = 0;
-        for (String part : VARIABLE.split(pattern)) {
-            parse.append(Pattern.quote(part));
-            if (cnt++ < tokens.length) {
-                parse.append(VARIABLE_CONTENT_PARSE);
-            }
-        }
-        return Pattern.compile(parse.toString());
+      StringBuffer parse = new StringBuffer();
+      int cnt = 0;
+      for (String part : VARIABLE.split(pattern)) {
+        parse.append(Pattern.quote(part));
+        if (cnt++ < tokens.length)
+          parse.append(VARIABLE_CONTENT_PARSE);
+      }
+      return Pattern.compile(parse.toString());
     }
 
     /**
@@ -126,15 +117,14 @@ public class Route<T> implements Iterabl
      * Parses the given uri using the route pattern
      */
     public Map<String, String> parse(String uri) {
-        HashMap<String, String> vars = new HashMap<String, String>();
-        Matcher matcher = regexParse.matcher(uri);
-        if (matcher.matches()) {
-            for (int i = 0; i < matcher.groupCount(); i++) {
-                vars.put(var(tokens[i]), matcher.group(i + 1).length() > 0 ? matcher.group(i + 1) : null);
-            }
+      HashMap<String, String> vars = new HashMap<String, String>();
+      Matcher matcher = regexParse.matcher(uri);
+      if (matcher.matches()) {
+        for (int i = 0; i < matcher.groupCount(); i++) {
+          vars.put(var(tokens[i]), matcher.group(i + 1).length() > 0 ? matcher.group(i + 1) : null);
         }
-
-        return vars;
+      }
+      return vars;
     }
 
     /**

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMCollection.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMCollection.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMCollection.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMCollection.java Mon Dec 19 10:03:09 2011
@@ -17,7 +17,6 @@
  */
 package org.apache.abdera2.parser.axiom;
 
-import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
@@ -26,7 +25,7 @@ import javax.xml.namespace.QName;
 
 import org.apache.abdera2.common.Constants;
 import org.apache.abdera2.common.iri.IRI;
-import org.apache.abdera2.common.mediatype.MimeTypeHelper;
+import org.apache.abdera2.common.misc.ArrayBuilder;
 import org.apache.abdera2.common.selector.Selector;
 import org.apache.abdera2.model.Categories;
 import org.apache.abdera2.model.Category;
@@ -39,6 +38,7 @@ import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
+import static org.apache.abdera2.common.mediatype.MimeTypeHelper.*;
 
 import com.google.common.collect.Iterables;
 
@@ -46,7 +46,6 @@ import com.google.common.collect.Iterabl
 public class FOMCollection extends FOMExtensibleElement implements Collection {
 
     private static final String[] ENTRY = {"application/atom+xml;type=\"entry\""};
-    private static final String[] EMPTY = new String[0];
 
     private static final long serialVersionUID = -5291734055253987136L;
 
@@ -126,23 +125,17 @@ public class FOMCollection extends FOMEx
     }
 
     public String[] getAccept() {
-        List<String> accept = new ArrayList<String>();
-        Iterator<?> i = getChildrenWithName(ACCEPT);
-        if (i == null || !i.hasNext())
-            i = getChildrenWithName(PRE_RFC_ACCEPT);
-        while (i.hasNext()) {
-            Element e = (Element)i.next();
-            String t = e.getText();
-            if (t != null) {
-                accept.add(t.trim());
-            }
-        }
-        if (accept.size() > 0) {
-            String[] list = accept.toArray(new String[accept.size()]);
-            return MimeTypeHelper.condense(list);
-        } else {
-            return EMPTY;
-        }
+      ArrayBuilder<String> accept = ArrayBuilder.list(String.class);
+      Iterator<?> i = getChildrenWithName(ACCEPT);
+      if (i == null || !i.hasNext())
+          i = getChildrenWithName(PRE_RFC_ACCEPT);
+      while (i.hasNext()) {
+          Element e = (Element)i.next();
+          String t = e.getText();
+          if (t != null)
+            accept.add(t.trim());
+      }
+      return condense(accept.build());
     }
 
     public Collection setAccept(String mediaRange) {
@@ -159,20 +152,16 @@ public class FOMCollection extends FOMEx
             _removeChildren(ACCEPT, true);
             _removeChildren(PRE_RFC_ACCEPT, true);
             if (mediaRanges.length == 1 && mediaRanges[0].equals("")) {
-                addExtension(ACCEPT);
+              addExtension(ACCEPT);
             } else {
-                mediaRanges = MimeTypeHelper.condense(mediaRanges);
-                for (String type : mediaRanges) {
-                    if (type.equalsIgnoreCase("entry")) {
-                        addSimpleExtension(ACCEPT, "application/atom+xml;type=entry");
-                    } else {
-                        try {
-                            addSimpleExtension(ACCEPT, new MimeType(type).toString());
-                        } catch (javax.activation.MimeTypeParseException e) {
-                            throw new org.apache.abdera2.common.mediatype.MimeTypeParseException(e);
-                        }
-                    }
+              mediaRanges = condense(mediaRanges);
+              for (String type : mediaRanges) {
+                if (type.equalsIgnoreCase("entry")) {
+                  addSimpleExtension(ACCEPT, "application/atom+xml;type=entry");
+                } else {
+                  addSimpleExtension(ACCEPT, unmodifiableMimeType(type).toString());
                 }
+              }
             }
         } else {
             _removeChildren(ACCEPT, true);
@@ -192,7 +181,7 @@ public class FOMCollection extends FOMEx
             if (!accepts(type))
               addSimpleExtension(
                 ACCEPT, 
-                MimeTypeHelper.unmodifiableMimeType(type).toString());
+                unmodifiableMimeType(type).toString());
         return this;
     }
 
@@ -219,11 +208,10 @@ public class FOMCollection extends FOMEx
     public boolean accepts(String mediaType) {
         String[] accept = getAccept();
         if (accept.length == 0)
-            accept = ENTRY;
-        for (String a : accept) {
-            if (MimeTypeHelper.isMatch(a, mediaType))
-                return true;
-        }
+          accept = ENTRY;
+        for (String a : accept)
+          if (isMatch(a, mediaType))
+            return true;
         return false;
     }
 
@@ -243,26 +231,24 @@ public class FOMCollection extends FOMEx
     }
 
     public Categories addCategories(String href) {
-        complete();
-        Categories cats = ((FOMFactory)factory).newCategories();
-        cats.setHref(href);
-        addCategories(cats);
-        return cats;
+      complete();
+      Categories cats = ((FOMFactory)factory).newCategories();
+      cats.setHref(href);
+      addCategories(cats);
+      return cats;
     }
 
     public Categories addCategories(List<Category> categories, boolean fixed, String scheme) {
-        complete();
-        Categories cats = ((FOMFactory)factory).newCategories();
-        cats.setFixed(fixed);
-        if (scheme != null)
-            cats.setScheme(scheme);
-        if (categories != null) {
-            for (Category category : categories) {
-                cats.addCategory(category);
-            }
-        }
-        addCategories(cats);
-        return cats;
+      complete();
+      Categories cats = ((FOMFactory)factory).newCategories();
+      cats.setFixed(fixed);
+      if (scheme != null)
+          cats.setScheme(scheme);
+      if (categories != null)
+        for (Category category : categories)
+          cats.addCategory(category);
+      addCategories(cats);
+      return cats;
     }
 
     public List<Categories> getCategories() {

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMDocument.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMDocument.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMDocument.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMDocument.java Mon Dec 19 10:03:09 2011
@@ -30,6 +30,7 @@ import javax.xml.stream.XMLStreamExcepti
 
 import org.apache.abdera2.common.iri.IRI;
 import org.apache.abdera2.common.lang.Lang;
+import org.apache.abdera2.common.misc.ArrayBuilder;
 import org.apache.abdera2.common.xml.XMLVersion;
 import org.apache.abdera2.common.http.EntityTag;
 import org.apache.abdera2.factory.Factory;
@@ -230,16 +231,16 @@ public class FOMDocument<T extends Eleme
     }
 
     public String[] getProcessingInstruction(String target) {
-        List<String> values = new ArrayList<String>();
+        ArrayBuilder<String> values = ArrayBuilder.list(String.class);
         for (Iterator<OMNode> i = getChildren(); i.hasNext();) {
-            OMNode node = i.next();
-            if (node.getType() == OMNode.PI_NODE) {
-                OMProcessingInstruction pi = (OMProcessingInstruction)node;
-                if (pi.getTarget().equalsIgnoreCase(target))
-                    values.add(pi.getValue());
-            }
+          OMNode node = i.next();
+          if (node.getType() == OMNode.PI_NODE) {
+            OMProcessingInstruction pi = (OMProcessingInstruction)node;
+            if (pi.getTarget().equalsIgnoreCase(target))
+                values.add(pi.getValue());
+          }
         }
-        return values.toArray(new String[values.size()]);
+        return values.build();
     }
 
     public Document<T> addProcessingInstruction(String target, String value) {

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/AbstractParseFilter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/AbstractParseFilter.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/AbstractParseFilter.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/AbstractParseFilter.java Mon Dec 19 10:03:09 2011
@@ -31,7 +31,7 @@ public abstract class AbstractParseFilte
   public static abstract class Builder<E extends ParseFilter> implements Supplier<E> {
     
     protected byte flags = 0;
-    private Class<? extends UnacceptableException> _throw;
+    Class<? extends UnacceptableException> _throw;
 
     public <X extends Builder<E>>X throwOnUnacceptable() {
       return (X)throwOnUnacceptable(UnacceptableException.class);

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/AbstractSetParseFilter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/AbstractSetParseFilter.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/AbstractSetParseFilter.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/AbstractSetParseFilter.java Mon Dec 19 10:03:09 2011
@@ -27,6 +27,9 @@ import java.util.Set;
 
 import javax.xml.namespace.QName;
 
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
 
 /**
  * ParseFilter's determine which elements and attributes are acceptable 
@@ -44,9 +47,9 @@ public abstract class AbstractSetParseFi
     public static abstract class Builder<E extends AbstractSetParseFilter> 
       extends AbstractParseFilter.Builder<E> {
       
-      private transient Set<QName> 
+      transient Set<QName> 
         qnames = new HashSet<QName>();
-      private transient Map<QName, Set<QName>> 
+      transient Map<QName, Set<QName>> 
         attributes = new HashMap<QName, Set<QName>>();     
       
       public <X extends Builder<E>>X add(QName qname) {
@@ -72,15 +75,13 @@ public abstract class AbstractSetParseFi
   
     private static final long serialVersionUID = -758691949740569208L;
 
-    private transient final Set<QName> 
-      qnames = new HashSet<QName>();
-    private transient final Map<QName, Set<QName>> 
-      attributes = new HashMap<QName, Set<QName>>();
+    private transient final Set<QName> qnames;
+    private transient final Map<QName, Set<QName>> attributes;
 
     protected AbstractSetParseFilter(Builder<?> builder) {
       super(builder);
-      this.qnames.addAll(builder.qnames);
-      this.attributes.putAll(builder.attributes);
+      this.qnames = ImmutableSet.copyOf(builder.qnames);
+      this.attributes = ImmutableMap.copyOf(builder.attributes);
     }
     
     public Object clone() throws CloneNotSupportedException {
@@ -91,13 +92,10 @@ public abstract class AbstractSetParseFi
       return qnames.contains(qname);
     }
 
-    public boolean contains(QName qname, QName attribute) {
-        if (attributes.containsKey(qname)) {
-            Set<QName> attrs = attributes.get(qname);
-            return attrs.contains(attribute);
-        } else {
-            return false;
-        }
+    public boolean contains(QName qname, QName attribute) {  
+      return attributes.containsKey(qname) ?
+        attributes.get(qname).contains(attribute) : 
+        false;
     }
 
     public abstract boolean acceptable(QName qname);
@@ -123,9 +121,8 @@ public abstract class AbstractSetParseFi
             final Set<QName> v = e.getValue();
             assert v != null;
             out.writeInt(v.size());
-            for (QName q : v) {
-                out.writeObject(q);
-            }
+            for (QName q : v)
+              out.writeObject(q);
         }
     }
 
@@ -135,9 +132,8 @@ public abstract class AbstractSetParseFi
         // qnames field
         final int qnamesSize = in.readInt();
         //qnames = new HashSet<QName>(qnamesSize);
-        for (int i = 0; i < qnamesSize; i++) {
-            qnames.add((QName)in.readObject());
-        }
+        for (int i = 0; i < qnamesSize; i++)
+          qnames.add((QName)in.readObject());
 
         // attributes field
         final int attributesSize = in.readInt();
@@ -146,9 +142,8 @@ public abstract class AbstractSetParseFi
             final QName k = (QName)in.readObject();
             final int vSize = in.readInt();
             final Set<QName> v = new HashSet<QName>(vSize);
-            for (int j = 0; j < vSize; j++) {
+            for (int j = 0; j < vSize; j++)
                 v.add((QName)in.readObject());
-            }
             attributes.put(k, v);
         }
     }

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/CompoundParseFilter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/CompoundParseFilter.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/CompoundParseFilter.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/CompoundParseFilter.java Mon Dec 19 10:03:09 2011
@@ -17,10 +17,9 @@
  */
 package org.apache.abdera2.parser.filter;
 
-import java.util.LinkedHashSet;
 import java.util.Set;
-
 import javax.xml.namespace.QName;
+import com.google.common.collect.ImmutableSet;
 
 
 /**
@@ -103,11 +102,12 @@ public class CompoundParseFilter 
       return new Builder();
     }
     
-    public static class Builder extends AbstractParseFilter.Builder<CompoundParseFilter> {
+    public static class Builder 
+      extends AbstractParseFilter.Builder<CompoundParseFilter> {
 
-      private Condition condition;
-      private final Set<ParseFilter> filters = 
-        new LinkedHashSet<ParseFilter>();
+      Condition condition;
+      final ImmutableSet.Builder<ParseFilter> filters = 
+        ImmutableSet.builder();
       
       public CompoundParseFilter get() {
         return new CompoundParseFilter(this);
@@ -131,13 +131,12 @@ public class CompoundParseFilter 
     }
 
     protected final Condition condition;
-    protected final Set<ParseFilter> filters = 
-      new LinkedHashSet<ParseFilter>();
+    protected final Set<ParseFilter> filters;
 
     protected CompoundParseFilter(Builder builder) {
       super(builder);
       this.condition = builder.condition;
-      this.filters.addAll(builder.filters);
+      this.filters = builder.filters.build();
     }
 
     private Iterable<ParseFilter> getFilters() {
@@ -145,27 +144,27 @@ public class CompoundParseFilter 
     }
 
     public boolean acceptable(QName qname) {
-        for (ParseFilter filter : getFilters()) {
-            switch (condition.evaluate(filter.acceptable(qname))) {
-                case 1:
-                    return true;
-                case -1:
-                    return checkThrow(false,qname,null);
-            }
+      for (ParseFilter filter : getFilters()) {
+        switch (condition.evaluate(filter.acceptable(qname))) {
+          case 1:
+            return true;
+          case -1:
+            return checkThrow(false,qname,null);
         }
-        return true;
+      }
+      return true;
     }
 
     public boolean acceptable(QName qname, QName attribute) {
-        for (ParseFilter filter : getFilters()) {
-            switch (condition.evaluate(filter.acceptable(qname, attribute))) {
-                case 1:
-                    return true;
-                case -1:
-                    return checkThrow(false,qname,attribute);
-            }
+      for (ParseFilter filter : getFilters()) {
+        switch (condition.evaluate(filter.acceptable(qname, attribute))) {
+          case 1:
+            return true;
+          case -1:
+            return checkThrow(false,qname,attribute);
         }
-        return true;
+      }
+      return true;
     }
 
     public Object clone() throws CloneNotSupportedException {

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/WhiteListParseFilter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/WhiteListParseFilter.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/WhiteListParseFilter.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/WhiteListParseFilter.java Mon Dec 19 10:03:09 2011
@@ -29,7 +29,7 @@ public class WhiteListParseFilter extend
   }
   
   public static class Builder extends AbstractSetParseFilter.Builder<WhiteListParseFilter> {
-    private boolean listAttributesExplicitly;
+    boolean listAttributesExplicitly;
     public Builder listAttributesExplicitly() {
       this.listAttributesExplicitly = true;
       return this;

Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractEntityCollectionAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractEntityCollectionAdapter.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractEntityCollectionAdapter.java (original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractEntityCollectionAdapter.java Mon Dec 19 10:03:09 2011
@@ -96,7 +96,7 @@ public abstract class AbstractEntityColl
                                 Content content,
                                 RequestContext request) throws ResponseContextException;
 
-    private Function<RequestContext,ResponseContext> postMedia() {
+    Function<RequestContext,ResponseContext> postMedia() {
       return new Function<RequestContext,ResponseContext>() {
         public ResponseContext apply(RequestContext input) {
           return createMediaEntry(input);
@@ -136,7 +136,7 @@ public abstract class AbstractEntityColl
         throw new ResponseContextException(ProviderHelper.notallowed(request));
     }
 
-    private Function<RequestContext,ResponseContext> postItem() {
+    Function<RequestContext,ResponseContext> postItem() {
       return new Function<RequestContext,ResponseContext>() {
         public ResponseContext apply(RequestContext input) {
           return createNonMediaEntry(input);

Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/SimpleCategoriesInfo.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/SimpleCategoriesInfo.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/SimpleCategoriesInfo.java (original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/SimpleCategoriesInfo.java Mon Dec 19 10:03:09 2011
@@ -18,9 +18,7 @@
 package org.apache.abdera2.protocol.server.impl;
 
 import java.io.Serializable;
-import java.util.ArrayList;
 import java.util.Iterator;
-import java.util.List;
 
 import org.apache.abdera2.common.misc.MoreFunctions;
 import org.apache.abdera2.common.protocol.RequestContext;
@@ -29,7 +27,7 @@ import org.apache.abdera2.protocol.serve
 import org.apache.abdera2.protocol.server.model.AtompubCategoryInfo;
 
 import com.google.common.base.Supplier;
-import com.google.common.collect.Iterators;
+import com.google.common.collect.ImmutableList;
 
 public class SimpleCategoriesInfo implements AtompubCategoriesInfo, Serializable {
 
@@ -38,11 +36,11 @@ public class SimpleCategoriesInfo implem
     }
   
     public static class Generator implements Supplier<AtompubCategoriesInfo> {
-      private String href;
-      private String scheme;
-      private boolean fixed;
-      private final List<AtompubCategoryInfo> list = 
-        new ArrayList<AtompubCategoryInfo>();
+      String href;
+      String scheme;
+      boolean fixed;
+      final ImmutableList.Builder<AtompubCategoryInfo> list = 
+        ImmutableList.builder();
       public Generator href(String href) {
         this.href = href;
         return this;
@@ -70,13 +68,13 @@ public class SimpleCategoriesInfo implem
     private final String href;
     private final String scheme;
     private final boolean fixed;
-    private final List<AtompubCategoryInfo> list = new ArrayList<AtompubCategoryInfo>();
+    private final ImmutableList<AtompubCategoryInfo> list;
 
     protected SimpleCategoriesInfo(Generator gen) {
       this.href = gen.href;
       this.scheme = gen.scheme;
       this.fixed = gen.fixed;
-      this.list.addAll(gen.list);
+      this.list = gen.list.build();
     }
     
     public String getHref(RequestContext request) {
@@ -92,7 +90,7 @@ public class SimpleCategoriesInfo implem
     }
 
     public Iterator<AtompubCategoryInfo> iterator() {
-        return Iterators.<AtompubCategoryInfo>unmodifiableIterator(list.iterator());
+        return list.iterator();
     }
 
     public int hashCode() {

Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/SimpleCategoryInfo.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/SimpleCategoryInfo.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/SimpleCategoryInfo.java (original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/SimpleCategoryInfo.java Mon Dec 19 10:03:09 2011
@@ -33,9 +33,9 @@ public class SimpleCategoryInfo implemen
     }
   
     public static class Generator implements Supplier<AtompubCategoryInfo> {
-      private String label;
-      private String term;
-      private String scheme;
+      String label;
+      String term;
+      String scheme;
       public Generator label(String label) {
         this.label = label;
         return this;

Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/SimpleCollectionInfo.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/SimpleCollectionInfo.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/SimpleCollectionInfo.java (original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/SimpleCollectionInfo.java Mon Dec 19 10:03:09 2011
@@ -18,9 +18,6 @@
 package org.apache.abdera2.protocol.server.impl;
 
 import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.LinkedHashSet;
-import java.util.List;
 import java.util.Set;
 
 import org.apache.abdera2.common.misc.MoreFunctions;
@@ -31,7 +28,7 @@ import org.apache.abdera2.model.Collecti
 import org.apache.abdera2.protocol.server.model.AtompubCategoriesInfo;
 import org.apache.abdera2.protocol.server.model.AtompubCollectionInfo;
 
-import com.google.common.collect.Iterables;
+import com.google.common.collect.ImmutableSet;
 
 public class SimpleCollectionInfo 
   extends BasicCollectionInfo
@@ -45,8 +42,8 @@ public class SimpleCollectionInfo 
     }
     
     public static class Generator extends BasicCollectionInfo.Generator {
-      private final Set<AtompubCategoriesInfo> catinfos =
-        new LinkedHashSet<AtompubCategoriesInfo>();
+      final ImmutableSet.Builder<AtompubCategoriesInfo> catinfos =
+        ImmutableSet.builder();
       public Generator category(AtompubCategoriesInfo info) {
         this.catinfos.add(info);
         return this;
@@ -56,16 +53,15 @@ public class SimpleCollectionInfo 
       }
     }
     
-    private final List<AtompubCategoriesInfo> catinfos = 
-      new ArrayList<AtompubCategoriesInfo>();
+    private final Set<AtompubCategoriesInfo> catinfos;
 
     protected SimpleCollectionInfo(Generator generator) {
       super(generator);
-      this.catinfos.addAll(generator.catinfos);
+      this.catinfos = generator.catinfos.build();
     }
 
     public Iterable<AtompubCategoriesInfo> getCategoriesInfo(RequestContext request) {
-        return Iterables.<AtompubCategoriesInfo>unmodifiableIterable(catinfos);
+        return catinfos;
     }
 
     @Override
@@ -91,7 +87,11 @@ public class SimpleCollectionInfo 
     }
 
     public Collection asCollectionElement(RequestContext request) {
-      Collection collection = AbstractAtompubProvider.getAbdera(request).getFactory().newCollection();
+      Collection collection = 
+        AbstractAtompubProvider
+          .getAbdera(request)
+          .getFactory()
+          .newCollection();
       collection.setHref(getHref(request));
       collection.setTitle(getTitle(request));
       collection.setAccept(getAccepts(request));

Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/ServiceRequestProcessor.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/ServiceRequestProcessor.java?rev=1220676&r1=1220675&r2=1220676&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/ServiceRequestProcessor.java (original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/ServiceRequestProcessor.java Mon Dec 19 10:03:09 2011
@@ -21,7 +21,6 @@ import java.io.IOException;
 
 import org.apache.abdera2.common.Constants;
 import org.apache.abdera2.common.http.EntityTag;
-import org.apache.abdera2.common.misc.ExceptionHelper;
 import org.apache.abdera2.common.protocol.RequestContext;
 import org.apache.abdera2.common.protocol.ResponseContext;
 import org.apache.abdera2.common.protocol.CollectionAdapter;



Mime
View raw message