commit-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FYI: Fix static protected confusion in En/Decoders


From: Mark Wielaard
Subject: FYI: Fix static protected confusion in En/Decoders
Date: Sat, 24 Apr 2004 00:36:52 +0200

Hi,

This looks like a big patch, but it doesn't do that much. The main thing
it does is making some static protected fields into non-static private
fields that get initialized through the (super-class) constructor. The
original code assumed that protected static fields got inherited as
static fields by subclasses.

2004-04-23  Mark Wielaard  <address@hidden>

       * java/io/OutputStreamWriter.java (getEncoding): Return null when
       out == null, otherwise call out.getSchemeName.
       * gnu/java/io/decode/Decoder.java (scheme_name): Make non-static
       private final.
       (scheme_description): Removed.
       (in): Make final.
       (getSchemeName): Make non-static.
       (getSchemeDescription): Removed.
       (Decoder): Make protected and add name parameter.
       gnu/java/io/decode/Decoder8859_1.java (lookup_table_8859_1): Make
       private static final.
       (static): Removed block.
       (Decoder8859_1): Call super(in, name, table).
       * gnu/java/io/decode/Decoder8859_2.java: Likewise.
       * gnu/java/io/decode/Decoder8859_3.java: Likewise.
       * gnu/java/io/decode/Decoder8859_4.java: Likewise.
       * gnu/java/io/decode/Decoder8859_5.java: Likewise.
       * gnu/java/io/decode/DecoderEightBitLookup.java (lookup_table): Make
       private final.
       (DecoderEightBitLookup): Make protected. Add name and table
       parameters. Call super(in, name).
       * gnu/java/io/decode/DecoderUTF8.java (static): Remove block.
       (DecoderUTF8): Call super(in, name).
       * gnu/java/io/encode/Encoder.java (scheme_description): Remove field.
       (scheme_name): Make non-static private final.
       (out): Make final.
       (getSchemeName): Make non-static.
       (getSchemeDescription): Removed.
       (Encoder): Make protected and add parameter name to initialize
       scheme_name.
       * gnu/java/io/encode/Encoder8859_1.java (lookup_table_8859_1): Make
       private and final.
       (static): Remove block.
       (Encoder8859_1): Call super(out, name, table).
       gnu/java/io/encode/Encoder8859_2.java: Likewise.
       gnu/java/io/encode/Encoder8859_3.java: Likewise.
       gnu/java/io/encode/Encoder8859_4.java: Likewise.
       gnu/java/io/encode/Encoder8859_5.java: Likewise.
       * gnu/java/io/encode/EncoderEightBitLookup.java (lookup_table):
       Removed field.
       (encoding_table): Make non-static and final.
       (loadTable): Make non-static private and return byte[] table.
       (EncoderEightBitLookup): Add parameters name and table. Call
       super(out, name) and initialize encoding_table with loadTable(table).
       * gnu/java/io/encode/EncoderUTF8.java (static): Remove block.
       (EncoderUTF8): Call super(out, name).

Committed.

Cheers,

Mark
Index: java/io/OutputStreamWriter.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/OutputStreamWriter.java,v
retrieving revision 1.10
diff -u -r1.10 OutputStreamWriter.java
--- java/io/OutputStreamWriter.java     28 Mar 2004 18:42:33 -0000      1.10
+++ java/io/OutputStreamWriter.java     23 Apr 2004 22:26:43 -0000
@@ -150,7 +150,7 @@
    */
   public String getEncoding ()
   {
-    return out.getSchemeName ();
+    return out != null ? out.getSchemeName () : null;
   }
 
   /**
Index: gnu/java/io/decode/Decoder.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/io/decode/Decoder.java,v
retrieving revision 1.4
diff -u -r1.4 Decoder.java
--- gnu/java/io/decode/Decoder.java     22 Jan 2002 22:26:57 -0000      1.4
+++ gnu/java/io/decode/Decoder.java     23 Apr 2004 22:26:43 -0000
@@ -1,5 +1,5 @@
 /* Decoder.java -- Base class for byte->char decoders
-   Copyright (C) 1998 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -60,16 +60,9 @@
  */
 
 /**
-  * This is the name of the current encoding. MUST be overriden by
-  * subclasses.
+  * This is the name of the current encoding. Set in the constructor.
   */
