abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1198949 [3/3] - in /abdera/abdera2: activities/src/main/java/org/apache/abdera2/activities/io/gson/ activities/src/main/java/org/apache/abdera2/activities/model/ activities/src/main/java/org/apache/abdera2/activities/model/objects/ activit...
Date Mon, 07 Nov 2011 21:31:55 GMT
Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TargetType.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TargetType.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TargetType.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TargetType.java
Mon Nov  7 21:31:52 2011
@@ -20,6 +20,8 @@ package org.apache.abdera2.common.protoc
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
+import org.apache.abdera2.common.misc.MoreFunctions;
+
 /**
  * Identifies the type of resource being requests.
  */
@@ -119,10 +121,7 @@ public final class TargetType {
     }
 
     public int hashCode() {
-        final int PRIME = 31;
-        int result = 1;
-        result = PRIME * result + ((name == null) ? 0 : name.hashCode());
-        return result;
+      return MoreFunctions.genHashCode(1, name);
     }
 
     public boolean equals(Object obj) {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/pusher/AbstractPusher.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/pusher/AbstractPusher.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/pusher/AbstractPusher.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/pusher/AbstractPusher.java
Mon Nov  7 21:31:52 2011
@@ -17,11 +17,13 @@
  */
 package org.apache.abdera2.common.pusher;
 
+import com.google.common.collect.Iterables;
+
 public abstract class AbstractPusher<T> 
   implements Pusher<T> {
 
   public void pushAll(Iterable<T> t) {
-    for (T i : t)
+    for (T i : Iterables.unmodifiableIterable(t))
       push(i);
   }
 

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/ApiKey.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/ApiKey.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/ApiKey.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/ApiKey.java Mon
Nov  7 21:31:52 2011
@@ -2,6 +2,7 @@ package org.apache.abdera2.common.securi
 
 import java.security.Key;
 
+import org.apache.abdera2.common.misc.MoreFunctions;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.codec.binary.Hex;
 
@@ -208,11 +209,7 @@ public class ApiKey extends KeyBase {
     }
     @Override
     public int hashCode() {
-      final int prime = 31;
-      int result = 1;
-      result = prime * result + (hex ? 1231 : 1237);
-      result = prime * result + ((key == null) ? 0 : key.hashCode());
-      return result;
+      return MoreFunctions.genHashCode(1, hex, key);
     }
     @Override
     public boolean equals(Object obj) {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/KeyBase.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/KeyBase.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/KeyBase.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/KeyBase.java Mon
Nov  7 21:31:52 2011
@@ -5,6 +5,7 @@ import java.security.SecureRandom;
 import javax.crypto.Mac;
 import javax.crypto.spec.SecretKeySpec;
 
+import org.apache.abdera2.common.misc.MoreFunctions;
 import org.apache.commons.codec.binary.Hex;
 
 import com.google.common.base.Supplier;
@@ -100,12 +101,7 @@ public abstract class KeyBase 
 
   @Override
   public int hashCode() {
-    final int prime = 31;
-    int result = 1;
-    result = prime * result + ((alg == null) ? 0 : alg.hashCode());
-    result = prime * result + ((key == null) ? 0 : key.hashCode());
-    result = prime * result + size;
-    return result;
+    return MoreFunctions.genHashCode(1, alg, key);
   }
 
   @Override

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/Otp.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/Otp.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/Otp.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/Otp.java Mon Nov
 7 21:31:52 2011
@@ -1,6 +1,8 @@
 package org.apache.abdera2.common.security;
 import java.security.Key;
 
+import org.apache.abdera2.common.misc.MoreFunctions;
+
 import com.google.common.base.Supplier;
 
 /**
@@ -187,10 +189,7 @@ public abstract class Otp extends KeyBas
 
     @Override
     public int hashCode() {
-      final int prime = 31;
-      int result = super.hashCode();
-      result = prime * result + step;
-      return result;
+      return MoreFunctions.genHashCode(super.hashCode(), step);
     }
 
     @Override

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/DefaultingContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/DefaultingContext.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/DefaultingContext.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/DefaultingContext.java
Mon Nov  7 21:31:52 2011
@@ -21,6 +21,8 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 
+import org.apache.abdera2.common.misc.MoreFunctions;
+
 @SuppressWarnings("unchecked")
 public class DefaultingContext 
   extends DelegatingContext {
@@ -63,10 +65,7 @@ public class DefaultingContext 
 
   @Override
   public int hashCode() {
-    final int prime = 31;
-    int result = 1;
-    result = prime * result + ((defaults == null) ? 0 : defaults.hashCode());
-    return result;
+    return MoreFunctions.genHashCode(1, defaults);
   }
 
   @Override

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/Expression.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/Expression.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/Expression.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/Expression.java
Mon Nov  7 21:31:52 2011
@@ -24,6 +24,7 @@ import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.abdera2.common.misc.MoreFunctions;
 import org.apache.abdera2.common.templates.Context;
 import org.apache.abdera2.common.templates.Expression;
 import org.apache.abdera2.common.templates.Operation;
@@ -55,12 +56,7 @@ public class Expression 
   
   @Override
   public int hashCode() {
-    final int prime = 31;
-    int result = 1;
-    result = prime * result + ((EXP == null) ? 0 : EXP.hashCode());
-    result = prime * result + ((op == null) ? 0 : op.hashCode());
-    result = prime * result + ((varspecs == null) ? 0 : varspecs.hashCode());
-    return result;
+    return MoreFunctions.genHashCode(1, EXP,op,varspecs);
   }
 
   @Override
@@ -160,12 +156,7 @@ public class Expression 
     }
     @Override
     public int hashCode() {
-      final int prime = 31;
-      int result = 1;
-      result = prime * result + (explode ? 1231 : 1237);
-      result = prime * result + length;
-      result = prime * result + ((name == null) ? 0 : name.hashCode());
-      return result;
+      return MoreFunctions.genHashCode(1, explode, length, name);
     }
     @Override
     public boolean equals(Object obj) {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/MapContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/MapContext.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/MapContext.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/MapContext.java
Mon Nov  7 21:31:52 2011
@@ -21,6 +21,7 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 
+import org.apache.abdera2.common.misc.MoreFunctions;
 import org.apache.abdera2.common.templates.Context;
 import org.apache.abdera2.common.templates.MapContext;
 
@@ -77,10 +78,7 @@ public class MapContext extends HashMap<
 
     @Override
     public int hashCode() {
-        final int prime = 31;
-        int result = super.hashCode();
-        result = prime * result + (isiri ? 1231 : 1237);
-        return result;
+      return MoreFunctions.genHashCode(super.hashCode(), isiri);
     }
 
     @Override

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/ObjectContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/ObjectContext.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/ObjectContext.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/ObjectContext.java
Mon Nov  7 21:31:52 2011
@@ -28,6 +28,8 @@ import java.util.Map;
 
 import static com.google.common.base.Preconditions.*;
 import static org.apache.abdera2.common.misc.MorePreconditions.*;
+
+import org.apache.abdera2.common.misc.MoreFunctions;
 import org.apache.abdera2.common.templates.CachingContext;
 import org.apache.abdera2.common.templates.ObjectContext;
 import org.apache.abdera2.common.anno.Name;
@@ -128,10 +130,7 @@ public final class ObjectContext extends
 
     @Override
     public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((target == null) ? 0 : target.hashCode());
-        return result;
+      return MoreFunctions.genHashCode(1, target);
     }
 
     @Override

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=1198949&r1=1198948&r2=1198949&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
Nov  7 21:31:52 2011
@@ -28,6 +28,7 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.abdera2.common.anno.URIRoute;
+import org.apache.abdera2.common.misc.MoreFunctions;
 
 /**
  * A type of URI Template loosely based on Ruby on Rails style Routes. Example: Route feed_route
= new
@@ -246,11 +247,7 @@ public class Route<T> implements Iterabl
     }
 
     public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((key == null) ? 0 : key.hashCode());
-        result = prime * result + ((pattern == null) ? 0 : pattern.hashCode());
-        return result;
+      return MoreFunctions.genHashCode(1, key, pattern);
     }
 
     public boolean equals(Object obj) {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/Template.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/Template.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/Template.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/Template.java
Mon Nov  7 21:31:52 2011
@@ -26,6 +26,7 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.abdera2.common.anno.URITemplate;
+import org.apache.abdera2.common.misc.MoreFunctions;
 import org.apache.abdera2.common.templates.Context;
 import org.apache.abdera2.common.templates.Expression;
 import org.apache.abdera2.common.templates.MapContext;
@@ -150,10 +151,7 @@ public final class Template implements I
 
     @Override
     public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((pattern == null) ? 0 : pattern.hashCode());
-        return result;
+      return MoreFunctions.genHashCode(1, pattern);
     }
 
     @Override

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/TemplateManager.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/TemplateManager.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/TemplateManager.java
(original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/templates/TemplateManager.java
Mon Nov  7 21:31:52 2011
@@ -22,6 +22,7 @@ import java.util.Iterator;
 import java.util.Map;
 
 import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.common.misc.MoreFunctions;
 
 import com.google.common.base.Supplier;
 import static com.google.common.base.Preconditions.*;
@@ -227,13 +228,7 @@ public class TemplateManager<T>
 
   @Override
   public int hashCode() {
-    final int prime = 31;
-    int result = 1;
-    result = prime * result
-        + ((contextDefaults == null) ? 0 : contextDefaults.hashCode());
-    result = prime * result + (isiri ? 1231 : 1237);
-    result = prime * result + ((templates == null) ? 0 : templates.hashCode());
-    return result;
+    return MoreFunctions.genHashCode(1, contextDefaults, isiri, templates);
   }
 
   @Override

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/text/CharUtils.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/text/CharUtils.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/text/CharUtils.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/text/CharUtils.java Mon
Nov  7 21:31:52 2011
@@ -17,8 +17,13 @@
  */
 package org.apache.abdera2.common.text;
 
+import static java.lang.String.format;
+
 import org.apache.abdera2.common.xml.XMLVersion;
 
+import com.google.common.base.Joiner;
+import com.google.common.collect.Iterables;
+
 /**
  * General utilities for dealing with Unicode characters
  */
@@ -135,6 +140,10 @@ public final class CharUtils {
     public static String quotedIfNotToken(String value) {
       return CodepointMatchers.isToken().all(value)?value:quoted(value,true);
     }
+    
+    public static String quotedIfNotToken(String value, boolean wrap) {
+      return CodepointMatchers.isToken().all(value)?value:quoted(value,false);
+    }
 
     public static String quoted(String val, boolean wrap) {
       StringBuilder buf = new StringBuilder();
@@ -168,4 +177,32 @@ public final class CharUtils {
       return -1;
     }
     
+    public static boolean appendcomma(boolean exp, StringBuilder buf) {
+      if (!exp) buf.append(", ");
+      return exp ? !exp : exp;
+    }
+    
+    public static void append(StringBuilder buf, String value) {
+      if (buf.length() > 0)
+          buf.append(", ");
+      buf.append(value);
+  }
+  
+  public static void appendif(boolean exp, StringBuilder buf, String value, Object... args)
{
+    if (exp) append(buf, format(value,args));
+  }
+
+  public static void appendif(boolean exp, StringBuilder buf, Iterable<String> items)
{
+    if (exp && !Iterables.isEmpty(items)) {
+      buf.append("=\"");
+      joiner.appendTo(buf,items);
+      buf.append('"');
+    } 
+  }
+  
+  public static boolean not_empty(String val) {
+    return val != null && val.length() > 0;
+  }
+  
+  public static final Joiner joiner = Joiner.on(',').skipNulls();
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/text/Slug.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/text/Slug.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/text/Slug.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/text/Slug.java Mon Nov 
7 21:31:52 2011
@@ -17,6 +17,7 @@
  */
 package org.apache.abdera2.common.text;
 
+import org.apache.abdera2.common.misc.MoreFunctions;
 import org.apache.abdera2.common.text.CharUtils.Profile;
 
 import com.google.common.base.Function;
@@ -109,10 +110,7 @@ public class Slug {
 
     @Override
     public int hashCode() {
-      final int prime = 31;
-      int result = 1;
-      result = prime * result + ((slug == null) ? 0 : slug.hashCode());
-      return result;
+      return MoreFunctions.genHashCode(1, slug);
     }
 
     @Override

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/Abdera.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/Abdera.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/Abdera.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/Abdera.java Mon Nov  7 21:31:52 2011
@@ -48,7 +48,9 @@ import org.apache.abdera2.xpath.XPath;
  */
 @Version(value="v2.0-SNAPSHOT",
          name="Abdera",
-         uri="http://abdera.apache.org")
+         uri="http://abdera.apache.org",
+         major=2, minor=0, revision=0, 
+         status=Version.Status.DEVELOPMENT)
 public class Abdera {
 
     /** A static instance of Abdera **/

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/factory/AbstractExtensionFactory.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/factory/AbstractExtensionFactory.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/factory/AbstractExtensionFactory.java
(original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/factory/AbstractExtensionFactory.java
Mon Nov  7 21:31:52 2011
@@ -31,6 +31,7 @@ import java.util.Set;
 import javax.xml.namespace.QName;
 
 import org.apache.abdera2.common.anno.AnnoUtil;
+import org.apache.abdera2.common.misc.MoreFunctions;
 import org.apache.abdera2.model.Base;
 import org.apache.abdera2.model.Document;
 import org.apache.abdera2.model.Element;
@@ -219,14 +220,7 @@ public abstract class AbstractExtensionF
     
     @Override
     public int hashCode() {
-      final int prime = 31;
-      int result = 1;
-      result = prime * result + ((impls == null) ? 0 : impls.hashCode());
-      result = prime * result
-          + ((mimetypes == null) ? 0 : mimetypes.hashCode());
-      result = prime * result
-          + ((namespaces == null) ? 0 : namespaces.hashCode());
-      return result;
+      return MoreFunctions.genHashCode(1, impls, mimetypes, namespaces);
     }
 
     @Override

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/model/selector/CollectionAcceptSelector.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/model/selector/CollectionAcceptSelector.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/model/selector/CollectionAcceptSelector.java
(original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/model/selector/CollectionAcceptSelector.java
Mon Nov  7 21:31:52 2011
@@ -17,11 +17,12 @@
  */
 package org.apache.abdera2.model.selector;
 
-import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.Set;
 
 import javax.activation.MimeType;
 
+import org.apache.abdera2.common.mediatype.MimeTypeHelper;
 import org.apache.abdera2.common.selector.AbstractSelector;
 import org.apache.abdera2.common.selector.Selector;
 import org.apache.abdera2.model.Collection;
@@ -37,20 +38,16 @@ extends AbstractSelector<Collection>
 
   private static final long serialVersionUID = 1821941024155067263L;
   private final Set<MimeType> types = 
-    new HashSet<MimeType>();
+    new LinkedHashSet<MimeType>();
   
   public CollectionAcceptSelector(String... types) {
-    try {
-      for (String type:types)
-        this.types.add(new MimeType(type));
-    } catch (Throwable t) {
-      throw new RuntimeException(t);
-    }
+    for (String type:types)
+      this.types.add(MimeTypeHelper.unmodifiableMimeType(type));
   }
   
   public CollectionAcceptSelector(MimeType... types) {
     for (MimeType type : types)
-      this.types.add(type);
+      this.types.add(MimeTypeHelper.unmodifiableMimeType(type));
   }
   
   public boolean select(Object item) {

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMAttribute.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMAttribute.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMAttribute.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMAttribute.java Mon
Nov  7 21:31:52 2011
@@ -19,6 +19,7 @@ package org.apache.abdera2.parser.axiom;
 
 import javax.xml.namespace.QName;
 
+import org.apache.abdera2.common.misc.MoreFunctions;
 import org.apache.abdera2.factory.Factory;
 import org.apache.abdera2.model.Attribute;
 import org.apache.axiom.om.OMAttribute;
@@ -50,10 +51,7 @@ public class FOMAttribute implements Att
 
     @Override
     public int hashCode() {
-        final int PRIME = 31;
-        int result = 1;
-        result = PRIME * result + ((attr == null) ? 0 : attr.hashCode());
-        return result;
+      return MoreFunctions.genHashCode(1, attr);
     }
 
     @Override

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=1198949&r1=1198948&r2=1198949&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
Nov  7 21:31:52 2011
@@ -187,16 +187,12 @@ public class FOMCollection extends FOMEx
 
     public Collection addAccepts(String... mediaRanges) {
         complete();
-        if (mediaRanges != null) {
-            for (String type : mediaRanges) {
-                if (!accepts(type)) {
-                    try {
-                        addSimpleExtension(ACCEPT, new MimeType(type).toString());
-                    } catch (Exception e) {
-                    }
-                }
-            }
-        }
+        if (mediaRanges != null) 
+          for (String type : mediaRanges)
+            if (!accepts(type))
+              addSimpleExtension(
+                ACCEPT, 
+                MimeTypeHelper.unmodifiableMimeType(type).toString());
         return this;
     }
 

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/UnacceptableException.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/UnacceptableException.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/UnacceptableException.java
(original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/UnacceptableException.java
Mon Nov  7 21:31:52 2011
@@ -2,6 +2,8 @@ package org.apache.abdera2.parser.filter
 
 import javax.xml.namespace.QName;
 
+import org.apache.abdera2.common.misc.MoreFunctions;
+
 public class UnacceptableException extends RuntimeException {
 
   private static final long serialVersionUID = -6923049484196141770L;
@@ -39,11 +41,7 @@ public class UnacceptableException exten
 
   @Override
   public int hashCode() {
-    final int prime = 31;
-    int result = 1;
-    result = prime * result + ((attribute == null) ? 0 : attribute.hashCode());
-    result = prime * result + ((element == null) ? 0 : element.hashCode());
-    return result;
+    return MoreFunctions.genHashCode(1, attribute.hashCode(), element.hashCode());
   }
 
   @Override

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/error/AbderaProtocolException.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/error/AbderaProtocolException.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/error/AbderaProtocolException.java
(original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/error/AbderaProtocolException.java
Mon Nov  7 21:31:52 2011
@@ -18,6 +18,7 @@
 package org.apache.abdera2.protocol.error;
 
 import org.apache.abdera2.Abdera;
+import org.apache.abdera2.common.misc.MoreFunctions;
 import org.apache.abdera2.common.protocol.ProtocolException;
 
 public class AbderaProtocolException extends ProtocolException {
@@ -41,13 +42,9 @@ public class AbderaProtocolException ext
 
     @Override
     public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        String message = error != null ? error.getMessage() : null;
-        int code = error != null ? error.getCode() : 0;
-        result = prime * result + ((message == null) ? 0 : message.hashCode());
-        result = prime * result + code;
-        return result;
+      String message = error != null ? error.getMessage() : null;
+      int code = error != null ? error.getCode() : 0;
+      return MoreFunctions.genHashCode(1, message, code);
     }
 
     @Override

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MapRedExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MapRedExample.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MapRedExample.java
(original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MapRedExample.java
Mon Nov  7 21:31:52 2011
@@ -22,7 +22,7 @@ import org.apache.abdera2.common.misc.Ma
 import org.apache.abdera2.common.misc.MoreFunctions;
 import org.apache.abdera2.common.misc.MapRed.Collector;
 import org.apache.abdera2.common.misc.MapRed.Mapper;
-import org.apache.abdera2.common.misc.MapRed.Pair;
+import org.apache.abdera2.common.misc.Pair;
 import org.apache.abdera2.common.misc.MapRed.PairBuilder;
 import org.apache.abdera2.common.misc.MapRed.ReducerFunction;
 import org.apache.abdera2.model.Document;
@@ -114,7 +114,7 @@ public class MapRedExample {
     // when it is complete
     for (Pair<Integer,Iterable<String>> entry : ff.apply(gen).get())
       System.out.println(
-        entry.key() + "=" + entry.val());
+        entry.first() + "=" + entry.second());
     
     
   }

Modified: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/Feature.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/Feature.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/Feature.java (original)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/Feature.java Mon Nov
 7 21:31:52 2011
@@ -84,25 +84,18 @@ public class Feature extends ExtensibleE
 
     public void addType(String... mediaRanges) {
         mediaRanges = MimeTypeHelper.condense(mediaRanges);
-        for (String mediaRange : mediaRanges) {
-            try {
-                addSimpleExtension(FeaturesHelper.TYPE, new MimeType(mediaRange).toString());
-            } catch (MimeTypeParseException e) {
-            }
-        }
+        for (String mediaRange : mediaRanges)
+          addSimpleExtension(
+            FeaturesHelper.TYPE, 
+            MimeTypeHelper.unmodifiableMimeType(mediaRange).toString());
     }
 
     public Iterable<String> getTypes() {
         Set<String> list = new HashSet<String>();
         for (Element type : getExtensions(FeaturesHelper.TYPE)) {
-            String value = type.getText();
-            if (value != null) {
-                value = value.trim();
-                try {
-                    list.add(new MimeType(value).toString());
-                } catch (MimeTypeParseException e) {
-                }
-            }
+          String value = type.getText();
+          if (value != null)
+            list.add(MimeTypeHelper.unmodifiableMimeType(value.trim()).toString());
         }
         return list;
     }

Modified: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/FeatureSelector.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/FeatureSelector.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/FeatureSelector.java
(original)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/features/FeatureSelector.java
Mon Nov  7 21:31:52 2011
@@ -20,6 +20,7 @@ package org.apache.abdera2.ext.features;
 import java.util.LinkedHashSet;
 import java.util.Set;
 
+import org.apache.abdera2.common.misc.MoreFunctions;
 import org.apache.abdera2.common.selector.AbstractSelector;
 import org.apache.abdera2.common.selector.Selector;
 import org.apache.abdera2.ext.features.FeaturesHelper.Status;
@@ -59,10 +60,7 @@ implements Selector<Collection> {
 
     @Override
     public int hashCode() {
-        final int PRIME = 31;
-        int result = 1;
-        result = PRIME * result + ((features == null) ? 0 : features.hashCode());
-        return result;
+      return MoreFunctions.genHashCode(1, features);
     }
 
     @Override

Modified: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/media/MediaContent.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/media/MediaContent.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/media/MediaContent.java (original)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/media/MediaContent.java Mon Nov
 7 21:31:52 2011
@@ -24,6 +24,8 @@ import org.apache.abdera2.model.Element;
 import org.apache.abdera2.model.ExtensibleElementWrapper;
 import org.apache.abdera2.common.anno.QName;
 import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.common.mediatype.MimeTypeHelper;
+
 import static org.apache.abdera2.ext.media.MediaConstants.*;
 
 @QName(value=LN_CONTENT, 
@@ -64,19 +66,17 @@ public class MediaContent extends Extens
     }
 
     public MimeType getType() {
-        try {
-            String type = getAttributeValue("type");
-            return (type != null) ? new MimeType(type) : null;
-        } catch (javax.activation.MimeTypeParseException e) {
-            throw new org.apache.abdera2.common.mediatype.MimeTypeParseException(e);
-        }
+      String type = getAttributeValue("type");
+      return type != null ? 
+        MimeTypeHelper.unmodifiableMimeType(type) : 
+        null;
     }
 
     public void setType(String type) {
-        if (type != null)
-            setAttributeValue("type", type);
-        else
-            removeAttribute("type");
+      if (type != null)
+        setAttributeValue("type", type);
+      else
+        removeAttribute("type");
     }
 
     public Medium getMedium() {

Modified: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/rss/RssEnclosure.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/rss/RssEnclosure.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/rss/RssEnclosure.java (original)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/rss/RssEnclosure.java Mon Nov
 7 21:31:52 2011
@@ -24,6 +24,7 @@ import javax.xml.namespace.QName;
 
 import org.apache.abdera2.factory.Factory;
 import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.common.mediatype.MimeTypeHelper;
 import org.apache.abdera2.model.Element;
 import org.apache.abdera2.model.ExtensibleElement;
 import org.apache.abdera2.model.ExtensibleElementWrapper;
@@ -54,12 +55,10 @@ public class RssEnclosure extends Extens
     }
 
     public MimeType getMimeType() {
-        try {
-            String type = getAttributeValue("type");
-            return (type != null) ? new MimeType(type) : null;
-        } catch (javax.activation.MimeTypeParseException e) {
-            throw new org.apache.abdera2.common.mediatype.MimeTypeParseException(e);
-        }
+      String type = getAttributeValue("type");
+      return type != null ? 
+        MimeTypeHelper.unmodifiableMimeType(type) : 
+        null;
     }
 
     public String getRel() {

Modified: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/serializer/AbstractConventions.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/serializer/AbstractConventions.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/serializer/AbstractConventions.java
(original)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/serializer/AbstractConventions.java
Mon Nov  7 21:31:52 2011
@@ -26,6 +26,7 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.regex.Pattern;
 
+import org.apache.abdera2.common.misc.MoreFunctions;
 import org.apache.abdera2.ext.serializer.annotation.Convention;
 
 public abstract class AbstractConventions implements Conventions, Cloneable, Serializable
{
@@ -80,11 +81,7 @@ public abstract class AbstractConvention
 
     @Override
     public int hashCode() {
-        final int PRIME = 31;
-        int result = 1;
-        result = PRIME * result + ((conventions == null) ? 0 : conventions.hashCode());
-        result = PRIME * result + (isCaseSensitive ? 1231 : 1237);
-        return result;
+      return MoreFunctions.genHashCode(1, conventions, isCaseSensitive);
     }
 
     @Override

Modified: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/thread/InReplyTo.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/thread/InReplyTo.java?rev=1198949&r1=1198948&r2=1198949&view=diff
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/thread/InReplyTo.java (original)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/thread/InReplyTo.java Mon Nov
 7 21:31:52 2011
@@ -24,6 +24,8 @@ import org.apache.abdera2.model.Element;
 import org.apache.abdera2.model.ElementWrapper;
 import org.apache.abdera2.common.anno.QName;
 import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.common.mediatype.MimeTypeHelper;
+
 import static org.apache.abdera2.ext.thread.ThreadConstants.*;
 
 @QName(value=LN_INREPLYTO,ns=THR_NS,pfx=THR_PREFIX)
@@ -43,12 +45,8 @@ public class InReplyTo extends ElementWr
     }
 
     public MimeType getMimeType() {
-        try {
-            String type = getAttributeValue("type");
-            return (type != null) ? new MimeType(type) : null;
-        } catch (javax.activation.MimeTypeParseException e) {
-            throw new org.apache.abdera2.common.mediatype.MimeTypeParseException(e);
-        }
+      String type = getAttributeValue("type");
+      return (type != null) ? MimeTypeHelper.unmodifiableMimeType(type) : null;
     }
 
     public IRI getRef() {

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=1198949&r1=1198948&r2=1198949&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 Nov  7 21:31:52 2011
@@ -22,6 +22,7 @@ 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;
 import org.apache.abdera2.model.Categories;
 import org.apache.abdera2.protocol.server.model.AtompubCategoriesInfo;
@@ -95,13 +96,7 @@ public class SimpleCategoriesInfo implem
     }
 
     public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + (fixed ? 1231 : 1237);
-        result = prime * result + ((href == null) ? 0 : href.hashCode());
-        result = prime * result + ((list == null) ? 0 : list.hashCode());
-        result = prime * result + ((scheme == null) ? 0 : scheme.hashCode());
-        return result;
+      return MoreFunctions.genHashCode(1, fixed, href, list, scheme);
     }
 
     public boolean equals(Object obj) {

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=1198949&r1=1198948&r2=1198949&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 Nov  7 21:31:52 2011
@@ -19,6 +19,7 @@ package org.apache.abdera2.protocol.serv
 
 import java.io.Serializable;
 
+import org.apache.abdera2.common.misc.MoreFunctions;
 import org.apache.abdera2.common.protocol.RequestContext;
 import org.apache.abdera2.model.Category;
 import org.apache.abdera2.protocol.server.model.AtompubCategoryInfo;
@@ -78,12 +79,7 @@ public class SimpleCategoryInfo implemen
     }
 
     public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((label == null) ? 0 : label.hashCode());
-        result = prime * result + ((scheme == null) ? 0 : scheme.hashCode());
-        result = prime * result + ((term == null) ? 0 : term.hashCode());
-        return result;
+      return MoreFunctions.genHashCode(1, label, scheme, term);
     }
 
     public boolean equals(Object obj) {

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=1198949&r1=1198948&r2=1198949&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 Nov  7 21:31:52 2011
@@ -23,6 +23,7 @@ import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
 
+import org.apache.abdera2.common.misc.MoreFunctions;
 import org.apache.abdera2.common.protocol.CollectionInfo;
 import org.apache.abdera2.common.protocol.RequestContext;
 import org.apache.abdera2.common.protocol.BasicCollectionInfo;
@@ -69,10 +70,7 @@ public class SimpleCollectionInfo 
 
     @Override
     public int hashCode() {
-      final int prime = 31;
-      int result = super.hashCode();
-      result = prime * result + ((catinfos == null) ? 0 : catinfos.hashCode());
-      return result;
+      return MoreFunctions.genHashCode(super.hashCode(), catinfos);
     }
 
     @Override
@@ -93,14 +91,13 @@ public class SimpleCollectionInfo 
     }
 
     public Collection asCollectionElement(RequestContext request) {
-        Collection collection = AbstractAtompubProvider.getAbdera(request).getFactory().newCollection();
-        collection.setHref(getHref(request));
-        collection.setTitle(getTitle(request));
-        collection.setAccept(getAccepts(request));
-        for (AtompubCategoriesInfo catsinfo : this.catinfos) {
-            collection.addCategories(catsinfo.asCategoriesElement(request));
-        }
-        return collection;
+      Collection collection = AbstractAtompubProvider.getAbdera(request).getFactory().newCollection();
+      collection.setHref(getHref(request));
+      collection.setTitle(getTitle(request));
+      collection.setAccept(getAccepts(request));
+      for (AtompubCategoriesInfo catsinfo : this.catinfos)
+        collection.addCategories(catsinfo.asCategoriesElement(request));
+      return collection;
     }
 
 }



Mime
View raw message