diff options
author | Martin Gruner <mg.pub@gmx.net> | 2004-06-04 09:14:52 +0000 |
---|---|---|
committer | Martin Gruner <mg.pub@gmx.net> | 2004-06-04 09:14:52 +0000 |
commit | 1b4907ef4310be86946da07b2f74d186ef5088f6 (patch) | |
tree | 73bfd961ff4b0e9b2986118caa1572714daf47fa /modules | |
parent | 9aa8e0a21e4d50ce99f52f3bf270adee62176788 (diff) | |
download | sword-tools-1b4907ef4310be86946da07b2f74d186ef5088f6.tar.gz |
initial import of source files for the new BHS-replacement WLC (Westminster Leningrad Codex).
Not functional yet at all.
git-svn-id: https://www.crosswire.org/svn/sword-tools/trunk@16 07627401-56e2-0310-80f4-f8cd0041bdcd
Diffstat (limited to 'modules')
40 files changed, 5035 insertions, 0 deletions
diff --git a/modules/hebrew-wlc/WLC2OSIS/Makefile b/modules/hebrew-wlc/WLC2OSIS/Makefile new file mode 100644 index 0000000..2ab3871 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/Makefile @@ -0,0 +1,297 @@ +# +# Makefile created at Fri Jun 4 10:48:57 2004, by mmake +# + +# Programs (with common options): +SHELL = /bin/sh +RM = rm -f +MV = mv -f +SED = sed +ETAGS = etags +XARGS = xargs +CAT = cat +FIND = find +CPP = cpp -C -P + +INSTALL = install +INSTALL_PROG = $(INSTALL) -m $(MODE_PROGS) +INSTALL_FILE = $(INSTALL) -m $(MODE_FILES) +INSTALL_DIR = $(INSTALL) -m $(MODE_DIRS) -d + +# Install modes +MODE_PROGS = 555 +MODE_FILES = 444 +MODE_DIRS = 2755 + +# Build programs +JAVAC = javac +JAVADOC = javadoc +JAR = jar + +# Build flags +JAVAC_FLAGS = +JAVADOC_FLAGS = -version -author +JAR_FLAGS = cvf0 +JIKES_DEP_FLAG = +M + +# ------------------------------------------------------------------- # + +# Prefix for every install directory +PREFIX = + +# Where to start installing the class files. Set this to an empty value +# if you dont want to install classes +CLASS_DIR = $(PREFIX)classes + +# The directory to install the jar file in. Set this to an empty value +# if you dont want to install a jar file +JAR_DIR = $(PREFIX)lib + +# The directory to install html files generated by javadoc +DOC_DIR = $(PREFIX)doc/api-docs + +# The directory to install script files in +SCRIPT_DIR = $(PREFIX)bin + +# ------------------------------------------------------------------- # + +# The name of the jar file to install +JAR_FILE = WLC2OSIS.jar + +# +# The VERSION variable below should be set to a value +# that will be tested in the .xjava code. +# +VERSION = CHANGE_ME + +# ------------------------------------------------------------------- # + + +# Packages we should compile +PACKAGES = \ + Utilities \ + WLC2OSIS.Utilities \ + WLC2OSIS \ + WLC2OSIS.Parse \ + WLC2OSIS.Translate \ + WLC2OSIS.GUI + + +# Resource packages +RESOURCES = + + +# Directories with shell scripts +SCRIPTS = + +# ------------------------------------------------------------------- # + +# A marker variable for the top level directory +TOPLEVEL := . + +# Subdirectories with java files: +JAVA_DIRS := $(subst .,/,$(PACKAGES)) $(TOPLEVEL) + +# Subdirectories with only resource files: +RESOURCE_DIRS := $(subst .,/,$(RESOURCES)) + +# All the .xjava source files: +XJAVA_SRC := $(foreach dir, $(JAVA_DIRS), $(wildcard $(dir)/*.xjava)) + +# All the xjava files to build +XJAVA_OBJS := $(XJAVA_SRC:.xjava=.java) + +# All the .java source files: +JAVA_SRC := $(foreach dir, $(JAVA_DIRS), $(wildcard $(dir)/*.java)) +JAVA_SRC := $(XJAVA_OBJS) $(JAVA_SRC) + +# Dependency files: +DEPEND_OBJS := $(JAVA_SRC:.java=.u) + +# Objects that should go into the jar file. (find syntax) +JAR_OBJS := \( -name '*.class' -o -name '*.gif' -o -name "*.au" \ + -o -name '*.properties' \) + +# The intermediate java files and main classes we should build: +JAVA_OBJS := $(XJAVA_OBJS) $(JAVA_SRC:.java=.class) + +# Resource files: +# Extend the list to install other files of your choice +RESOURCE_SRC := *.properties *.gif *.au +# Search for resource files in both JAVA_DIRS and RESOURCE_DIRS +RESOURCE_OBJS := $(foreach dir, $(JAVA_DIRS) $(RESOURCE_DIRS), \ + $(wildcard $(foreach file, $(RESOURCE_SRC), \ + $(dir)/$(file)))) + +# All the shell scripts source +SCRIPT_SRCS := $(foreach dir, $(SCRIPTS), $(wildcard $(dir)/*.sh)) +# All shell scripts we should install +SCRIPT_OBJS := $(SCRIPT_SRCS:.sh=) + +# All the files to install into CLASS_DIR +INSTALL_OBJS := $(foreach dir, $(JAVA_DIRS), $(wildcard $(dir)/*.class)) +# Escape inner class delimiter $ +INSTALL_OBJS := $(subst $$,\$$,$(INSTALL_OBJS)) +# Add the resource files to be installed as well +INSTALL_OBJS := $(INSTALL_OBJS) $(RESOURCE_OBJS) + + +# ------------------------------------------------------------------- # + + +define check-exit +|| exit 1 + +endef + + +# ----------- +# Build Rules +# ----------- + +%.java: %.xjava + $(CPP) -D$(VERSION) $< $@ + +%.class: %.java + $(JAVAC) $(JAVAC_FLAGS) $< + +%.jar: $(JAVA_OBJS) $(RESOURCE_OBJS) + $(FIND) $(TOPLEVEL) $(JAR_OBJS) -print | $(XARGS) \ + $(JAR) $(JAR_FLAGS) $(JAR_FILE) + +%.u: %.java + $(JAVAC) $(JIKES_DEP_FLAG) $< + + +# ------- +# Targets +# ------- + +.PHONY: all jar install uninstall doc clean depend tags + +all:: $(JAVA_OBJS) + + +help: + @echo "Usage: make {all|jar|install|uninstall|doc|clean|depend|tags}" + + +# Jar target +ifneq ($(strip $(JAR_FILE)),) +jar: $(JAR_FILE) +ifneq ($(strip $(JAR_DIR)),) +install:: $(JAR_FILE) + @echo "===> [Installing jar file, $(JAR_FILE) in $(JAR_DIR)] " + $(INSTALL_DIR) $(JAR_DIR) $(check-exit) + $(INSTALL_FILE) $(JAR_FILE) $(JAR_DIR) $(check-exit) +uninstall:: + @echo "===> [Removing jar file, $(JAR_FILE) from $(JAR_DIR)] " + $(RM) $(JAR_DIR)/$(JAR_FILE) $(check-exit) +else +install:: + @echo "No jar install dir defined" +endif +clean:: + $(RM) $(JAR_FILE) +else +jar: + @echo "No jar file defined" +endif + + + +# Install target for Classes and Resources +ifneq ($(strip $(CLASS_DIR)),) +install:: $(JAVA_OBJS) + @echo "===> [Installing classes in $(CLASS_DIR)] " + $(INSTALL_DIR) $(CLASS_DIR) $(check-exit) + $(foreach dir, $(JAVA_DIRS) $(RESOURCE_DIRS), \ + $(INSTALL_DIR) $(CLASS_DIR)/$(dir) $(check-exit)) + $(foreach file, $(INSTALL_OBJS), \ + $(INSTALL_FILE) $(file) $(CLASS_DIR)/$(file) \ + $(check-exit)) +uninstall:: + @echo "===> [Removing class-files from $(CLASS_DIR)] " + $(foreach file, $(INSTALL_OBJS), \ + $(RM) $(CLASS_DIR)/$(file) \ + $(check-exit)) +else +# Print a warning here if you like. (No class install dir defined) +endif + + + +# Depend target +ifeq ($(findstring jikes,$(JAVAC)),jikes) +depend: $(XJAVA_OBJS) $(DEPEND_OBJS) + ( $(CAT) $(DEPEND_OBJS) | $(SED) -e '/\.class$$/d' \ + -e '/.*$$.*/d' > $(MAKEFILE_DEPEND); $(RM) $(DEPEND_OBJS); ) +else +depend: + @echo "mmake needs the jikes compiler to build class dependencies" +endif + + + +# Doc target +ifneq ($(strip $(PACKAGES)),) +doc: $(JAVA_SRC) + @echo "===> [Installing java documentation in $(DOC_DIR)] " + $(INSTALL_DIR) $(DOC_DIR) $(check-exit) + $(JAVADOC) -d $(DOC_DIR) $(JAVADOC_FLAGS) $(PACKAGES) +else +doc: + @echo "You must put your source files in a package to run make doc" +endif + + + +# Script target +ifneq ($(strip $(SCRIPT_OBJS)),) +all:: $(SCRIPT_OBJS) +ifneq ($(strip $(SCRIPT_DIR)),) +install:: $(SCRIPT_OBJS) + @echo "===> [Installing shell-scripts in $(SCRIPT_DIR)] " + $(INSTALL_DIR) $(SCRIPT_DIR) $(check-exit) + $(foreach file, $(SCRIPT_OBJS), \ + $(INSTALL_PROG) $(file) $(SCRIPT_DIR) $(check-exit)) +uninstall:: + @echo "===> [Removing shell-scripts from $(SCRIPT_DIR)] " + $(foreach file, $(SCRIPT_OBJS), \ + $(RM) $(SCRIPT_DIR)/$(file) $(check-exit)) +else +# Print a warning here if you like. (No script install dir defined) +endif +clean:: + rm -f $(SCRIPT_OBJS) +endif + + + +# Tag target +tags: + @echo "Tagging" + $(ETAGS) $(filter-out $(XJAVA_OBJS), $(JAVA_SRC)) $(XJAVA_SRC) + + + +# Various cleanup routines +clean:: + $(FIND) . \( -name '*~' -o -name '*.class' \) -print | \ + $(XARGS) $(RM) + $(FIND) . -name '*.u' -print | $(XARGS) $(RM) + +ifneq ($(strip $(XJAVA_SRC)),) +clean:: + $(RM) $(XJAVA_OBJS) +endif + +# ---------------------------------------- +# Include the dependency graph if it exist +# ---------------------------------------- +MAKEFILE_DEPEND = makefile.dep +DEPEND = $(wildcard $(MAKEFILE_DEPEND)) +ifneq ($(DEPEND),) + include $(MAKEFILE_DEPEND) +endif + diff --git a/modules/hebrew-wlc/WLC2OSIS/Utilities/BrowserLauncher.java b/modules/hebrew-wlc/WLC2OSIS/Utilities/BrowserLauncher.java new file mode 100644 index 0000000..01e5e70 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/Utilities/BrowserLauncher.java @@ -0,0 +1,584 @@ +package Utilities ; +// Formerly: edu.stanford.ejalbert +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +/** + * BrowserLauncher is a class that provides one static method, openURL, which opens the default + * web browser for the current user of the system to the given URL. It may support other + * protocols depending on the system -- mailto, ftp, etc. -- but that has not been rigorously + * tested and is not guaranteed to work. + * <p> + * Yes, this is platform-specific code, and yes, it may rely on classes on certain platforms + * that are not part of the standard JDK. What we're trying to do, though, is to take something + * that's frequently desirable but inherently platform-specific -- opening a default browser -- + * and allow programmers (you, for example) to do so without worrying about dropping into native + * code or doing anything else similarly evil. + * <p> + * Anyway, this code is completely in Java and will run on all JDK 1.1-compliant systems without + * modification or a need for additional libraries. All classes that are required on certain + * platforms to allow this to run are dynamically loaded at runtime via reflection and, if not + * found, will not cause this to do anything other than returning an error when opening the + * browser. + * <p> + * There are certain system requirements for this class, as it's running through Runtime.exec(), + * which is Java's way of making a native system call. Currently, this requires that a Macintosh + * have a Finder which supports the GURL event, which is true for Mac OS 8.0 and 8.1 systems that + * have the Internet Scripting AppleScript dictionary installed in the Scripting Additions folder + * in the Extensions folder (which is installed by default as far as I know under Mac OS 8.0 and + * 8.1), and for all Mac OS 8.5 and later systems. On Windows, it only runs under Win32 systems + * (Windows 95, 98, and NT 4.0, as well as later versions of all). On other systems, this drops + * back from the inherently platform-sensitive concept of a default browser and simply attempts + * to launch Netscape via a shell command. + * <p> + * This code is Copyright 1999-2001 by Eric Albert (ejalbert@cs.stanford.edu) and may be + * redistributed or modified in any form without restrictions as long as the portion of this + * comment from this paragraph through the end of the comment is not removed. The author + * requests that he be notified of any application, applet, or other binary that makes use of + * this code, but that's more out of curiosity than anything and is not required. This software + * includes no warranty. The author is not repsonsible for any loss of data or functionality + * or any adverse or unexpected effects of using this software. + * <p> + * Credits: + * <br>Steven Spencer, JavaWorld magazine (<a href="http://www.javaworld.com/javaworld/javatips/jw-javatip66.html">Java Tip 66</a>) + * <br>Thanks also to Ron B. Yeh, Eric Shapiro, Ben Engber, Paul Teitlebaum, Andrea Cantatore, + * Larry Barowski, Trevor Bedzek, Frank Miedrich, and Ron Rabakukk + * + * @author Eric Albert (<a href="mailto:ejalbert@cs.stanford.edu">ejalbert@cs.stanford.edu</a>) + * @version 1.4b1 (Released June 20, 2001) + */ +public class BrowserLauncher { + + /** + * The Java virtual machine that we are running on. Actually, in most cases we only care + * about the operating system, but some operating systems require us to switch on the VM. */ + private static int jvm; + + /** The browser for the system */ + private static Object browser; + + /** + * Caches whether any classes, methods, and fields that are not part of the JDK and need to + * be dynamically loaded at runtime loaded successfully. + * <p> + * Note that if this is <code>false</code>, <code>openURL()</code> will always return an + * IOException. + */ + private static boolean loadedWithoutErrors; + + /** The com.apple.mrj.MRJFileUtils class */ + private static Class mrjFileUtilsClass; + + /** The com.apple.mrj.MRJOSType class */ + private static Class mrjOSTypeClass; + + /** The com.apple.MacOS.AEDesc class */ + private static Class aeDescClass; + + /** The <init>(int) method of com.apple.MacOS.AETarget */ + private static Constructor aeTargetConstructor; + + /** The <init>(int, int, int) method of com.apple.MacOS.AppleEvent */ + private static Constructor appleEventConstructor; + + /** The <init>(String) method of com.apple.MacOS.AEDesc */ + private static Constructor aeDescConstructor; + + /** The findFolder method of com.apple.mrj.MRJFileUtils */ + private static Method findFolder; + + /** The getFileCreator method of com.apple.mrj.MRJFileUtils */ + private static Method getFileCreator; + + /** The getFileType method of com.apple.mrj.MRJFileUtils */ + private static Method getFileType; + + /** The openURL method of com.apple.mrj.MRJFileUtils */ + private static Method openURL; + + /** The makeOSType method of com.apple.MacOS.OSUtils */ + private static Method makeOSType; + + /** The putParameter method of com.apple.MacOS.AppleEvent */ + private static Method putParameter; + + /** The sendNoReply method of com.apple.MacOS.AppleEvent */ + private static Method sendNoReply; + + /** Actually an MRJOSType pointing to the System Folder on a Macintosh */ + private static Object kSystemFolderType; + + /** The keyDirectObject AppleEvent parameter type */ + private static Integer keyDirectObject; + + /** The kAutoGenerateReturnID AppleEvent code */ + private static Integer kAutoGenerateReturnID; + + /** The kAnyTransactionID AppleEvent code */ + private static Integer kAnyTransactionID; + + /** The linkage object required for JDirect 3 on Mac OS X. */ + private static Object linkage; + + /** The framework to reference on Mac OS X */ + private static final String JDirect_MacOSX = "/System/Library/Frameworks/Carbon.framework/Frameworks/HIToolbox.framework/HIToolbox"; + + /** JVM constant for MRJ 2.0 */ + private static final int MRJ_2_0 = 0; + + /** JVM constant for MRJ 2.1 or later */ + private static final int MRJ_2_1 = 1; + + /** JVM constant for Java on Mac OS X 10.0 (MRJ 3.0) */ + private static final int MRJ_3_0 = 3; + + /** JVM constant for MRJ 3.1 */ + private static final int MRJ_3_1 = 4; + + /** JVM constant for any Windows NT JVM */ + private static final int WINDOWS_NT = 5; + + /** JVM constant for any Windows 9x JVM */ + private static final int WINDOWS_9x = 6; + + /** JVM constant for any other platform */ + private static final int OTHER = -1; + + /** + * The file type of the Finder on a Macintosh. Hardcoding "Finder" would keep non-U.S. English + * systems from working properly. + */ + private static final String FINDER_TYPE = "FNDR"; + + /** + * The creator code of the Finder on a Macintosh, which is needed to send AppleEvents to the + * application. + */ + private static final String FINDER_CREATOR = "MACS"; + + /** The name for the AppleEvent type corresponding to a GetURL event. */ + private static final String GURL_EVENT = "GURL"; + + /** + * The first parameter that needs to be passed into Runtime.exec() to open the default web + * browser on Windows. + */ + private static final String FIRST_WINDOWS_PARAMETER = "/c"; + + /** The second parameter for Runtime.exec() on Windows. */ + private static final String SECOND_WINDOWS_PARAMETER = "start"; + + /** + * The third parameter for Runtime.exec() on Windows. This is a "title" + * parameter that the command line expects. Setting this parameter allows + * URLs containing spaces to work. + */ + private static final String THIRD_WINDOWS_PARAMETER = "\"\""; + + /** + * The shell parameters for Netscape that opens a given URL in an already-open copy of Netscape + * on many command-line systems. + */ + private static final String NETSCAPE_REMOTE_PARAMETER = "-remote"; + private static final String NETSCAPE_OPEN_PARAMETER_START = "'openURL("; + private static final String NETSCAPE_OPEN_PARAMETER_END = ")'"; + + /** + * The message from any exception thrown throughout the initialization process. + */ + private static String errorMessage; + + /** + * An initialization block that determines the operating system and loads the necessary + * runtime data. + */ + static { + loadedWithoutErrors = true; + String osName = System.getProperty("os.name"); + if (osName.startsWith("Mac OS")) { + String mrjVersion = System.getProperty("mrj.version"); + String majorMRJVersion = mrjVersion.substring(0, 3); + try { + double version = Double.valueOf(majorMRJVersion).doubleValue(); + if (version == 2) { + jvm = MRJ_2_0; + } else if (version >= 2.1 && version < 3) { + // Assume that all 2.x versions of MRJ work the same. MRJ 2.1 actually + // works via Runtime.exec() and 2.2 supports that but has an openURL() method + // as well that we currently ignore. + jvm = MRJ_2_1; + } else if (version == 3.0) { + jvm = MRJ_3_0; + } else if (version >= 3.1) { + // Assume that all 3.1 and later versions of MRJ work the same. + jvm = MRJ_3_1; + } else { + loadedWithoutErrors = false; + errorMessage = "Unsupported MRJ version: " + version; + } + } catch (NumberFormatException nfe) { + loadedWithoutErrors = false; + errorMessage = "Invalid MRJ version: " + mrjVersion; + } + } else if (osName.startsWith("Windows")) { + if (osName.indexOf("9") != -1) { + jvm = WINDOWS_9x; + } else { + jvm = WINDOWS_NT; + } + } else { + jvm = OTHER; + } + + if (loadedWithoutErrors) { // if we haven't hit any errors yet + loadedWithoutErrors = loadClasses(); + } + } + + /** + * This class should be never be instantiated; this just ensures so. + */ + private BrowserLauncher() { } + + /** + * Called by a static initializer to load any classes, fields, and methods required at runtime + * to locate the user's web browser. + * @return <code>true</code> if all intialization succeeded + * <code>false</code> if any portion of the initialization failed + */ + private static boolean loadClasses() { + switch (jvm) { + case MRJ_2_0: + try { + Class aeTargetClass = Class.forName("com.apple.MacOS.AETarget"); + Class osUtilsClass = Class.forName("com.apple.MacOS.OSUtils"); + Class appleEventClass = Class.forName("com.apple.MacOS.AppleEvent"); + Class aeClass = Class.forName("com.apple.MacOS.ae"); + aeDescClass = Class.forName("com.apple.MacOS.AEDesc"); + + aeTargetConstructor = aeTargetClass.getDeclaredConstructor(new Class [] { int.class }); + appleEventConstructor = appleEventClass.getDeclaredConstructor(new Class[] { int.class, int.class, aeTargetClass, int.class, int.class }); + aeDescConstructor = aeDescClass.getDeclaredConstructor(new Class[] { String.class }); + + makeOSType = osUtilsClass.getDeclaredMethod("makeOSType", new Class [] { String.class }); + putParameter = appleEventClass.getDeclaredMethod("putParameter", new Class[] { int.class, aeDescClass }); + sendNoReply = appleEventClass.getDeclaredMethod("sendNoReply", new Class[] { }); + + Field keyDirectObjectField = aeClass.getDeclaredField("keyDirectObject"); + keyDirectObject = (Integer) keyDirectObjectField.get(null); + Field autoGenerateReturnIDField = appleEventClass.getDeclaredField("kAutoGenerateReturnID"); + kAutoGenerateReturnID = (Integer) autoGenerateReturnIDField.get(null); + Field anyTransactionIDField = appleEventClass.getDeclaredField("kAnyTransactionID"); + kAnyTransactionID = (Integer) anyTransactionIDField.get(null); + } catch (ClassNotFoundException cnfe) { + errorMessage = cnfe.getMessage(); + return false; + } catch (NoSuchMethodException nsme) { + errorMessage = nsme.getMessage(); + return false; + } catch (NoSuchFieldException nsfe) { + errorMessage = nsfe.getMessage(); + return false; + } catch (IllegalAccessException iae) { + errorMessage = iae.getMessage(); + return false; + } + break; + case MRJ_2_1: + try { + mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils"); + mrjOSTypeClass = Class.forName("com.apple.mrj.MRJOSType"); + Field systemFolderField = mrjFileUtilsClass.getDeclaredField("kSystemFolderType"); + kSystemFolderType = systemFolderField.get(null); + findFolder = mrjFileUtilsClass.getDeclaredMethod("findFolder", new Class[] { mrjOSTypeClass }); + getFileCreator = mrjFileUtilsClass.getDeclaredMethod("getFileCreator", new Class[] { File.class }); + getFileType = mrjFileUtilsClass.getDeclaredMethod("getFileType", new Class[] { File.class }); + } catch (ClassNotFoundException cnfe) { + errorMessage = cnfe.getMessage(); + return false; + } catch (NoSuchFieldException nsfe) { + errorMessage = nsfe.getMessage(); + return false; + } catch (NoSuchMethodException nsme) { + errorMessage = nsme.getMessage(); + return false; + } catch (SecurityException se) { + errorMessage = se.getMessage(); + return false; + } catch (IllegalAccessException iae) { + errorMessage = iae.getMessage(); + return false; + } + break; + case MRJ_3_0: + try { + Class linker = Class.forName("com.apple.mrj.jdirect.Linker"); + Constructor constructor = linker.getConstructor(new Class[]{ Class.class }); + linkage = constructor.newInstance(new Object[] { BrowserLauncher.class }); + } catch (ClassNotFoundException cnfe) { + errorMessage = cnfe.getMessage(); + return false; + } catch (NoSuchMethodException nsme) { + errorMessage = nsme.getMessage(); + return false; + } catch (InvocationTargetException ite) { + errorMessage = ite.getMessage(); + return false; + } catch (InstantiationException ie) { + errorMessage = ie.getMessage(); + return false; + } catch (IllegalAccessException iae) { + errorMessage = iae.getMessage(); + return false; + } + break; + case MRJ_3_1: + try { + mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils"); + openURL = mrjFileUtilsClass.getDeclaredMethod("openURL", new Class[] { String.class }); + } catch (ClassNotFoundException cnfe) { + errorMessage = cnfe.getMessage(); + return false; + } catch (NoSuchMethodException nsme) { + errorMessage = nsme.getMessage(); + return false; + } + break; + default: + break; + } + return true; + } + + /** + * Attempts to locate the default web browser on the local system. Caches results so it + * only locates the browser once for each use of this class per JVM instance. + * @return The browser for the system. Note that this may not be what you would consider + * to be a standard web browser; instead, it's the application that gets called to + * open the default web browser. In some cases, this will be a non-String object + * that provides the means of calling the default browser. + */ + private static Object locateBrowser() { + if (browser != null) { + return browser; + } + switch (jvm) { + case MRJ_2_0: + try { + Integer finderCreatorCode = (Integer) makeOSType.invoke(null, new Object[] { FINDER_CREATOR }); + Object aeTarget = aeTargetConstructor.newInstance(new Object[] { finderCreatorCode }); + Integer gurlType = (Integer) makeOSType.invoke(null, new Object[] { GURL_EVENT }); + Object appleEvent = appleEventConstructor.newInstance(new Object[] { gurlType, gurlType, aeTarget, kAutoGenerateReturnID, kAnyTransactionID }); + // Don't set browser = appleEvent because then the next time we call + // locateBrowser(), we'll get the same AppleEvent, to which we'll already have + // added the relevant parameter. Instead, regenerate the AppleEvent every time. + // There's probably a way to do this better; if any has any ideas, please let + // me know. + return appleEvent; + } catch (IllegalAccessException iae) { + browser = null; + errorMessage = iae.getMessage(); + return browser; + } catch (InstantiationException ie) { + browser = null; + errorMessage = ie.getMessage(); + return browser; + } catch (InvocationTargetException ite) { + browser = null; + errorMessage = ite.getMessage(); + return browser; + } + case MRJ_2_1: + File systemFolder; + try { + systemFolder = (File) findFolder.invoke(null, new Object[] { kSystemFolderType }); + } catch (IllegalArgumentException iare) { + browser = null; + errorMessage = iare.getMessage(); + return browser; + } catch (IllegalAccessException iae) { + browser = null; + errorMessage = iae.getMessage(); + return browser; + } catch (InvocationTargetException ite) { + browser = null; + errorMessage = ite.getTargetException().getClass() + ": " + ite.getTargetException().getMessage(); + return browser; + } + String[] systemFolderFiles = systemFolder.list(); + // Avoid a FilenameFilter because that can't be stopped mid-list + for(int i = 0; i < systemFolderFiles.length; i++) { + try { + File file = new File(systemFolder, systemFolderFiles[i]); + if (!file.isFile()) { + continue; + } + // We're looking for a file with a creator code of 'MACS' and + // a type of 'FNDR'. Only requiring the type results in non-Finder + // applications being picked up on certain Mac OS 9 systems, + // especially German ones, and sending a GURL event to those + // applications results in a logout under Multiple Users. + Object fileType = getFileType.invoke(null, new Object[] { file }); + if (FINDER_TYPE.equals(fileType.toString())) { + Object fileCreator = getFileCreator.invoke(null, new Object[] { file }); + if (FINDER_CREATOR.equals(fileCreator.toString())) { + browser = file.toString(); // Actually the Finder, but that's OK + return browser; + } + } + } catch (IllegalArgumentException iare) { + browser = browser; + errorMessage = iare.getMessage(); + return null; + } catch (IllegalAccessException iae) { + browser = null; + errorMessage = iae.getMessage(); + return browser; + } catch (InvocationTargetException ite) { + browser = null; + errorMessage = ite.getTargetException().getClass() + ": " + ite.getTargetException().getMessage(); + return browser; + } + } + browser = null; + break; + case MRJ_3_0: + case MRJ_3_1: + browser = ""; // Return something non-null + break; + case WINDOWS_NT: + browser = "cmd.exe"; + break; + case WINDOWS_9x: + browser = "command.com"; + break; + case OTHER: + default: + browser = "netscape"; + break; + } + return browser; + } + + /** + * Attempts to open the default web browser to the given URL. + * @param url The URL to open + * @throws IOException If the web browser could not be located or does not run + */ + public static void openURL(String url) throws IOException { + if (!loadedWithoutErrors) { + throw new IOException("Exception in finding browser: " + errorMessage); + } + Object browser = locateBrowser(); + if (browser == null) { + throw new IOException("Unable to locate browser: " + errorMessage); + } + + switch (jvm) { + case MRJ_2_0: + Object aeDesc = null; + try { + aeDesc = aeDescConstructor.newInstance(new Object[] { url }); + putParameter.invoke(browser, new Object[] { keyDirectObject, aeDesc }); + sendNoReply.invoke(browser, new Object[] { }); + } catch (InvocationTargetException ite) { + throw new IOException("InvocationTargetException while creating AEDesc: " + ite.getMessage()); + } catch (IllegalAccessException iae) { + throw new IOException("IllegalAccessException while building AppleEvent: " + iae.getMessage()); + } catch (InstantiationException ie) { + throw new IOException("InstantiationException while creating AEDesc: " + ie.getMessage()); + } finally { + aeDesc = null; // Encourage it to get disposed if it was created + browser = null; // Ditto + } + break; + case MRJ_2_1: + Runtime.getRuntime().exec(new String[] { (String) browser, url } ); + break; + case MRJ_3_0: + int[] instance = new int[1]; + int result = ICStart(instance, 0); + if (result == 0) { + int[] selectionStart = new int[] { 0 }; + byte[] urlBytes = url.getBytes(); + int[] selectionEnd = new int[] { urlBytes.length }; + result = ICLaunchURL(instance[0], new byte[] { 0 }, urlBytes, + urlBytes.length, selectionStart, + selectionEnd); + if (result == 0) { + // Ignore the return value; the URL was launched successfully + // regardless of what happens here. + ICStop(instance); + } else { + throw new IOException("Unable to launch URL: " + result); + } + } else { + throw new IOException("Unable to create an Internet Config instance: " + result); + } + break; + case MRJ_3_1: + try { + openURL.invoke(null, new Object[] { url }); + } catch (InvocationTargetException ite) { + throw new IOException("InvocationTargetException while calling openURL: " + ite.getMessage()); + } catch (IllegalAccessException iae) { + throw new IOException("IllegalAccessException while calling openURL: " + iae.getMessage()); + } + break; + case WINDOWS_NT: + case WINDOWS_9x: + // Add quotes around the URL to allow ampersands and other special + // characters to work. + Process process = Runtime.getRuntime().exec(new String[] { (String) browser, + FIRST_WINDOWS_PARAMETER, + SECOND_WINDOWS_PARAMETER, + THIRD_WINDOWS_PARAMETER, + '"' + url + '"' }); + // This avoids a memory leak on some versions of Java on Windows. + // That's hinted at in <http://developer.java.sun.com/developer/qow/archive/68/>. + try { + process.waitFor(); + process.exitValue(); + } catch (InterruptedException ie) { + throw new IOException("InterruptedException while launching browser: " + ie.getMessage()); + } + break; + case OTHER: + // Assume that we're on Unix and that Netscape is installed + + // First, attempt to open the URL in a currently running session of Netscape + process = Runtime.getRuntime().exec(new String[] { (String) browser, + NETSCAPE_REMOTE_PARAMETER, + NETSCAPE_OPEN_PARAMETER_START + + url + + NETSCAPE_OPEN_PARAMETER_END }); + try { + int exitCode = process.waitFor(); + if (exitCode != 0) { // if Netscape was not open + Runtime.getRuntime().exec(new String[] { (String) browser, url }); + } + } catch (InterruptedException ie) { + throw new IOException("InterruptedException while launching browser: " + ie.getMessage()); + } + break; + default: + // This should never occur, but if it does, we'll try the simplest thing possible + Runtime.getRuntime().exec(new String[] { (String) browser, url }); + break; + } + } + + /** + * Methods required for Mac OS X. The presence of native methods does not cause + * any problems on other platforms. + */ + private native static int ICStart(int[] instance, int signature); + private native static int ICStop(int[] instance); + private native static int ICLaunchURL(int instance, byte[] hint, byte[] data, int len, + int[] selectionStart, int[] selectionEnd); +} diff --git a/modules/hebrew-wlc/WLC2OSIS/Utilities/FileChooser.java b/modules/hebrew-wlc/WLC2OSIS/Utilities/FileChooser.java new file mode 100644 index 0000000..2e1b5e7 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/Utilities/FileChooser.java @@ -0,0 +1,165 @@ +package Utilities;
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import java.io.File ;
+//==============================================================================
+/**
+*
+* <b>Positionable version of JFileChooser.</b><p>
+*
+* (The JFileChooser position isn't set or read by setLocation(...)
+* or getLocation.)<p>
+*
+*
+*<pre>
+*Dear Mr. Kimball,
+*
+*This is a known bug:
+*
+* http://developer.java.sun.com/developer/bugParade/bugs/4390885.html
+*
+*We are working on a solution for a later release. In the meantime, the
+*only workaround I can think of is to subclass JFileChooser and override
+*the method showDialog(), adding a call to setLocation().
+*
+*See example code below.
+*
+*Regards,
+*
+*Leif Samuelsson
+*
+*Sun Microsystems, Inc.
+*Java Swing Team
+*</pre>
+*/
+//==============================================================================
+
+public class FileChooser extends JFileChooser {
+ private JDialog dialog;
+
+ private int returnValue = ERROR_OPTION;
+ private Point Location = new Point(250, 250) ;
+ private Dimension Size = new Dimension( 600, 250) ;
+
+//------------------------------------------------------------------------------
+/**
+*
+* Constructor is the same as the no-argument version of JFileChooser.<p>
+*
+* Use setCurrentDirectory to set the initial directory.
+*
+*/
+ public FileChooser(){
+ super() ;
+ }
+//------------------------------------------------------------------------------\/**
+
+/** Replaces showDialog of JFileChooser */
+
+ public int showDialog(Component parent, String approveButtonText) {
+ if (approveButtonText != null) {
+ setApproveButtonText(approveButtonText);
+ setDialogType(CUSTOM_DIALOG);
+ }
+
+ Frame frame = parent instanceof Frame ? (Frame) parent
+ : (Frame)SwingUtilities.getAncestorOfClass(Frame.class, parent);
+ String title = getUI().getDialogTitle(this);
+
+ dialog = new JDialog(frame, title, true);
+ dialog.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ returnValue = CANCEL_OPTION;
+ }
+ });
+ dialog.getContentPane().add(this, BorderLayout.CENTER);
+ dialog.pack();
+ dialog.setLocation(Location) ;
+ dialog.setSize(Size) ;
+
+ rescanCurrentDirectory();
+ returnValue = ERROR_OPTION;
+
+ dialog.show();
+ Location = dialog.getLocation() ;
+ Size = dialog.getSize() ;
+ return returnValue;
+ }
+//------------------------------------------------------------------------------\/**
+
+/** Replaces approveSelection of JFileChooser */
+ public void approveSelection() {
+ returnValue = APPROVE_OPTION;
+ if (dialog != null) {
+ dialog.setVisible(false);
+ }
+ super.approveSelection();
+ }
+//------------------------------------------------------------------------------\/**
+
+/** Replaces cancelSelection of JFileChooser */
+ public void cancelSelection() {
+ returnValue = CANCEL_OPTION;
+ if (dialog != null) {
+ dialog.setVisible(false);
+ }
+ super.cancelSelection();
+ }
+//------------------------------------------------------------------------------\/**
+
+/** Sets the location of the FileChooser */
+
+public void setLocation(Point P) {
+ this.Location = P ;
+ }
+//------------------------------------------------------------------------------\/**
+
+/** Sets the size of the FileChooser */
+
+public void setSize(Dimension D) {
+ this.Size = D ;
+ }
+//------------------------------------------------------------------------------\/**
+
+/** Returns the location of the FileChooser */
+
+public Point getLocation() {
+ return Location ;
+ }
+//------------------------------------------------------------------------------\/**
+
+/** Returns the size of the FileChooser */
+
+public Dimension getSize() {
+ return Size ;
+ }
+//------------------------------------------------------------------------------\/**
+
+/** Test program provided by Leif Samuelsson */
+
+ public static void main(String[] s) throws Exception {
+ JFrame frame = new JFrame("FileChooser test");
+ frame.setVisible(true);
+ JFileChooser chooser = new FileChooser();
+ chooser.setLocation(new Point(200,200)) ;
+ int returnVal = chooser.showOpenDialog(frame);
+ System.out.println("Position: " + chooser.getLocation()) ;
+ switch (returnVal) {
+ case APPROVE_OPTION:
+ System.out.println("You chose to open this file: " + chooser.getSelectedFile().getName());
+ break;
+
+ case CANCEL_OPTION:
+ System.out.println("Cancelled");
+ break;
+
+ case ERROR_OPTION:
+ System.out.println("An error occurred");
+ break;
+ }
+ System.exit(0);
+ }
+}
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/Utilities/Fmt.java b/modules/hebrew-wlc/WLC2OSIS/Utilities/Fmt.java new file mode 100644 index 0000000..193ab42 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/Utilities/Fmt.java @@ -0,0 +1,355 @@ +package Utilities ;
+
+import java.text.* ;
+import java.text.Format.* ;
+import java.io.* ;
+import java.awt.*;
+//==============================================================================
+/**
+*
+* <b>Formating tools.</b><p>
+*
+* <pre>
+* F = new Fmt() ;
+* System.out.println(F.i(2,10)) ; // 10 digit integer field.
+* System.out.println(F.f(3.1415,10, 2)) ; // 10 digit F10.2 field.
+* System.out.println(F.fill("-", 10)) ; // 10 digits of "-".
+* System.out.println(F.prepad(F.fill("-",10), 12) ;
+* // 2 digits of blank before fill.
+* </pre>
+*
+*/
+//==============================================================================
+
+public class Fmt{
+
+NumberFormat NF = NumberFormat.getInstance() ; // Provides commas in integers
+
+//-----------------------------------------------------------------------------
+/**
+* Simple constructor: Fmt F = new Fmt() ;
+*
+*/
+public Fmt(){
+}
+//-----------------------------------------------------------------------------
+/**
+*
+* Yields a string of specified FieldWidth and DecimalDigits containing
+* the given double.<p>
+*
+* @param f double to be converted.
+* @param FieldWidth Maximum number of characters to be produced. If more
+* characters are produced, the field is filled with *.
+* @param DecimalDigits int number of points after the decimal point.
+* @return String String of exactly FieldWidth characters.
+*
+*/
+public String f( double f, int FieldWidth, int DecimalDigits) {
+ if(DecimalDigits>FieldWidth-2){
+ String s = fill("!", FieldWidth) ;
+ return s ;
+ }
+ String FormatString = "0." ;
+ for (int k = 0; k < DecimalDigits; k++){
+ FormatString = FormatString + "0" ;
+ }
+ while (FormatString.length() < FieldWidth){
+ FormatString = "#" + FormatString ;
+ }
+
+ DecimalFormat DF = new DecimalFormat(FormatString) ;
+ String s = DF.format(f) ;
+ if (s.length()< FieldWidth){
+ s = prepad(s, FieldWidth) ;
+ }
+ else if(s.length()>FieldWidth){
+ s = fill("*", FieldWidth) ;
+ }
+ return s ;
+ }
+//-----------------------------------------------------------------------------
+/**
+*
+* Yields a string of specified FieldWidth containing the given integer.<p>
+*
+* @param i integer to be converted.
+* @param FieldWidth Maximum number of characters to be produced. If more
+* characters are produced, the field is filled with *.
+* @return String String of exactly FieldWidth characters.
+*
+*/
+public String i( int i, int FieldWidth) {
+ String s = NF.format(i) ;
+ if (s.length()< FieldWidth){
+ s = prepad(s, FieldWidth) ;
+ }
+ else if(s.length()>FieldWidth){
+ s = "";
+ for(int k = 0; k<FieldWidth; k++){
+ s = s + "*" ;
+ }
+ }
+ return s ;
+ }
+//-----------------------------------------------------------------------------
+/**
+*
+* Yields a string containing the given integer.<p>
+*
+* @param i integer to be converted.
+* @return String String representing i.
+*
+*/
+public String i( int i) {
+ return NF.format(i) ;
+ }
+//-----------------------------------------------------------------------------
+/**
+*
+* Yields a string of Width specified characters.<p>
+*
+* @param c String (usually a single character) to be repeated.
+* @param Width int number of times to repeat S.
+* @return String of Width characters.
+*
+*/
+public String fill( String c, int Width){
+ String s = "" ;
+ for(int i = 0; i < Width; i++){
+ s = s + c ;
+ }
+ return s;
+ }
+//-----------------------------------------------------------------------------
+/**
+*
+* Prints a string of Width specified characters to a specified PrintStream.<p>
+*
+* @param P PrintStream such as System.out.
+* @param c String (usually a single character) to be repeated.
+* @param Width int number of times to repeat S.
+*
+*/
+public void bar(PrintStream P, String c, int Width){
+ String s = "" ;
+ for(int i = 0; i < Width; i++){
+ s = s + c ;
+ }
+ P.println(s) ;
+ return ;
+ }
+//-----------------------------------------------------------------------------
+/**
+*
+* Prints a string of Width specified characters to System.out.<p>
+*
+* @param c String (usually a single character) to be repeated.
+* @param Width int number of times to repeat S.
+* @return String String of Width characters.
+*
+*/
+public void bar(String c, int Width){
+ bar(System.out, c, Width) ;
+ return ;
+ }
+//-----------------------------------------------------------------------------
+/**
+*
+* Removes blanks anywhere in String.<p>
+*
+* @param c String to be deblanked.
+* @return String String without any blanks.
+*
+*/
+public String deblank(String c){
+ String s = "" ;
+ for (int i = 0; i < c.length(); i++){
+ if(c.charAt(i) != ' '){
+ s = s + c.charAt(i) ;
+ }
+ }
+ return s ;
+ }
+//-----------------------------------------------------------------------------
+/**
+*
+* Pads the front of a String, giving a String of a specified length.<p>
+*
+* @param s String to be prepaded.
+* @param n Desired length of output string.
+* @return String Prepadded String.
+*
+*/
+public String prepad(String s, int n){
+ int len = s.length() ;
+ if (len == n){ // String is already long enough.
+ return s ;
+ }
+ else if(len > n){
+ return fill("!", n) ;
+ }
+// Prepad
+ String OutString = "" ;
+ int Pads = n - len ;
+ for (int i = 0; i < Pads; i++){
+ OutString = OutString + " " ;
+ }
+// Original String
+ OutString = OutString + s ;
+ return OutString ;
+ }
+//-----------------------------------------------------------------------------
+/**
+*
+* Pads the end of a String, giving a String of a specified length.<p>
+*
+* @param s String to be postpaded.
+* @param n Desired length of output string.
+* @return String Prepadded String.
+*
+*/
+public String postpad(String s, int n){
+ int len = s.length() ;
+ if (len == n){ // String is already long enough.
+ return s ;
+ }
+ else if(len > n){
+ return fill("!", n) ;
+ }
+// Original String
+// Postpad
+ String OutString = "" ;
+ for (int i = 0; i < len; i++){
+ OutString = OutString + s.charAt(i) ;
+ }
+// Postpad
+ while (OutString.length() <= n){
+ OutString = OutString + " " ;
+ }
+ return OutString ;
+ }
+//-----------------------------------------------------------------------------
+/**
+* Gives a convenient maximum size for a text area
+* specified in rows, columns.<p>
+*
+* @param font Font of text.
+* @param rows int giving number of rows of text.
+* @param columns int giving number of columns of text.
+* @return D Dimension of best size.
+*/
+public Dimension areaSize( Font font, int rows, int columns ){
+ double XFactor = 0.70 ;
+// double YFactor = 1.42;
+ double YFactor = 1.65;
+
+ Integer X = new Integer( font.getSize() ) ;
+ double x = XFactor*X.doubleValue()*columns ;
+ Integer Y = new Integer( font.getSize() ) ;
+ double y = YFactor*Y.doubleValue()*rows ;
+ Dimension D = new Dimension( (new Double(x)).intValue(),
+ (new Double(y)).intValue() ) ;
+ return D ;
+ }
+//-----------------------------------------------------------------------------
+/**
+* Gives a convenient maximum size for a text area
+* specified as a dimension.<p>
+*
+* @param font Font of text.
+* @param d Dimnsion object giving number of rows and columns of text.
+* @return D Dimension of best size.
+*/
+public Dimension areaSize( Font font, Dimension d){
+ double XFactor = 0.70 ;
+ double YFactor = 1.42;
+
+ Integer X = new Integer( font.getSize() ) ;
+ double x = XFactor*X.doubleValue()*d.getWidth() ;
+ Integer Y = new Integer( font.getSize() ) ;
+ double y = YFactor*Y.doubleValue()*d.getHeight() ;
+ Dimension D = new Dimension( (new Double(x)).intValue(),
+ (new Double(y)).intValue() ) ;
+ return D ;
+ }
+//-----------------------------------------------------------------------------
+/**
+* Removes the extension, including the ".", from a file name String.<p>
+*
+* If the Name doesn't contain a ".", the original Name is returned.
+*
+* @param Name String containing file name.
+* @return String with extension and "." removed.
+*/
+public static String removeExtension( String Name){
+
+ boolean HasDot = false ;
+ for (int k = 0; k < Name.length() ; k++){
+ if(Name.charAt(k) == '.'){
+ HasDot = true ;
+ }
+ }
+ if(!HasDot) return Name ;
+
+ String NewName = "" ;
+ for (int k = Name.length()-1; k >= 0; k--){
+ if( Name.charAt(k) == '.'){
+ for (int j = 0; j < k ; j ++) {
+ NewName = NewName + Name.charAt(j) ;
+ }
+ break ;
+ }
+ }
+ if (NewName == "."){
+ NewName = "" ;
+ }
+ return NewName ;
+ }
+//-----------------------------------------------------------------------------
+/**
+* gets the extension, including the ".", from a file name String.<p>
+*
+* If the Name doesn't contain a ".", the original Name is returned.
+* From Sun JFileChooser tutorial
+*
+* @param s String containing file name with extension.
+* @return String giving the extension.
+*/
+public static String getExtension( String s){
+
+ String ext = "";
+ int i = s.lastIndexOf('.');
+
+ if (i > 0 && i < s.length() - 1) {
+ ext = s.substring(i+1).toLowerCase();
+ }
+ return ext;
+ }
+//-----------------------------------------------------------------------------
+/**
+* Prints the name of the calling location
+* plus the current Thread to System.out.<p>
+*
+* @param Location String giving location of call.
+*/
+public void printThread( String Location){
+ Thread t = Thread.currentThread() ;
+ System.out.println("At " + Location + ", the current Thread is "
+ + t.getName() );
+ return;
+ }
+//-----------------------------------------------------------------------------
+/**
+* Test program.<p>
+*/
+public static void main( String[] args) {
+ Fmt F = new Fmt() ;
+ String Name = "XYX.txt.spa" ;
+ System.out.println(Name) ;
+ System.out.println(F.removeExtension(Name)) ;
+ System.out.println(F.removeExtension(F.removeExtension(Name))) ;
+ }
+ } // End of class
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/Utilities/GetParentFrame.java b/modules/hebrew-wlc/WLC2OSIS/Utilities/GetParentFrame.java new file mode 100644 index 0000000..9fcd472 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/Utilities/GetParentFrame.java @@ -0,0 +1,34 @@ +package Utilities ;
+
+import java.awt.*;
+import javax.swing.*;
+//==============================================================================
+/**
+ * <b>Gets ultimate parent Frame of a component.</b><p>
+ *
+ * From page 274 of Pure JFC Swing.<p>
+ *
+ */
+//==============================================================================
+
+public class GetParentFrame{
+
+//-------------------------------------------------------------------------------
+/**
+ * Gets the ultimate parent Frame of a Component.<p>
+ *
+ * @param comp a Component whose parent is sought.
+ * @return a Frame Ultimate parent Frame of component.
+ */
+static public Frame GetParentFrame(Component comp){
+ if (comp instanceof Frame) return (JFrame)comp ;
+ for (Component c = comp; c!= null; c = c.getParent() ){
+ if (c instanceof Frame){
+ return (Frame)c ;
+ }
+ }
+ return null ;
+ }
+// end of class
+}
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/Utilities/Stoppable.java b/modules/hebrew-wlc/WLC2OSIS/Utilities/Stoppable.java new file mode 100644 index 0000000..70047c9 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/Utilities/Stoppable.java @@ -0,0 +1,25 @@ +package Utilities ;
+//==============================================================================
+/**
+*
+* <b>Stoppable interface.<p></b>
+*
+* For use with WindowEventHandler, an implementing object
+* must provide a done() method to implement this interface.
+*/
+//==============================================================================
+
+public interface Stoppable{
+
+//------------------------------------------------------------------------------
+/**
+* WindowEventHandler will call this method when close occurs.
+*
+*/
+public void done() ;
+
+//-----------------------------------------------------------------------------
+// end of interface
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/Utilities/SuperContainer.java b/modules/hebrew-wlc/WLC2OSIS/Utilities/SuperContainer.java new file mode 100644 index 0000000..7c249c5 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/Utilities/SuperContainer.java @@ -0,0 +1,176 @@ +package Utilities ;
+
+import java.awt.*;
+import java.applet.* ;
+import java.awt.event.*;
+import javax.swing.*;
+//==============================================================================
+/**
+*
+* <b>Container object with JApplet, JFrame, and JDialog properties.<p></b>
+*
+*/
+//==============================================================================
+public class SuperContainer{
+
+Container InputContainer ;
+JRootPane RP ;
+Frame SuperFrame ; // Frame of overall screen.
+
+boolean IsJApplet = false ;
+boolean IsJFrame = false ;
+boolean IsJDialog = false ;
+boolean IsWindow = false ;
+
+/**
+* Container object with JApplet, JFrame, and JDialog properties.
+*
+* @param InputContainer Container, either a JApplet, JFrame, or JDialog.
+*/
+public SuperContainer(Container InputContainer){
+ this.InputContainer = InputContainer ;
+ if(InputContainer instanceof JApplet){
+ IsJApplet = true ;
+ RP = ((JApplet) InputContainer).getRootPane() ;
+ }
+ else if(InputContainer instanceof JFrame){
+ IsJFrame = true ;
+ RP = ((JFrame) InputContainer).getRootPane() ;
+ }
+ else if(InputContainer instanceof JDialog){
+ RP = ((JDialog) InputContainer).getRootPane() ;
+ IsJDialog = true ;
+ }
+ else{
+ System.out.println("SuperContainer: Bad input type!") ;
+ }
+ IsWindow = IsJFrame | IsJDialog ;
+ SuperFrame = GetParentFrame.GetParentFrame(RP.getContentPane()) ;
+ }
+//------------------------------------------------------------------------------
+public Container getContentPane(){
+ return RP.getContentPane() ;
+ }
+//------------------------------------------------------------------------------
+public boolean isApplet(){
+ return IsJApplet ;
+ }
+//------------------------------------------------------------------------------
+public boolean isWindow(){
+ return IsWindow ;
+ }
+//------------------------------------------------------------------------------
+public void setResizable(boolean Resizable) {
+ if(IsJDialog){
+ ((Dialog)InputContainer).setResizable(Resizable) ;
+ }
+ else{
+ SuperFrame.setResizable(Resizable) ;
+ }
+ }
+//------------------------------------------------------------------------------
+public void setTitle(String Title) {
+ if(IsJFrame){
+ ((JFrame) InputContainer).setTitle(Title);
+ }
+ else if(IsJDialog){
+ ((JDialog) InputContainer).setTitle(Title);
+ }
+ return ;
+ }
+//------------------------------------------------------------------------------
+public void addWindowListener(WindowListener WL) {
+ if (IsWindow){
+ ((Window)InputContainer).addWindowListener(WL) ;
+ }
+ return ;
+ }
+//------------------------------------------------------------------------------
+public void setLocation( Point P ) {
+ if (IsWindow){
+ ((Window)InputContainer).setLocation(P) ;
+ }
+ return ;
+ }
+//------------------------------------------------------------------------------
+public void setSize( Dimension D ) {
+ if (IsWindow){
+ ((Window)InputContainer).setSize(D) ;
+ }
+ return ;
+ }
+//------------------------------------------------------------------------------
+public void setVisible(boolean Visible) {
+ ((Component)InputContainer).setVisible(Visible) ;
+ return ;
+ }
+//------------------------------------------------------------------------------
+public void dispose() {
+ if (IsWindow){
+ ((Window)InputContainer).dispose() ;
+ }
+ else{
+ // Restart ?
+ }
+ return ;
+ }
+//------------------------------------------------------------------------------
+public Point getLocation() {
+ if (IsWindow){
+ return ((Window)InputContainer).getLocation() ;
+ }
+ else{
+ return null ;
+ }
+ }
+//------------------------------------------------------------------------------
+public void pack() {
+ if (IsWindow){
+ ((Window)InputContainer).pack() ;
+ }
+ return ;
+ }
+//------------------------------------------------------------------------------
+public Dimension getSize() {
+ if (IsWindow){
+ return ((Window)InputContainer).getSize() ;
+ }
+ else{
+ return null ;
+ }
+ }
+//------------------------------------------------------------------------------
+public void setIconImage(Image I) {
+ if (IsWindow){
+ SuperFrame.setIconImage(I) ;
+ }
+ }
+//------------------------------------------------------------------------------
+public Frame superFrame() {
+ return SuperFrame ;
+ }
+//------------------------------------------------------------------------------
+public void showStatus(String Status) {
+ if (!IsWindow){
+ ((Applet)InputContainer).getAppletContext().showStatus(Status) ;
+ }
+ }
+//------------------------------------------------------------------------------
+public Component getGlassPane() {
+ return RP.getGlassPane() ;
+ }
+//------------------------------------------------------------------------------
+public void setGlassPane(Component GP) {
+ RP.setGlassPane(GP) ;
+ }
+//------------------------------------------------------------------------------
+public JRootPane getRootPane() {
+ return RP.getRootPane() ;
+ }
+//------------------------------------------------------------------------------
+public void addMouseListener(MouseListener ML) {
+ RP.addMouseListener(ML);
+ }
+//------------------------------------------------------------------------------
+}
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/Utilities/WindowEventHandler.java b/modules/hebrew-wlc/WLC2OSIS/Utilities/WindowEventHandler.java new file mode 100644 index 0000000..a16f1cf --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/Utilities/WindowEventHandler.java @@ -0,0 +1,40 @@ +package Utilities ;
+
+import java.awt.* ;
+import java.awt.event.* ;
+import javax.swing.*;
+import javax.swing.event.* ;
+//==============================================================================
+/**
+ * <b> Handles window events by calling done() method of
+ * object to which it is attached.</b><p>
+ *
+ */
+//==============================================================================
+public class WindowEventHandler extends WindowAdapter{
+
+Stoppable T ;
+
+//------------------------------------------------------------------------------
+/**
+*
+* Pass the Stoppable object to the handler in the constructor.<p>
+*
+* @param T Stoppable class.
+*
+*/
+public WindowEventHandler(Stoppable T ){
+ this.T = T ;
+ }
+
+//------------------------------------------------------------------------------
+/**
+*
+* Window closing causes T.stop to be called.<p>
+*/
+public void windowClosing(WindowEvent evt){
+ T.done() ;
+ }
+// End of class
+}
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/Utilities/package.html b/modules/hebrew-wlc/WLC2OSIS/Utilities/package.html new file mode 100644 index 0000000..ad40db7 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/Utilities/package.html @@ -0,0 +1,9 @@ +<HTML>
+<BODY>
+<b>General java utilities.</B>
+(/Utilities/package.html)
+<p>
+
+</BODY>
+</HTML>
+
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/GUI/FileChoices.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/GUI/FileChoices.java new file mode 100644 index 0000000..09b5437 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/GUI/FileChoices.java @@ -0,0 +1,71 @@ +package WLC2OSIS.GUI ;
+
+import WLC2OSIS.* ;
+import Utilities.* ;
+
+import java.awt.* ;
+import java.util.* ;
+import java.io.* ;
+import java.awt.event.* ;
+import javax.swing.*;
+import javax.swing.event.* ;
+import javax.swing.border.*;
+//==============================================================================
+/**
+ * <b>Gets the input and output files.</b><p>
+ */
+//==============================================================================
+
+public class FileChoices {
+
+WLC2OSIS A ;
+
+public FileChoices(WLC2OSIS A){
+ this.A = A ;
+ }
+public String getInputFilename(String DefaultInputFilename){
+ FileChooser inchooser = new FileChooser() ;
+ inchooser.setSelectedFile(new File(DefaultInputFilename) ) ;
+ inchooser.setDialogTitle("Give the input file") ;
+ inchooser.setApproveButtonText("Set") ;
+ inchooser.setSize( new Dimension( 500, 400 ) ) ;
+ inchooser.setLocation(new Point(200, 200) );
+ inchooser.revalidate() ;
+ int returnValue = inchooser.showOpenDialog(A.OverallContainer) ;
+ if(returnValue==JFileChooser.APPROVE_OPTION){
+ String InputFilename = inchooser.getSelectedFile().getPath() ;
+ return InputFilename ;
+ }
+ else{
+ System.out.println("WLC2OSIS:FileChoices: Didn't choose the input file.") ;
+ System.exit(0) ;
+ return null ;}
+ }
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+public String getOutputDirectory(String DefaultOutputDirectory){
+ FileChooser outchooser = new FileChooser() ;
+ outchooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY) ;
+ File InitialDirectory = new File(DefaultOutputDirectory ) ;
+ outchooser.setSelectedFile(InitialDirectory) ;
+ outchooser.setDialogTitle("Set the output directory") ;
+ outchooser.setApproveButtonText("Set") ;
+ outchooser.setSize( new Dimension( 500, 400 ) ) ;
+ outchooser.setLocation(new Point(200, 200) );
+ outchooser.revalidate() ;
+ int returnValue = outchooser.showOpenDialog(A.OverallContainer) ;
+ if(returnValue==JFileChooser.APPROVE_OPTION){
+ String OutputDirectory = outchooser.getSelectedFile().getPath() ;
+ return OutputDirectory ;
+ }
+ else{
+ System.out.println("WLC2OSIS: Didn't choose the output directory.") ;
+ System.exit(0) ;
+ return null ;
+ }
+ }
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/GUI/GetDate.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/GUI/GetDate.java new file mode 100644 index 0000000..2c909a4 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/GUI/GetDate.java @@ -0,0 +1,102 @@ +package WLC2OSIS.GUI ;
+
+import WLC2OSIS.* ;
+import Utilities.* ;
+
+import java.awt.* ;
+import java.util.* ;
+import java.io.* ;
+import java.awt.event.* ;
+import javax.swing.*;
+import javax.swing.event.* ;
+import javax.swing.border.*;
+//==============================================================================
+/**
+ * <b>Gets the input file date.</b><p>
+ */
+//==============================================================================
+
+public class GetDate extends JDialog
+ implements ActionListener, Stoppable {
+
+WLC2OSIS A ;
+JTextField DateField ;
+JButton Set ;
+
+public GetDate(WLC2OSIS A){
+ super(A.SC.superFrame(), true) ; // A modal dialog
+ this.A = A ;
+ this.setTitle("Give the date of this input file") ;
+ this.setLocation(new Point(300, 300) );
+ this.addWindowListener(new WindowEventHandler((Stoppable) this)) ;
+
+ Set = new JButton("Set") ;
+ Set.addActionListener(this) ;
+
+ int hs = 10 ;
+ int vs = 10 ;
+
+ JPanel p0 = new JPanel() ;
+ p0.setLayout( new BoxLayout(p0, BoxLayout.Y_AXIS) ) ;
+ p0.add(Box.createVerticalStrut(vs) ) ;
+//------------------------------------------------------------------------------
+
+// Data name
+
+ JLabel DateLabel = new JLabel("Date of this input file:") ;
+ DateField = new JTextField() ;
+ DateField.setText(A.DefaultInputDate) ;
+ Dimension TFD = new Dimension (100, 25) ;
+ DateField.setPreferredSize(TFD) ;
+ DateField.setMaximumSize(TFD) ;
+ JPanel p1 = new JPanel() ;
+ p1.setLayout( new BoxLayout(p1, BoxLayout.X_AXIS) ) ;
+ p1.add(Box.createHorizontalStrut(hs) ) ;
+ p1.add(DateLabel) ;
+ p1.add(Box.createHorizontalStrut(hs) ) ;
+ p1.add(DateField) ;
+ p1.add(Box.createHorizontalGlue() ) ;
+ p0.add(p1) ;
+ p0.add(Box.createVerticalStrut(vs) ) ;
+//------------------------------------------------------------------------------
+
+// Set button
+
+ JPanel p5 = new JPanel() ;
+ p5.setLayout( new BoxLayout(p5, BoxLayout.X_AXIS) ) ;
+ p5.add(Box.createHorizontalStrut(hs) ) ;
+ p5.add(Box.createHorizontalGlue() ) ;
+ p5.add(Set) ;
+ p5.add(Box.createHorizontalStrut(hs) ) ;
+ p0.add(p5) ;
+ p0.add(Box.createVerticalStrut(vs) ) ;
+
+//------------------------------------------------------------------------------
+ p0.setPreferredSize(null) ;
+ this.setSize(p0.getPreferredSize()) ;
+ this.getContentPane().add(p0) ;
+ this.pack() ;
+ this.show() ;
+ }
+//------------------------------------------------------------------------------
+
+public void done(){
+ this.dispose() ;
+ }
+//------------------------------------------------------------------------------
+
+public void actionPerformed(ActionEvent e){
+
+ if (e.getActionCommand() == "Set"){
+ String tname = DateField.getText() ;
+ if(tname.length() !=0){
+ A.Date = tname ;
+ }
+ done() ;
+ }
+ }
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/GUI/Messages.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/GUI/Messages.java new file mode 100644 index 0000000..8c1e770 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/GUI/Messages.java @@ -0,0 +1,64 @@ +package WLC2OSIS.GUI ;
+
+import WLC2OSIS.* ;
+import Utilities.* ;
+
+import java.awt.* ;
+import java.util.* ;
+import java.io.* ;
+import java.awt.event.* ;
+import javax.swing.*;
+import javax.swing.event.* ;
+import javax.swing.border.*;
+//==============================================================================
+/**
+ * <b>Outputs messages to operator.</b><p>
+ */
+//==============================================================================
+
+public class Messages {
+
+WLC2OSIS A ;
+
+public Messages(WLC2OSIS A){
+ this.A = A ;
+ }
+public void initialMessage(){
+ String IntroMessage = "WLC2OSIS ("+ A.ProgramDate
+ + "): Conversion of WHI text files to XML files.\n\n"
+ + "Important messages will be written to command window.\n"
+ + "Please be ready to write them down.\n\n" ;
+ JOptionPane.showMessageDialog(A.OverallContainer, IntroMessage) ;
+ }
+public void doneMessage(){
+ String DoneMessage = "The 40 output files appear to have been written\n"
+ + "normally. Please examine the Java Console for possible errors.\n"
+ + "If any errors have occured please make a careful note of them.\n\n"
+ + "If no errors occurred and the 11 supporting files, \n\n"
+ + " CC.somerights.gif,\n"
+ + " Sarissa.js,\n"
+ + " SBL_Hebrew.ttf,\n"
+ + " SBL_Hebrew_readme.txt,\n"
+ + " Tanach.Counts.html,\n"
+ + " Tanach.License.html,\n"
+ + " Tanach.Version.html,\n"
+ + " Tanach.xsd,\n"
+ + " Tanach.xsl.xml,\n"
+ + " WHIbanner.gif,\n"
+ + " WLC2OSIS.jar,\n\n"
+ + "are in the output directory, then press \"OK\" to see the index file.\n\n";
+ JOptionPane.showMessageDialog(A.OverallContainer, DoneMessage) ;
+ }
+public void endMessage(){
+ String EndMessage = "\nWLC2OSIS: Normal end.\n\n"
+ + "Don't forget to update Tanach.Version.html to reflect\n"
+ + "the fact that the text has been updated.\n\n"
+ + "Then ZIP all 51 files into Tanach.zip\n"
+ + "and place Tanach.zip in output directory.\n\n";
+ JOptionPane.showMessageDialog(A.OverallContainer, EndMessage) ;
+ }
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/GUI/package.html b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/GUI/package.html new file mode 100644 index 0000000..563fa18 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/GUI/package.html @@ -0,0 +1,9 @@ +<HTML>
+<BODY>
+<b>Graphical user interface (GUI)</b>.
+<p/>
+<p align="right"> (<b><tt>BHS2XML/GUI/package.html</tt></b>)
+</p>
+Crude graphical interfaces.
+</BODY>
+</HTML>
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Books.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Books.java new file mode 100644 index 0000000..036fafb --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Books.java @@ -0,0 +1,91 @@ +package WLC2OSIS.Parse ;
+
+import WLC2OSIS.* ;
+import WLC2OSIS.Translate.* ;
+import WLC2OSIS.Utilities.* ;
+//==============================================================================
+/**
+ * <b>Processes books.</b>
+ *
+ * Special to WLC.
+ */
+//==============================================================================
+public class Books{
+
+WLC2OSIS A ;
+Parser P ;
+public BookName[] BookNames ;
+BookName BookObject ;
+String Filename ;
+//-----------------------------------------------------------------------------
+
+public Books(WLC2OSIS A, Parser P ) {
+ this.A = A ;
+ this.P = P ;
+ BookNames = BookName.setBookNames() ;
+ }
+//------------------------------------------------------------------------------
+
+// Starts a book. Enter with WLC BookCode
+
+public void start(String BookCode){
+
+ BookObject = BookName.getBookName(BookNames, BookCode) ;
+ P.Book = BookObject.name ;
+ P.TanachBookCount = P.TanachBookCount + 1 ;
+ P.BookVerseCount = 0;
+ P.BookChapterCount = 0 ;
+
+//-----------------------------------------------------------------------------
+
+// Begin writing the book as a file
+
+ Filename = BookObject.filename ;
+
+ A.w = new XMLWriter(A.OutputDirectory, Filename, "Tanach",
+ "Tanach", "" ) ;
+
+// Write the header
+ Header.writeHeader(A, A.w) ;
+
+//-----------------------------------------------------------------------------
+
+ P.ChapterNumber = 0 ;
+ P.VerseNumber = 0 ;
+ P.WordNumber = 0 ;
+ A.w.openTag("tanach", 0) ;
+ A.w.openTag("book", 1) ;
+ A.w.openTag("names", 2) ;
+ A.w.writeString("name", 3, BookObject.name ) ;
+ A.w.writeString("abbrev", 3, BookObject.abbrev) ;
+ A.w.writeInt("number", 3, BookObject.number) ;
+ A.w.writeString("filename", 3, BookObject.filename) ;
+ A.w.writeString("hebrewname", 3, BookObject.hebrewname) ;
+ A.w.closeTag("names", 2) ;
+ }
+//------------------------------------------------------------------------------
+
+// Ends a book.
+
+public void end(){
+ if (P.Book != null){
+
+ P.BookChapterCount = P.ChapterNumber ;
+ P.TanachChapterCount = P.TanachChapterCount + P.ChapterNumber ;
+
+ A.w.writeInt("vs", 2, P.BookVerseCount) ;
+ A.w.writeInt("cs", 2, P.BookChapterCount) ;
+ A.w.closeTag("book", 1) ;
+ A.w.closeTag("tanach", 0) ;
+
+// Add the transcription notes.
+ Note.writeNotes(A.w) ;
+
+ A.w.close() ;
+ System.out.println( Filename + ".xml has been written." ) ;
+ }
+ }
+//----------------------------------------------------------------------------
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Chapters.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Chapters.java new file mode 100644 index 0000000..03068a9 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Chapters.java @@ -0,0 +1,49 @@ +package WLC2OSIS.Parse ;
+
+import WLC2OSIS.* ;
+//==============================================================================
+/**
+ * <b>Processes chapters.</b>
+ */
+//==============================================================================
+public class Chapters{
+
+WLC2OSIS A ;
+Parser P ;
+//-----------------------------------------------------------------------------
+
+public Chapters(WLC2OSIS A, Parser P ) {
+ this.A = A ;
+ this.P = P ;
+ }
+//------------------------------------------------------------------------------
+
+// Starts a book.
+
+public void start(){
+ P.ChapterVerseCount = 0 ;
+ P.ChapterNumber = P.ChapterNumber + 1 ;
+ P.VerseNumber = 0 ;
+ P.WordNumber = 0 ;
+ A.w.openAttributedTag("c", 2, "n", new Integer(P.ChapterNumber).toString() ) ;
+// System.out.println("\nChapter " + A.F.i(P.ChapterNumber,2) + " start." ) ;
+ }
+//------------------------------------------------------------------------------
+
+// Ends a book.
+
+public void end(){
+ if (P.ChapterNumber != 0){
+ P.ChapterVerseCount = P.VerseNumber ;
+ P.BookVerseCount = P.BookVerseCount + P.VerseNumber ;
+ P.TanachVerseCount = P.TanachVerseCount + P.VerseNumber ;
+ A.w.writeInt("vs", 3, P.VerseNumber) ;
+ A.w.closeTag("c", 2) ;
+// System.out.println("Chapter " + A.F.i(P.ChapterNumber,2) + " ends with "
+// + A.F.i(P.VerseNumber,2) + " verses." ) ;
+ }
+ }
+//----------------------------------------------------------------------------
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Markers.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Markers.java new file mode 100644 index 0000000..78e66e0 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Markers.java @@ -0,0 +1,68 @@ +package WLC2OSIS.Parse ;
+
+import WLC2OSIS.* ;
+
+import java.io.* ;
+//==============================================================================
+/**
+ * <b>Processes markers.</b>
+ *
+ * Before any marker is written, the TrailingMaqaf flag must be
+ * tested. If a trailing maqaf word precedes the mark, it must be
+ * written before the marker.
+ */
+//==============================================================================
+public class Markers{
+
+WLC2OSIS A ;
+Parser P ;
+
+//-----------------------------------------------------------------------------
+
+public Markers(WLC2OSIS A, Parser P ) {
+ this.A = A ;
+ this.P = P ;
+ }
+//------------------------------------------------------------------------------
+
+// Samek
+public void samek(){
+ testMaqafWord() ;
+ A.w.writeMarker("samekh", 4) ;
+ P.MarkerWritten = true ;
+ }
+//------------------------------------------------------------------------------
+
+// Pe
+public void pe(){
+ testMaqafWord() ;
+ A.w.writeMarker("pe", 4) ;
+ P.MarkerWritten = true ;
+ }
+//------------------------------------------------------------------------------
+
+// Line
+public void line(){
+ System.out.println("Markers: End-of-line encountered!") ;
+ }
+//----------------------------------------------------------------------------
+/**
+ * Tests for a preceding trailing maqaf word and writes it.
+ *
+ * Before any marker is written, the TrailingMaqaf flag must be
+ * tested. If a trailing maqaf word precedes the mark, it must be
+ * written before the marker.
+ *
+ * Apparemtly ONLY EOLs cause this test to be activated.
+ */
+void testMaqafWord(){
+ if (P.w.TrailingMaqaf){
+// System.out.print("Markers: Marker follows trailing maqaf at ") ;
+// P.printPosition() ;
+ P.w.writeWord(P.w.MaqafWord, P.w.MaqafWordType) ;
+ P.w.TrailingMaqaf = false ;
+ }
+ }
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Parser.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Parser.java new file mode 100644 index 0000000..fd726a5 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Parser.java @@ -0,0 +1,205 @@ +package WLC2OSIS.Parse ;
+
+import WLC2OSIS.* ;
+import WLC2OSIS.Translate.* ;
+//==============================================================================
+/**
+ * <b>Parser dispatches tokens to Books, Chapters, Markers, Tanach,
+ * Verses, and Words start/end methods, special to WLC. </b>
+ *
+ * Extensively modified for WLC.
+ */
+//==============================================================================
+public class Parser{
+
+WLC2OSIS A ;
+Tokenizer t ;
+
+// Working classes
+
+Tanach tanach ;
+public Books b ;
+Chapters c ;
+Verses v ;
+public Words w ;
+Translate T ;
+Markers m ;
+public WKQ wkq ;
+
+// Current state
+
+public boolean MarkerWritten ; // Indicates a marker has been written
+ // between two words.
+
+String BookName ;
+
+String Book ;
+int Chapter ;
+int Verse ;
+
+String LastBookCode = "" ;
+int LastChapter = -1 ;
+int LastVerse = -1 ;
+
+
+// Assorted counts
+public int ChapterVerseCount ;
+public int BookVerseCount ;
+public int BookChapterCount ;
+
+public int TanachVerseCount ;
+public int TanachChapterCount ;
+public int TanachBookCount ;
+
+int ChapterNumber ;
+int VerseNumber ;
+int WordNumber ;
+
+//-----------------------------------------------------------------------------
+public Parser(WLC2OSIS A) {
+ this.A = A ;
+
+ T = new Translate(A, this) ;
+
+// Set up the tokenizer
+ t = new Tokenizer(A) ;
+
+// Set up the Tanach, Books, Chapters, Verses, Words, and Markers classes.
+ tanach = new Tanach(A, this) ;
+ b = new Books(A, this) ;
+ c = new Chapters(A, this) ;
+ v = new Verses(A, this) ;
+ w = new Words(A, this) ;
+ m = new Markers(A, this) ;
+ wkq = new WKQ(this) ;
+ new MC() ;
+ }
+//------------------------------------------------------------------------------
+
+// Gets the next token as a String.
+
+// EOF is indicated by a return of EOF.
+
+public void parse(){
+ String s ;
+ boolean PreviousEOL = true ;
+ System.out.println("\n") ;
+ tanach.start() ;
+ for (int k = 0; k < A.InputChars.length ; k++){
+
+ s = t.nextToken() ;
+
+ if(s.compareTo(t.EOF) == 0){
+ break ;
+ }
+
+//-----------------------------------------------------------------------------
+
+// Process a line identifier
+
+ if (PreviousEOL){
+ int ColonIndex = s.indexOf(':') ;
+ if(ColonIndex <=0 ){
+ System.out.println("Parser: Incorrect line identifier: " + s + " !") ;
+ break ;
+ }
+ PreviousEOL= false ;
+
+// Parse the identifier
+ String BookCode = s.substring(0,2) ;
+ int Chapter = Integer.parseInt( s.substring(2, ColonIndex) ) ;
+ int Verse = Integer.parseInt( s.substring(ColonIndex+1) ) ;
+
+// Change in Book, start a book.
+ if(BookCode.compareTo(LastBookCode) != 0){
+ v.end() ;
+ c.end() ;
+ b.end() ;
+ b.start(BookCode) ;
+ c.start() ;
+ v.start() ;
+ LastBookCode = BookCode ;
+ LastChapter = 1 ;
+ LastVerse = 1 ;
+ }
+
+// Change in Chapter, start a Chapter.
+ if(Chapter != LastChapter){
+ v.end() ;
+ c.end() ;
+ c.start() ;
+ v.start() ;
+ LastChapter = Chapter ;
+ LastVerse = 1 ;
+ }
+
+// Change in Verse, start a Verse.
+ if(Verse != LastVerse){
+ v.end() ;
+ v.start() ;
+ LastVerse = Verse ;
+ }
+ }
+//-----------------------------------------------------------------------------
+
+// Process a word.
+
+ else{
+ if(s.compareTo(t.EOL) == 0){
+ PreviousEOL = true ;
+ }
+ else{
+ if (s.length() > 1){
+ w.process(s) ;
+ }
+ else{
+// Look for 1 letter words.
+ if( s.compareTo("P")==0){
+ m.pe();
+ }
+ else if( s.compareTo("S")==0){
+ m.samek() ;
+ }
+ else if( s.compareTo("?")==0){
+ m.line() ;
+ }
+ else{ // It's a word
+ w.process(s) ;
+ }
+ }
+ }
+ }
+
+ }
+ v.end() ;
+ c.end() ;
+ b.end() ;
+ tanach.end() ;
+ return ;
+ }
+//----------------------------------------------------------------------------
+
+// Counts the number of occurences of a character in a String.
+
+public int countChar(String W, char c){
+ int Count = 0 ;
+ for(int k=0; k < W.length(); k++){
+ if(W.charAt(k)==c){
+ Count++ ;
+ }
+ }
+ return Count ;
+ }
+//----------------------------------------------------------------------------
+
+// Prints a verse identification.
+
+public void printPosition(){
+ System.out.print(" at " + Book + " " + A.F.i(ChapterNumber,3) + ":"
+ + A.F.i(VerseNumber,2)
+ + "." + A.F.i(WordNumber,2) + "\n") ;
+ }
+//------------------------------------------------------------------------------
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Tanach.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Tanach.java new file mode 100644 index 0000000..f019865 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Tanach.java @@ -0,0 +1,49 @@ +package WLC2OSIS.Parse ;
+
+import WLC2OSIS.* ;
+import WLC2OSIS.Translate.* ;
+import WLC2OSIS.Utilities.* ;
+
+//==============================================================================
+/**
+ * <b>Processes Tanach.</b>
+ */
+//==============================================================================
+public class Tanach{
+
+WLC2OSIS A ;
+Parser P ;
+
+//-----------------------------------------------------------------------------
+
+public Tanach(WLC2OSIS A, Parser P ) {
+ this.A = A ;
+ this.P = P ;
+ }
+//------------------------------------------------------------------------------
+
+// Starts a book.
+
+public void start(){
+ P.ChapterVerseCount = 0 ;
+ P.BookVerseCount = 0 ;
+ P.BookChapterCount = 0 ;
+ P.TanachVerseCount = 0 ;
+ P.TanachChapterCount = 0 ;
+ P.TanachBookCount = 0 ;
+ }
+//------------------------------------------------------------------------------
+
+// Ends a book.
+
+public void end(){
+ if (P.Book != null){
+ System.out.println("\nTanach ends with "
+ + A.F.i(P.TanachBookCount,2) + " books." ) ;
+ }
+
+ }
+//----------------------------------------------------------------------------
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Tokenizer.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Tokenizer.java new file mode 100644 index 0000000..f896239 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Tokenizer.java @@ -0,0 +1,87 @@ +package WLC2OSIS.Parse ;
+
+import WLC2OSIS.* ;
+
+import java.io.* ;
+import javax.swing.* ;
+import java.awt.* ;
+//==============================================================================
+/**
+ * <b>Tokenizer based on standard Java tokenizer, special to WLC.</b>
+ *
+ * Special to WLC.
+ */
+//==============================================================================
+public class Tokenizer{
+
+public final String EOF = "***EOF***" ;
+public final String EOL = "***EOL***" ;
+WLC2OSIS A ;
+CharArrayReader car ;
+StreamTokenizer st ;
+
+//-----------------------------------------------------------------------------
+
+public Tokenizer(WLC2OSIS A ) {
+ this.A = A ;
+
+// Set up the tokenizer
+
+ car = new CharArrayReader(A.InputChars) ;
+ st = new StreamTokenizer( car) ;
+ st.resetSyntax() ;
+ st.wordChars(33, 126 ) ; // All printables are word characters
+ st.ordinaryChar(63) ; // ? is a special symbol, the EOL marker.
+ st.eolIsSignificant(true) ;
+ }
+//------------------------------------------------------------------------------
+
+// Gets the next token as a String.
+
+// EOF is indicated by a return of EOF.
+// EOL is indicated by a return of EOL.
+
+public String nextToken(){
+ int TokenType = 0 ;
+ boolean Found = false ; // Found a word token or EOF ;
+ String Value = "" ; // The returned String.
+ do{
+ try{
+ TokenType = st.nextToken() ;
+ }
+ catch (IOException e) {
+ System.out.println("Tokenizer: IOException in tokenization: " + e) ;
+ }
+
+ if (TokenType==StreamTokenizer.TT_WORD){
+ Value = st.sval ;
+ Found = true ;
+ }
+ else if(TokenType==StreamTokenizer.TT_EOF){
+ Value = EOF ;
+ Found = true ;
+ }
+ else if(TokenType==StreamTokenizer.TT_EOL){
+ Value = EOL ;
+ Found = true ;
+ }
+ if (TokenType==63){ // EOL marker
+ Value = "?" ;
+ Found = true ;
+ }
+
+ }while(!Found) ;
+
+ return Value ;
+ }
+//------------------------------------------------------------------------------
+
+// Does a pushBack on the StreamTokenizer, st.
+
+public void pushBack(){
+ st.pushBack() ;
+ }
+//-----------------------------------------------------------------------------
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Verses.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Verses.java new file mode 100644 index 0000000..99e172d --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Verses.java @@ -0,0 +1,43 @@ +package WLC2OSIS.Parse ;
+
+import WLC2OSIS.* ;
+//==============================================================================
+/**
+ * <b>Processes verses.</b>
+ */
+//==============================================================================
+public class Verses{
+
+WLC2OSIS A ;
+Parser P ;
+//-----------------------------------------------------------------------------
+
+public Verses(WLC2OSIS A, Parser P ) {
+ this.A = A ;
+ this.P = P ;
+ }
+//------------------------------------------------------------------------------
+
+// Starts a book.
+
+public void start(){
+ P.VerseNumber = P.VerseNumber + 1 ;
+ P.WordNumber = 0 ;
+ A.w.openAttributedTag("v", 3, "n", new Integer(P.VerseNumber).toString() ) ;
+// System.out.println("\nVerse " + A.F.i(P.VerseNumber,2) + " start." ) ;
+ }
+//------------------------------------------------------------------------------
+
+// Ends a book.
+
+public void end(){
+ if( P.VerseNumber != 0){
+ A.w.closeTag("v", 3) ;
+// System.out.println("Verse " + A.F.i(P.VerseNumber,2) + " ends with "
+// + A.F.i(P.WordNumber,2) + " words." ) ;
+ }
+ }
+//----------------------------------------------------------------------------
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Words.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Words.java new file mode 100644 index 0000000..0988bda --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/Words.java @@ -0,0 +1,119 @@ +package WLC2OSIS.Parse ;
+
+import WLC2OSIS.* ;
+import WLC2OSIS.Translate.H ;
+import WLC2OSIS.Utilities.* ;
+//==============================================================================
+/**
+ * <b>Processes words, sending them to the Translate class
+ * after their word, qere, ketiv properties have been determined.</b>
+ */
+//==============================================================================
+public class Words{
+
+WLC2OSIS A ;
+Parser P ;
+
+boolean TrailingMaqaf ;
+String MaqafWord ;
+String MaqafWordType ;
+
+//-----------------------------------------------------------------------------
+
+public Words(WLC2OSIS A, Parser P ) {
+ this.A = A ;
+ this.P = P ;
+ }
+//------------------------------------------------------------------------------
+
+// Processes a word,
+
+public void process(String W){
+
+//----------------------------------------------------------------------------------
+
+// Process WKQ
+ P.wkq.process(W) ;
+
+//----------------------------------------------------------------------------------
+
+
+// System.out.println(P.Book + " " + A.F.i(P.ChapterNumber,2) + ":"
+// + A.F.i(P.VerseNumber,2)
+// + "." + A.F.i(P.WordNumber,2) + " " + W) ;
+ }
+//----------------------------------------------------------------------------------
+
+// Translates and writes a word (simple, ketib, qere) with exception markers.
+
+// All returns leave P.MarkerWritten = false ;
+
+public void write(String W, String Type) {
+
+
+ String Word = P.T.translate(W) ;
+
+// Check for any KQ markers which should NOT be here!
+
+ int asteriskcount = P.countChar(W, '*') ;
+
+ if (asteriskcount > 0){
+ System.out.print("Words.write: Unexpected KQ character * ") ;
+ P.printPosition() ;
+ System.out.println("Word: " + W) ;
+ }
+
+// Look for a case in which there's been trailing maqaf
+// without an intervening marker.
+
+ if(TrailingMaqaf & !P.MarkerWritten ){
+ if(MaqafWordType.charAt(0)== Type.charAt(0) ){
+ Word = MaqafWord+Word ; // Combine them.
+ }
+ else{
+// System.out.print("Words: Mismatched types for combining "
+// + MaqafWordType + ", " + Type + " at " ) ;
+// P.printPosition() ;
+ writeWord(MaqafWord, MaqafWordType) ;
+ TrailingMaqaf = false ;
+ }
+ }
+
+// Check for a trailing maqaf.
+// Don't write the word here.
+
+ TrailingMaqaf = false ;
+ if( Word.charAt(Word.length()-1) == H.maqaf){
+ TrailingMaqaf = true ;
+ MaqafWord = Word ;
+ MaqafWordType = Type ;
+ P.MarkerWritten = false ;
+ return ;
+ }
+
+ writeWord(Word, Type) ;
+ }
+//----------------------------------------------------------------------------------
+
+public void writeWord(String Word, String Type) {
+
+// Check for any exception markers ]x
+
+ String Out = "" ;
+ for (int k=0 ; k < Word.length() ; k++){
+ char c = Word.charAt(k) ;
+ if(c == ']'){
+ k++ ;
+ char ExceptionValue = Word.charAt(k) ;
+ Out = Out + "<x>" + ExceptionValue +"</x>" ;
+ }
+ else{
+ Out = Out + c ;
+ }
+ }
+ A.w.writeString(Type, 4, Out) ;
+ P.MarkerWritten = false ;
+ }
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/package.html b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/package.html new file mode 100644 index 0000000..175262f --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Parse/package.html @@ -0,0 +1,9 @@ +<HTML>
+<BODY>
+<b>Parsing classes</b>.
+<p/>
+<p align="right"> (<b><tt>BHS2XML/Parse/package.html</tt></b>)
+</p>
+Only the Parse and Tokenizer classes are specific to the WLC.
+</BODY>
+</HTML>
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/BookName.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/BookName.java new file mode 100644 index 0000000..67b2e19 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/BookName.java @@ -0,0 +1,158 @@ +package WLC2OSIS.Translate ;
+
+import WLC2OSIS.* ;
+import WLC2OSIS.Translate.* ;
+import Utilities.* ;
+
+import java.io.*;
+//==============================================================================
+/**
+ * <b>Object containing alternative book names, abbreviations,
+ * and numbers.</b><p>
+ *
+ * Special to WLC.
+ */
+//==============================================================================
+public class BookName{
+
+public int wlcnumber = 0 ; // Book number in WLC text.
+public String wlcname = "" ; // Book name in WLC text.
+
+public int number = 0 ; // Book number in JPS Tanach.
+public String name = "" ; // Book name in JPS Tanach.
+public String abbrev = "" ; // Book abreviation in NSRV.
+public String filename = "" ; // Book filename
+public String hebrewname = "" ;
+
+//-----------------------------------------------------------------------------
+
+// Full definition
+
+public BookName( int wlcnumber, String wlcname,
+ int number, String name, String abbrev,
+ String hebrewname, String filename ) {
+ this.wlcnumber = wlcnumber ;
+ this.wlcname = wlcname ;
+ this.number = number ;
+ this.name = name ;
+ this.abbrev = abbrev ;
+ this.hebrewname = hebrewname ;
+ this.filename = filename ;
+ }
+//-----------------------------------------------------------------------------
+
+// Definition for books that have names that are valid filenames.
+// Their filenames are their abbrev.
+
+public BookName( int wlcnumber, String wlcname,
+ int number, String name, String abbrev, String hebrewname ) {
+ this(wlcnumber, wlcname, number, name, abbrev,
+ hebrewname, name ) ;
+ }
+//-----------------------------------------------------------------------------
+
+// Provides an array of BookNames
+
+public static BookName[] setBookNames() {
+ BookName[] BookNames = new BookName[40] ;
+
+ BookNames[ 1] = new BookName(1, "gn",
+ 1, "Genesis", "Gen", H.Gen ) ;
+ BookNames[ 2] = new BookName(2, "ex",
+ 2, "Exodus", "Ex", H.Exod) ;
+ BookNames[ 3] = new BookName(3, "lv",
+ 3, "Leviticus", "Lev", H.Lev) ;
+ BookNames[ 4] = new BookName(4, "nu",
+ 4, "Numbers", "Num", H.Num) ;
+ BookNames[ 5] = new BookName(5, "dt",
+ 5, "Deuteronomy", "Deut", H.Deut) ;
+
+ BookNames[ 6] = new BookName(6, "js",
+ 6, "Joshua", "Josh", H.Josh) ;
+ BookNames[ 7] = new BookName(7, "ju",
+ 7, "Judges", "Judg", H.Judg) ;
+ BookNames[ 8] = new BookName(8, "1s",
+ 8, "1 Samuel", "1 Sam", H.Sam1, "Samuel 1") ;
+ BookNames[ 9] = new BookName(9, "2s",
+ 9, "2 Samuel", "2 Sam", H.Sam2, "Samuel 2") ;
+ BookNames[10] = new BookName(10, "1k",
+ 10, "1 Kings", "1 Kings", H.Kgs1, "Kings 1") ;
+ BookNames[11] = new BookName(11, "2k",
+ 11, "2 Kings", "2 Kings", H.Kgs2, "Kings 2") ;
+ BookNames[12] = new BookName(12, "is",
+ 12, "Isaiah", "Isa", H.Isa) ;
+ BookNames[13] = new BookName(13, "je",
+ 13, "Jeremiah", "Jer", H.Jer) ;
+ BookNames[14] = new BookName(14, "ek",
+ 14, "Ezekiel", "Ezek", H.Ezek) ;
+
+ BookNames[15] = new BookName(15, "ho",
+ 15, "Hosea", "Hos", H.Hos) ;
+ BookNames[16] = new BookName(16, "jl",
+ 16, "Joel", "Joel", H.Joel) ;
+ BookNames[17] = new BookName(17, "am",
+ 17, "Amos", "Am", H.Amos) ;
+ BookNames[18] = new BookName(18, "ob",
+ 18, "Obadiah", "Ob", H.Obad) ;
+ BookNames[19] = new BookName(19, "jn",
+ 19, "Jonah", "Jon", H.Jonah) ;
+ BookNames[20] = new BookName(20, "mi",
+ 20, "Micah", "Mic", H.Micah) ;
+ BookNames[21] = new BookName(21, "na",
+ 21, "Nahum", "Nah", H.Nahum) ;
+ BookNames[22] = new BookName(22, "hb",
+ 22, "Habakkuk", "Hab", H.Hab) ;
+ BookNames[23] = new BookName(23, "zp",
+ 23, "Zephaniah", "Zeph", H.Zeph) ;
+ BookNames[24] = new BookName(24, "hg",
+ 24, "Haggai", "Hag", H.Hag) ;
+ BookNames[25] = new BookName(25, "zc",
+ 25, "Zechariah", "Zech", H.Zech) ;
+ BookNames[26] = new BookName(26, "ma",
+ 26, "Malachi", "Mal", H.Mal) ;
+
+ BookNames[27] = new BookName(27, "ps",
+ 27, "Psalms", "Ps", H.Ps) ;
+ BookNames[28] = new BookName(28, "jb",
+ 29, "Job", "Job", H.Job) ;
+ BookNames[29] = new BookName(29, "pr",
+ 28, "Proverbs", "Prov", H.Prov) ;
+ BookNames[30] = new BookName(30, "ru",
+ 31, "Ruth", "Ruth", H.Ruth) ;
+ BookNames[31] = new BookName(31, "ca",
+ 30, "The Song of Songs", "Song", H.Song, "Song of Songs") ;
+ BookNames[32] = new BookName(32, "ec",
+ 33, "Ecclesiastes", "Eccl", H.Eccl) ;
+ BookNames[33] = new BookName(33, "lm",
+ 32, "Lamentations", "Lam", H.Lam) ;
+ BookNames[34] = new BookName(34, "es",
+ 34, "Esther", "Esth", H.Esth) ;
+ BookNames[35] = new BookName(35, "da",
+ 35, "Daniel", "Dan", H.Dan) ;
+ BookNames[36] = new BookName(36, "er",
+ 36, "Ezra", "Ezra", H.Ezra) ;
+ BookNames[37] = new BookName(37, "ne",
+ 37, "Nehemiah", "Neh", H.Neh) ;
+ BookNames[38] = new BookName(38, "1c",
+ 38, "1 Chronicles", "1 Chr", H.Chr1, "Chronicles 1") ;
+ BookNames[39] = new BookName(39, "2c",
+ 39, "2 Chronicles", "2 Chr", H.Chr2, "Chronicles 2") ;
+ return BookNames ;
+ }
+//-----------------------------------------------------------------------------
+
+// Returns a BookName object given a 2 letter book code.
+
+public static BookName getBookName(BookName[] BookNames, String BookCode) {
+ for (int k =1; k < BookNames.length; k++) {
+ if( BookCode.compareTo(BookNames[k].wlcname)==0){
+ return BookNames[k] ;
+ }
+ }
+ System.out.println("BookName: No book found for code " + BookCode + " !") ;
+ return null ;
+ }
+//-----------------------------------------------------------------------------
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/H.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/H.java new file mode 100644 index 0000000..c8bc4fc --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/H.java @@ -0,0 +1,196 @@ +package WLC2OSIS.Translate ;
+
+//==============================================================================
+/**
+ * <b>Unicode Hebrew characters</b><p>
+ *
+ * From Unicode Hebrew, Version 4.0.
+ */
+//==============================================================================
+public class H{
+
+// Letters = Consonants
+
+public static final char alef = '\u05d0' ;
+public static final char bet = '\u05d1' ;
+public static final char gimel = '\u05d2' ;
+public static final char dalet = '\u05d3' ;
+public static final char he = '\u05d4' ;
+public static final char vav = '\u05d5' ;
+public static final char zayin = '\u05d6' ;
+public static final char het = '\u05d7' ;
+public static final char tet = '\u05d8' ;
+public static final char yod = '\u05d9' ;
+public static final char finalkaf = '\u05dA' ;
+public static final char kaf = '\u05dB' ;
+public static final char lamed = '\u05dC' ;
+public static final char finalmem = '\u05dD' ;
+public static final char mem = '\u05dE' ;
+public static final char finalnun = '\u05dF' ;
+public static final char nun = '\u05e0' ;
+public static final char samekh = '\u05e1' ;
+public static final char ayin = '\u05e2' ;
+public static final char finalpe = '\u05e3' ;
+public static final char pe = '\u05e4' ;
+public static final char finaltsadi = '\u05e5' ;
+public static final char tsadi = '\u05e6' ;
+public static final char qof = '\u05e7' ;
+public static final char resh = '\u05e8' ;
+public static final char shin = '\u05e9' ;
+public static final char tav = '\u05eA' ;
+
+// Points and punctuation
+
+public static final char sheva = '\u05b0' ;
+public static final char hatafsegol = '\u05b1' ;
+public static final char hatafpatah = '\u05b2' ;
+public static final char hatafqamats = '\u05b3' ;
+public static final char hiriq = '\u05b4' ;
+public static final char tsere = '\u05b5' ;
+public static final char segol = '\u05b6' ;
+public static final char patah = '\u05b7' ;
+public static final char qamats = '\u05b8' ;
+public static final char holam = '\u05b9' ;
+public static final char reserved = '\u05ba' ;
+public static final char qubuts = '\u05bb' ;
+public static final char dagesh = '\u05bc' ;
+public static final char meteg = '\u05bd' ;
+public static final char maqaf = '\u05be' ;
+public static final char rafe = '\u05bf' ;
+public static final char paseq = '\u05c0' ;
+public static final char shindot = '\u05c1' ;
+public static final char sindot = '\u05c2' ;
+public static final char sofpasuq = '\u05c3' ;
+public static final char upperdot = '\u05c4' ;
+
+public static final char masoranumberdot = '\u0307' ;
+
+// Accents
+
+public static final char etnachta = '\u0591' ;
+public static final char accentsegol = '\u0592' ;
+public static final char shalshelet = '\u0593' ;
+public static final char zaqefqatan = '\u0594' ;
+public static final char zaqefgadol = '\u0595' ;
+public static final char tipeha = '\u0596' ;
+public static final char revia = '\u0597' ;
+public static final char zarqa = '\u0598' ;
+public static final char pashta = '\u0599' ;
+public static final char yetiv = '\u059a' ;
+public static final char tevir = '\u059b' ;
+public static final char geresh = '\u059c' ;
+public static final char gereshmuqdam= '\u059d' ;
+public static final char gershayim = '\u059e' ;
+public static final char qarneypara = '\u059f' ;
+public static final char telishagedola='\u05a0' ;
+public static final char pazer = '\u05a1' ;
+public static final char reserved2 = '\u05a2' ;
+public static final char munah = '\u05a3' ;
+public static final char mahapakh = '\u05a4' ;
+public static final char merkha = '\u05a5' ;
+public static final char merkhakefula= '\u05a6' ;
+public static final char darga = '\u05a7' ;
+public static final char qadma = '\u05a8' ;
+public static final char telishaqetana='\u05a9' ;
+public static final char yerahbenyomo= '\u05aa' ;
+public static final char ole = '\u05ab' ;
+public static final char iluy = '\u05ac' ;
+public static final char dehi = '\u05ad' ;
+public static final char zinor = '\u05ae' ;
+public static final char masoracircle= '\u05af' ;
+
+// Yiddish ligatures for completeness
+public static final char doublevav = '\u05f0' ;
+public static final char vavyod = '\u05f1' ;
+public static final char doubleyod = '\u05f2' ;
+
+
+// Additional punctuation
+public static final char punctgeresh = '\u05f3' ;
+public static final char punctgershayim = '\u05f4' ;
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+
+// Letters = Consonants as Strings have initial capital letter in name.
+
+public static final String Alef = "\u05d0" ;
+public static final String Bet = "\u05d1" ;
+public static final String Gimel = "\u05d2" ;
+public static final String Dalet = "\u05d3" ;
+public static final String He = "\u05d4" ;
+public static final String Vav = "\u05d5" ;
+public static final String Zayin = "\u05d6" ;
+public static final String Het = "\u05d7" ;
+public static final String Tet = "\u05d8" ;
+public static final String Yod = "\u05d9" ;
+public static final String Finalkaf = "\u05dA" ;
+public static final String Kaf = "\u05dB" ;
+public static final String Lamed = "\u05dC" ;
+public static final String Finalmem = "\u05dD" ;
+public static final String Mem = "\u05dE" ;
+public static final String Finalnun = "\u05dF" ;
+public static final String Nun = "\u05e0" ;
+public static final String Invertednun = "\uf300" ;
+public static final String Samekh = "\u05e1" ;
+public static final String Ayin = "\u05e2" ;
+public static final String Finalpe = "\u05e3" ;
+public static final String Pe = "\u05e4" ;
+public static final String Finaltsadi = "\u05e5" ;
+public static final String Tsadi = "\u05e6" ;
+public static final String Qof = "\u05e7" ;
+public static final String Resh = "\u05e8" ;
+public static final String Shin = "\u05e9" ;
+public static final String Tav = "\u05eA" ;
+//-----------------------------------------------------------------------------
+
+// Book names in Hebrew
+
+public static final String Tnk = Tav+Nun+Character.toString(punctgershayim)+Finalkaf ;
+
+public static final String Gen = Bet+Resh+Alef+Shin+Yod+Tav ;
+public static final String Exod = Shin+Mem+Vav+Tav ;
+public static final String Lev = Vav+Yod+Qof+Resh+Alef ;
+public static final String Num = Bet+Mem+Dalet+Bet+Dalet ;
+public static final String Deut = Dalet+Bet+Resh+Yod+Finalmem ;
+
+public static final String Josh = Yod+He+Vav+Shin+Ayin ;
+public static final String Judg = Shin+Vav+Pe+Tet+Yod+Finalmem ;
+public static final String Sam1 = Shin+Mem+Vav+Alef+Lamed+" "+Alef ;
+public static final String Sam2 = Shin+Mem+Vav+Alef+Lamed+" "+Bet ;
+public static final String Kgs1 = Mem+Lamed+Kaf+Yod+Finalmem+" "+Alef ;
+public static final String Kgs2 = Mem+Lamed+Kaf+Yod+Finalmem+" "+Bet ;
+public static final String Isa = Yod+Shin+Ayin+He ;
+public static final String Jer = Yod+Resh+Mem+Yod+He ;
+public static final String Ezek = Yod+Het+Zayin+Qof+Alef+Lamed ;
+
+public static final String Hos = He+Vav+Shin+Ayin ;
+public static final String Joel = Yod+Vav+Alef+Lamed ;
+public static final String Amos = Ayin+Mem+Vav+Samekh ;
+public static final String Obad = Ayin+Bet+Dalet+Yod+He ;
+public static final String Jonah = Yod+Vav+Nun+He ;
+public static final String Micah = Mem+Yod+Kaf+He ;
+public static final String Nahum = Nun+Het+Vav+Finalmem ;
+public static final String Hab = Het+Bet+Qof+Vav+Qof ;
+public static final String Zeph = Tsadi+Pe+Nun+Yod+He ;
+public static final String Hag = Het+Gimel+Yod ;
+public static final String Zech = Zayin+Kaf+Resh+Yod+He ;
+public static final String Mal = Mem+Lamed+Alef+Kaf+Yod ;
+
+public static final String Ps = Tav+He+Yod+Lamed+Yod+Finalmem ;
+public static final String Job = Alef+Yod+Vav+Bet ;
+public static final String Prov = Mem+Shin+Lamed+Yod ;
+public static final String Ruth = Resh+Vav+Tav ;
+public static final String Song = Shin+Yod+Resh+" "+He+Shin+Yod+Resh+Yod+Finalmem ;
+public static final String Eccl = Qof+He+Lamed+Tav ;
+public static final String Lam = Alef+Yod+Kaf+He ;
+public static final String Esth = Alef+Samekh+Tav+Resh ;
+public static final String Dan = Dalet+Nun+Yod+Alef+Lamed ;
+public static final String Ezra = Ayin+Zayin+Resh+Alef ;
+public static final String Neh= Nun+Het+Mem+Yod+He ;
+public static final String Chr1 = Dalet+Bet+Resh+Yod+" "+He+Yod+Mem+Yod+Finalmem+" "+Alef ;
+public static final String Chr2 = Dalet+Bet+Resh+Yod+" "+He+Yod+Mem+Yod+Finalmem+" "+Bet ;
+//-----------------------------------------------------------------------------
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/Header.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/Header.java new file mode 100644 index 0000000..1052d0d --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/Header.java @@ -0,0 +1,46 @@ +package WLC2OSIS.Translate ;
+
+import WLC2OSIS.* ;
+import WLC2OSIS.Translate.* ;
+import WLC2OSIS.Utilities.* ;
+
+import java.util.Date ;
+import java.text.SimpleDateFormat ;
+//==============================================================================
+/**
+ * <b>Header information for Tanach.</b><p>
+ */
+//==============================================================================
+public class Header{
+
+static SimpleDateFormat DateFormat = new SimpleDateFormat("dd MMM yyyy") ;
+static String DateTime ;
+
+public Header(){
+ }
+//-----------------------------------------------------------------------------
+
+// Writes the Notes to the XML file.
+
+public static void writeHeader(WLC2OSIS A, XMLWriter w) {
+ Date DT = new Date() ;
+ DateTime = DateFormat.format(DT) ;
+ A.w.openTag("header", 0) ;
+ A.w.writeString("name", 1, "Tanach") ;
+ A.w.writeString("hebrewname", 1, H.Tnk) ;
+ A.w.writeString("title", 1, A.Title) ;
+ A.w.writeString("shortdescription", 1, A.ShortDescription) ;
+ for (int i =0; i < A.Description.length; i++){
+ A.w.writeString("description", 1, A.Description[i]) ;
+ }
+ A.w.writeString("date", 1, A.Date) ;
+ A.w.writeString("transcriptiondate", 1, DateTime) ;
+ A.w.writeString("copyright", 1, "\u00A9 C. V. Kimball 2004") ;
+ A.w.writeString("filename", 1, A.InputFilename) ;
+ A.w.closeTag("header", 0) ;
+ }
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/Index.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/Index.java new file mode 100644 index 0000000..6e5bd95 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/Index.java @@ -0,0 +1,71 @@ +package WLC2OSIS.Translate ;
+
+import WLC2OSIS.* ;
+import WLC2OSIS.Parse.* ;
+import WLC2OSIS.Utilities.* ;
+
+import java.util.Date ;
+import java.text.SimpleDateFormat ;
+//==============================================================================
+/**
+ * <b>Writes the Tanach.xml file containing only the index.</b><p>
+ *
+ * Special to WLC
+ */
+//==============================================================================
+public class Index{
+
+public Index(){
+ }
+//-----------------------------------------------------------------------------
+
+// Writes the index to the Tanach.xml file.
+
+public static void writeIndex(WLC2OSIS A) {
+
+ A.w = new XMLWriter(A.OutputDirectory,
+ "Tanach", "Tanach",
+ "Tanach", "" ) ;
+ Header.writeHeader(A, A.w) ;
+ A.w.openTag("index", 0) ;
+ A.w.writeInt("n", 1, A.p.TanachBookCount) ;
+ A.w.openTag("books", 1) ;
+
+ for (int i = 1; i <= A.p.TanachBookCount; i++){
+
+// Place the books out in their usual, not MCW order
+
+ boolean Found = false;
+ int k = 0 ;
+ for (int j = 1; j <= A.p.TanachBookCount; j++){
+ if(A.p.b.BookNames[j].number == i){
+ Found = true ;
+ k = j ;
+ }
+ }
+ if(!Found){
+ System.out.println("Index: Index " + i + " not found in BookNames table.") ;
+ }
+
+ A.w.openTag("names", 2) ;
+ A.w.writeString("name", 3, A.p.b.BookNames[k].name ) ;
+ A.w.writeString("abbrev", 3, A.p.b.BookNames[k].abbrev) ;
+ A.w.writeInt("number", 3, A.p.b.BookNames[k].number) ;
+ A.w.writeString("filename", 3, A.p.b.BookNames[k].filename) ;
+ A.w.writeString("hebrewname", 3, A.p.b.BookNames[k].hebrewname) ;
+ A.w.closeTag("names", 2) ;
+ }
+
+ A.w.closeTag("books", 1) ;
+ A.w.writeInt("vs", 1, A.p.TanachVerseCount) ;
+ A.w.writeInt("cs", 1, A.p.TanachChapterCount) ;
+ A.w.closeTag("index", 0) ;
+ UnicodeChar.writeUnicodeChars(A.w) ;
+ Note.writeNotes(A.w) ;
+ A.w.close() ;
+ }
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/MC.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/MC.java new file mode 100644 index 0000000..851b76c --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/MC.java @@ -0,0 +1,242 @@ +package WLC2OSIS.Translate ;
+
+import WLC2OSIS.Utilities.* ;
+import Utilities.* ;
+
+import java.io.*;
+//==============================================================================
+/**
+ * <b>MC ASCII decoding constants</b>.<p/>
+ */
+//==============================================================================
+public class MC{
+
+/** Array of MCOs indexed by the lowest 7 bits of the character value. */
+static MCO[] Characters = new MCO[128] ;
+/** Array of MCOs indexed by integers from 0 to 99 */
+static MCO[] Numbers = new MCO[100] ;
+//-----------------------------------------------------------------------------
+
+// static initializer
+
+static {
+
+//-----------------------------------------------------------------------------
+
+// Set Unknown to all types.
+
+ for (int k=0; k < 128; k++){
+ Characters[k] = new MCO("Unknown", MCO.Unknown, "Unspecified", "Unspecified", 0 ) ;
+ }
+ for (int k=0; k < 100; k++){
+ Numbers[k] = new MCO("Unknown", MCO.Unknown, "Unspecified", "Unspecified", 0 ) ;
+ }
+//-----------------------------------------------------------------------------
+
+// Set the Characters table
+
+ for (int k=0; k < 128; k++){
+
+// Set the Consonants.
+
+ if(k == (int) ')') Characters[k] =
+ new MCO("alef", MCO.Consonant, H.alef, H.alef, 0 ) ;
+ if(k == (int) 'B') Characters[k] =
+ new MCO("bet", MCO.Consonant, H.bet, H.bet, 0 ) ;
+ if(k == (int) 'G') Characters[k] =
+ new MCO("gimel", MCO.Consonant, H.gimel, H.gimel, 0 ) ;
+ if(k == (int) 'D') Characters[k] =
+ new MCO("dalet", MCO.Consonant, H.dalet, H.dalet, 0 ) ;
+ if(k == (int) 'H') Characters[k] =
+ new MCO("he", MCO.Consonant, H.he, H.he, 0 ) ;
+ if(k == (int) 'W') Characters[k] =
+ new MCO("vav", MCO.Consonant, H.vav, H.vav, 0 ) ;
+ if(k == (int) 'Z') Characters[k] =
+ new MCO("zayin", MCO.Consonant, H.zayin, H.zayin, 0 ) ;
+ if(k == (int) 'X') Characters[k] =
+ new MCO("het", MCO.Consonant, H.het, H.het, 0 ) ;
+ if(k == (int) '+') Characters[k] =
+ new MCO("tet", MCO.Consonant, H.tet, H.tet, 0 ) ;
+ if(k == (int) 'Y') Characters[k] =
+ new MCO("yod", MCO.Consonant, H.yod, H.yod, 0 ) ;
+ if(k == (int) 'K') Characters[k] =
+ new MCO("kaf", MCO.Consonant, H.kaf, H.finalkaf, 0 ) ;
+ if(k == (int) 'L') Characters[k] =
+ new MCO("lamed", MCO.Consonant, H.lamed, H.lamed, 0 ) ;
+ if(k == (int) 'M') Characters[k] =
+ new MCO("mem", MCO.Consonant, H.mem, H.finalmem, 0 ) ;
+ if(k == (int) 'N') Characters[k] =
+ new MCO("nun", MCO.Consonant, H.nun, H.finalnun, 0 );
+ if(k == (int) 'S') Characters[k] =
+ new MCO("samekh", MCO.Consonant, H.samekh, H.samekh, 0 ) ;
+ if(k == (int) 'P') Characters[k] =
+ new MCO("pe", MCO.Consonant, H.pe, H.finalpe, 0 ) ;
+ if(k == (int) '(') Characters[k] =
+ new MCO("ayin", MCO.Consonant, H.ayin, H.ayin, 0 ) ;
+ if(k == (int) 'C') Characters[k] =
+ new MCO("tsadi", MCO.Consonant, H.tsadi, H.finaltsadi, 0 ) ;
+ if(k == (int) 'Q') Characters[k] =
+ new MCO("qof", MCO.Consonant, H.qof, H.qof, 0 ) ;
+ if(k == (int) 'R') Characters[k] =
+ new MCO("resh", MCO.Consonant, H.resh, H.resh, 0 ) ;
+ if(k == (int) '$'){
+ MCO m = new MCO("shindot", MCO.Mark, H.shindot, H.shindot, 1 ) ;
+ Characters[k] =
+ new MCO("shin", MCO.ConsonantMark, H.shin, H.shin, 0, m) ;
+ }
+ if(k == (int) '&') {
+ MCO m = new MCO("sindot", MCO.Mark, H.sindot, H.sindot, 2 ) ;
+ Characters[k] =
+ new MCO("shin", MCO.ConsonantMark, H.shin, H.shin, 0, m) ;
+ }
+ if(k == (int) '#') Characters[k] =
+ new MCO("shin", MCO.Consonant, H.shin, H.shin, 0 ) ;
+ if(k == (int) 'T') Characters[k] =
+ new MCO("tav", MCO.Consonant, H.tav, H.tav, 0 ) ;
+
+
+// Set the dagesh.
+
+ if(k == (int) '.') Characters[k] =
+ new MCO("dagesh", MCO.Mark, H.dagesh, H.dagesh, 3 ) ;
+
+// Set the rafe.
+
+ if(k == (int) ',') Characters[k] =
+ new MCO("rafe", MCO.Mark, H.rafe, H.rafe, 4 ) ;
+
+// Set the maqaf.
+
+ if(k == (int) '-') Characters[k] =
+ new MCO("maqef", MCO.Punctuation, H.maqaf, H.maqaf, 16 ) ;
+
+// Set the morphological division indicator.
+
+ if(k == (int) '/') Characters[k] =
+ new MCO("morphological divider", MCO.MorphologicalDivision, ' ', ' ', 15 ) ;
+
+// Set the vowels
+
+// : is the hataf indicator
+ if(k == (int) ':') Characters[k] =
+ new MCO("sheva", MCO.Sheva, H.sheva, H.sheva, 7 ) ;
+ if(k == (int) 'O') Characters[k] =
+ new MCO("holam", MCO.Mark, H.holam, H.holam, 5 ) ;
+ if(k == (int) 'I') Characters[k] =
+ new MCO("hiriq", MCO.Mark, H.hiriq, H.hiriq, 7 ) ;
+ if(k == (int) 'U') Characters[k] =
+ new MCO("qubuts", MCO.Mark, H.qubuts, H.qubuts, 7 ) ;
+ if(k == (int) '"') Characters[k] =
+ new MCO("tsere", MCO.Mark, H.tsere, H.tsere, 7 ) ;
+ if(k == (int) 'A') Characters[k] =
+ new MCO("patah", MCO.Vowel, H.patah, H.hatafpatah, 7 ) ;
+ if(k == (int) 'F') Characters[k] =
+ new MCO("qamatz", MCO.Vowel, H.qamats, H.hatafqamats, 7 ) ;
+ if(k == (int) 'E') Characters[k] =
+ new MCO("segol", MCO.Vowel, H.segol, H.hatafsegol, 7 ) ;
+
+// Set the accents as digits in the Characters table.
+
+ if(k == (int) '0') Characters[k] =
+ new MCO("0", MCO.Number, '0', '0', 0 ) ;
+ if(k == (int) '1') Characters[k] =
+ new MCO("1", MCO.Number, '1', '1', 0 ) ;
+ if(k == (int) '2') Characters[k] =
+ new MCO("0", MCO.Number, '2', '2', 0 ) ;
+ if(k == (int) '3') Characters[k] =
+ new MCO("3", MCO.Number, '3', '3', 0 ) ;
+ if(k == (int) '4') Characters[k] =
+ new MCO("4", MCO.Number, '4', '4', 0 ) ;
+ if(k == (int) '5') Characters[k] =
+ new MCO("5", MCO.Number, '5', '5', 0 ) ;
+ if(k == (int) '6') Characters[k] =
+ new MCO("6", MCO.Number, '6', '6', 0 ) ;
+ if(k == (int) '7') Characters[k] =
+ new MCO("7", MCO.Number, '7', '7', 0 ) ;
+ if(k == (int) '8') Characters[k] =
+ new MCO("8", MCO.Number, '8', '8', 0 ) ;
+ if(k == (int) '9') Characters[k] =
+ new MCO("9", MCO.Number, '9', '9', 0 ) ;
+
+// Note
+
+ if(k == (int) ']') Characters[k] =
+ new MCO("Note", MCO.Note, ' ', ' ', 14 ) ;
+
+ }
+
+//-----------------------------------------------------------------------------
+
+// Set the accents (From Grove's supplement.)
+// The same Unicode character may apply to several MCW accent codes.
+
+ Numbers[0] = new MCO("sof pasuq", MCO.Punctuation, H.sofpasuq, H.sofpasuq, 16 ) ;
+ Numbers[1] = new MCO("accentsegol", MCO.Mark, H.accentsegol, H.accentsegol, 11 ) ;
+ Numbers[2] = new MCO("zinor", MCO.Mark, H.zinor, H.zinor, 13 ) ;
+ Numbers[3] = new MCO("pashta", MCO.Mark, H.pashta, H.pashta, 13 ) ;
+ Numbers[4] = new MCO("telishaqetana", MCO.Mark, H.telishaqetana, H.telishaqetana, 13 ) ;
+ Numbers[5] = new MCO("blank+paseq", MCO.Punctuation, " " + H.paseq, " " + H.paseq, 16 ) ;
+
+ Numbers[10] = new MCO("yetiv", MCO.PrepositiveMark, H.yetiv, H.yetiv, 10 ) ;
+ Numbers[13] = new MCO("dehi", MCO.PrepositiveMark, H.dehi, H.dehi, 10 ) ;
+
+ Numbers[11] = new MCO("gereshmuqdam", MCO.PrepositiveMark, H.gereshmuqdam, H.gereshmuqdam, 11 ) ;
+ Numbers[14] = new MCO("telishagedola", MCO.PrepositiveMark, H.telishagedola, H.telishagedola, 11 ) ;
+
+ Numbers[24] = new MCO("telishaqetana", MCO.Mark, H.telishaqetana, H.telishaqetana, 13 ) ;
+ Numbers[33] = new MCO("pashta", MCO.Mark, H.pashta, H.pashta, 13 ) ;
+ Numbers[44] = new MCO("telishagedola", MCO.Mark, H.telishagedola, H.telishagedola, 11 ) ;
+ Numbers[52] = new MCO("lowpunctum", MCO.Mark,'\u0323', '\u0323' , 9 ) ;
+ Numbers[53] = new MCO("highpunctum", MCO.Mark, '\u05c4', '\u05c4', 12 ) ;
+ Numbers[60] = new MCO("ole", MCO.Mark, H.ole, H.ole, 11 ) ;
+ Numbers[61] = new MCO("geresh", MCO.Mark, H.geresh, H.geresh, 11 ) ;
+ Numbers[62] = new MCO("gershayim", MCO.Mark, H.gershayim, H.gershayim, 11 ) ;
+ Numbers[63] = new MCO("qadma", MCO.Mark, H.qadma, H.qadma, 11 ) ;
+ Numbers[64] = new MCO("iluy", MCO.Mark, H.iluy, H.iluy,11 ) ;
+ Numbers[65] = new MCO("shalshelet", MCO.Mark, H.shalshelet, H.shalshelet, 11 ) ;
+ Numbers[80] = new MCO("zaqefqatan", MCO.Mark, H.zaqefqatan, H.zaqefqatan, 11 ) ;
+ Numbers[81] = new MCO("revia", MCO.Mark, H.revia, H.revia, 11 ) ;
+ Numbers[82] = new MCO("zarqa", MCO.Mark, H.zarqa, H.zarqa, 11 ) ;
+ Numbers[83] = new MCO("pazer", MCO.Mark, H.pazer, H.pazer, 11 ) ;
+ Numbers[84] = new MCO("qarneypara", MCO.Mark, H.qarneypara, H.qarneypara, 11 ) ;
+ Numbers[85] = new MCO("zaqefgadol", MCO.Mark, H.zaqefgadol, H.zaqefgadol, 11 ) ;
+ String ZWJMeteg = Character.toString('\u200D')+ Character.toString(H.meteg) ;
+ Numbers[35] = new MCO("centermeteg", MCO.Mark, ZWJMeteg, ZWJMeteg, 8 ) ;
+ Numbers[70] = new MCO("mahapakh", MCO.Mark, H.mahapakh, H.mahapakh, 7 ) ;
+ Numbers[71] = new MCO("merka", MCO.Mark, H.merkha, H.merkha, 7 ) ;
+ Numbers[72] = new MCO("merkhakefula", MCO.Mark, H.merkhakefula, H.merkhakefula, 7 ) ;
+ Numbers[73] = new MCO("tipeha", MCO.Mark, H.tipeha, H.tipeha, 7 ) ;
+ Numbers[74] = new MCO("munah", MCO.Mark, H.munah, H.munah, 7 ) ;
+ Numbers[75] = new MCO("leftmeteg", MCO.Mark, H.meteg, H.meteg, 8 ) ;
+ Numbers[91] = new MCO("tevir", MCO.Mark, H.tevir, H.tevir, 7 ) ;
+ Numbers[92] = new MCO("etnachta", MCO.Mark, H.etnachta, H.etnachta, 7 ) ;
+ Numbers[93] = new MCO("yerahbenyomo", MCO.Mark, H.yerahbenyomo, H.yerahbenyomo, 7 ) ;
+ Numbers[94] = new MCO("darga", MCO.Mark, H.darga, H.darga, 7 ) ;
+ Numbers[95] = new MCO("rightmeteg", MCO.Mark, H.meteg, H.meteg, 6 ) ;
+//-----------------------------------------------------------------------------
+
+// Place the Characters results into the UnicodeChars array.
+
+ UnicodeChar.setUnicodeChars(Characters, Numbers) ;
+ }
+//-----------------------------------------------------------------------------
+/**
+* Returns an MCO from a character.
+*
+*/
+public static MCO getMCO(char c){
+ int k = (int) c ;
+ return Characters[k] ;
+ }
+//-----------------------------------------------------------------------------
+/**
+* Returns an MCO from an integer.
+*
+*/
+public static MCO getMCO(int k){
+ return Numbers[k] ;
+ }
+//-----------------------------------------------------------------------------
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/MCO.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/MCO.java new file mode 100644 index 0000000..79643b0 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/MCO.java @@ -0,0 +1,108 @@ +package WLC2OSIS.Translate ;
+
+//==============================================================================
+/**
+ * <b>Object representing characters with Name, Type, Group, and Unicode Hebrew
+ * initial and final values.</b><p>
+ */
+//==============================================================================
+public class MCO implements Cloneable{
+
+
+// Definition of MCO
+
+/** Name of this object */
+public String Name = "" ;
+/** Type of character, an integer. */
+public int Type = 0 ;
+/** Type of the object, changes during processing. */
+public String Value = "" ;
+/** The a final value Unicode character corresponding to the MC character
+ * at this position in the CharValue[] CharValues. */
+public String FinalValue = "" ;
+/** Order group */
+public int Group = 0 ;
+/** Included MCO used for ConsonantMark Type only.*/
+public MCO Object = null ;
+
+// Definition of Types
+
+/** No known MC character correponds to this index. */
+public static final int Unknown = 0 ;
+/** MC character correponding to this index is a Consonant. */
+public static final int Consonant = 1 ;
+/** MC character correponding to this index is a Vowel. */
+public static final int Vowel = 2 ;
+/** MC character correponding to this index is a Mark */
+public static final int Mark = 3 ;
+/** MC character correponding to this index is a MorphologicalDivision */
+public static final int MorphologicalDivision = 4 ;
+/** MC character correponding to this index is a Punctuation */
+public static final int Punctuation = 5 ;
+
+// The following types > 5 require expansion or re-ordering
+
+/** MC character correponding to this index is a PrepositiveMark */
+public static final int PrepositiveMark = 6 ;
+/** MC character correponding to this index is a ConsonantMark */
+public static final int ConsonantMark = 7;
+/** MC character correponding to this index is a Number */
+public static final int Number = 8;
+/** MC character correponding to this index is a Sheva */
+public static final int Sheva = 9 ;
+/** MC character correponding to this index is a Note */
+public static final int Note = 10 ;
+
+//-----------------------------------------------------------------------------
+/**
+ * Generate from full specification.
+ */
+public MCO( String Name, int Type, String Value, String FinalValue, int Group ) {
+ this.Name = Name ;
+ this.Type = Type ;
+ this.Value = Value ;
+ this.FinalValue = FinalValue ;
+ this.Group = Group ;
+ this.Object = Object ;
+ }
+//-----------------------------------------------------------------------------
+/**
+ * Generate from Value, FinalValue as char with Object.
+ */
+public MCO( String Name, int Type, char Value, char FinalValue, int Group,
+ MCO Object ) {
+ this.Name = Name ;
+ this.Type = Type ;
+ this.Value = Character.toString(Value) ;
+ this.FinalValue = Character.toString(FinalValue) ;
+ this.Group = Group ;
+ this.Object = Object ;
+ }
+//-----------------------------------------------------------------------------
+/**
+ * Generate from Value, FinalValue as char without Object.
+ */
+public MCO( String Name, int Type, char Value, char FinalValue, int Group ) {
+ this.Name = Name ;
+ this.Type = Type ;
+ this.Value = Character.toString(Value) ;
+ this.FinalValue = Character.toString(FinalValue) ;
+ this.Group = Group ;
+ this.Object = null ;
+ }
+//-----------------------------------------------------------------------------
+
+public void print(){
+ System.out.print(Name + " + ") ;
+ }
+//-----------------------------------------------------------------------------
+
+public Object clone(){
+ MCO M = new MCO( Name, Type, Value, FinalValue, Group ) ;
+ M.Object = Object ;
+ return M ;
+ }
+//-----------------------------------------------------------------------------
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/Note.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/Note.java new file mode 100644 index 0000000..c42998d --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/Note.java @@ -0,0 +1,78 @@ +package WLC2OSIS.Translate ;
+
+import WLC2OSIS.Utilities.* ;
+
+import java.util.Vector ;
+
+//==============================================================================
+/**
+ * <b>MC notes.</b><p>
+ */
+//==============================================================================
+public class Note{
+
+String Code ;
+String Note ;
+
+static Vector Notes = new Vector() ;
+
+Note(String Code, String Note){
+ this.Code = Code ;
+ this.Note = Note ;
+ }
+//-----------------------------------------------------------------------------
+
+// Writes the Notes to the XML file.
+
+public static void writeNotes(XMLWriter w) {
+ setNotes() ;
+ w.openTag("notes", 0) ;
+ for (int k=0; k < Notes.size() ; k++){
+ Note n = (Note) Notes.elementAt(k) ;
+ w.openTag("note", 1) ;
+ w.writeString("code", 2, n.Code ) ;
+ w.writeString("note", 2, n.Note ) ;
+ w.closeTag("note", 1) ;
+ }
+ w.closeTag("notes", 0) ;
+ }
+//-----------------------------------------------------------------------------
+
+// Writes the Notes to the XML file.
+
+static void setNotes() {
+
+// Do this only once!
+
+ if(Notes.size() > 1) return ;
+ Notes.add(new Note("1", "BHS has been faithful to the Leningrad Codex where "
+ + "\nthere might be a question of the validity of the form "
+ + "\nand we keep the same form as BHS.")) ;
+ Notes.add(new Note("2", "We have added a sop pasuq where L and BHC omit it."
+ + "\n(The added sof pasuq often is missing from the text.)" )) ;
+ Notes.add(new Note("3", "We read or understand L differently than BHC (1983 Edition). "
+ + "\nOften this notation indicates a typographical error in BHS.")) ;
+ Notes.add(new Note("4", "Puncta Extraordaria -- "
+ + "\na \\u05c4 is used to mark such marks in the text"
+ + "\nwhen they are above the line and"
+ + "\na \\u0323 when they are below the line."));
+ Notes.add(new Note("5", "Large letter(s).")) ;
+ Notes.add(new Note("6", "Small letter(s).")) ;
+ Notes.add(new Note("7", "Suspended letter(s).")) ;
+ Notes.add(new Note("8", "Inverted nun in the text.")) ;
+ Notes.add(new Note("9", "BHS has abandoned L and we concur. "
+ + "\nAll of these occurrences are ketib/qere problems.")) ;
+ Notes.add(new Note("a", "Adaptations to a Qere which L and BHS, by their design, "
+ + "do not indicate.")) ;
+ Notes.add(new Note("m", "Miscellaneous notes to the text and occasions "
+ + "\nwhere more than one bracket category applies.")) ;
+ Notes.add(new Note("q", "We have abandoned or added a ketib/qere relative to BHS. "
+ + "\nIn doing this we agree with L against BHS.")) ;
+ Notes.add(new Note("y", "Yathir readings in L which we have designated as Qeres "
+ + "\nwhen both Dothan and BHS list a Qere.")) ;
+ }
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/Translate.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/Translate.java new file mode 100644 index 0000000..c0400a4 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/Translate.java @@ -0,0 +1,349 @@ +package WLC2OSIS.Translate ;
+
+import WLC2OSIS.* ;
+import WLC2OSIS.Parse.* ;
+import WLC2OSIS.Utilities.* ;
+import Utilities.* ;
+
+import java.io.* ;
+import java.util.Vector ;
+//==============================================================================
+/**
+ * <b>Critical translation of KQ-free MC words into Unicode characters.</b><p>
+ */
+//==============================================================================
+public class Translate{
+
+Parser P ;
+WLC2OSIS A ;
+
+MCO M ;
+MCO Mark ;
+Vector MCOs, OrderedMCOs ;
+int Type, I, k1, len ;
+int[] ConsonantPositions = new int[100] ;
+char c, c1 ;
+//-----------------------------------------------------------------------------
+
+public Translate(WLC2OSIS A, Parser P) {
+ this.A = A ;
+ this.P = P ;
+ }
+//------------------------------------------------------------------------------
+
+// Translates an MC word (not qere or ketib) to a Unicode String.
+// Notes are included as <x>n</x>.
+
+public String translate(String W){
+ len = W.length() ;
+
+// Convert characters in String to MCO objects, expanding
+// ConsonantMarks, Numbers, and Notes as necessary.
+// Move PrepositiveMarks to after their consonants.
+
+ MCOs = new Vector() ;
+ for (int k = 0; k < len; k++) {
+ c = W.charAt(k) ;
+
+
+ M = (MCO) (MC.getMCO(c)).clone() ;
+ Type = M.Type ;
+
+// Unknown
+ if(Type == MCO.Unknown){
+ message("MC: MC Object is of type Unknown."
+ + "\nWord: " + W
+ + "\nCharacter: " + c
+ + "\n " ) ;
+ }
+ else if(Type <= 5){ // These types need no expansion.
+ MCOs.add(M) ;
+ }
+ else if(Type == MCO.Sheva ){
+// Might be a Hatef Vowel
+ k1 = k + 1 ;
+ if(k1 < len){
+ c1 = W.charAt(k1) ;
+ Mark = (MCO) (MC.getMCO(c1)).clone() ;
+ if (Mark.Type == MCO.Vowel){
+// It is a Hatef vowel
+ MCO Hatef = new MCO("hataf"+Mark.Name, MCO.Vowel,
+ Mark.FinalValue, Mark.FinalValue, Mark.Group) ;
+ MCOs.add(Hatef) ;
+ k++ ;
+ }
+// Not a Hatef Vowel
+ else{
+ MCOs.add(M) ;
+ }
+ }
+// Could only be a Sheva
+ else{
+ MCOs.add(M) ;
+ }
+ }
+ else if(Type == MCO.ConsonantMark){
+ Mark = (MCO) (M.Object).clone() ;
+ M.Type = MCO.Consonant ;
+ MCOs.add(M) ;
+ MCOs.add(Mark) ;
+ }
+//-----------------------------------------------------------------------------
+ else if(Type == MCO.Number){
+ k++ ;
+ String StringInt = "" ;
+ StringInt = StringInt + c ;
+ StringInt = StringInt + W.charAt(k) ;
+
+ I = new Integer(StringInt).intValue() ;
+ if ((I > 99) | (I < 0) ){
+ message("MC: Reconstructed int is out of range."
+ + "\nWord: " + W
+ + "\nCharacters: " + c + W.charAt(k)
+ + "\nint: " + I ) ;
+ }
+ else{
+// Found a Mark of some sort
+ MCO Found = MC.getMCO(I) ;
+
+ if(Found.Type == MCO.PrepositiveMark){
+// System.out.println("***** Found a prepositive mark. " + I) ;
+ k++ ;
+ c1 = W.charAt(k) ;
+ M = (MCO) (MC.getMCO(c1)).clone() ;
+ if( M.Type == MCO.Consonant | M.Type == MCO.ConsonantMark ){
+ // System.out.println("Swapping prepositive mark and consonant.") ;
+ MCOs.add(M) ;
+ MCOs.add(Found) ;
+ }
+ else{
+ System.out.println("MC: PrepositiveMark not followed by a Consonant."
+ + "\nWord: " + W + "\nType: " + M.Type ) ;
+ MCOs.add(M) ;
+ System.exit(0) ;
+ }
+ }
+ else{
+ MCOs.add(MC.getMCO(I)) ;
+ }
+ }
+ }
+//-----------------------------------------------------------------------------
+
+ else if(Type == MCO.Note){
+ k++ ;
+ c1 = W.charAt(k) ;
+// Check for an inverted nun. Assumes the note immediately follows a nun.
+ if (c1=='8'){
+ MCO Mtemp = (MCO) MCOs.lastElement() ;
+ if( (Mtemp.Name).compareTo("nun") == 0) {
+ String in = H.Invertednun ;
+ Mtemp.Name = "invertednun" ;
+ Mtemp.Value = in ;
+ Mtemp.FinalValue = in ;
+// The masoranumberdot fails to work in IE. Ezra SIL already provides a dot.
+// Providing no accent.
+// MCO ud = (MCO) (MC.getMCO(81)).clone() ; // revia 81, masora 96
+// MCOs.add(ud) ;
+ }
+ else{
+ System.out.println("Prior MCO isn't a nun!") ;
+ }
+ }
+// Leave a note
+ M.Value = Character.toString(c1) ;
+ MCOs.add(M) ;
+ }
+ else{
+ System.out.println("MC: Unknown type for an MCO Object.") ;
+ }
+ }
+//-----------------------------------------------------------------------------
+
+// At this point the Consonants are where they should be.
+// Locating the consonants and FinalConsonants.
+
+// An incoming word a final consonant before a maqaf
+// as well as at the end .
+
+ int LastConsonant = -1 ;
+ int ConsonantIndex = 0 ;
+ int ConsonantCount = 0 ;
+ for (int k = 0; k < MCOs.size(); k++){
+ M = (MCO) MCOs.elementAt(k) ;
+ if( M.Type == MCO.Consonant ){
+ ConsonantPositions[ConsonantIndex] = k ;
+ LastConsonant = k ;
+ ConsonantIndex++ ;
+ ConsonantCount++ ;
+ }
+// Look for a Maqef, if found, set the LastConsonant final.
+ if( (M.Name).compareTo("maqef") == 0){
+ setFinal(LastConsonant) ;
+ }
+ }
+// System.out.println("ObjectCount: " + MCOs.size() ) ;
+// System.out.println("ConsonantCount: " + ConsonantCount) ;
+// System.out.println("LastConsonant: " + LastConsonant) ;
+
+// for (int k = 0; k < ConsonantCount; k++){
+// System.out.println("ConsonantPositions[" + k + "]: " + ConsonantPositions[k]) ;
+// }
+//-----------------------------------------------------------------------------
+
+ if (ConsonantCount > 0){
+
+// Set the final consonant, if any.
+
+ setFinal(LastConsonant) ;
+
+// print(MCOs) ;
+
+//-----------------------------------------------------------------------------
+
+// Order the MCOs
+
+ OrderedMCOs = new Vector() ;
+ int Limit = 0 ;
+ for( int ConsonantNumber = 0; ConsonantNumber < ConsonantCount; ConsonantNumber++) {
+ if (ConsonantNumber+1 == ConsonantCount){
+ Limit = MCOs.size() ;
+ }
+ else{
+ Limit = ConsonantPositions[ConsonantNumber+1] ;
+ }
+ Order(MCOs, ConsonantPositions[ConsonantNumber], Limit, OrderedMCOs ) ;
+
+ }
+
+ }
+ else{
+ OrderedMCOs = MCOs ;
+ }
+
+
+// print(OrderedMCOs) ;
+
+//-----------------------------------------------------------------------------
+
+// Output the ordered Vector
+
+ String S = "" ;
+ for (int k = 0; k < OrderedMCOs.size(); k++){
+ M = (MCO) OrderedMCOs.elementAt(k) ;
+ Type = M.Type ;
+// Only Notes require special treatment
+ if (Type == MCO.Note){
+ S = S + "<x>" + M.Value + "</x>" ;
+ }
+ else if ((Type == MCO.MorphologicalDivision)){
+ S = S + A.MorphologicalDivisionMarker ;
+ }
+ else{
+ S = S + M.Value ;
+// System.out.println(Integer.toString( (int) M.Value.charAt(0), 16)) ;
+ }
+ }
+
+ return S ;
+ }
+//-----------------------------------------------------------------------------
+
+// Order the Marks following a Consonant.
+
+void Order( Vector MCOs, int StartIndex, int Limit, Vector OrderedMCOs) {
+ MCO m ;
+
+// Check for no Marks
+ if(StartIndex+1==Limit){
+ m = (MCO) MCOs.elementAt(StartIndex) ;
+ OrderedMCOs.add(m) ;
+ return ;
+ }
+// Check for one Mark
+ if(StartIndex+2==Limit){
+ m = (MCO) MCOs.elementAt(StartIndex) ;
+ OrderedMCOs.add(m) ;
+ m = (MCO) MCOs.elementAt(StartIndex+1) ;
+ OrderedMCOs.add(m) ;
+ return ;
+ }
+
+// Two or more Marks
+
+// Save the Consonant
+ m = (MCO) MCOs.elementAt(StartIndex) ;
+ OrderedMCOs.add(m) ;
+
+// Order the marks
+ int MarkCount = (Limit-StartIndex)-1 ;
+ boolean[] Written = new boolean[MarkCount] ;
+ for (int k =0; k < MarkCount; k++){
+ Written[k] = false ;
+ }
+
+ int WrittenCount = 0 ;
+ do{
+// Find the MCO with the smallest possible Group value and write it.
+ int GroupTest = 1000 ;
+ int MCOMin = -1 ;
+ for( int k = StartIndex+1; k < Limit; k++){
+ if(!Written[ k -(StartIndex+1) ]){
+ m = (MCO) MCOs.elementAt(k) ;
+ int g = m.Group ;
+ if ( g < GroupTest ){
+ GroupTest = g ;
+ MCOMin = k ;
+ }
+ }
+ }
+ m = (MCO) MCOs.elementAt(MCOMin) ;
+ OrderedMCOs.add(m) ;
+ Written[MCOMin -(StartIndex+1) ] = true ;
+ WrittenCount++ ;
+ }while(WrittenCount < MarkCount) ;
+
+ }
+//-----------------------------------------------------------------------------
+
+// Output a message plus position.
+
+public void message(String m){
+ System.out.print(m) ;
+ P.printPosition() ;
+ }
+//-----------------------------------------------------------------------------
+
+// Output a message plus position.
+
+public void print(Vector v){
+ System.out.println("\n") ;
+ for (int k = 0; k < v.size(); k++){
+ MCO m = (MCO) v.elementAt(k) ;
+ m.print() ;
+ }
+ System.out.println("\n") ;
+ }
+//-----------------------------------------------------------------------------
+
+// Set a consonant as final.
+
+public void setFinal(int Position){
+// Do nothing if there's no Position to set
+ if (Position < 0) return ;
+
+ M = (MCO) MCOs.elementAt(Position) ;
+ if (M.Type == MCO.Consonant){
+ MCO Final = new MCO("final" + M.Name, MCO.Consonant, M.FinalValue, M.FinalValue,
+ M.Group) ;
+ MCOs.setElementAt(Final, Position) ;
+ }
+ else{
+ message("LastConsonant is not a consonant!") ;
+ }
+ return ;
+ }
+//-----------------------------------------------------------------------------
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/UnicodeChar.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/UnicodeChar.java new file mode 100644 index 0000000..aac1eb1 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/UnicodeChar.java @@ -0,0 +1,391 @@ +package WLC2OSIS.Translate ;
+
+import WLC2OSIS.* ;
+import WLC2OSIS.Utilities.* ;
+//==============================================================================
+/**
+ * <b>Object describing Unicode Hebrew characters and their relation
+ * to the MC characters.</b><p>
+ *
+ * The static array UnicodeChars describes Hebrew Unicode characters
+ * and gives their relationship to the MCW letter code.
+ */
+//==============================================================================
+public class UnicodeChar{
+/** Starting index for block of Hebrew Unicode characters.*/
+public static final int UnicodeStart = 0x00000590 ;
+/** Ending index for block of Hebrew Unicode characters.*/
+public static final int UnicodeEnd = 0x00000600 ;
+/** Size of block of Hebrew Unicode characters.*/
+public static final int N = (UnicodeEnd - UnicodeStart) ;
+
+// Object contents
+
+/** Unicode name WITHOUT the word HEBREW or its type.
+ * Capital followed by lower case.
+ */
+public String Name = "" ; // Unicode name WITHOUT the word HEBREW or
+ // its type. Capital followed by lower case.
+/** Unicode type: Accent, Point, Punctuation, Letter, or Ligature. */
+public String Type = " " ;
+ /** Unicode character value. */
+public char Value= ' ' ; // Unicode character value.
+/** List of equivalent characters represented by this Unicode character.*/
+public String Equivalents = "" ; // List of equivalents
+/** Notes provided by the Unicode group.*/
+public String Notes = "" ; // Additional notes.
+/** MCW characters corresponding to this Unicode character.*/
+public String MCCode = "" ;
+/** Combining group value. */
+public String Group = "" ;
+
+/** Array of all Hebrew Unicode characters, 0...N. */
+public static UnicodeChar[] UnicodeChars = new UnicodeChar[N] ;
+/** Number of special Unicode characters */
+public static final int Special = 6;
+/** Array of special, non-Hebrew characters */
+public static UnicodeChar[] SpecialChars = new UnicodeChar[Special] ;
+
+//-----------------------------------------------------------------------------
+/**
+ * Creates a UnicodeChar object from the given arguments.
+ */
+UnicodeChar( char Value, String Name, String Type, String Equivalents, String Notes){
+ this.Value = Value ;
+ this.Name = Name ;
+ this.Type = Type ;
+ this.Equivalents = Equivalents ;
+ this.Notes = Notes ;
+ }
+//-----------------------------------------------------------------------------
+/**
+ * Sets the array of UnicodeChar[], UnicodeChars, from the
+ * Characters array.
+ *
+ * @param Characters MCO[] array of MCO object whose
+ * index is the value of the corresponding MCW character.
+ */
+public static void setUnicodeChars( MCO[] Characters, MCO[] Numbers ) {
+
+ for (char k =0; k < N; k++){
+ UnicodeChars[k] = new UnicodeChar( '?', "Undefined", "Unspecified", " " , " ") ;
+ }
+ for (char k =0; k < Special; k++){
+ SpecialChars[k] = new UnicodeChar( '?', "Undefined", "Unspecified", " " , " ") ;
+ }
+
+// Verify the H assignment and enter into table
+
+ enterChar(0x0591, H.etnachta, "Etnachta", "Accent") ;
+ enterChar(0x0592, H.accentsegol, "Segol", "Accent" ) ;
+ enterChar(0x0593, H.shalshelet,"Shalshelet", "Accent" ) ;
+ enterChar(0x0594, H.zaqefqatan, "Zaqef Qatan", "Accent" ) ;
+ enterChar(0x0595, H.zaqefgadol, "Zaqef Gadol", "Accent" ) ;
+ enterChar(0x0596, H.tipeha, "Tipeha", "Accent", "Tarha", " " ) ;
+ enterChar(0x0597, H.revia, "Revia", "Accent" ) ;
+ enterChar(0x0598, H.zarqa, "Zarqa", "Accent",
+ "Tsinorit, Zinorit, Tsinor, Zinor",
+ "This character is to be used when Zarqa or Tsinor are placed above, and also for Tsinorit."
+ ) ;
+ enterChar(0x0599, H.pashta, "Pashta", "Accent" ) ;
+ enterChar(0x059a, H.yetiv, "Yetiv", "Accent" ) ;
+ enterChar(0x059b, H.tevir, "Tevir", "Accent" ) ;
+ enterChar(0x059c, H.geresh, "Geresh", "Accent" ) ;
+ enterChar(0x059d, H.gereshmuqdam, "Geresh Muqdam", "Accent" ) ;
+ enterChar(0x059e, H.gershayim, "Gereshayim", "Accent" ) ;
+ enterChar(0x059f, H.qarneypara, "Qarney Para", "Accent" ) ;
+ enterChar(0x05a0, H.telishagedola, "Telisha Gedola", "Accent") ;
+ enterChar(0x05a1, H.pazer, "Pazer", "Accent" ) ;
+ enterChar(0x05a3, H.munah, "Munah", "Accent" ) ;
+ enterChar(0x05a4, H.mahapakh, "Mahapakh", "Accent" ) ;
+ enterChar(0x05a5, H.merkha, "Merkha", "Accent",
+ "Yored", " ") ;
+ enterChar(0x05a6, H.merkhakefula, "Merkha Kefula", "Accent") ;
+ enterChar(0x05a7, H.darga, "Darga", "Accent") ;
+ enterChar(0x05a8, H.qadma, "Qadma", "Accent" ) ;
+ enterChar(0x05a9, H.telishaqetana, "Telisha Qetana", "Accent" ) ;
+ enterChar(0x05aa, H.yerahbenyomo, "Yerah Ben Yomo", "Accent",
+ "Galgal", " " ) ;
+ enterChar(0x05ab, H.ole, "Ole", "Accent" ) ;
+ enterChar(0x05ac, H.iluy, "Iluy", "Accent" ) ;
+ enterChar(0x05ad, H.dehi, "Dehi", "Accent" ) ;
+ enterChar(0x05ae, H.zinor, "Zinor", "Accent",
+ "Tsinor, Zarqa",
+ "This character is to be used when Zarqa or Tsinor are placed above left." ) ;
+ enterChar(0x05af, H.masoracircle, "Masora Circle", "Mark" ) ;
+ enterMCCodeAndGroup(0x05af, "Not used", "12") ;
+ enterChar(0x05b0, H.sheva, "Sheva", "Point") ;
+ enterChar(0x05b1, H.hatafsegol, "Hataf Segol", "Point" ) ;
+ enterChar(0x05b2, H.hatafpatah, "Hataf Patah", "Point" ) ;
+ enterChar(0x05b3, H.hatafqamats, "Hataf Qamats", "Point" ) ;
+ enterChar(0x05b4, H.hiriq, "Hiriq", "Point" ) ;
+ enterChar(0x05b5, H.tsere, "Tsere", "Point" ) ;
+ enterChar(0x05b6, H.segol, "Segol", "Point" ) ;
+ enterChar(0x05b7, H.patah, "Patah", "Point",
+ " ",
+ "Furtive patah is not a distinct character.") ;
+ enterChar(0x05b8, H.qamats, "Qamats", "Point" ) ;
+ enterChar(0x05b9, H.holam, "Holam", "Point") ;
+ enterChar(0x05bb, H.qubuts, "Qubuts", "Point" ) ;
+ enterChar(0x05bc, H.dagesh, "Dagesh", "Point",
+ "Mapiq, Shuriq", "Falls within base letter." ) ;
+ enterChar(0x05bd, H.meteg, "Meteg", "Point",
+ "Siluq",
+ "Maybe used as a Hebrew accent sof pasuq."
+ + "Left (75), center (35), and right (95) metegs are separately grouped"
+ + " to produce correct positioning."
+ + " The center meteg is preceded by a ZWJ, u200D, for positioning." ) ;
+ enterChar(0x05be, H.maqaf, "Maqaf", "Point") ;
+ enterChar(0x05bf, H.rafe, "Rafe", "Point" ) ;
+ enterChar(0x05c0, H.paseq, "Paseq", "Punctuation",
+ "Legarmeh",
+ "May be treated as spacing punctuation, not as a point. "
+ + "Each Paseq is preceded by a Space, \\u0020, for positioning." ) ;
+ enterChar(0x05c1, H.shindot, "Shin Dot", "Point") ;
+ enterChar(0x05c2, H.sindot, "Sin Dot", "Point" ) ;
+ enterChar(0x05c3, H.sofpasuq, "Sof Pasuq", "Point",
+ " ", "May be used as a Hebrew punctuation colon.") ;
+ enterChar(0x05c4, H.upperdot, "Upper Dot", "Mark" ) ;
+
+ enterChar(0x05d0, H.alef, "Alef", "Letter" , "Aleph", " ") ;
+ enterChar(0x05d1, H.bet, "Bet", "Letter" ) ;
+ enterChar(0x05d2, H.gimel, "Gimel", "Letter" ) ;
+ enterChar(0x05d3, H.dalet, "Dalet", "Letter" ) ;
+ enterChar(0x05d4, H.he, "He", "Letter" ) ;
+ enterChar(0x05d5, H.vav, "Vav", "Letter" ) ;
+ enterChar(0x05d6, H.zayin, "Zayin", "Letter" ) ;
+ enterChar(0x05d7, H.het, "Het", "Letter" ) ;
+ enterChar(0x05d8, H.tet, "Tet", "Letter" ) ;
+ enterChar(0x05d9, H.yod, "Yod", "Letter" ) ;
+ enterChar(0x05da, H.finalkaf, "Final Kaf", "Letter" ) ;
+ enterChar(0x05db, H.kaf, "Kaf", "Letter" ) ;
+ enterChar(0x05dc, H.lamed, "Lamed", "Letter" ) ;
+ enterChar(0x05dd, H.finalmem, "Final Mem", "Letter" ) ;
+ enterChar(0x05de, H.mem, "Mem", "Letter" ) ;
+ enterChar(0x05df, H.finalnun, "Final Nun", "Letter" ) ;
+ enterChar(0x05e0, H.nun, "Nun", "Letter" ) ;
+ enterChar(0x05e1, H.samekh, "Samekh", "Letter" ) ;
+ enterChar(0x05e2, H.ayin, "Ayin", "Letter" ) ;
+ enterChar(0x05e3, H.finalpe, "Final Pe", "Letter" ) ;
+ enterChar(0x05e4, H.pe, "Pe", "Letter" ) ;
+ enterChar(0x05e5, H.finaltsadi, "Final Tsadi", "Letter") ;
+ enterChar(0x05e6, H.tsadi, "Tsadi", "Letter") ;
+ enterChar(0x05e7, H.qof, "Qof", "Letter" ) ;
+ enterChar(0x05e8, H.resh, "Resh", "Letter" ) ;
+ enterChar(0x05e9, H.shin, "Shin", "Letter" ) ;
+ enterChar(0x05ea, H.tav, "Tav", "Letter" ) ;
+
+// enterChar(0x05f0, H.doublevav, "Yiddish Double Vav", "Ligature" ) ;
+// enterChar(0x05f1, H.vavyod, "Yiddish Vav Yod", "Ligature" ) ;
+// enterChar(0x05f2, H.doubleyod, "Yiddish Double Yod", "Ligature" ) ;
+
+// enterChar(0x05f3, H.punctgeresh, "Geresh", "Punctuation",
+// " ", "Punctuation, not an accent.") ;
+// enterChar(0x05f4, H.punctgershayim, "Gershayim", "Punctuation",
+// " ", "Punctuation, not an accent.") ;
+
+//-----------------------------------------------------------------------------
+
+// Set the MCO[] Characters into the UnicodeChar array.
+
+ for(int k=0; k < 128; k++){
+ MCO m = Characters[k];
+ if(m.Type!=MCO.Unknown){
+ char test = (m.Value).charAt(0) ;
+// Try to find the Value in the UnicodeChars array,
+ boolean FoundValue = false;
+ int j ;
+ for (j = 0; j < N; j++){
+ if(test == UnicodeChars[j].Value ){
+ FoundValue = true ;
+ break ;
+ }
+ }
+ if(FoundValue){
+ if((char)k=='&'){
+ }
+ else{
+ UnicodeChars[j].MCCode = new Character((char)k).toString() ;
+ UnicodeChars[j].Group = new Integer(m.Group).toString() ;
+ }
+ }
+// Try to find it as a final character
+ test = (m.FinalValue).charAt(0) ;
+ FoundValue = false ;
+ for (j = 0; j < N; j++){
+ if(test == UnicodeChars[j].Value ){
+ FoundValue = true ;
+ break ;
+ }
+ }
+ if(FoundValue){
+ if((char)k=='&'){
+ }
+ else{
+ UnicodeChars[j].MCCode = new Character((char)k).toString() ;
+ UnicodeChars[j].Group = new Integer(m.Group).toString() ;
+ }
+ }
+ }
+ }
+//-----------------------------------------------------------------------------
+
+// Set the MCO[] Numbers into the UnicodeChar array.
+
+ for(int k=0; k < 100; k++){
+ MCO m = Numbers[k];
+ if(m.Type!=MCO.Unknown){
+ char test = (m.Value).charAt(0) ;
+// Try to find the Value in the UnicodeChars array,
+ boolean FoundValue = false;
+ int j ;
+ for (j = 0; j < N; j++){
+ if(test == UnicodeChars[j].Value ){
+ FoundValue = true ;
+ break ;
+ }
+ }
+ if(FoundValue){
+ if (UnicodeChars[j].MCCode.compareTo("") == 0){
+ UnicodeChars[j].MCCode = new Integer(k).toString() ;
+ }
+ else{
+ UnicodeChars[j].MCCode = UnicodeChars[j].MCCode
+ + ", " + new Integer(k).toString() ;
+ }
+ UnicodeChars[j].Group = new Integer(m.Group).toString() ;
+ }
+ }
+ }
+// Special characters
+
+ enterMCCodeAndGroup(0x05bd, "35, 75, 95", "8, 8, 6") ;
+ enterMCCodeAndGroup(0x05c0, "5", "16") ;
+ enterMCCodeAndGroup(0x05c1, "Not used", "1") ;
+ enterMCCodeAndGroup(0x05c2, "Not used", "2") ;
+ UnicodeChars[33].MCCode = ":E" ;
+ UnicodeChars[33].Group = "7" ;
+ UnicodeChars[34].MCCode = ":A" ;
+ UnicodeChars[34].Group = "7" ;
+ UnicodeChars[35].MCCode = ":F" ;
+ UnicodeChars[35].Group = "7" ;
+ UnicodeChars[89].MCCode = "&, $" ;
+ UnicodeChars[89].Group = "0" ;
+
+//----------------------------------------------------------------------------
+
+// Special, non-Hebrew characters
+
+ SpecialChars[0] = new UnicodeChar( '\u0020', "Space",
+ "Space" , " ", "Paseq is a Space + Paseq.") ;
+ SpecialChars[0].Group = " " ;
+ SpecialChars[0].MCCode = "Not used";
+
+ SpecialChars[1] = new UnicodeChar( '/', "Slash",
+ "Morphological divider." , " ", "Morphological divider." ) ;
+ SpecialChars[1].Group = " " ;
+ SpecialChars[1].MCCode = "/";
+
+ SpecialChars[2] = new UnicodeChar( '\u0307', "Masora or Number dot",
+ "PrepositiveMark" , " ", "Upper punctum. MC code 53, is translated "
+ + "as an Upper Dot, \\u05c4, not as this character. "
+ + "This mark is not currently positioned properly by Internet Explorer.") ;
+ SpecialChars[2].Group = "12" ;
+ SpecialChars[2].MCCode = "(53)";
+
+ SpecialChars[3] = new UnicodeChar( '\u0323', "Combining dot below",
+ "PrepositiveMark" , " ", "Lower punctum. "
+ + "This mark is not currently positioned properly by Internet Explorer.") ;
+ SpecialChars[3].Group = "12" ;
+ SpecialChars[3].MCCode = "52";
+
+ SpecialChars[4] = new UnicodeChar( '\u200D', "Zero width joiner (ZWJ)",
+ "General punct." , " ", "Center meteg is a ZWJ + meteg.") ;
+ SpecialChars[4].Group = " " ;
+ SpecialChars[4].MCCode = "Not used";
+
+ SpecialChars[5] = new UnicodeChar( '\uf300', "Inverted nun",
+ "General punct." , " ", "Not part of the current Unicode standard. "
+ + "Displays acceptably in either SBL Hebrew or Ezra SIL fonts.") ;
+ SpecialChars[5].Group = " " ;
+ SpecialChars[5].MCCode = "Not used";
+
+
+//-----------------------------------------------------------------------------
+ return ;
+ }
+//-----------------------------------------------------------------------------
+/**
+* Enters a Unicode character into the array UnicodeChars.
+*/
+static void enterChar(int value, char c, String Name, String Type,
+ String Equivalents, String Notes) {
+ if ( c != (char) value ){
+ System.out.println("UnicodeChars: Error in character table!") ;
+ System.out.println("Character: " + c + " Value: " + value ) ;
+ }
+ UnicodeChars[value-UnicodeStart]
+ = new UnicodeChar( (char)value, Name, Type, Equivalents, Notes) ;
+ }
+//-----------------------------------------------------------------------------
+/**
+* Enters a Unicode character into the array UnicodeChars.
+*/
+static void enterChar(int value, char c, String Name, String Type) {
+ if ( c != (char) value ){
+ System.out.println("UnicodeChars: Error in character table!") ;
+ System.out.println("Character: " + c + " Value: " + value ) ;
+ }
+ UnicodeChars[value-UnicodeStart]
+ = new UnicodeChar( (char)value, Name, Type, "", "") ;
+ }
+//-----------------------------------------------------------------------------
+/**
+* Enters the MCCode and Group number for a UnicodeChar.
+*/
+static void enterMCCodeAndGroup(int k, String MCCode, String Group ){
+ UnicodeChars[k-UnicodeStart].MCCode = MCCode ;
+ UnicodeChars[k-UnicodeStart].Group = Group ;
+ }
+//-----------------------------------------------------------------------------
+
+// Writes the Unicode characters as an XML file.
+
+// ** This belongs in UnicodeChars ***
+
+public static void writeUnicodeChars(XMLWriter w) {
+ w.openTag("coding", 0) ;
+ for (int k=0; k < N ; k++){
+ int i = (int) UnicodeChars[k].Value ;
+ String h = Integer.toHexString(i) ;
+ w.openTag("char", 1) ;
+ w.writeString("value", 2, new Character(UnicodeChars[k].Value).toString() ) ;
+ w.writeString("hexvalue", 2, h ) ;
+ w.writeString("name", 2, UnicodeChars[k].Name) ;
+ w.writeString("mccode", 2, UnicodeChars[k].MCCode) ;
+ w.writeString("type", 2, UnicodeChars[k].Type) ;
+ w.writeString("equivalents", 2, UnicodeChars[k].Equivalents) ;
+ w.writeString("notes", 2, UnicodeChars[k].Notes) ;
+ w.writeString("group", 2, UnicodeChars[k].Group) ;
+ w.closeTag("char", 1) ;
+ }
+ for (int k=0; k < Special ; k++){
+ int i = (int) SpecialChars[k].Value ;
+ String h = Integer.toHexString(i) ;
+ w.openTag("specialchar", 1) ;
+ w.writeString("value", 2, new Character(SpecialChars[k].Value).toString() ) ;
+ w.writeString("hexvalue", 2, h ) ;
+ w.writeString("name", 2, SpecialChars[k].Name) ;
+ w.writeString("mccode", 2, SpecialChars[k].MCCode) ;
+ w.writeString("type", 2, SpecialChars[k].Type) ;
+ w.writeString("equivalents", 2, SpecialChars[k].Equivalents) ;
+ w.writeString("notes", 2, SpecialChars[k].Notes) ;
+ w.writeString("group", 2, SpecialChars[k].Group) ;
+ w.closeTag("specialchar", 1) ;
+ }
+ w.closeTag("coding", 0) ;
+ }
+//-----------------------------------------------------------------------------
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/WKQ.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/WKQ.java new file mode 100644 index 0000000..da45a34 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/WKQ.java @@ -0,0 +1,102 @@ +package WLC2OSIS.Translate;
+
+import WLC2OSIS.* ;
+import WLC2OSIS.Parse.* ;
+import WLC2OSIS.Utilities.* ;
+//==============================================================================
+/**
+ * <b>Processes usual and Ketib/Qere words.</b><p>
+ *
+ * Modified for WLC **qq and *kk null qere and null ketib entries.
+ */
+//==============================================================================
+public class WKQ{
+
+Parser P ;
+
+String Ketib;
+int KCount ;
+boolean KStarted ;
+
+String Qere ;
+int QCount ;
+boolean QStarted ;
+//-----------------------------------------------------------------------------
+
+public WKQ( Parser P ) {
+ this.P = P ;
+ }
+//------------------------------------------------------------------------------
+/**
+ * Processes MCW words, writing them using the Word.write(Word, Type) method.
+ *
+ * @param W String containing MCW word of any type.
+ */
+public void process(String W) {
+
+ int asteriskcount = P.countChar(W, '*') ;
+ int FirstAsterisk = W.indexOf('*') ;
+ int LastAsterisk = W.lastIndexOf("*") ;
+//----------------------------------------------------------------------------------
+
+// Process a non-KQ
+
+ if (asteriskcount == 0){
+ P.w.write(W, "w") ;
+ }
+//----------------------------------------------------------------------------------
+
+// Look for a KQ that starts with a non-KQ string in the word
+// usually abc*xyz. Write abc as a nonKQ word, the process *wxyz.
+
+
+ if (FirstAsterisk > 0 && P.countChar(W,'*') >= 1 ){
+ String NonKQ = W.substring(0, FirstAsterisk) ;
+ P.w.write(NonKQ, "w") ;
+ W = W.substring(FirstAsterisk, W.length() ) ;
+ process(W) ; // Could be either K or Q
+ }
+//-----------------------------------------------------------------------------
+
+// One word has two K,Q sections. *xyz**abc, **xyz*abc, *xyz*abc, **xyz**abc
+// Process the two parts separately.
+
+ else if(P.countChar(W,'*') >= 2 & LastAsterisk > 1 ){
+ int Split = W.indexOf('*', 2) ;
+ String Part1 = W.substring(0, Split) ;
+ String Part2 = W.substring(Split, W.length()) ;
+ process(Part1) ;
+ process(Part2) ;
+ }
+//-----------------------------------------------------------------------------
+
+// W has ONLY a leading asterisk or two leading asterisks
+
+ else{
+ if(W.charAt(0) == '*'){
+ if(W.charAt(1) != '*'){
+
+// Ketib
+
+// Do nothing if a null K
+ if (W.compareTo("*kk") != 0){
+ P.w.write(W.substring(1, W.length() ), "k") ;
+ }
+ }
+ else{
+
+// Qere
+
+// Check for a null Q
+ if (W.compareTo("**qq") != 0){
+ P.w.write(W.substring(2, W.length() ), "q") ;
+ }
+ }
+ }
+ }
+ return ;
+ }
+//------------------------------------------------------------------------------
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/package.html b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/package.html new file mode 100644 index 0000000..ae7d180 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Translate/package.html @@ -0,0 +1,8 @@ +<HTML>
+<BODY>
+<b>Classes to translate from the ASCII MC format to Unicode<b>.
+<p/>
+<p align="right"> (BHS2XML/Translate/package.html)
+<p/>
+Only the BookName and Note classes are specific to the WLC.</BODY>
+</HTML>
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Utilities/FileRead.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Utilities/FileRead.java new file mode 100644 index 0000000..85c5df3 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Utilities/FileRead.java @@ -0,0 +1,106 @@ +package WLC2OSIS.Utilities ;
+
+import WLC2OSIS.* ;
+import Utilities.FileChooser ;
+//import Utilities.Message ;
+
+import java.io.* ;
+import javax.swing.* ;
+import java.awt.* ;
+//==============================================================================
+/**
+ * <b>Reads the input file.</b>
+ */
+//==============================================================================
+public class FileRead{
+
+
+WLC2OSIS A ;
+int InputLength ;
+public byte[] InputBuffer ;
+File F ;
+FileInputStream FIS ;
+boolean Error ;
+//-----------------------------------------------------------------------------
+
+public FileRead(WLC2OSIS A ) {
+ this.A = A ;
+ InputBuffer = new byte[A.InputBufferSize] ;
+ Error = false ;
+ }
+//------------------------------------------------------------------------------
+
+// Reads the specified file, forming the char[] InputChars and StringBuffer Input.
+
+public void read(String Filename){
+ Error = true ;
+
+// Open the file
+
+ F = new File(Filename) ;
+
+ try{
+ FIS = new FileInputStream(F);
+ if (FIS.available() > InputBuffer.length){
+ System.out.println(
+ "The input file length, " + FIS.available()
+ + " bytes,\nis too long for the internal buffer of "
+ + InputBuffer.length + " bytes.") ;
+ return ;
+ }
+ }
+ catch(IOException e){
+ System.out.println(
+ "FileRead.read: Error in opening FileInputStream.\n\n"
+ + F.getPath() + "\n\n"
+ + e.toString() + "\nNo further action taken.") ;
+ return ;
+ }
+//------------------------------------------------------------------------------
+
+// Read the file
+
+ try{
+ InputLength = FIS.read(InputBuffer) ;
+ }
+ catch(IOException e){
+ System.out.println(
+ "FileRead.read: Error on read of input file.\n\n"
+ + F.getPath() + "\n\n"
+ + e.toString() + "\nNo further action taken.") ;
+ return;
+ }
+
+// Close the file.
+
+ try{
+ FIS.close() ;
+ }
+ catch(IOException e){
+ System.out.println(
+ "FileRead.read: Error on close of input file.\n\n"
+ + F.getPath() + "\n\n"
+ + e.toString() + "\nNo further action taken.") ;
+ }
+
+// Convert bytes to char[] array.
+
+ A.InputChars = new char[InputLength] ;
+ for (int k = 0; k < InputLength; k++){
+ short shrt = (short) InputBuffer[k] ;
+ A.InputChars[k] = (char) shrt ;
+ }
+
+ Error = false ;
+ }
+//------------------------------------------------------------------------------
+
+// Gets the error condition.
+
+public boolean getError(){
+ return Error ;
+ }
+//-----------------------------------------------------------------------------
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Utilities/Test.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Utilities/Test.java new file mode 100644 index 0000000..fe7b913 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Utilities/Test.java @@ -0,0 +1,47 @@ +package WLC2OSIS.Utilities ;
+
+import WLC2OSIS.* ;
+import WLC2OSIS.Parse.* ;
+import WLC2OSIS.Translate.* ;
+import Utilities.* ;
+
+import java.lang.System ;
+import java.io.* ;
+//==============================================================================
+/**
+ * <b>Tests the conversion from MC ASCII String to XML output.</b>
+ */
+//==============================================================================
+public class Test{
+
+//-----------------------------------------------------------------------------
+/**
+ * Writes an XML file showing the Unicode output for a specified
+ * MC ASCII string.
+ *
+ * @param MC ASCII String to be translated.
+ *
+*/
+public static void test(WLC2OSIS A, String MC){
+ A.p = new Parser(A) ;
+ Translate T = new Translate(A, A.p) ;
+ String Word = T.translate(MC) ;
+ A.w = new XMLWriter("C:\\kimball\\JavaProjects\\WLC2OSIS\\Tanach", "Test", "Test",
+ "Test", "" ) ;
+ A.w.writeString("mc", 1, MC) ;
+ A.p.w.writeWord(Word, "w") ;
+ A.w.close() ;
+ try{
+ BrowserLauncher.openURL("file:\\C:/kimball/JavaProjects/WLC2OSIS/Tanach/"
+ + "Test" + ".xml") ;
+ }
+ catch(IOException e){
+ System.out.println("WLC2OSIS: Couldn't launch browser.") ;
+ }
+ System.exit(0) ;
+ }
+//-----------------------------------------------------------------------------
+// end of class
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Utilities/XMLWriter.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Utilities/XMLWriter.java new file mode 100644 index 0000000..ef89155 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Utilities/XMLWriter.java @@ -0,0 +1,157 @@ +package WLC2OSIS.Utilities ;
+
+import Utilities.* ;
+
+import java.lang.System ;
+import java.io.* ;
+//==============================================================================
+/**
+ * <b>Writes the output XML files.</b>
+ */
+//==============================================================================
+public class XMLWriter{
+
+String Directory ;
+String Filename ;
+String IndentString = " " ;
+FileOutputStream FOS ;
+OutputStreamWriter OSW ;
+char[] CharBuffer ;
+Fmt F = new Fmt() ;
+String XMLTag ;
+//-----------------------------------------------------------------------------
+/**
+ * Writes an XML file.
+ *
+ * @param Directory String giving directory WITHOUT final \.
+ * @param Filename String giving file name WITHOUT extension.
+ * @param XMLTag String giving XML tag.
+ * @param XSLXSDName String giving .xsl and xsd file names WITHOUT extension.
+ * @param ToXSL String giving route to .xsl file and .xsd file, i.e. "..\\"
+ * or ".." + File.separator.
+ *
+*/
+public XMLWriter(String Directory, String Filename, String XMLTag, String XSLXSDName, String ToXSL){
+
+ this.Directory = Directory ;
+ this.Filename = Filename ;
+ this.XMLTag = XMLTag ;
+
+ try{
+ FOS = new FileOutputStream(Directory + File.separator + Filename + ".xml") ;
+ OSW = new OutputStreamWriter(FOS, "UTF8") ;
+ }
+ catch(IOException e){
+ System.out.println("XMLWriter: Error in opening output file.\n" + e) ;
+ }
+ writeString("<?xml version = \"1.0\" encoding=\"UTF-8\"?>");
+ writeString("\n<?xml-stylesheet type=\"text/xsl\" href=\"" + ToXSL + XSLXSDName + ".xsl.xml\"?>");
+ writeString("\n<" + XMLTag
+ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ + "xsi:noNamespaceSchemaLocation =\"" + ToXSL + XSLXSDName + ".xsd\">" ) ;
+ writeString("\n<!-- Copyright C.V.Kimball 2004 -->" ) ;
+ }
+//-----------------------------------------------------------------------------
+public void writeString(String Tag, int Level, String S){
+ String s = "\n" ;
+ for (int k = 0; k < Level; k++){
+ s = s + IndentString ;
+ }
+ s = s + "<" + Tag + ">" ;
+ s = s + S ;
+ s = s + "</" + Tag + ">" ;
+ writeString(s) ;
+ }
+//-----------------------------------------------------------------------------
+public void writeBoolean(String Tag, int Level, boolean B){
+ String s = "\n" ;
+ for (int k = 0; k < Level; k++){
+ s = s + IndentString ;
+ }
+ s = s + "<" + Tag + ">" ;
+ s = s + B ;
+ s = s + "</" + Tag + ">" ;
+ writeString(s) ;
+ }
+//-----------------------------------------------------------------------------
+public void writeInt(String Tag, int Level, int I){
+ String s = "\n" ;
+ for (int k = 0; k < Level; k++){
+ s = s + IndentString ;
+ }
+ s = s + "<" + Tag + ">" ;
+ s = s + I ;
+ s = s + "</" + Tag + ">" ;
+ writeString(s) ;
+ }
+//-----------------------------------------------------------------------------
+public void openTag(String Tag, int Level){
+ String s = "\n" ;
+ for (int k = 0; k < Level; k++){
+ s = s + IndentString ;
+ }
+ s = s + "<" + Tag + ">" ;
+ writeString(s) ;
+ }
+//-----------------------------------------------------------------------------
+public void openAttributedTag(String Tag, int Level, String Attribute, String Value){
+ String s = "\n" ;
+ for (int k = 0; k < Level; k++){
+ s = s + IndentString ;
+ }
+ s = s + "<" + Tag + " " + Attribute + "=\"" + Value + "\">" ;
+ writeString(s) ;
+ }
+//-----------------------------------------------------------------------------
+public void closeTag(String Tag, int Level){
+ String s = "\n" ;
+ if (Level > 0) {
+ for (int k = 0; k < Level; k++){
+ s = s + IndentString ;
+ }
+ }
+ s = s + "</" + Tag + ">" ;
+ writeString(s) ;
+ }
+//-----------------------------------------------------------------------------
+public void writeMarker(String Tag, int Level){
+ String s = "\n" ;
+ if (Level > 0) {
+ for (int k = 0; k < Level; k++){
+ s = s + IndentString ;
+ }
+ }
+ s = s + "<" + Tag + "/>" ;
+ writeString(s) ;
+ }
+//-----------------------------------------------------------------------------
+public void writeException( char Exception){
+ String s ;
+ s = "<x>" + Exception + "</x>" ;
+ writeString(s) ;
+ }
+//-----------------------------------------------------------------------------
+public void close(){
+ writeString("\n</" + XMLTag + ">") ;
+ try{
+ OSW.close() ;
+ }
+ catch(IOException e){
+ System.out.println("XMLWriter: Error in closing output file.\n" + e) ;
+ }
+ }
+//-----------------------------------------------------------------------------
+void writeString(String S){
+ CharBuffer = S.toCharArray() ;
+ try{
+ OSW.write(CharBuffer, 0, CharBuffer.length) ;
+ }
+ catch(IOException e){
+ System.out.println("XMLWriter: Error in output file.\n" + e) ;
+ }
+ }
+//-----------------------------------------------------------------------------
+// end of class
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Utilities/package.html b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Utilities/package.html new file mode 100644 index 0000000..ec59776 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/Utilities/package.html @@ -0,0 +1,8 @@ +<HTML>
+<BODY>
+<b>Utilities for text reading and XML writing, not specialized to WLC</b>.<p/>
+<p align="right"> (<b><tt>BHS2XML/Utilities/package.html</tt></b>)
+<p/>
+Includes a Test class to write XML for MC ASCII test cases.
+</BODY>
+</HTML>
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/WLC2OSIS.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/WLC2OSIS.java new file mode 100644 index 0000000..bb404c3 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/WLC2OSIS.java @@ -0,0 +1,180 @@ +package WLC2OSIS ;
+
+import WLC2OSIS.GUI.* ;
+import WLC2OSIS.Parse.* ;
+import WLC2OSIS.Translate.* ;
+import WLC2OSIS.Utilities.* ;
+import Utilities.* ;
+
+import java.awt.*;
+import java.io.*;
+import java.awt.event.*;
+import javax.swing.*;
+import java.util.*;
+//=================================================================================================
+/**
+*
+* <b>Core of WLC2OSIS, set Strings here before running program.<p></b>
+*
+*/
+//=================================================================================================
+
+public class WLC2OSIS implements Stoppable {
+
+// Definitions of input and output to be set by user.
+
+public String ProgramDate = "30 May 2004" ;
+public String DefaultInputFilename = "" ;
+public String InputFilename ;
+public String DefaultInputDate = "5 March 2004" ;
+public String Date ;
+public String DefaultOutputDirectory = "" ;
+public String OutputDirectory ;
+// Define the title and descriptions.
+public String Title = "The Westminster Leningrad Codex (WLC)" ;
+
+public String ShortDescription = "from the electronic version of the Leningrad Codex "
+ + "maintained by the Westminster Hebrew Institute." ;
+
+public String[] Description = {
+ "This text began as an electronic transcription by Whitaker and Parunak of the 1983 "
+ + "printed edition of Biblia Hebraica Stuttgartensia (BHS). The "
+ + "transcription is called the Michigan-Claremont electronic text and was archived "
+ + "at the Oxford Text Archive (OTA) in 1987. "
+ + "Since that time, the text has been modified to "
+ + "conform to the photo-facsimile of the Leningrad Codex, Firkovich "
+ + "B19A, residing at the Russian National Library, St. "
+ + "Petersberg; hence the change of name."
+ + "This version contains all 6 of the "
+ + "textual elements of the OTA document: consonants, vowels, cantillation "
+ + "marks, \"paragraph\" (pe, samekh) markers, ketib-qere variants, and morphological divisions. ",
+
+ "The BHS so-called \"paragraph\" markers (pe and samekh) do "
+ + "not actually occur in the Leningrad Codex. The editors of BHS use them "
+ + "to indicate open space deliberately left blank by the scribe. Pe "
+ + "(\"open\" paragraph) represents a space between verses, where the new "
+ + "verse begins on a new column line. This represents a major section of "
+ + "the text. Samekh (\"closed\" paragraph) represents a space of less than "
+ + "a line between verses. This is understood to be a subdivision of the "
+ + "corresponding \"open\" section. Since these markers represent an actual "
+ + "physical feature of the text, they have been retained. " ,
+
+ "The transcription was based on the \"Supplement to the code manual for "
+ + "the Michigan Old Testament\" by Alan Groves and includes the "
+ + "transcription notes defined there. A listing of these notes can be "
+ + "obtained by clicking on the \"Notes\" link of the index page. "
+ + "Transcription notes appear as superscripts and can be viewed by clicking "
+ + "on them.",
+
+ "The book names in English and Hebrew of the Jewish Publication Society "
+ + "(JPS) Tanach have been added."} ;
+
+public char MorphologicalDivisionMarker = '/' ;
+//-----------------------------------------------------------------------------
+
+public final int InputBufferSize = 4000000 ; // Length of input in bytes.
+public SuperContainer SC ;
+Container InputContainer ;
+public Frame SuperFrame ;
+public Container OverallContainer ; // Actually, the content pane.
+public JRootPane RP ;
+public char[] InputChars ; // Input char[] array set by FileRead.
+public Parser p ;
+public XMLWriter w ;
+public Fmt F = new Fmt() ;
+public boolean StandAlone = true ; // If used by another app,
+Messages M;
+
+public WLC2OSIS( Container InputContainer ){
+ this.InputContainer = InputContainer ;
+ this.SC = new SuperContainer(InputContainer) ;
+ OverallContainer = SC.getContentPane() ;
+ SuperFrame = SC.superFrame() ;
+ StandAlone = true ;
+//-----------------------------------------------------------------------------
+
+// Crude GUI
+
+ M = new Messages(this) ;
+ FileChoices fc = new FileChoices(this) ;
+
+ M.initialMessage() ;
+ InputFilename = fc.getInputFilename(DefaultInputFilename) ;
+ GetDate gd = new GetDate(this) ;
+ OutputDirectory = fc.getOutputDirectory(DefaultOutputDirectory) ;
+//-----------------------------------------------------------------------------
+
+// Identifying printouts
+
+ F.bar("=", 80) ;
+ System.out.println("\nWLC2OSIS: " + Title + " " + ShortDescription ) ;
+ System.out.println("\nInput file: " + InputFilename ) ;
+ System.out.println( "Input file date: " + Date ) ;
+ System.out.println("\nOutput directory: " + OutputDirectory ) ;
+
+ FileRead FR = new FileRead(this) ;
+ FR.read(InputFilename) ;
+//-----------------------------------------------------------------------------
+
+// *** DISABLED *** Test of CCAT format -> XML translation.
+
+//L5253W.L\"815253)5253]4
+//YI&:RF)\"80L
+ if(false){
+ String TestString = "HA/$.FMA73YIM" ;
+ Test.test(this, TestString) ;
+ }
+//-----------------------------------------------------------------------------
+
+// Read, parse, and write the book files.
+ p = new Parser(this) ;
+ p.parse() ;
+//-----------------------------------------------------------------------------
+
+// Write the Tanach.xml file
+
+ Index.writeIndex(this) ;
+ System.out.println("\nThe index file, Tanach.xml, has been written.\n") ;
+
+//-----------------------------------------------------------------------------
+ M.doneMessage() ;
+//-----------------------------------------------------------------------------
+
+// Launch the browser on Tanach.xml
+
+ try{
+ BrowserLauncher.openURL("file:\\" + OutputDirectory
+ + File.separator + "Tanach.xml") ;
+ }
+ catch(IOException e){
+ System.out.println("WLC2OSIS: Couldn't launch browser.") ;
+ }
+
+ done() ;
+ }
+//-----------------------------------------------------------------------------
+
+// Applet stop() method, calls done() method.
+
+public void stop() {
+ done() ;
+ }
+//------------------------------------------------------------------------------
+/**
+ * Universal exit.
+ */
+public void done(){
+ M.endMessage() ;
+ System.out.println("\nWLC2OSIS: Normal end.") ;
+ F.bar("=", 80) ;
+ if(!SC.isApplet()){
+ if(StandAlone){
+ System.exit(0) ;
+ }
+ }
+ }
+//-----------------------------------------------------------------------------
+// End of class
+}
+//========================================================================================
+//========================================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/WLC2OSISMain.java b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/WLC2OSISMain.java new file mode 100644 index 0000000..39ac753 --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/WLC2OSISMain.java @@ -0,0 +1,80 @@ +package WLC2OSIS ;
+
+import Utilities.* ;
+
+import java.awt.*;
+import javax.swing.*;
+//==============================================================================
+/**
+ * <b>WLC2OSISMain main method and applet launcher,
+ * actual working program is in the WLC2OSIS class.</b><p>
+ *
+ * This is a general purpose launching class. It can launch
+ *
+ * 1. Applets
+ * 2. Applications
+ * 3. Dialogs launched from other programs
+ *
+ */
+//==============================================================================
+public class WLC2OSISMain extends JApplet{
+
+static WLC2OSIS A ;
+
+//==============================================================================
+
+// Applet
+
+/**
+ * Applet init() method for use as an applet.
+ */
+public void init(){
+// System.out.println ("init() called.") ;
+ }
+//------------------------------------------------------------------------------
+/**
+ * Applet start() method goes to WLC2OSISCore.start()
+ */
+public void start() {
+// System.out.println ("start() called.") ;
+ A = new WLC2OSIS(this) ;
+ this.setVisible(true) ;
+ }
+//------------------------------------------------------------------------------
+/**
+ * Applet stop() method which goes to WLC2OSISCore.stop()
+ */
+public void stop() {
+// System.out.println("WLC2OSIS: stop() called.") ;
+ A.stop() ;
+ }
+//==============================================================================
+/**
+ * Static main() method for use as an application or dialog.
+ *
+ * @param args String[] un-used.
+ */
+public static void main( String[] args) {
+
+ boolean Dialog = false ; // Either a dialog or application window.
+
+ Frame SuperFrame = GetParentFrame.GetParentFrame(new JFrame()) ;
+
+ if (Dialog){
+
+// As a MODAL JDialog
+ JDialog WLC2OSISDialog = new JDialog(SuperFrame, true) ;
+ A = new WLC2OSIS( WLC2OSISDialog ) ;
+ System.exit(0) ;
+ }
+ else{
+
+// Ss a JFrame
+ JFrame ThisFrame = new JFrame() ;
+ A = new WLC2OSIS(ThisFrame) ;
+ }
+ }
+// end of class
+}
+//==============================================================================
+//==============================================================================
diff --git a/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/package.html b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/package.html new file mode 100644 index 0000000..9fa7dea --- /dev/null +++ b/modules/hebrew-wlc/WLC2OSIS/WLC2OSIS/package.html @@ -0,0 +1,57 @@ +<HTML>
+<BODY>
+<b>WLC2XML - Conversion of Westminister Leningrad Codex (WLC) to Unicode/XML format</b>.
+<p/>
+<p align="right"> <b><tt>(BHS2XML/package.html)</tt></b>
+<p/>
+Converts the <b>wlc.txt</b> file to 39 books and one index XML file for
+the Unicode/XML Tanach.
+<p/>This software consists of 5 packages which must be located
+in the Java <i>classpath</i>. That is, if your <i>classpath</i> is
+<b><tt>X:\Y\Z</tt></b>, then:
+<p/>
+<table border="2" cellspacing="2" width="80%" align="center">
+<th>
+<tr><td>Package</td><td>Location</td><td>Content</td></tr>
+</th>
+<tr><td>Utilities</td><td><b><tt>X:\Y\Z\Utilites</tt></b></td>
+ <td>General purpose Java utilities. Note that only 5 classes
+ in this package are actually used by software.</td></tr>
+<tr><td>WLC2XML</td><td><b><tt>X:\Y\Z\WLC2XML</tt></b></td>
+ <td>Main class.</td></tr>
+<tr><td>WLC2XML.Parse</td><td><b><tt>X:\Y\Z\WLC2XML\Parse</tt></b></td>
+ <td>Parsing classes.</td></tr>
+<tr><td>WLC2XML.Translate</td><td><b><tt>X:\Y\Z\WLC2XML\Translate</tt></b></td>
+ <td>Translation from ASCII CCAT format to Unicode.</td></tr>
+<tr><td>WLC2XML.Utilities</td><td><b><tt>X:\Y\Z\WLC2XML\Utilities</tt></b></td>
+ <td>File read and XML writing utilities.</td></tr>
+</table>
+<p/>
+The main,
+launching class is <b><tt>WLC2XMLMain</tt></b>.
+<p/>
+To run this program, first set the following Strings in the WLC2XML class:
+<p/>
+
+<table border="2" cellspacing="2" width="80%" align="center">
+<tr><td>InputFilename</td><td>Full path to input <b><tt>wlc.txt</tt></b> input file.</td></tr>
+<tr><td>OutputDirectory</td><td>Full path to directory to contain the output files. Must
+ terminate with a "/",</td></tr>
+<tr><td>Title</td><td>Title to appear above "Tanach" on index page.</td></tr>
+<tr><td>ShortDescription</td><td>Short description of output to appear
+ below "Tanach" on index and book name on book pages. Keep it short.</td></tr>
+<tr><td>Description</td><td>String[] giving separate paragraphs of description to appear on
+ the About page.</td></tr>
+<tr><td>Date</td><td>The version date of the input file.</td></tr>
+</table>
+<p/>
+Other parameters can be changed with only great caution and no warranty!
+The program can be run by typing
+<p/><center>
+<b><tt>java WLC2XML.WLC2XMLMain</tt></b>
+</center>
+<p/>
+on a command line. A confirmation print to System.out occurs during operation. This print ends with "WLC2XML: Normal end." if the program completed successfully.
+<p/>
+</BODY>
+</HTML>
|