elena 2004/06/16 08:57:28 Modified: java/src/org/apache/xerces/impl/dv/util Base64.java Log: Update implementation according to the errata: http://www.w3.org/2001/05/xmlschema-errata#e2-54 Revision Changes Path 1.10 +3 -41 xml-xerces/java/src/org/apache/xerces/impl/dv/util/Base64.java Index: Base64.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/util/Base64.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- Base64.java 24 Feb 2004 22:44:26 -0000 1.9 +++ Base64.java 16 Jun 2004 15:57:28 -0000 1.10 @@ -114,55 +114,19 @@ int fewerThan24bits = lengthDataBits%TWENTYFOURBITGROUP; int numberTriplets = lengthDataBits/TWENTYFOURBITGROUP; int numberQuartet = fewerThan24bits != 0 ? numberTriplets+1 : numberTriplets; - int numberLines = (numberQuartet-1)/19+1; char encodedData[] = null; - encodedData = new char[numberQuartet*4+numberLines]; + encodedData = new char[numberQuartet*4]; byte k=0, l=0, b1=0,b2=0,b3=0; int encodedIndex = 0; int dataIndex = 0; - int i = 0; if (fDebug) { System.out.println("number of triplets = " + numberTriplets ); } - for (int line = 0; line < numberLines-1; line++) { - for (int quartet = 0; quartet < 19; quartet++) { - b1 = binaryData[dataIndex++]; - b2 = binaryData[dataIndex++]; - b3 = binaryData[dataIndex++]; - - if (fDebug) { - System.out.println( "b1= " + b1 +", b2= " + b2 + ", b3= " + b3 ); - } - - l = (byte)(b2 & 0x0f); - k = (byte)(b1 & 0x03); - - byte val1 = ((b1 & SIGN)==0)?(byte)(b1>>2):(byte)((b1)>>2^0xc0); - - byte val2 = ((b2 & SIGN)==0)?(byte)(b2>>4):(byte)((b2)>>4^0xf0); - byte val3 = ((b3 & SIGN)==0)?(byte)(b3>>6):(byte)((b3)>>6^0xfc); - - if (fDebug) { - System.out.println( "val2 = " + val2 ); - System.out.println( "k4 = " + (k<<4)); - System.out.println( "vak = " + (val2 | (k<<4))); - } - - encodedData[encodedIndex++] = lookUpBase64Alphabet[ val1 ]; - encodedData[encodedIndex++] = lookUpBase64Alphabet[ val2 | ( k<<4 )]; - encodedData[encodedIndex++] = lookUpBase64Alphabet[ (l <<2 ) | val3 ]; - encodedData[encodedIndex++] = lookUpBase64Alphabet[ b3 & 0x3f ]; - - i++; - } - encodedData[encodedIndex++] = 0xa; - } - - for (; i<numberTriplets; i++) { + for (int i=0; i<numberTriplets; i++) { b1 = binaryData[dataIndex++]; b2 = binaryData[dataIndex++]; b3 = binaryData[dataIndex++]; @@ -219,8 +183,6 @@ encodedData[encodedIndex++] = PAD; } - encodedData[encodedIndex] = 0xa; - return new String(encodedData); }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]