quintonm 2003/03/09 16:37:04
Modified: email/src/java/org/apache/commons/mail
ByteArrayDataSource.java
Log:
- Moved package declaration to the first line of the file.
- Updated javadocs.
- Style fixes
- Deprecated class since it is not used by anything else in this package.
Revision Changes Path
1.3 +42 -49
jakarta-commons-sandbox/email/src/java/org/apache/commons/mail/ByteArrayDataSource.java
Index: ByteArrayDataSource.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/email/src/java/org/apache/commons/mail/ByteArrayDataSource.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ByteArrayDataSource.java 19 Jan 2003 20:06:17 -0000 1.2
+++ ByteArrayDataSource.java 10 Mar 2003 00:37:04 -0000 1.3
@@ -1,3 +1,5 @@
+package org.apache.commons.mail;
+
/* ====================================================================
* The Apache Software License, Version 1.1
*
@@ -51,8 +53,6 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-package org.apache.commons.mail;
-
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
@@ -71,40 +71,33 @@
* - a byte array<br>
* - a String<br>
*
- * @author <a href="mailto:[EMAIL PROTECTED]">Colin Chalmers</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Colin Chalmers</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jon S. Stevens</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Brett McLaughlin</a>
* @version $Id$
+ * @deprecated no replacement
*/
public class ByteArrayDataSource
- implements DataSource
+ implements DataSource
{
/** Stream containg the Data */
private ByteArrayOutputStream baos = null;
-
+
/** Content-type. */
private String type = "application/octet-stream";
/**
- * Default constructor
- *
- */
- public ByteArrayDataSource()
- {
- }
-
- /**
* Create a datasource from a byte array.
*
* @param data A byte[].
* @param type A String.
- * @exception IOException.
+ * @exception IOException
*/
public ByteArrayDataSource(byte[] data, String type)
- throws IOException
+ throws IOException
{
ByteArrayInputStream Bis = null;
-
+
try
{
Bis = new ByteArrayInputStream(data);
@@ -132,48 +125,48 @@
/**
* Create a datasource from an input stream.
*
- * @param is An InputStream.
+ * @param aIs An InputStream.
* @param type A String.
- * @exception IOException.
+ * @exception IOException
*/
public ByteArrayDataSource(InputStream aIs, String type)
- throws IOException
+ throws IOException
{
this.byteArrayDataSource(aIs, type);
}
-
+
/**
* Create a datasource from an input stream.
*
- * @param is An InputStream.
+ * @param aIs An InputStream.
* @param type A String.
- * @exception IOException.
+ * @exception IOException
*/
private void byteArrayDataSource(InputStream aIs, String type)
- throws IOException
+ throws IOException
{
this.type = type;
-
+
BufferedInputStream Bis = null;
BufferedOutputStream osWriter = null;
-
+
try
{
int length = 0;
byte[] buffer = new byte[512];
-
+
Bis = new BufferedInputStream( aIs );
- baos = new ByteArrayOutputStream();
+ baos = new ByteArrayOutputStream();
osWriter = new BufferedOutputStream( baos );
- //Write the InputData to OutputStream
- while ((length = Bis.read(buffer)) != -1)
+ //Write the InputData to OutputStream
+ while ((length = Bis.read(buffer)) != -1)
{
osWriter.write(buffer, 0 , length);
- }
+ }
osWriter.flush();
osWriter.close();
-
+
}
catch (IOException ioex)
{
@@ -190,34 +183,34 @@
if (baos != null)
{
baos.close();
- }
+ }
if (osWriter != null)
{
osWriter.close();
- }
+ }
}
catch (IOException ignored)
{
}
}
}
-
+
/**
* Create a datasource from a String.
*
* @param data A String.
* @param type A String.
- * @exception IOException.
+ * @exception IOException
*/
public ByteArrayDataSource(String data, String type)
- throws IOException
+ throws IOException
{
this.type = type;
-
+
try
{
- baos = new ByteArrayOutputStream();
-
+ baos = new ByteArrayOutputStream();
+
// Assumption that the string contains only ASCII
// characters! Else just pass in a charset into this
// constructor and use it in getBytes().
@@ -232,7 +225,7 @@
catch (IOException ignored)
{
// Ignore
- }
+ }
finally
{
try
@@ -240,12 +233,12 @@
if (baos != null)
{
baos.close();
- }
+ }
}
catch (IOException ignored)
{
}
- }
+ }
}
/**
@@ -262,15 +255,15 @@
* Get the input stream.
*
* @return An InputStream.
- * @exception IOException.
+ * @exception IOException
*/
public InputStream getInputStream()
- throws IOException
+ throws IOException
{
if (baos == null)
{
throw new IOException("no data");
- }
+ }
return new ByteArrayInputStream(baos.toByteArray());
}
@@ -283,15 +276,15 @@
{
return "ByteArrayDataSource";
}
-
+
/**
* Get the OutputStream to write to
*
* @return An OutputStream
- * @exception IOException
+ * @exception IOException
*/
public OutputStream getOutputStream()
- throws IOException
+ throws IOException
{
baos = new ByteArrayOutputStream();
return baos;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]