abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r607807 - /incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/XmlUtil.java
Date Tue, 01 Jan 2008 05:47:50 GMT
Author: jmsnell
Date: Mon Dec 31 21:47:48 2007
New Revision: 607807

URL: http://svn.apache.org/viewvc?rev=607807&view=rev
Log:
Use an Inversion Set instead of BitSet

Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/XmlUtil.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/XmlUtil.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/XmlUtil.java?rev=607807&r1=607806&r2=607807&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/XmlUtil.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/XmlUtil.java Mon
Dec 31 21:47:48 2007
@@ -17,7 +17,7 @@
 */
 package org.apache.abdera.util;
 
-import org.apache.abdera.i18n.ChainableBitSet;
+import org.apache.abdera.i18n.text.CharUtils;
 import org.apache.abdera.i18n.text.Filter;
 
 public class XmlUtil {
@@ -34,7 +34,8 @@
     }
   };
   
-  private static class XmlFilter implements Filter {
+  private static class XmlFilter 
+    implements Filter {
     private final XMLVersion version;
     XmlFilter(XMLVersion version) {
       this.version = version;
@@ -44,32 +45,34 @@
     }
   }
   
-  private static final ChainableBitSet restrictedchar10 =
-    new ChainableBitSet().set2(0, 8)
-                         .set2(11, 12)
-                         .set2(14, 31)
-                         .set2(55296, 57343)
-                         .set2(65534, 65535);
-
-  private static final ChainableBitSet restrictedchar11 = 
-    new ChainableBitSet().set2(0, 8)
-                         .set2(11, 12)
-                         .set2(14, 31)
-                         .set2(127, 159)
-                         .set2(55296, 57343)
-                         .set2(65534, 65535);
+  // inversion set
+  private static int[] RESTRICTED_SET_v1 = {
+    0,   9,
+    11, 13,
+    14, 32,
+    55296, 57344,
+    65534, 65536
+  };
+  
+  // inversion set
+  private static int[] RESTRICTED_SET_v11 = {
+    11, 13,
+    14, 32,
+    127, 160,
+    55296, 57344,
+    65534, 65536      
+  };
   
   public static boolean restricted(XMLVersion version, char c) {
     return restricted(version,(int)c);
   }
   
   public static boolean restricted(XMLVersion version, int c) {
-    switch(version) {
-      case XML11:
-        return restrictedchar11.get(c);
-      default:
-        return restrictedchar10.get(c);
-    }
+    return CharUtils.invset_contains(
+      version == XMLVersion.XML10 ? 
+        RESTRICTED_SET_v1 : 
+        RESTRICTED_SET_v11, 
+      c);
   }
   
   public static XMLVersion getVersion(String version) {



Mime
View raw message