-protected static String scheme_name = "undefined";
-
-/**
-  * This is a description of the current encoding.  MUST be overridden
-  * by subclasses.
-  */
-protected static String scheme_description = "undefined";
+private final String scheme_name;
 
 /*************************************************************************/
 
@@ -80,62 +73,46 @@
 /**
   * This is the <code>InputStream</code> bytes are read from
   */
-protected InputStream in;
+protected final InputStream in;
 
 /*************************************************************************/
 
 /*
- * Class Methods
+ * Constructors
  */
 
 /**
-  * This method returns the name of the encoding scheme in use
-  *
-  * @return The name of the encoding scheme
-  */
-public static String
-getSchemeName()
-{
-  return(scheme_name);
-}
-
-/*************************************************************************/
-
-/**
-  * This method returns a description of the encoding scheme in use
+  * This method initializes a new <code>Decoder</code> to read from the
+  * specified <code>InputStream</code>.
   *
-  * @param A description of the decoding scheme.
+  * @param in The <code>InputStream</code> to read from
+  * @param name The character scheme name
   */
-public static String
-getSchemeDescription()
+protected
+Decoder(InputStream in, String name)
 {
-  return(scheme_description);
+  this.in = in;
+  this.scheme_name = name;
 }
 
 /*************************************************************************/
 
 /*
- * Constructors
+ * Instance Methods
  */
 
 /**
-  * This method initializes a new <code>Decoder</code> to read from the
-  * specified <code>InputStream</code>.
+  * This method returns the name of the encoding scheme in use
   *
-  * @param in The <code>InputStream</code> to read from
+  * @return The name of the encoding scheme
   */
-public
-Decoder(InputStream in)
+public String
+getSchemeName()
 {
-  this.in = in;
+  return(scheme_name);
 }
 
 /*************************************************************************/
-
-/*
- * Instance Methods
- */
-
 /**
   * For a given set of bytes, this method returns the number of characters
   * that byte array will translate into.  If the bytes do not all translate 
Index: gnu/java/io/decode/Decoder8859_1.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/io/decode/Decoder8859_1.java,v
retrieving revision 1.3
diff -u -r1.3 Decoder8859_1.java
--- gnu/java/io/decode/Decoder8859_1.java       22 Jan 2002 22:26:57 -0000      
1.3
+++ gnu/java/io/decode/Decoder8859_1.java       23 Apr 2004 22:26:43 -0000
@@ -1,5 +1,5 @@
 /* Decoder8859_1.java -- Decoder for ISO-Latin-1 Character set
-   Copyright (C) 1998 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -50,13 +50,11 @@
 public class Decoder8859_1 extends DecoderEightBitLookup
 {
 
-/*************************************************************************/
-
 /**
   * This is the lookup table for this encoding
   */
 
-protected static char[] lookup_table_8859_1 = { 
+private static final char[] lookup_table_8859_1 = { 
 0x0000,
 0x0001,
 0x0002,
@@ -315,22 +313,10 @@
 0x00FF
 };
 
-static
-{
-  scheme_name = "8859_1";
-  scheme_description = "ISO-8859-1 (Latin-1 character set)";
-  lookup_table = lookup_table_8859_1;
-}
-
-/*************************************************************************/
-
-/*
- * Constructors
- */
 public
 Decoder8859_1(InputStream in)
 {
-  super(in);
+  super(in, "8859_1", lookup_table_8859_1);
 }
 
 } // class Decoder8859_1
Index: gnu/java/io/decode/Decoder8859_2.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/io/decode/Decoder8859_2.java,v
retrieving revision 1.3
diff -u -r1.3 Decoder8859_2.java
--- gnu/java/io/decode/Decoder8859_2.java       22 Jan 2002 22:26:57 -0000      
1.3
+++ gnu/java/io/decode/Decoder8859_2.java       23 Apr 2004 22:26:43 -0000
@@ -1,5 +1,5 @@
 /* Decoder8859_2.java -- Decoder for ISO-Latin-2 Character set
-   Copyright (C) 1998 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -50,13 +50,11 @@
 public class Decoder8859_2 extends DecoderEightBitLookup
 {
 
-/*************************************************************************/
-
 /**
   * This is the lookup table for this encoding
   */
 
