directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r111134 - in incubator/directory: ldap/trunk/clients ldap/trunk/common ldap/trunk/snacc-provider ldap/trunk/snickers-provider seda/trunk snickers/trunk snickers/trunk/ber snickers/trunk/codec snickers/trunk/codec/src/java/org/apache/commons/codec/binary
Date Tue, 07 Dec 2004 20:49:23 GMT
Author: akarasulu
Date: Tue Dec  7 12:49:22 2004
New Revision: 111134

URL: http://svn.apache.org/viewcvs?view=rev&rev=111134
Log:
massive changes to deps
Added:
   incubator/directory/snickers/trunk/codec/src/java/org/apache/commons/codec/binary/BinaryCodec.java
Removed:
   incubator/directory/snickers/trunk/codec/project.properties
Modified:
   incubator/directory/ldap/trunk/clients/project.xml
   incubator/directory/ldap/trunk/common/project.xml
   incubator/directory/ldap/trunk/snacc-provider/project.properties
   incubator/directory/ldap/trunk/snacc-provider/project.xml
   incubator/directory/ldap/trunk/snickers-provider/project.xml
   incubator/directory/seda/trunk/project.properties
   incubator/directory/seda/trunk/project.xml
   incubator/directory/snickers/trunk/ber/project.xml
   incubator/directory/snickers/trunk/codec/project.xml
   incubator/directory/snickers/trunk/project.properties

Modified: incubator/directory/ldap/trunk/clients/project.xml
Url: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/clients/project.xml?view=diff&rev=111134&p1=incubator/directory/ldap/trunk/clients/project.xml&r1=111133&p2=incubator/directory/ldap/trunk/clients/project.xml&r2=111134
==============================================================================
--- incubator/directory/ldap/trunk/clients/project.xml	(original)
+++ incubator/directory/ldap/trunk/clients/project.xml	Tue Dec  7 12:49:22 2004
@@ -5,7 +5,7 @@
   <artifactId>ldap-clients</artifactId>
   <groupId>incubator-directory</groupId>
   <name>ldap-clients</name>
-  <currentVersion>SNAPSHOT</currentVersion>
+  <currentVersion>0.8.0</currentVersion>
 
   <organization>
     <name>The Apache Incubator</name>

Modified: incubator/directory/ldap/trunk/common/project.xml
Url: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/common/project.xml?view=diff&rev=111134&p1=incubator/directory/ldap/trunk/common/project.xml&r1=111133&p2=incubator/directory/ldap/trunk/common/project.xml&r2=111134
==============================================================================
--- incubator/directory/ldap/trunk/common/project.xml	(original)
+++ incubator/directory/ldap/trunk/common/project.xml	Tue Dec  7 12:49:22 2004
@@ -5,7 +5,7 @@
     <groupId>incubator-directory</groupId>	
     <id>ldap-common</id>
     <name>Common LDAP API</name>
-    <currentVersion>SNAPSHOT</currentVersion>
+    <currentVersion>0.8.0</currentVersion>
     
     <organization>
       <name>The Apache Incubator</name>
@@ -60,8 +60,8 @@
 
     <dependency>
       <groupId>incubator-directory</groupId>
-      <artifactId>codec-stateful</artifactId>
-      <version>SNAPSHOT</version>
+      <artifactId>snickers-codec</artifactId>
+      <version>0.2.0</version>
     </dependency>
 
     </dependencies>
@@ -120,14 +120,6 @@
           </includes>
         </resource>
                                                                                 
-        <resource>
-          <directory>${basedir}/conf</directory>
-          <targetPath>BLOCK-INF</targetPath>
-          <includes>
-            <include>block.xml</include>
-          </includes>
-        </resource>
-
         <resource>
           <directory>${basedir}/src/java/org/apache/ldap/common/name</directory>
           <targetPath>org/apache/ldap/common/name</targetPath>

