tn5250j/src/org/tn5250j/encoding CodePage.java,1.1,1.2 JavaCodePage.java,1.1,1.2

"Kenneth J. Pouncey" <[email protected]> Thu, 16 Jun 2005 04:41:18 +0000
Newsgroups gmane.comp.java.tn5250j.cvs
Message-ID <[email protected]>
Update of /cvsroot/tn5250j/tn5250j/src/org/tn5250j/encoding
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24279/src/org/tn5250j/encoding

Modified Files:
	CodePage.java JavaCodePage.java 
Log Message:
the rest of the story

Index: JavaCodePage.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/encoding/JavaCodePage.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** JavaCodePage.java	2 Mar 2003 16:53:50 -0000	1.1
--- JavaCodePage.java	16 Jun 2005 04:41:16 -0000	1.2
***************
*** 1,89 ****
! /**
!  * Title: JavaCodePage
!  * Copyright:   Copyright (c) 2001, 2002, 2003
!  * Company:
!  * @author  LDC, WVL, Luc
!  * @version 0.4
!  *
!  * Description:
!  *
!  * This program is free software; you can redistribute it and/or modify
!  * it under the terms of the GNU General Public License as published by
!  * the Free Software Foundation; either version 2, or (at your option)
!  * any later version.
!  *
!  * This program is distributed in the hope that it will be useful,
!  * but WITHOUT ANY WARRANTY; without even the implied warranty of
!  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!  * GNU General Public License for more details.
!  *
!  * You should have received a copy of the GNU General Public License
!  * along with this software; see the file COPYING.  If not, write to
!  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
!  * Boston, MA 02111-1307 USA
!  *
!  */
! package org.tn5250j.encoding;
! 
! import java.io.UnsupportedEncodingException;
! import java.io.CharConversionException;
! import sun.io.CharToByteConverter;
! import sun.io.ByteToCharConverter;
! 
! class JavaCodePage extends CodePage {
!   JavaCodePage(String encoding, CharToByteConverter c2b, ByteToCharConverter b2c)
!   {
!     super(encoding);
!     this.c2b = c2b;
!     this.b2c = b2c;
!   }
! 
!   public char ebcdic2uni (int index)
!   {
!     try
!     {
!       return b2c.convertAll(new byte[] { (byte) index})[0];
!     }
!     catch (CharConversionException cce)
!     {
!       return ' ';
!     }
!   }
! 
!   public byte uni2ebcdic (char index)
!   {
!     try
!     {
!       return c2b.convertAll(new char[] {index})[0];
!     }
!     catch (CharConversionException cce)
!     {
!       return 0x0;
!     }
!   }
! 
!   public static CodePage getCodePage(String encoding)
!   {
!     CharToByteConverter c2b;
!     ByteToCharConverter b2c;
!     try
!     {
!       c2b = CharToByteConverter.getConverter(encoding);
!       b2c = ByteToCharConverter.getConverter(encoding);
!     }
!     catch (UnsupportedEncodingException uee)
!     {
!       c2b = null;
!       b2c = null;
!     }
! 
!     if ( (c2b != null) && (b2c != null) )
!       return new JavaCodePage(encoding, c2b, b2c);
! 
!     return null;
!   }
! 
! 
!   private CharToByteConverter c2b;
!   private ByteToCharConverter b2c;
  }