-protected static char[] lookup_table_8859_2 = { 
+private static final char[] lookup_table_8859_2 = { 
 // Start of range undefined in the spec file I used.
 0x0000,
 0x0001,
@@ -319,22 +317,10 @@
 0x02D9
 };
 
-static
-{
-  scheme_name = "8859_2";
-  scheme_description = "ISO-8859-2 (Latin-2 character set)";
-  lookup_table = lookup_table_8859_2;
-}
-
-/*************************************************************************/
-
-/*
- * Constructors
- */
 public
 Decoder8859_2(InputStream in)
 {
-  super(in);
+  super(in, "8859_2", lookup_table_8859_2);
 }
 
 } // class Decoder8859_2
Index: gnu/java/io/decode/Decoder8859_3.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/io/decode/Decoder8859_3.java,v
retrieving revision 1.3
diff -u -r1.3 Decoder8859_3.java
--- gnu/java/io/decode/Decoder8859_3.java       22 Jan 2002 22:26:57 -0000      
1.3
+++ gnu/java/io/decode/Decoder8859_3.java       23 Apr 2004 22:26:43 -0000
@@ -1,5 +1,5 @@
 /* Decoder8859_3.java -- Decoder for ISO-Latin-3 Character set
-   Copyright (C) 1998 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -50,13 +50,11 @@
 public class Decoder8859_3 extends DecoderEightBitLookup
 {
 
-/*************************************************************************/
-
 /**
   * This is the lookup table for this encoding
   */
 
-protected static char[] lookup_table_8859_3 = { 
+private static final  char[] lookup_table_8859_3 = { 
 // Begin range undefined in spec document I used
 0x0000,
 0x0001,
@@ -312,22 +310,10 @@
 0x02D9
 };
 
-static
-{
-  scheme_name = "8859_3";
-  scheme_description = "ISO-8859-3 (Latin-3 character set)";
-  lookup_table = lookup_table_8859_3;
-}
-
-/*************************************************************************/
-
-/*
- * Constructors
- */
 public
 Decoder8859_3(InputStream in)
 {
-  super(in);
+  super(in, "8859_3", lookup_table_8859_3);
 }
 
 } // class Decoder8859_3
Index: gnu/java/io/decode/Decoder8859_4.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/io/decode/Decoder8859_4.java,v
retrieving revision 1.3
diff -u -r1.3 Decoder8859_4.java
--- gnu/java/io/decode/Decoder8859_4.java       22 Jan 2002 22:26:57 -0000      
1.3
+++ gnu/java/io/decode/Decoder8859_4.java       23 Apr 2004 22:26:43 -0000
@@ -1,5 +1,5 @@
 /* Decoder8859_4.java -- Decoder for ISO-Latin-4 Character set
-   Copyright (C) 1998 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -41,7 +41,7 @@
 import java.io.InputStream;
 
 /**
-  * This class decodes bytes in ISO-8859-3 (Latin-4) format to Unicode.
+  * This class decodes bytes in ISO-8859-4 (Latin-4) format to Unicode.
   *
   * @version 0.0
   *
@@ -50,13 +50,11 @@
 public class Decoder8859_4 extends DecoderEightBitLookup
 {
 
-/*************************************************************************/
-
 /**
   * This is the lookup table for this encoding
   */
 
-protected static char[] lookup_table_8859_4 = { 
+private static final char[] lookup_table_8859_4 = { 
 // Begin range undefined in spec document I used
 0x0000,
 0x0001,
@@ -319,22 +317,10 @@
 0x02D9
 };
 
-static
-{
-  scheme_name = "8859_4";
-  scheme_description = "ISO-8859-4 (Latin-4 character set)";
-  lookup_table = lookup_table_8859_4;
-}
-
-/*************************************************************************/
-
-/*
- * Constructors
- */
 public
 Decoder8859_4(InputStream in)
 {
-  super(in);
+  super(in, "8859_4", lookup_table_8859_4);
 }
 
 } // class Decoder8859_4