Modified: incubator/directory/ldap/trunk/snacc-provider/project.properties
Url: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/snacc-provider/project.properties?view=diff&rev=111134&p1=incubator/directory/ldap/trunk/snacc-provider/project.properties&r1=111133&p2=incubator/directory/ldap/trunk/snacc-provider/project.properties&r2=111134
==============================================================================
--- incubator/directory/ldap/trunk/snacc-provider/project.properties	(original)
+++ incubator/directory/ldap/trunk/snacc-provider/project.properties	Tue Dec  7 12:49:22 2004
@@ -13,3 +13,7 @@
 #in the build.properties.  Remember to include the final forward slash.
 module.name=ldap-snacc-provider
 maven.repo.remote=http://cvs.apache.org/repository, http://www.ibiblio.org/maven/, http://ldapd.sourceforge.net/maven/repository/
+maven.repo.central=minotaur.apache.org
+maven.repo.central.directory=/www/cvs.apache.org/repository
+maven.remote.group=apcvs
+

Modified: incubator/directory/ldap/trunk/snacc-provider/project.xml
Url: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/snacc-provider/project.xml?view=diff&rev=111134&p1=incubator/directory/ldap/trunk/snacc-provider/project.xml&r1=111133&p2=incubator/directory/ldap/trunk/snacc-provider/project.xml&r2=111134
==============================================================================
--- incubator/directory/ldap/trunk/snacc-provider/project.xml	(original)
+++ incubator/directory/ldap/trunk/snacc-provider/project.xml	Tue Dec  7 12:49:22 2004
@@ -6,7 +6,7 @@
     <groupId>incubator-directory</groupId>
     <id>ldap-snacc-provider</id>
     <name>ldap-snacc-provider</name>
-    <currentVersion>SNAPSHOT</currentVersion>
+    <currentVersion>0.8.0</currentVersion>
     
     <organization>
       <name>The Apache Incubator</name>
@@ -28,33 +28,33 @@
       Snacc based LDAP message codec provider.
     </shortDescription>
     
-	<dependencies>
+    <dependencies>
 
     <dependency>
       <groupId>incubator-directory</groupId>
       <artifactId>ldap-common</artifactId>
-      <version>SNAPSHOT</version>
+      <version>0.8.0</version>
     </dependency>
 
     <dependency>
       <groupId>incubator-directory</groupId>
-      <artifactId>codec-stateful</artifactId>
-      <version>SNAPSHOT</version>
+      <artifactId>snickers-codec</artifactId>
+      <version>0.2.0</version>
     </dependency>
 
-		<dependency>
-			<groupId>snacc4j</groupId>
-			<artifactId>snacc</artifactId>
-			<version>2.3</version>
-			<url>http://www.alphaworks.ibm.com/tech/snaccforjava</url>
-		</dependency>
-
-		<dependency>
-			<groupId>commons-collections</groupId>
-			<artifactId>commons-collections</artifactId>
-			<version>2.1</version>
-			<url>http://jakarta.apache.org/commons/collections.html</url>
-		</dependency>
+    <dependency>
+      <groupId>snacc4j</groupId>
+      <artifactId>snacc</artifactId>
+      <version>2.3</version>
+      <url>http://www.alphaworks.ibm.com/tech/snaccforjava</url>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-collections</groupId>
+      <artifactId>commons-collections</artifactId>
+      <version>2.1</version>
+      <url>http://jakarta.apache.org/commons/collections.html</url>
+    </dependency>
 
     <dependency>
       <groupId>commons-lang</groupId>
@@ -63,14 +63,7 @@
       <url>http://jakarta.apache.org/commons/lang</url>
     </dependency>
 
-    <dependency>
-      <groupId>commons-codec</groupId>
-      <artifactId>commons-codec</artifactId>
-      <version>SNAPSHOT</version>
-      <url>http://jakarta.apache.org/commons/codec</url>
-    </dependency>
-
-	</dependencies>
+  </dependencies>
     
     <build>
       <nagEmailAddress>ldapd-devel@sourceforge.net</nagEmailAddress>

