Package: jasperreports3.7 / 3.7.4+dfsg-2

09_use_commons_codec.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
Description: Use Commons Codec Base64 decode/encode
  instead of non-DFSG-free W3C one (removed from tarball).
Author: Damien Raude-Morvan <drazzib@debian.org>
Forwarded: no
Last-Update: 2010-04-20
--- a/src/net/sf/jasperreports/engine/export/JRXmlExporter.java
+++ b/src/net/sf/jasperreports/engine/export/JRXmlExporter.java
@@ -88,7 +88,7 @@
 import net.sf.jasperreports.engine.util.JRXmlWriteHelper;
 import net.sf.jasperreports.engine.xml.JRXmlConstants;
 
-import org.w3c.tools.codec.Base64Encoder;
+import org.apache.commons.codec.binary.Base64;
 
 
 /**
@@ -841,13 +841,8 @@
 			{
 				try
 				{
-					ByteArrayInputStream bais = new ByteArrayInputStream(renderer.getImageData());
-					ByteArrayOutputStream baos = new ByteArrayOutputStream();
-					
-					Base64Encoder encoder = new Base64Encoder(bais, baos);
-					encoder.process();
-					
-					imageSource = new String(baos.toByteArray(), DEFAULT_XML_ENCODING);
+					byte[] byteOut = Base64.decodeBase64(renderer.getImageData());
+					imageSource = new String(byteOut, DEFAULT_XML_ENCODING);
 				}
 				catch (IOException e)
 				{
--- a/src/net/sf/jasperreports/engine/util/JRValueStringUtils.java
+++ b/src/net/sf/jasperreports/engine/util/JRValueStringUtils.java
@@ -34,9 +34,7 @@
 
 import net.sf.jasperreports.engine.JRRuntimeException;
 
-import org.w3c.tools.codec.Base64Decoder;
-import org.w3c.tools.codec.Base64Encoder;
-import org.w3c.tools.codec.Base64FormatException;
+import org.apache.commons.codec.binary.Base64;
 
 
 /**
@@ -459,12 +457,8 @@
 		{
 			try
 			{
-				ByteArrayInputStream dataIn = new ByteArrayInputStream(data.getBytes());
-				ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
-				Base64Decoder dec = new Base64Decoder(dataIn, bytesOut);
-				dec.process();
-				
-				ByteArrayInputStream bytesIn = new ByteArrayInputStream(bytesOut.toByteArray());
+				byte[] bytesOut = Base64.decodeBase64(data.getBytes());
+				ByteArrayInputStream bytesIn = new ByteArrayInputStream(bytesOut);
 				ObjectInputStream objectIn = new ObjectInputStream(bytesIn);
 				return objectIn.readObject();
 			}
@@ -476,10 +470,6 @@
 			{
 				throw new JRRuntimeException(e);
 			}
-			catch (Base64FormatException e)
-			{
-				throw new JRRuntimeException(e);
-			}
 		}
 
 		public String serialize(Object value)
@@ -490,14 +480,9 @@
 				ObjectOutputStream objectOut = new ObjectOutputStream(bytesOut);
 				objectOut.writeObject(value);
 				objectOut.close();
-				
-				ByteArrayInputStream bytesIn = new ByteArrayInputStream(bytesOut.toByteArray());
-				ByteArrayOutputStream dataOut = new ByteArrayOutputStream();				
-				
-				Base64Encoder enc = new Base64Encoder(bytesIn, dataOut);
-				enc.process();
-				
-				return new String(dataOut.toByteArray(), "UTF-8");
+
+				byte[] dataOut = Base64.decodeBase64(bytesOut.toByteArray());   
+				return new String(dataOut, "UTF-8");
 			}
 			catch (NotSerializableException e)
 			{
--- a/src/net/sf/jasperreports/engine/xml/JRPrintImageSourceObject.java
+++ b/src/net/sf/jasperreports/engine/xml/JRPrintImageSourceObject.java
@@ -30,8 +30,7 @@
 import net.sf.jasperreports.engine.JRImageRenderer;
 import net.sf.jasperreports.engine.JRPrintImage;
 
-import org.w3c.tools.codec.Base64Decoder;
-
+import org.apache.commons.codec.binary.Base64;
 
 /**
  * @author Teodor Danciu (teodord@users.sourceforge.net)
@@ -79,13 +78,8 @@
 		{
 			try
 			{
-				ByteArrayInputStream bais = new ByteArrayInputStream(imageSource.getBytes("UTF-8"));//FIXMENOW other encodings ?
-				ByteArrayOutputStream baos = new ByteArrayOutputStream();
-				
-				Base64Decoder decoder = new Base64Decoder(bais, baos);
-				decoder.process();
-				
-				printImage.setRenderer(JRImageRenderer.getInstance(baos.toByteArray()));//, JRImage.ON_ERROR_TYPE_ERROR));
+				byte[] decodedBytes =  Base64.decodeBase64(imageSource.getBytes("UTF-8")); //FIXMENOW other encodings ?
+				printImage.setRenderer(JRImageRenderer.getInstance(decodedBytes));//, JRImage.ON_ERROR_TYPE_ERROR));
 			}
 			catch (Exception e)
 			{