Index: gnu/java/io/decode/Decoder8859_5.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/io/decode/Decoder8859_5.java,v
retrieving revision 1.3
diff -u -r1.3 Decoder8859_5.java
--- gnu/java/io/decode/Decoder8859_5.java       22 Jan 2002 22:26:57 -0000      
1.3
+++ gnu/java/io/decode/Decoder8859_5.java       23 Apr 2004 22:26:43 -0000
@@ -1,5 +1,5 @@
 /* Decoder8859_5.java -- Decoder for ISO-Latin-5 Character set
-   Copyright (C) 1998 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -41,7 +41,7 @@
 import java.io.InputStream;
 
 /**
-  * This class decodes bytes in ISO-8859-3 (Latin-3) format to Unicode.
+  * This class decodes bytes in ISO-8859-5 (Latin-5) format to Unicode.
   *
   * @version 0.0
   *
@@ -50,13 +50,11 @@
 public class Decoder8859_5 extends DecoderEightBitLookup
 {
 
-/*************************************************************************/
-
 /**
   * This is the lookup table for this encoding
   */
 
-protected static char[] lookup_table_8859_5 = { 
+private static final char[] lookup_table_8859_5 = { 
 // Begin range undefined in spec document I used
 0x0000,
 0x0001,
@@ -319,22 +317,10 @@
 0x045F
 };
 
-static
-{
-  scheme_name = "8859_5";
-  scheme_description = "ISO-8859-5 (Latin-5 character set)";
-  lookup_table = lookup_table_8859_5;
-}
-
-/*************************************************************************/
-
-/*
- * Constructors
- */
 public
 Decoder8859_5(InputStream in)
 {
-  super(in);
+  super(in, "8859_5", lookup_table_8859_5);
 }
 
 } // class Decoder8859_5
Index: gnu/java/io/decode/DecoderEightBitLookup.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/io/decode/DecoderEightBitLookup.java,v
retrieving revision 1.6
diff -u -r1.6 DecoderEightBitLookup.java
--- gnu/java/io/decode/DecoderEightBitLookup.java       12 Aug 2003 12:17:31 
-0000      1.6
+++ gnu/java/io/decode/DecoderEightBitLookup.java       23 Apr 2004 22:26:43 
-0000
@@ -1,5 +1,5 @@
 /* DecoderEightBitLookup.java -- Decodes eight-bit encodings
-   Copyright (C) 1998, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2001, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -68,17 +68,18 @@
   * byte in the appropriate index slot.  For example, to convert 0xE3 to
   * \u3768, put \u3768 at index 227 (0xE3) in the lookup table.
   */
-protected static char[] lookup_table;
+private final char[] lookup_table;
 
 /*************************************************************************/
 
 /*
  * Constructors
  */
-public
-DecoderEightBitLookup(InputStream in)
+protected
+DecoderEightBitLookup(InputStream in, String name, char[] table)
 {
-  super(in);
+  super(in, name);
+  this.lookup_table = table;
 }
 
 /*************************************************************************/
Index: gnu/java/io/decode/DecoderUTF8.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/io/decode/DecoderUTF8.java,v
retrieving revision 1.4
diff -u -r1.4 DecoderUTF8.java
--- gnu/java/io/decode/DecoderUTF8.java 16 Aug 2003 13:16:53 -0000      1.4
+++ gnu/java/io/decode/DecoderUTF8.java 23 Apr 2004 22:26:43 -0000
@@ -1,5 +1,5 @@
 /* DecoderUTF8.java -- Decoder for the UTF-8 character encoding.
-   Copyright (C) 1998, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -55,12 +55,6 @@
 public class DecoderUTF8 extends Decoder
 {
 
-static
-{
-  scheme_name = "UTF8";
-  scheme_description = "UCS Transformation Format 8 (see RFC-2279)";
-}
-
 /*************************************************************************/
 
 /*
@@ -70,7 +64,7 @@
 public
 DecoderUTF8(InputStream in)
 {
-  super(in);
+  super(in, "UTF8");
 }
 
 /*************************************************************************/
Index: gnu/java/io/encode/Encoder.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/io/encode/Encoder.java,v
retrieving revision 1.4
diff -u -r1.4 Encoder.java
--- gnu/java/io/encode/Encoder.java     15 Aug 2002 19:58:51 -0000      1.4
+++ gnu/java/io/encode/Encoder.java     23 Apr 2004 22:26:43 -0000
@@ -1,5 +1,5 @@
 /* Encoder.java -- Base class for char->byte encoders
-   Copyright (C) 1998 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -63,13 +63,7 @@
   * This is the name of the current encoding. MUST be overriden by
   * subclasses.
   */