Modified: incubator/directory/ldap/trunk/snickers-provider/project.xml
Url: http://svn.apache.org/viewcvs/incubator/directory/ldap/trunk/snickers-provider/project.xml?view=diff&rev=111134&p1=incubator/directory/ldap/trunk/snickers-provider/project.xml&r1=111133&p2=incubator/directory/ldap/trunk/snickers-provider/project.xml&r2=111134
==============================================================================
--- incubator/directory/ldap/trunk/snickers-provider/project.xml	(original)
+++ incubator/directory/ldap/trunk/snickers-provider/project.xml	Tue Dec  7 12:49:22 2004
@@ -5,7 +5,7 @@
   
   <name>Snickers based LDAP BER Message Provider</name>
   <package>org.apache.ldap.common.berlib.snickers</package>
-  <currentVersion>SNAPSHOT</currentVersion>
+  <currentVersion>0.8.0</currentVersion>
   <inceptionYear>2004</inceptionYear>
       
   <shortDescription>Snickers BER Message Provider</shortDescription>
@@ -24,13 +24,6 @@
     </dependency>
 
     <dependency>
-      <groupId>commons-codec</groupId>
-      <artifactId>commons-codec</artifactId>
-      <version>SNAPSHOT</version>
-      <url>http://jakarta.apache.org/commons/codec</url>
-    </dependency>
-
-    <dependency>
       <groupId>commons-logging</groupId>
       <artifactId>commons-logging</artifactId>
       <version>1.0.3</version>
@@ -53,30 +46,33 @@
 
     <dependency>
       <groupId>incubator-directory</groupId>
-      <artifactId>codec-stateful</artifactId>
-      <version>SNAPSHOT</version>
+      <artifactId>snickers-codec</artifactId>
+      <version>0.2.0</version>
+      <url>
+        http://incubator.apache.org/directory/subprojects/snickers/codec
+      </url>
     </dependency>
 
     <dependency>
       <groupId>incubator-directory</groupId>
       <artifactId>ldap-common</artifactId>
-      <version>SNAPSHOT</version>
+      <version>0.8.0</version>
       <url>http://incubator.apache.org/directory/subprojects/ldap/common</url>
     </dependency>
 
     <dependency>
       <groupId>incubator-directory</groupId>
-      <artifactId>snickers-ber-codec</artifactId>
-      <version>SNAPSHOT</version>
+      <artifactId>snickers-ber</artifactId>
+      <version>0.2.0</version>
       <url>
-        http://incubator.apache.org/directory/subprojects/snickers/ber-codec
+        http://incubator.apache.org/directory/subprojects/snickers/ber
       </url>
     </dependency>
 
     <dependency>
       <groupId>incubator-directory</groupId>
       <artifactId>ldap-snacc-provider</artifactId>
-      <version>SNAPSHOT</version>
+      <version>0.8.0</version>
       <url>
         http://incubator.apache.org/directory/subprojects/ldap/snacc-provider
       </url>

Modified: incubator/directory/seda/trunk/project.properties
Url: http://svn.apache.org/viewcvs/incubator/directory/seda/trunk/project.properties?view=diff&rev=111134&p1=incubator/directory/seda/trunk/project.properties&r1=111133&p2=incubator/directory/seda/trunk/project.properties&r2=111134
==============================================================================
--- incubator/directory/seda/trunk/project.properties	(original)
+++ incubator/directory/seda/trunk/project.properties	Tue Dec  7 12:49:22 2004
@@ -7,9 +7,9 @@
 # remote repository properties
 #
 
-maven.repo.remote=http://cvs.apache.org/repository, http://ibiblio.org/maven
+maven.repo.remote=http://cvs.apache.org/repository, http://mirrors.sunsite.dk/maven/
 maven.repo.central=minotaur.apache.org
 maven.repo.central.directory=/www/cvs.apache.org/repository
 maven.remote.group=apcvs
 
-maven.compile.source = 1.3
\ No newline at end of file
+maven.compile.source = 1.3

Modified: incubator/directory/seda/trunk/project.xml
Url: http://svn.apache.org/viewcvs/incubator/directory/seda/trunk/project.xml?view=diff&rev=111134&p1=incubator/directory/seda/trunk/project.xml&r1=111133&p2=incubator/directory/seda/trunk/project.xml&r2=111134
==============================================================================
--- incubator/directory/seda/trunk/project.xml	(original)
+++ incubator/directory/seda/trunk/project.xml	Tue Dec  7 12:49:22 2004
@@ -5,7 +5,7 @@
   <id>seda</id>
   <name>seda</name>
   <package>org.apache.seda</package>