\ No newline at end of file
--- 1,89 ----
! /**
!  * Title: JavaCodePage
!  * Copyright:   Copyright (c) 2001, 2002, 2003
!  * Company:
!  * @author  LDC, WVL, Luc
!  * @version 0.4
!  *
!  * Description:
!  *
!  * This program is free software; you can redistribute it and/or modify
!  * it under the terms of the GNU General Public License as published by
!  * the Free Software Foundation; either version 2, or (at your option)
!  * any later version.
!  *
!  * This program is distributed in the hope that it will be useful,
!  * but WITHOUT ANY WARRANTY; without even the implied warranty of
!  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!  * GNU General Public License for more details.
!  *
!  * You should have received a copy of the GNU General Public License
!  * along with this software; see the file COPYING.  If not, write to
!  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
!  * Boston, MA 02111-1307 USA
!  *
!  */
! package org.tn5250j.encoding;
! 
! import java.io.UnsupportedEncodingException;
! import java.io.CharConversionException;
! import sun.io.CharToByteConverter;
! import sun.io.ByteToCharConverter;
! 
! class JavaCodePage extends CodePage {
!   JavaCodePage(String encoding, CharToByteConverter c2b, ByteToCharConverter b2c)
!   {
!     super(encoding);
!     this.c2b = c2b;
!     this.b2c = b2c;
!   }
! 
!   public char ebcdic2uni (int index)
!   {
!     try
!     {
!       return b2c.convertAll(new byte[] { (byte) index})[0];
!     }
!     catch (CharConversionException cce)
!     {
!       return ' ';
!     }
!   }
! 
!   public byte uni2ebcdic (char index)
!   {
!     try
!     {
!       return c2b.convertAll(new char[] {index})[0];
!     }
!     catch (CharConversionException cce)
!     {
!       return 0x0;
!     }
!   }
! 
!   public static CodePage getCodePage(String encoding)
!   {
!     CharToByteConverter c2b;
!     ByteToCharConverter b2c;
!     try
!     {
!       c2b = CharToByteConverter.getConverter(encoding);
!       b2c = ByteToCharConverter.getConverter(encoding);
!     }
!     catch (UnsupportedEncodingException uee)
!     {
!       c2b = null;
!       b2c = null;
!     }
! 
!     if ( (c2b != null) && (b2c != null) )
!       return new JavaCodePage(encoding, c2b, b2c);
! 
!     return null;
!   }
! 
! 
!   private CharToByteConverter c2b;
!   private ByteToCharConverter b2c;
  }
\ No newline at end of file

Index: CodePage.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/encoding/CodePage.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** CodePage.java	2 Mar 2003 16:53:50 -0000	1.1
--- CodePage.java	16 Jun 2005 04:41:16 -0000	1.2
***************
*** 1,50 ****
! /**
!  * Title: CodePage.java
!  * Copyright:   Copyright (c) 2001, 2002, 2003
!  * Company:
!  * @author  Kenneth J. Pouncey
!  *          rewritten by LDC, WVL, Luc
!  * @version 0.4
!  *
!  * Description:
!  *
!  * This program is free software; you can redistribute it and/or modify
!  * it under the terms of the GNU General Public License as published by
!  * the Free Software Foundation; either version 2, or (at your option)
!  * any later version.
!  *
!  * This program is distributed in the hope that it will be useful,
!  * but WITHOUT ANY WARRANTY; without even the implied warranty of
!  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!  * GNU General Public License for more details.
!  *
!  * You should have received a copy of the GNU General Public License
!  * along with this software; see the file COPYING.  If not, write to
!  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
!  * Boston, MA 02111-1307 USA
!  *
!  */
! package org.tn5250j.encoding;
! 
! /**
!  *
!  * This class controls the translation from EBCDIC to ASCII and ASCII to EBCDIC
!  *
!  */
! public abstract class CodePage
! {
!   protected CodePage(String encoding)
!   {
!     this.encoding = encoding;
!   }
! 
!   public abstract char ebcdic2uni (int index);
!   public abstract byte uni2ebcdic (char index);
! 
!   public String getEncoding ()
!   {
!      return encoding;
!   }
! 
!   protected String encoding;
! }
--- 1,50 ----
! /**
!  * Title: CodePage.java
!  * Copyright:   Copyright (c) 2001, 2002, 2003
!  * Company:
!  * @author  Kenneth J. Pouncey
!  *          rewritten by LDC, WVL, Luc
!  * @version 0.4
!  *
!  * Description:
!  *
!  * This program is free software; you can redistribute it and/or modify
!  * it under the terms of the GNU General Public License as published by
!  * the Free Software Foundation; either version 2, or (at your option)
!  * any later version.
!  *
!  * This program is distributed in the hope that it will be useful,
!  * but WITHOUT ANY WARRANTY; without even the implied warranty of
!  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!  * GNU General Public License for more details.
!  *
!  * You should have received a copy of the GNU General Public License
!  * along with this software; see the file COPYING.  If not, write to
!  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
!  * Boston, MA 02111-1307 USA
!  *
!  */
! package org.tn5250j.encoding;
! 
! /**
!  *
!  * This class controls the translation from EBCDIC to ASCII and ASCII to EBCDIC
!  *
!  */
! public abstract class CodePage
! {
!   protected CodePage(String encoding)
!   {
!     this.encoding = encoding;
!   }
! 
!   public abstract char ebcdic2uni (int index);
!   public abstract byte uni2ebcdic (char index);
! 
!   public String getEncoding ()
!   {
!      return encoding;
!   }
! 
!   protected String encoding;
! }



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click