-protected static String scheme_name = "undefined";
-
-/**
-  * This is a description of the current encoding.  MUST be overridden
-  * by subclasses.
-  */
-protected static String scheme_description = "undefined";
+private final String scheme_name;
 
 /*************************************************************************/
 
@@ -80,7 +74,7 @@
 /**
   * This is the <code>OutputStream</code> bytes are written to
   */
-protected OutputStream out;
+protected final OutputStream out;
 
 /**
   * This is the value that is substituted for bad characters that can't
@@ -104,7 +98,7 @@
   *
   * @return The name of the encoding scheme
   */
-public static String
+public String
 getSchemeName()
 {
   return(scheme_name);
@@ -112,19 +106,6 @@
 
 /*************************************************************************/
 
-/**
-  * This method returns a description of the encoding scheme in use
-  *
-  * @param A description of the decoding scheme.
-  */
-public static String
-getSchemeDescription()
-{
-  return(scheme_description);
-}
-
-/*************************************************************************/
-
 /*
  * Constructors
  */
@@ -133,12 +114,14 @@
   * This method initializes a new <code>Encoder</code> to write to the
   * specified <code>OutputStream</code>.
   *
+  * @param name The character scheme name
   * @param out The <code>OutputStream</code> to read from
   */
-public
-Encoder(OutputStream out)
+protected
+Encoder(OutputStream out, String name)
 {
   this.out = out;
+  this.scheme_name = name;
 }
 
 /*************************************************************************/
Index: gnu/java/io/encode/Encoder8859_1.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/io/encode/Encoder8859_1.java,v
retrieving revision 1.4
diff -u -r1.4 Encoder8859_1.java
--- gnu/java/io/encode/Encoder8859_1.java       9 Feb 2002 03:28:16 -0000       
1.4
+++ gnu/java/io/encode/Encoder8859_1.java       23 Apr 2004 22:26:43 -0000
@@ -1,5 +1,5 @@
 /* Encoder8859_1.java -- Encoder for ISO-Latin-1 Character set
-   Copyright (C) 1998 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -56,7 +56,7 @@
   * This is the lookup table for this encoding
   */
 
-protected static char[] lookup_table_8859_1 = { 
+private static final char[] lookup_table_8859_1 = { 
 0x0000,
 0x0001,
 0x0002,
@@ -315,24 +315,10 @@
 0x00FF
 };
 
-static
-{
-  scheme_name = "8859_1";
-  scheme_description = "ISO-8859-1 (Latin-1 character set)";
-  lookup_table = lookup_table_8859_1;
-  EncoderEightBitLookup.loadTable();
-  // FIXME explicit super class is workaround for jikes1.15a and orp 1.0.9
-}
-
-/*************************************************************************/
-
-/*
- * Constructors
- */
 public
 Encoder8859_1(OutputStream out)
 {
-  super(out);
+  super(out, "8859_1", lookup_table_8859_1);
 }
 
 } // class Encoder8859_1
Index: gnu/java/io/encode/Encoder8859_2.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/io/encode/Encoder8859_2.java,v
retrieving revision 1.4
diff -u -r1.4 Encoder8859_2.java
--- gnu/java/io/encode/Encoder8859_2.java       9 Feb 2002 03:28:16 -0000       
1.4
+++ gnu/java/io/encode/Encoder8859_2.java       23 Apr 2004 22:26:43 -0000
@@ -1,5 +1,5 @@
 /* Encoder8859_2.java -- Encoder for ISO-Latin-2 Character set
-   Copyright (C) 1998 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -56,7 +56,7 @@
   * This is the lookup table for this encoding
   */
 
-protected static char[] lookup_table_8859_2 = { 
+private static final char[] lookup_table_8859_2 = { 
 // Start of range undefined in the spec file I used.
 0x0000,
 0x0001,
@@ -319,24 +319,10 @@
 0x02D9
 };
 
-static
-{
-  scheme_name = "8859_2";
-  scheme_description = "ISO-8859-2 (Latin-2 character set)";
-  lookup_table = lookup_table_8859_2;
-  EncoderEightBitLookup.loadTable();
-  // FIXME explicit super class is workaround for jikes1.15a and orp 1.0.9
-}
-
-/*************************************************************************/
-
-/*
- * Constructors
- */
 public
 Encoder8859_2(OutputStream out)
 {
-  super(out);
+  super(out, "8859_2", lookup_table_8859_2);
 }
 
 } // class Encoder8859_2
Index: gnu/java/io/encode/Encoder8859_3.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/io/encode/Encoder8859_3.java,v
retrieving revision 1.4
diff -u -r1.4 Encoder8859_3.java
--- gnu/java/io/encode/Encoder8859_3.java       9 Feb 2002 03:28:16 -0000       
1.4
+++ gnu/java/io/encode/Encoder8859_3.java       23 Apr 2004 22:26:43 -0000
@@ -1,5 +1,5 @@
 /* Encoder8859_3.java -- Encoder for ISO-Latin-3 Character set
-   Copyright (C) 1998 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -56,7 +56,7 @@
   * This is the lookup table for this encoding
   */
 
-protected static char[] lookup_table_8859_3 = { 
+private static final char[] lookup_table_8859_3 = { 
 // Begin range undefined in spec document I used
 0x0000,
 0x0001,
@@ -312,24 +312,13 @@
 0x02D9
 };
 
-static
-{
-  scheme_name = "8859_3";
-  scheme_description = "ISO-8859-3 (Latin-3 character set)";
-  lookup_table = lookup_table_8859_3;
-  EncoderEightBitLookup.loadTable();
-  // FIXME explicit super class is workaround for jikes1.15a and orp 1.0.9
-}
-
-/*************************************************************************/
-
 /*
  * Constructors
  */
 public
 Encoder8859_3(OutputStream out)
 {
-  super(out);
+  super(out, "8859_3", lookup_table_8859_3);
 }
 
 } // class Encoder8859_3
Index: gnu/java/io/encode/Encoder8859_4.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/io/encode/Encoder8859_4.java,v
retrieving revision 1.3
diff -u -r1.3 Encoder8859_4.java
--- gnu/java/io/encode/Encoder8859_4.java       22 Jan 2002 22:26:57 -0000      
1.3
+++ gnu/java/io/encode/Encoder8859_4.java       23 Apr 2004 22:26:43 -0000
@@ -1,5 +1,5 @@
 /* Encoder8859_4.java -- Encoder for ISO-Latin-4 Character set
-   Copyright (C) 1998 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -41,7 +41,7 @@
 import java.io.OutputStream;
 
 /**
-  * This class decodes bytes in ISO-8859-3 (Latin-4) format to Unicode.
+  * This class decodes bytes in ISO-8859-4 (Latin-4) format to Unicode.
   *
   * @version 0.0
   *
@@ -56,7 +56,7 @@
   * This is the lookup table for this encoding
   */
 
-protected static char[] lookup_table_8859_4 = { 
+private static final char[] lookup_table_8859_4 = { 
 // Begin range undefined in spec document I used
 0x0000,
 0x0001,
@@ -319,22 +319,10 @@
 0x02D9
 };
 
-static
-{
-  scheme_name = "8859_4";
-  scheme_description = "ISO-8859-4 (Latin-4 character set)";
-  lookup_table = lookup_table_8859_4;
-}
-
-/*************************************************************************/
-
-/*
- * Constructors
- */
 public
 Encoder8859_4(OutputStream out)
 {
-  super(out);
+  super(out, "8859_4", lookup_table_8859_4);
 }
 
 } // class Encoder8859_4
Index: gnu/java/io/encode/Encoder8859_5.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/io/encode/Encoder8859_5.java,v
retrieving revision 1.3
diff -u -r1.3 Encoder8859_5.java
--- gnu/java/io/encode/Encoder8859_5.java       22 Jan 2002 22:26:57 -0000      
1.3
+++ gnu/java/io/encode/Encoder8859_5.java       23 Apr 2004 22:26:43 -0000
@@ -1,5 +1,5 @@
 /* Encoder8859_5.java -- Encoder for ISO-Latin-5 Character set
-   Copyright (C) 1998 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -41,7 +41,7 @@
 import java.io.OutputStream;
 
 /**
-  * This class decodes bytes in ISO-8859-3 (Latin-3) format to Unicode.
+  * This class decodes bytes in ISO-8859-5 (Latin-5) format to Unicode.
   *
   * @version 0.0
   *
@@ -56,7 +56,7 @@
   * This is the lookup table for this encoding
   */
 
-protected static char[] lookup_table_8859_5 = { 
+private static final char[] lookup_table_8859_5 = { 
 // Begin range undefined in spec document I used
 0x0000,
 0x0001,
@@ -319,22 +319,10 @@
 0x045F
 };
 
-static
-{
-  scheme_name = "8859_5";
-  scheme_description = "ISO-8859-5 (Latin-5 character set)";
-  lookup_table = lookup_table_8859_5;
-}
-
-/*************************************************************************/
-
-/*
- * Constructors
- */
 public
 Encoder8859_5(OutputStream out)
 {
-  super(out);
+  super(out, "8859_5", lookup_table_8859_5);
 }
 
 } // class Encoder8859_5
Index: gnu/java/io/encode/EncoderEightBitLookup.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/io/encode/EncoderEightBitLookup.java,v
retrieving revision 1.6
diff -u -r1.6 EncoderEightBitLookup.java
--- gnu/java/io/encode/EncoderEightBitLookup.java       12 Aug 2003 12:17:30 
-0000      1.6
+++ gnu/java/io/encode/EncoderEightBitLookup.java       23 Apr 2004 22:26:43 
-0000
@@ -1,5 +1,5 @@
 /* EncoderEightBitLookup.java -- Encodes eight-bit encodings
-   Copyright (C) 1998 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -63,19 +63,12 @@
  * Class Variables
  */
  
-/**
-  * This is the lookup table.  Subclasses must allocate a 255 byte char
-  * array and put each Unicode character into the slot corresponding to
-  * where it is encoded.  For example, if \u3768 corresponds to 0xE3,
-  * put \3768 at index 277 (0xE3) in the lookup table.
-  */
-protected static char[] lookup_table;
 
 /**
   * This is the second generation lookup table that is loaded when the
   * class is loaded and is where the encoding actually takes place.
   */
-private static byte[] encoding_table; /* changed this from char[] to byte[] */
+private final byte[] encoding_table; /* changed this from char[] to byte[] */
 
 /*************************************************************************/
 
@@ -88,8 +81,8 @@
   * into a larger encoder table.  Yes, this is slow, but it is only done
   * the first time the class is accessed.
   */
-protected static void
-loadTable()
+private byte[]
+loadTable(char[] lookup_table)
 {
   /* determine required size of encoding_table: */
   int max = 0; 
@@ -99,16 +92,17 @@
       max = (c > max) ? c : max;
     }
 
-  encoding_table = new byte[max+1];
+  byte[] table = new byte[max+1];
 
   for (int i = 0; i < lookup_table.length; i++)
     {
       int c = lookup_table[i]; 
       if (c != 0) 
        {
-         encoding_table[c] = (byte)i;
+         table[c] = (byte)i;
        }
     }
+  return table;
 }
 
 /*************************************************************************/