-  <currentVersion>SNAPSHOT</currentVersion>
+  <currentVersion>0.2.0</currentVersion>
   <inceptionYear>2004</inceptionYear>
 
   <organization>
@@ -108,8 +108,8 @@
 
     <dependency>
       <groupId>incubator-directory</groupId>
-      <artifactId>codec-stateful</artifactId>
-      <version>SNAPSHOT</version>
+      <artifactId>snickers-codec</artifactId>
+      <version>0.2.0</version>
       <url>http://incubator.apache.org/directory/subprojects/ldap/common</url>
     </dependency>
 

Modified: incubator/directory/snickers/trunk/ber/project.xml
Url: http://svn.apache.org/viewcvs/incubator/directory/snickers/trunk/ber/project.xml?view=diff&rev=111134&p1=incubator/directory/snickers/trunk/ber/project.xml&r1=111133&p2=incubator/directory/snickers/trunk/ber/project.xml&r2=111134
==============================================================================
--- incubator/directory/snickers/trunk/ber/project.xml	(original)
+++ incubator/directory/snickers/trunk/ber/project.xml	Tue Dec  7 12:49:22 2004
@@ -2,12 +2,10 @@
 <project>
   <extend>${basedir}/../project.xml</extend>
   <groupId>incubator-directory</groupId>
-  <id>snickers-ber-codec</id>
-  <version>0.2.0</version>
+  <id>snickers-ber</id>
   
   <name>Snickers BER API</name>
   <package>org.apache.snickers.ber</package>
-  <currentVersion>SNAPSHOT</currentVersion>
   <inceptionYear>2004</inceptionYear>
       
   <shortDescription>Snickers BER API</shortDescription>
@@ -49,27 +47,27 @@
     <dependency>
       <groupId>commons-primitives</groupId>
       <artifactId>commons-primitives</artifactId>
-      <version>SNAPSHOT</version>
+      <version>20041207.202534</version>
       <url>http://jakarta.apache.org/commons/primitives</url>
     </dependency>
 
     <dependency>
       <groupId>incubator-directory</groupId>
-      <artifactId>codec-stateful</artifactId>
+      <artifactId>snickers-codec</artifactId>
       <version>0.2.0</version>
     </dependency>
 
     <dependency>
       <groupId>incubator-directory</groupId>
       <artifactId>ldap-common</artifactId>
-      <version>SNAPSHOT</version>
+      <version>0.8.0</version>
       <url>http://incubator.apache.org/directory/subprojects/ldap/common</url>
     </dependency>
 
     <dependency>
       <groupId>incubator-directory</groupId>
       <artifactId>ldap-snacc-provider</artifactId>
-      <version>SNAPSHOT</version>
+      <version>0.8.0</version>
       <url>
         http://incubator.apache.org/directory/subprojects/ldap/snacc-provider
       </url>
@@ -82,12 +80,12 @@
       <url>http://alphaworks.ibm.com/tech/snaccforjava</url>
     </dependency>
     
-		<dependency>
-			<groupId>regexp</groupId>
-			<artifactId>regexp</artifactId>
-			<version>1.2</version>
-			<url>http://jakarta.apache.org/regexp/index.html</url>
-		</dependency>
+    <dependency>
+      <groupId>regexp</groupId>
+      <artifactId>regexp</artifactId>
+      <version>1.2</version>
+      <url>http://jakarta.apache.org/regexp/index.html</url>
+    </dependency>
 
   </dependencies>
 </project>

Deleted: /incubator/directory/snickers/trunk/codec/project.properties
Url: http://svn.apache.org/viewcvs/incubator/directory/snickers/trunk/codec/project.properties?view=auto&rev=111133
==============================================================================

