abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1195592 - in /abdera/abdera2/common/src/main/java/org/apache/abdera2/common/lang: Lang.java Range.java
Date Mon, 31 Oct 2011 18:14:47 GMT
Author: jmsnell
Date: Mon Oct 31 18:14:47 2011
New Revision: 1195592

URL: http://svn.apache.org/viewvc?rev=1195592&view=rev
Log: (empty)

Modified:
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/lang/Lang.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/lang/Range.java

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=1195592&r1=1195591&r2=1195592&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 Oct 31
18:14:47 2011
@@ -26,6 +26,8 @@ import java.util.regex.Pattern;
 
 import org.apache.abdera2.common.lang.Subtag.Type;
 
+import com.google.common.collect.Iterables;
+
 /**
  * Implementation of RFC 4646 Language Tags. Instances are immutable and 
  * safe for use by multiple threads. Iterators returned by calling 
@@ -140,14 +142,14 @@ public final class Lang 
       return t_extension;
     }
     
-    public Subtag[] extensions() {
+    public Iterable<Subtag> extensions() {
       List<Subtag> list = new ArrayList<Subtag>();
       Subtag extension = extension();
       while(extension != null) {
         list.add(extension);
         extension = nextExtension(extension);
       }
-      return list.toArray(new Subtag[list.size()]);
+      return Iterables.unmodifiableIterable(list);
     }
     
     public Subtag extension(String name) {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/lang/Range.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/lang/Range.java?rev=1195592&r1=1195591&r2=1195592&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/lang/Range.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/lang/Range.java Mon Oct
31 18:14:47 2011
@@ -28,6 +28,7 @@ import org.apache.abdera2.common.lang.Su
 
 import com.google.common.base.Function;
 import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
 
 /**
  * A language range used for matching language tags
@@ -204,45 +205,45 @@ public final class Range 
         }
     }
 
-    public Function<Lang[],Lang[]> filter() {
+    public Function<Lang[],Iterable<Lang>> filter() {
       final Range thisRange = this;
-      return new Function<Lang[],Lang[]>() {
-        public Lang[] apply(Lang[] input) {
+      return new Function<Lang[],Iterable<Lang>>() {
+        public Iterable<Lang> apply(Lang[] input) {
           return thisRange.filter(input);
         }
       };
     }
     
-    public Function<String[],String[]> filterString() {
+    public Function<String[],Iterable<String>> filterString() {
       final Range thisRange = this;
-      return new Function<String[],String[]>() {
-        public String[] apply(String[] input) {
+      return new Function<String[],Iterable<String>>() {
+        public Iterable<String> apply(String[] input) {
           return thisRange.filter(input);
         }
       };
     }
     
-    public Lang[] filter(Lang... lang) {
+    public Iterable<Lang> filter(Lang... lang) {
         List<Lang> langs = new LinkedList<Lang>();
         for (Lang l : lang)
             if (matches(l))
                 langs.add(l);
-        return langs.toArray(new Lang[langs.size()]);
+        return Iterables.unmodifiableIterable(langs);
     }
 
-    public String[] filter(String... lang) {
+    public Iterable<String> filter(String... lang) {
         List<String> langs = new LinkedList<String>();
         for (String l : lang)
             if (matches(l))
                 langs.add(l);
-        return langs.toArray(new String[langs.size()]);
+        return Iterables.unmodifiableIterable(langs);
     }
 
-    public static Lang[] filter(String range, Lang... lang) {
+    public static Iterable<Lang> filter(String range, Lang... lang) {
         return new Range(range).filter(lang);
     }
 
-    public static String[] filter(String range, String... lang) {
+    public static Iterable<String> filter(String range, String... lang) {
         return new Range(range).filter(lang);
     }
     



Mime
View raw message