/*******************************************************************************
*                                                                              *
*  File:        LuaJava_09.java                         Revision:  1.0         *
*                                                                              *
*  Purpose:     accompanying Java class for LuaJava_09.lua                     *
*                                                                              *
*  Creation:    06.11.2004                     Last Modification:  07.11.2004  *
*                                                                              *
*  Platform:    IBM-compatible PC running Windows 98SE                         *
*                                                                              *
*  Environment: Java 1.4                                                       *
*                                                                              *
*  Author:      Andreas Rozek           Phone:  ++49 (7031) 222305             *
*               Bunsenstraße 80/1       Fax:    -                              *
*             D-71032 Böblingen         EMail:  Info@Andreas-Rozek.De          *
*               Germany                                                        *
*                                                                              *
*  URL:         http://www.Andreas-Rozek.de/                                   *
*                                                                              *
*  Copyright:   this software is published under the  "GNU Lesser General Pub- *
*               lic  License"  (see  "http://www.fsf.org/copyleft/lesser.html" *
*               for additional information)                                    *
*                                                                              *
*  Comments:    (none)                                                         *
*                                                                              *
*******************************************************************************/

public class LuaJava_09 {

/*******************************************************************************
*                                                                              *
*                          Non-Public Class Constants                          *
*                                                                              *
*******************************************************************************/

  final static char[] HexTable = new char[] {
    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
  };

/*******************************************************************************
*                                                                              *
*                                 Constructors                                 *
*                                                                              *
*******************************************************************************/

  public LuaJava_09 () {
    super();                                              // just to be complete
  };

/*******************************************************************************
*                                                                              *
*                           Non-Public Class Methods                           *
*                                                                              *
*******************************************************************************/

/*******************************************************************************
*                                                                              *
* CharToHex                 yields the unicode definition of a given character *
*                                                                              *
*******************************************************************************/

  static String CharToHex (char Argument) {
    char[] Result = new char[4];
      for (int i = 3; i >= 0; i--) {
        Result[i] = HexTable[Argument & 0x0F];
        Argument >>= 4;
      };
    return "\\u" + (new String(Result));
  };

/*******************************************************************************
*                                                                              *
*                             Public Class Methods                             *
*                                                                              *
*******************************************************************************/

/*******************************************************************************
*                                                                              *
* Java2Lua                               passes a "real" Unicode string to Lua *
*                                                                              *
*******************************************************************************/

  public static String Java2Lua () {
    return "\u0161\u0262\u0363";               // "abc" with different codepages
  };

/*******************************************************************************
*                                                                              *
* Lua2Java                      yields the Unicode codes of a given Lua string *
*                                                                              *
*******************************************************************************/

  public static String Lua2Java (String Argument) {
    String Result = "";
      for (int i = 0; i < Argument.length(); i++) {
        Result += CharToHex(Argument.charAt(i));
      };
    return Result;
  };
};