@@ -116,10 +110,11 @@
 /*
  * Constructors
  */
-public
-EncoderEightBitLookup(OutputStream out)
+protected
+EncoderEightBitLookup(OutputStream out, String name, char[] table)
 {
-  super(out);
+  super(out, name);
+  encoding_table = loadTable(table);
 }
 
 /*************************************************************************/
@@ -195,5 +190,5 @@
   out.write(bbuf);
 }
 
-} // class DecoderEightBitLookup
+} // class EncoderEightBitLookup
 
Index: gnu/java/io/encode/EncoderUTF8.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/io/encode/EncoderUTF8.java,v
retrieving revision 1.6
diff -u -r1.6 EncoderUTF8.java
--- gnu/java/io/encode/EncoderUTF8.java 18 Jan 2003 22:49:28 -0000      1.6
+++ gnu/java/io/encode/EncoderUTF8.java 23 Apr 2004 22:26:43 -0000
@@ -1,5 +1,5 @@
 /* EncoderUTF8.java -- Encoding class for the UTF-8 scheme
-   Copyright (C) 1998, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2002, 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -53,12 +53,6 @@
 public class EncoderUTF8 extends Encoder
 {
 
-static
-{
-  scheme_name = "UTF8";
-  scheme_description = "UCS Transformation Format 8 (see RFC-2279)";
-}
-
 /*************************************************************************/
 
 /*
@@ -68,7 +62,7 @@
 public
 EncoderUTF8(OutputStream out)
 {
-  super(out);
+  super(out, "UTF8");
 }
 
 /*************************************************************************/

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]