You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by ra...@apache.org on 2005/04/03 18:05:01 UTC
cvs commit: xml-security/src/org/apache/xml/security/utils UnsyncByteArrayOutputStream.java Base64.java JavaUtils.java
raul 2005/04/03 09:05:01
Modified: src/org/apache/xml/security/c14n/implementations
CanonicalizerBase.java
src/org/apache/xml/security/utils Base64.java JavaUtils.java
Added: src/org/apache/xml/security/utils
UnsyncByteArrayOutputStream.java
Log:
Added unsync bytearryoutputstream, a little faster for j2me jvm.
Revision Changes Path
1.15 +3 -2 xml-security/src/org/apache/xml/security/c14n/implementations/CanonicalizerBase.java
Index: CanonicalizerBase.java
===================================================================
RCS file: /home/cvs/xml-security/src/org/apache/xml/security/c14n/implementations/CanonicalizerBase.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- CanonicalizerBase.java 7 Mar 2005 20:39:33 -0000 1.14
+++ CanonicalizerBase.java 3 Apr 2005 16:05:01 -0000 1.15
@@ -34,6 +34,7 @@
import org.apache.xml.security.c14n.CanonicalizerSpi;
import org.apache.xml.security.c14n.helper.AttrCompare;
import org.apache.xml.security.utils.Constants;
+import org.apache.xml.security.utils.UnsyncByteArrayOutputStream;
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Attr;
import org.w3c.dom.Comment;
@@ -90,7 +91,7 @@
* in subtree canonicalizations.
*/
Node _excludeNode =null;
- OutputStream _writer = new ByteArrayOutputStream();//null;
+ OutputStream _writer = new UnsyncByteArrayOutputStream();//null;
/**
* Constructor CanonicalizerBase
1.17 +1 -2 xml-security/src/org/apache/xml/security/utils/Base64.java
Index: Base64.java
===================================================================
RCS file: /home/cvs/xml-security/src/org/apache/xml/security/utils/Base64.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- Base64.java 13 Nov 2004 23:31:24 -0000 1.16
+++ Base64.java 3 Apr 2005 16:05:01 -0000 1.17
@@ -19,7 +19,6 @@
import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -302,7 +301,7 @@
public static byte[] decode(BufferedReader reader)
throws IOException, Base64DecodingException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ UnsyncByteArrayOutputStream baos = new UnsyncByteArrayOutputStream();
String line;
while (null != (line = reader.readLine())) {
1.12 +2 -3 xml-security/src/org/apache/xml/security/utils/JavaUtils.java
Index: JavaUtils.java
===================================================================
RCS file: /home/cvs/xml-security/src/org/apache/xml/security/utils/JavaUtils.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- JavaUtils.java 2 Apr 2005 18:52:39 -0000 1.11
+++ JavaUtils.java 3 Apr 2005 16:05:01 -0000 1.12
@@ -18,7 +18,6 @@
-import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -57,7 +56,7 @@
{
FileInputStream fisRef = new FileInputStream(fileName);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ UnsyncByteArrayOutputStream baos = new UnsyncByteArrayOutputStream();
byte buf[] = new byte[1024];
int len;
@@ -108,7 +107,7 @@
byte refBytes[] = null;
{
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ UnsyncByteArrayOutputStream baos = new UnsyncByteArrayOutputStream();
byte buf[] = new byte[1024];
int len;
1.1 xml-security/src/org/apache/xml/security/utils/UnsyncByteArrayOutputStream.java
Index: UnsyncByteArrayOutputStream.java
===================================================================
package org.apache.xml.security.utils;
import java.io.ByteArrayOutputStream;
/**
* A simple Unsynced ByteArryOutputStream
* @author raul
*
*/
public class UnsyncByteArrayOutputStream extends ByteArrayOutputStream {
int size=1024;
byte []buf=new byte[size];
int pos;
/** @inheritDoc */
public void write(byte[] arg0) {
int newPos=pos+arg0.length;
if (newPos>size) {
expandSize();
}
System.arraycopy(arg0,0,buf,pos,arg0.length);
pos=newPos;
}
/** @inheritDoc */
public void write(byte[] arg0, int arg1, int arg2) {
int newPos=pos+arg2;
if (newPos>size) {
expandSize();
}
System.arraycopy(arg0,arg1,buf,pos,arg2);
pos=newPos;
}
/** @inheritDoc */
public void write(int arg0) {
if (pos>=size) {
expandSize();
}
buf[pos++]=(byte)arg0;
}
/** @inheritDoc */
public byte[] toByteArray() {
byte result[]=new byte[pos];
System.arraycopy(buf,0,result,0,pos);
return result;
}
/** @inheritDoc */
public void reset() {
pos=0;
}
/** @inheritDoc */
void expandSize() {
int newSize=size<<2;
byte newBuf[]=new byte[newSize];
System.arraycopy(buf,0,newBuf,0,pos);
buf=newBuf;
size=newSize;
}
}