Author: mrglavas
Date: Sun Jul 16 16:48:08 2006
New Revision: 422572

URL: http://svn.apache.org/viewvc?rev=422572&view=rev
Log:
Adding constructors which allow a byte array to be passed directly to each of 
Xerces' Reader classes.

Modified:
    xerces/java/trunk/src/org/apache/xerces/impl/io/ASCIIReader.java
    xerces/java/trunk/src/org/apache/xerces/impl/io/Latin1Reader.java
    xerces/java/trunk/src/org/apache/xerces/impl/io/UCSReader.java
    xerces/java/trunk/src/org/apache/xerces/impl/io/UTF8Reader.java

Modified: xerces/java/trunk/src/org/apache/xerces/impl/io/ASCIIReader.java
URL: 
http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/io/ASCIIReader.java?rev=422572&r1=422571&r2=422572&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/io/ASCIIReader.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/io/ASCIIReader.java Sun Jul 16 
16:48:08 2006
@@ -55,10 +55,10 @@
 
     // message formatter; used to produce localized
     // exception messages
-    private MessageFormatter fFormatter = null;
+    private final MessageFormatter fFormatter;
 
     //Locale to use for messages
-    private Locale fLocale = null;
+    private final Locale fLocale;
 
     //
     // Constructors
@@ -88,11 +88,24 @@
      */
     public ASCIIReader(InputStream inputStream, int size,
             MessageFormatter messageFormatter, Locale locale) {
+        this(inputStream, new byte[size], messageFormatter, locale);
+    } // <init>(InputStream, int, MessageFormatter, Locale)
+    
+    /** 
+     * Constructs an ASCII reader from the specified input stream and buffer.
+     *
+     * @param inputStream The input stream.
+     * @param buffer      The byte buffer.
+     * @param messageFormatter  the MessageFormatter to use to message 
reporting.
+     * @param locale    the Locale for which messages are to be reported
+     */
+    public ASCIIReader(InputStream inputStream, byte [] buffer,
+            MessageFormatter messageFormatter, Locale locale) {
         fInputStream = inputStream;
-        fBuffer = new byte[size];
+        fBuffer = buffer;
         fFormatter = messageFormatter;
         fLocale = locale;
-    } // <init>(InputStream,int, MessageFormatter, Locale)
+    } // <init>(InputStream, byte[], MessageFormatter, Locale)
 
     //
     // Reader methods

Modified: xerces/java/trunk/src/org/apache/xerces/impl/io/Latin1Reader.java
URL: 
http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/io/Latin1Reader.java?rev=422572&r1=422571&r2=422572&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/io/Latin1Reader.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/io/Latin1Reader.java Sun Jul 
16 16:48:08 2006
@@ -71,9 +71,19 @@
      * @param size        The initial buffer size.
      */
     public Latin1Reader(InputStream inputStream, int size) {
-        fInputStream = inputStream;
-        fBuffer = new byte[size];
+        this(inputStream, new byte[size]);
     } // <init>(InputStream, int)
+    
+    /** 
+     * Constructs an ISO-8859-1 reader from the specified input stream and 
buffer.
+     *
+     * @param inputStream The input stream.
+     * @param buffer      The byte buffer.
+     */
+    public Latin1Reader(InputStream inputStream, byte [] buffer) {
+        fInputStream = inputStream;
+        fBuffer = buffer;
+    } // <init>(InputStream, byte[])
     
     //
     // Reader methods

Modified: xerces/java/trunk/src/org/apache/xerces/impl/io/UCSReader.java
URL: 
http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/io/UCSReader.java?rev=422572&r1=422571&r2=422572&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/io/UCSReader.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/io/UCSReader.java Sun Jul 16 
16:48:08 2006
@@ -36,7 +36,8 @@
     // Constants
     //
 
-    /** Default byte buffer size (8192, larger than that of ASCIIReader
+    /** 
+     * Default byte buffer size (8192, larger than that of ASCIIReader
      * since it's reasonable to surmise that the average UCS-4-encoded
      * file should be 4 times as large as the average ASCII-encoded file). 
      */
@@ -65,7 +66,7 @@
     //
 
     /** 
-     * Constructs an ASCII reader from the specified input stream 
+     * Constructs a UCS reader from the specified input stream 
      * using the default buffer size.  The Endian-ness and whether this is
      * UCS-2 or UCS-4 needs also to be known in advance.
      *
@@ -77,7 +78,7 @@
     } // <init>(InputStream, short)
 
     /** 
-     * Constructs an ASCII reader from the specified input stream 
+     * Constructs a UCS reader from the specified input stream 
      * and buffer size.  The Endian-ness and whether this is
      * UCS-2 or UCS-4 needs also to be known in advance.
      *
@@ -86,8 +87,21 @@
      * @param encoding One of UCS2LE, UCS2BE, UCS4LE or UCS4BE.
      */
     public UCSReader(InputStream inputStream, int size, short encoding) {
+        this(inputStream, new byte[size], encoding);
+    } // <init>(InputStream,int,short)
+    
+    /** 
+     * Constructs a UCS reader from the specified input stream 
+     * and buffer.  The Endian-ness and whether this is
+     * UCS-2 or UCS-4 needs also to be known in advance.
+     *
+     * @param inputStream The input stream.
+     * @param buffer      The byte buffer.
+     * @param encoding One of UCS2LE, UCS2BE, UCS4LE or UCS4BE.
+     */
+    public UCSReader(InputStream inputStream, byte [] buffer, short encoding) {
         fInputStream = inputStream;
-        fBuffer = new byte[size];
+        fBuffer = buffer;
         fEncoding = encoding;
     } // <init>(InputStream,int,short)
 

Modified: xerces/java/trunk/src/org/apache/xerces/impl/io/UTF8Reader.java
URL: 
http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/io/UTF8Reader.java?rev=422572&r1=422571&r2=422572&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/io/UTF8Reader.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/io/UTF8Reader.java Sun Jul 16 
16:48:08 2006
@@ -66,10 +66,10 @@
 
     // message formatter; used to produce localized
     // exception messages
-    private MessageFormatter fFormatter = null;
+    private final MessageFormatter fFormatter;
 
     //Locale to use for messages
-    private Locale fLocale = null;
+    private final Locale fLocale;
 
     //
     // Constructors
@@ -109,11 +109,25 @@
      */
     public UTF8Reader(InputStream inputStream, int size,
             MessageFormatter messageFormatter, Locale locale) {
+        this(inputStream, new byte[size], messageFormatter, locale);
+    } // <init>(InputStream, int, MessageFormatter, Locale)
+    
+    /**
+     * Constructs a UTF-8 reader from the specified input stream,
+     * buffer and MessageFormatter.
+     *
+     * @param inputStream The input stream.
+     * @param buffer      The byte buffer.
+     * @param messageFormatter  the formatter for localizing/formatting errors.
+     * @param locale    the Locale to use for messages
+     */
+    public UTF8Reader(InputStream inputStream, byte [] buffer,
+            MessageFormatter messageFormatter, Locale locale) {
         fInputStream = inputStream;
-        fBuffer = new byte[size];
+        fBuffer = buffer;
         fFormatter = messageFormatter;
         fLocale = locale;
-    } // <init>(InputStream, int, MessageFormatter, Locale)
+    } // <init>(InputStream, byte[], MessageFormatter, Locale)
 
     //
     // Reader methods
@@ -690,4 +704,4 @@
 
     } // invalidSurrogate(int)
 
-} // class UTF8Reader
\ No newline at end of file
+} // class UTF8Reader



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to