/[classpath]/classpath/gnu/java/io/encode/Encoder.java
ViewVC logotype

Diff of /classpath/gnu/java/io/encode/Encoder.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by robilad, Sun Jul 25 17:04:17 2004 UTC revision 1.8 by jfrijters, Wed Nov 17 14:46:24 2004 UTC
# Line 38  exception statement from your version. * Line 38  exception statement from your version. *
38    
39  package gnu.java.io.encode;  package gnu.java.io.encode;
40    
 import java.io.CharConversionException;  
41  import java.io.IOException;  import java.io.IOException;
42  import java.io.OutputStream;  import java.io.OutputStream;
43  import java.io.Writer;  import java.io.Writer;
# Line 76  private final String scheme_name; Line 75  private final String scheme_name;
75    */    */
76  protected final OutputStream out;  protected final OutputStream out;
77    
 /**  
   * This is the value that is substituted for bad characters that can't  
   * be encoded.  
   */  
 protected char bad_char;  
   
 /**  
   * This indicates whether or not the bad char is set or not  
   */  
 protected boolean bad_char_set;  
   
78  /*************************************************************************/  /*************************************************************************/
79    
80  /*  /*
# Line 143  Encoder(OutputStream out, String name) Line 131  Encoder(OutputStream out, String name)
131    *    *
132    * @return The number of bytes than will be encoded from the char array    * @return The number of bytes than will be encoded from the char array
133    *    *
   * @exception CharConversionException If bad char value are encountered for this encoding  
134    */    */
135  public int  public int
136  bytesInCharArray(char[] buf) throws CharConversionException  bytesInCharArray(char[] buf)
137  {  {
138    return(bytesInCharArray(buf, 0, buf.length));    return(bytesInCharArray(buf, 0, buf.length));
139  }  }
# Line 169  bytesInCharArray(char[] buf) throws Char Line 156  bytesInCharArray(char[] buf) throws Char
156    *    *
157    * @return The number of bytes than can be encoded from the char array    * @return The number of bytes than can be encoded from the char array
158    *    *
   * @exception CharConversionException If bad char value are encountered for this encoding  
159    */    */
160  public abstract int  public abstract int
161  bytesInCharArray(char[] buf, int offset, int len) throws CharConversionException;  bytesInCharArray(char[] buf, int offset, int len);
162    
163  /*************************************************************************/  /*************************************************************************/
164    
# Line 184  bytesInCharArray(char[] buf, int offset, Line 170  bytesInCharArray(char[] buf, int offset,
170    *    *
171    * @return The converted bytes array    * @return The converted bytes array
172    *    *
   * @exception CharConversionException If an error occurs  
173    */    */
174  public byte[]  public byte[]
175  convertToBytes(char[] buf) throws CharConversionException  convertToBytes(char[] buf)
176  {  {
177    return(convertToBytes(buf, 0, buf.length));    return(convertToBytes(buf, 0, buf.length));
178  }  }
# Line 205  convertToBytes(char[] buf) throws CharCo Line 190  convertToBytes(char[] buf) throws CharCo
190    *    *
191    * @return The converted byte array    * @return The converted byte array
192    *    *
   * @exception CharConversionException If an error occurs.  
193    */    */
194  public byte[]  public byte[]
195  convertToBytes(char[] buf, int offset, int len) throws CharConversionException  convertToBytes(char[] buf, int offset, int len)
196  {  {
197    byte[] bbuf = new byte[bytesInCharArray(buf, offset, len)];    byte[] bbuf = new byte[bytesInCharArray(buf, offset, len)];
198    
# Line 233  convertToBytes(char[] buf, int offset, i Line 217  convertToBytes(char[] buf, int offset, i
217    * @return The byte array passed by the caller as a param, now filled with converted bytes.    * @return The byte array passed by the caller as a param, now filled with converted bytes.
218    *    *
219    * @exception ArrayIndexOutOfBoundsException If the destination byte array is not big enough to hold all the converted bytes    * @exception ArrayIndexOutOfBoundsException If the destination byte array is not big enough to hold all the converted bytes
   * @exception CharConversionException If any other error occurs.  
220    */    */
221  public byte[]  public byte[]
222  convertToBytes(char[] buf, byte[] bbuf, int bbuf_offset) throws  convertToBytes(char[] buf, byte[] bbuf, int bbuf_offset)
                   CharConversionException  
223  {  {
224    return(convertToBytes(buf, 0, buf.length, bbuf, bbuf_offset));    return(convertToBytes(buf, 0, buf.length, bbuf, bbuf_offset));
225  }  }
# Line 263  convertToBytes(char[] buf, byte[] bbuf, Line 245  convertToBytes(char[] buf, byte[] bbuf,
245    * @return The byte array passed by the caller as a param, now filled with converted bytes.    * @return The byte array passed by the caller as a param, now filled with converted bytes.
246    *    *
247    * @exception ArrayIndexOutOfBoundsException If the destination byte array is not big enough to hold all the converted bytes.    * @exception ArrayIndexOutOfBoundsException If the destination byte array is not big enough to hold all the converted bytes.
   * @exception CharConversionException If any other error occurs.  
248    */    */
249  public abstract byte[]  public abstract byte[]
250  convertToBytes(char[] buf, int buf_offset, int len, byte[] bbuf,  convertToBytes(char[] buf, int buf_offset, int len, byte[] bbuf,
251                 int bbuf_offset) throws CharConversionException;                 int bbuf_offset);
252    
253  /*************************************************************************/  /*************************************************************************/
254    
# Line 297  flush() throws IOException Line 278  flush() throws IOException
278    
279  /*************************************************************************/  /*************************************************************************/
280    
 /**  
   * This method sets that character that will be used when converting  
   * a Unicode character that is invalid in the current encoding.  If this  
   * is set, it will be substituted for the bad value.  Otherwise, an  
   * exception will be thrown.  Note that this character itself must be  
   * valid for the current encoding.  If it is not, an exception is thrown.  
   *  
   * @param bad_char The substitute for any bad characters found.  
   *  
   * @exception CharConversionException If the bad char value is not valid in this encoding  
   */  
 public void  
 setBadCharValue(char bad_char) throws CharConversionException  
 {  
   char[] buf = new char[1];  
   buf[0] = bad_char;  
   convertToBytes(buf);  
   
   this.bad_char = bad_char;  
   bad_char_set = true;  
 }  
   
281  } // class Encoder  } // class Encoder
282    

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26