Modified: incubator/directory/snickers/trunk/codec/project.xml
Url: http://svn.apache.org/viewcvs/incubator/directory/snickers/trunk/codec/project.xml?view=diff&rev=111134&p1=incubator/directory/snickers/trunk/codec/project.xml&r1=111133&p2=incubator/directory/snickers/trunk/codec/project.xml&r2=111134
==============================================================================
--- incubator/directory/snickers/trunk/codec/project.xml	(original)
+++ incubator/directory/snickers/trunk/codec/project.xml	Tue Dec  7 12:49:22 2004
@@ -2,13 +2,13 @@
 <project>
   <extend>${basedir}/../project.xml</extend>
   <groupId>incubator-directory</groupId>
-  <id>codec-stateful</id>
+  <id>snickers-codec</id>
   
-  <name>Stateful Codec API</name>
-  <package>org.apache.common.codec</package>
+  <name>Snickers stateful chunking codec API</name>
+  <package>org.apache.snickers.codecs</package>
   <inceptionYear>2004</inceptionYear>
       
-  <shortDescription>Stateful Codec API</shortDescription>
+  <shortDescription>API for stateful chunking encoder/decoder pairs</shortDescription>
 
   <description>
     API for stackable stateful encoders and decoders.  Such codec interfaces

Added: incubator/directory/snickers/trunk/codec/src/java/org/apache/commons/codec/binary/BinaryCodec.java
Url: http://svn.apache.org/viewcvs/incubator/directory/snickers/trunk/codec/src/java/org/apache/commons/codec/binary/BinaryCodec.java?view=auto&rev=111134
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/codec/src/java/org/apache/commons/codec/binary/BinaryCodec.java
Tue Dec  7 12:49:22 2004
@@ -0,0 +1,285 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ */ 
+
+package org.apache.commons.codec.binary;
+
+import org.apache.commons.codec.BinaryDecoder;
+import org.apache.commons.codec.BinaryEncoder;
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.EncoderException;
+
+/**
+ * Translates between byte arrays and strings of "0"s and "1"s.
+ * 
+ * @todo may want to add more bit vector functions like and/or/xor/nand 
+ * @todo also might be good to generate boolean[]
+ * from byte[] et. cetera.
+ * 
+ * @author Apache Software Foundation
+ * @since 1.3
+ * @version $Id $
+ */
+public class BinaryCodec implements BinaryDecoder, BinaryEncoder {
+    /*
+     * tried to avoid using ArrayUtils to minimize dependencies while using these empty arrays
- dep is just not worth
+     * it.
+     */
+    /** Empty char array. */
+    private static final char[] EMPTY_CHAR_ARRAY = new char[0];
+
+    /** Empty byte array. */
+    private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
+
+    /** Mask for bit 0 of a byte. */
+    private static final int BIT_0 = 1;
+
+    /** Mask for bit 1 of a byte. */
+    private static final int BIT_1 = 0x02;
+
+    /** Mask for bit 2 of a byte. */
+    private static final int BIT_2 = 0x04;
+
+    /** Mask for bit 3 of a byte. */
+    private static final int BIT_3 = 0x08;
+
+    /** Mask for bit 4 of a byte. */
+    private static final int BIT_4 = 0x10;
+
+    /** Mask for bit 5 of a byte. */
+    private static final int BIT_5 = 0x20;
+
+    /** Mask for bit 6 of a byte. */
+    private static final int BIT_6 = 0x40;
+
+    /** Mask for bit 7 of a byte. */
+    private static final int BIT_7 = 0x80;
+
+    private static final int[] BITS = {BIT_0, BIT_1, BIT_2, BIT_3, BIT_4, BIT_5, BIT_6, BIT_7};
+
+    /**
+     * Converts an array of raw binary data into an array of ascii 0 and 1 characters.
+     * 
+     * @param raw
+     *                  the raw binary data to convert
+     * @return 0 and 1 ascii character bytes one for each bit of the argument
+     * @see org.apache.commons.codec.BinaryEncoder#encode(byte[])
+     */
+    public byte[] encode(byte[] raw) {
+        return toAsciiBytes(raw);
+    }
+
+    /**
+     * Converts an array of raw binary data into an array of ascii 0 and 1 chars.
+     * 
+     * @param raw
+     *                  the raw binary data to convert
+     * @return 0 and 1 ascii character chars one for each bit of the argument
+     * @throws EncoderException
+     *                  if the argument is not a byte[]
+     * @see org.apache.commons.codec.Encoder#encode(java.lang.Object)
+     */
+    public Object encode(Object raw) throws EncoderException {
+        if (!(raw instanceof byte[])) {
+            throw new EncoderException("argument not a byte array");
+        }
+        return toAsciiChars((byte[]) raw);
+    }
+
+    /**
+     * Decodes a byte array where each byte represents an ascii '0' or '1'.
+     * 
+     * @param ascii
+     *                  each byte represents an ascii '0' or '1'
+     * @return the raw encoded binary where each bit corresponds to a byte in the byte array
argument
+     * @throws DecoderException
+     *                  if argument is not a byte[], char[] or String
+     * @see org.apache.commons.codec.Decoder#decode(java.lang.Object)
+     */
+    public Object decode(Object ascii) throws DecoderException {
+        if (ascii == null) {
+            return EMPTY_BYTE_ARRAY;
+        }
+        if (ascii instanceof byte[]) {
+            return fromAscii((byte[]) ascii);
+        }
+        if (ascii instanceof char[]) {
+            return fromAscii((char[]) ascii);
+        }
+        if (ascii instanceof String) {
+            return fromAscii(((String) ascii).toCharArray());
+        }
+        throw new DecoderException("argument not a byte array");
+    }
+
+    /**
+     * Decodes a byte array where each byte represents an ascii '0' or '1'.
+     * 
+     * @param ascii
+     *                  each byte represents an ascii '0' or '1'
+     * @return the raw encoded binary where each bit corresponds to a byte in the byte array
argument
+     * @see org.apache.commons.codec.Decoder#decode(Object)
+     */
+    public byte[] decode(byte[] ascii) {
+        return fromAscii(ascii);
+    }
+
+    /**
+     * Decodes a String where each char of the String represents an ascii '0' or '1'.
+     * 
+     * @param ascii
+     *                  String of '0' and '1' characters
+     * @return the raw encoded binary where each bit corresponds to a byte in the byte array
argument
+     * @see org.apache.commons.codec.Decoder#decode(Object)
+     */
+    public byte[] toByteArray(String ascii) {
+        if (ascii == null) {
+            return EMPTY_BYTE_ARRAY;
+        }
+        return fromAscii(ascii.toCharArray());
+    }
+
+    // ------------------------------------------------------------------------
+    //
+    // static codec operations
+    //
+    // ------------------------------------------------------------------------
+    /**
+     * Decodes a byte array where each char represents an ascii '0' or '1'.
+     * 
+     * @param ascii
+     *                  each char represents an ascii '0' or '1'
+     * @return the raw encoded binary where each bit corresponds to a char in the char array
argument
+     */
+    public static byte[] fromAscii(char[] ascii) {
+        if (ascii == null || ascii.length == 0) {
+            return EMPTY_BYTE_ARRAY;
+        }
+        // get length/8 times bytes with 3 bit shifts to the right of the length
+        byte[] l_raw = new byte[ascii.length >> 3];
+        /*
+         * We decr index jj by 8 as we go along to not recompute indices using multiplication
every time inside the
+         * loop.
+         */
+        for (int ii = 0, jj = ascii.length - 1; ii < l_raw.length; ii++, jj -= 8) {
+            for (int bits = 0; bits < BITS.length; ++bits) {
+                if (ascii[jj - bits] == '1') {
+                    l_raw[ii] |= BITS[bits];
+                }
+            }
+        }
+        return l_raw;
+    }
+
+    /**
+     * Decodes a byte array where each byte represents an ascii '0' or '1'.
+     * 
+     * @param ascii
+     *                  each byte represents an ascii '0' or '1'
+     * @return the raw encoded binary where each bit corresponds to a byte in the byte array
argument
+     */
+    public static byte[] fromAscii(byte[] ascii) {
+        if (ascii == null || ascii.length == 0) {
+            return EMPTY_BYTE_ARRAY;
+        }
+        // get length/8 times bytes with 3 bit shifts to the right of the length
+        byte[] l_raw = new byte[ascii.length >> 3];
+        /*
+         * We decr index jj by 8 as we go along to not recompute indices using multiplication
every time inside the
+         * loop.
+         */
+        for (int ii = 0, jj = ascii.length - 1; ii < l_raw.length; ii++, jj -= 8) {
+            for (int bits = 0; bits < BITS.length; ++bits) {
+                if (ascii[jj - bits] == '1') {
+                    l_raw[ii] |= BITS[bits];
+                }
+            }
+        }
+        return l_raw;
+    }
+
+    /**
+     * Converts an array of raw binary data into an array of ascii 0 and 1 character bytes
- each byte is a truncated
+     * char.
+     * 
+     * @param raw
+     *                  the raw binary data to convert
+     * @return an array of 0 and 1 character bytes for each bit of the argument
+     * @see org.apache.commons.codec.BinaryEncoder#encode(byte[])
+     */
+    public static byte[] toAsciiBytes(byte[] raw) {
+        if (raw == null || raw.length == 0) {
+            return EMPTY_BYTE_ARRAY;
+        }
+        // get 8 times the bytes with 3 bit shifts to the left of the length
+        byte[] l_ascii = new byte[raw.length << 3];
+        /*
+         * We decr index jj by 8 as we go along to not recompute indices using multiplication
every time inside the
+         * loop.
+         */
+        for (int ii = 0, jj = l_ascii.length - 1; ii < raw.length; ii++, jj -= 8) {
+            for (int bits = 0; bits < BITS.length; ++bits) {
+                if ((raw[ii] & BITS[bits]) == 0) {
+                    l_ascii[jj - bits] = '0';
+                } else {
+                    l_ascii[jj - bits] = '1';
+                }
+            }
+        }
+        return l_ascii;
+    }
+
+    /**
+     * Converts an array of raw binary data into an array of ascii 0 and 1 characters.
+     * 
+     * @param raw
+     *                  the raw binary data to convert
+     * @return an array of 0 and 1 characters for each bit of the argument
+     * @see org.apache.commons.codec.BinaryEncoder#encode(byte[])
+     */
+    public static char[] toAsciiChars(byte[] raw) {
+        if (raw == null || raw.length == 0) {
+            return EMPTY_CHAR_ARRAY;
+        }
+        // get 8 times the bytes with 3 bit shifts to the left of the length
+        char[] l_ascii = new char[raw.length << 3];
+        /*
+         * We decr index jj by 8 as we go along to not recompute indices using multiplication
every time inside the
+         * loop.
+         */
+        for (int ii = 0, jj = l_ascii.length - 1; ii < raw.length; ii++, jj -= 8) {
+            for (int bits = 0; bits < BITS.length; ++bits) {
+                if ((raw[ii] & BITS[bits]) == 0) {
+                    l_ascii[jj - bits] = '0';
+                } else {
+                    l_ascii[jj - bits] = '1';
+                }
+            }
+        }
+        return l_ascii;
+    }
+
+    /**
+     * Converts an array of raw binary data into a String of ascii 0 and 1 characters.
+     * 
+     * @param raw
+     *                  the raw binary data to convert
+     * @return a String of 0 and 1 characters representing the binary data
+     * @see org.apache.commons.codec.BinaryEncoder#encode(byte[])
+     */
+    public static String toAsciiString(byte[] raw) {
+        return new String(toAsciiChars(raw));
+    }
+}

Modified: incubator/directory/snickers/trunk/project.properties
Url: http://svn.apache.org/viewcvs/incubator/directory/snickers/trunk/project.properties?view=diff&rev=111134&p1=incubator/directory/snickers/trunk/project.properties&r1=111133&p2=incubator/directory/snickers/trunk/project.properties&r2=111134
==============================================================================
--- incubator/directory/snickers/trunk/project.properties	(original)
+++ incubator/directory/snickers/trunk/project.properties	Tue Dec  7 12:49:22 2004
@@ -12,7 +12,7 @@
 tag2.scope=all
 
 #maven.clover.instrument.tests=true
-maven.junit.fork=true
+#maven.junit.fork=true
 maven.changelog.factory=org.apache.maven.svnlib.SvnChangeLogFactory
 maven.license.licenseFile=../../LICENSE.txt
 maven.xdoc.date=left

Mime
View raw message