de7fa4e2408623273462d6bbe00a6f056708abe5
[debian/jabref.git] / src / java / net / sf / jabref / Globals.java
1 /* (C) 2003 Nizar N. Batada, Morten O. Alver
2
3  All programs in this directory and
4  subdirectories are published under the GNU General Public License as
5  described below.
6
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or (at
10  your option) any later version.
11
12  This program is distributed in the hope that it will be useful, but
13  WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  General Public License for more details.
16
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20  USA
21
22  Further information about the GNU GPL is available at:
23  http://www.gnu.org/copyleft/gpl.ja.html
24
25  */
26 package net.sf.jabref;
27
28 import java.io.* ;
29 import java.util.* ;
30 import java.util.logging.* ;
31 import java.util.logging.Filter ;
32
33 import java.awt.* ;
34 import javax.swing.* ;
35
36 import net.sf.jabref.collab.* ;
37 import net.sf.jabref.imports.* ;
38 import net.sf.jabref.util.* ;
39 import net.sf.jabref.journals.JournalAbbreviations;
40
41 public class Globals {
42
43   public static int SHORTCUT_MASK,// = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
44       FUTURE_YEAR = 2050, // Needs to give a year definitely in the future. Used for guessing the
45                           // year field when parsing textual data.  :-)
46
47       STANDARD_EXPORT_COUNT = 5, // The number of standard export formats.
48       METADATA_LINE_LENGTH = 70; // The line length used to wrap metadata.
49
50   private static String resourcePrefix = "resource/JabRef",
51                         menuResourcePrefix = "resource/Menu",
52                         integrityResourcePrefix = "resource/IntegrityMessage";
53   private static final String buildInfos = "/resource/build.properties" ;
54   private static String logfile = "jabref.log";
55   public static ResourceBundle messages, menuTitles, intMessages ;
56   public static FileUpdateMonitor fileUpdateMonitor = new FileUpdateMonitor();
57     public static ImportFormatReader importFormatReader = new ImportFormatReader();
58
59
60
61    public static String VERSION,
62                        BUILD,
63                        BUILD_DATE ;
64
65   static
66   {
67     TBuildInfo bi = new TBuildInfo(buildInfos) ;
68     VERSION = bi.getBUILD_VERSION() ;
69     BUILD = bi.getBUILD_NUMBER() ;
70     BUILD_DATE = bi.getBUILD_DATE() ;
71   }
72
73
74
75   //public static ResourceBundle preferences = ResourceBundle.getBundle("resource/defaultPrefs");
76   public static Locale locale;
77   public static final String FILETYPE_PREFS_EXT = "_dir",
78       SELECTOR_META_PREFIX = "selector_",
79       LAYOUT_PREFIX = "/resource/layout/",
80       MAC = "Mac OS X",
81       DOI_LOOKUP_PREFIX = "http://dx.doi.org/",
82       NONE = "_non__",
83       FORMATTER_PACKAGE = "net.sf.jabref.export.layout.format.";
84   public static float duplicateThreshold = 0.75f;
85   private static Handler consoleHandler = new java.util.logging.ConsoleHandler();
86   public static String[] ENCODINGS = new String[] {"ISO8859_1", "UTF8", "UTF-16", "ASCII",
87       "Cp1250", "Cp1251", "Cp1252", "Cp1253", "Cp1254", "Cp1257",
88       "JIS", "SJIS", "EUC-JP",      // Added Japanese encodings.
89       "Big5", "Big5_HKSCS", "GBK",
90       "ISO8859_2", "ISO8859_3", "ISO8859_4", "ISO8859_5", "ISO8859_6",
91       "ISO8859_7", "ISO8859_8", "ISO8859_9", "ISO8859_13", "ISO8859_15"};
92
93   // String array that maps from month number to month string label:
94   public static String[] MONTHS = new String[] {"jan", "feb", "mar", "apr", "may", "jun",
95           "jul", "aug", "sep", "oct", "nov", "dec"};
96
97   // Map that maps from month string labels to
98   public static Map MONTH_STRINGS = new HashMap();
99   static {
100       MONTH_STRINGS.put("jan", "January");
101       MONTH_STRINGS.put("feb", "February");
102       MONTH_STRINGS.put("mar", "March");
103       MONTH_STRINGS.put("apr", "April");
104       MONTH_STRINGS.put("may", "May");
105       MONTH_STRINGS.put("jun", "June");
106       MONTH_STRINGS.put("jul", "July");
107       MONTH_STRINGS.put("aug", "August");
108       MONTH_STRINGS.put("sep", "September");
109       MONTH_STRINGS.put("oct", "October");
110       MONTH_STRINGS.put("nov", "November");
111       MONTH_STRINGS.put("dec", "December");
112   }
113
114
115   public static GlobalFocusListener focusListener = new GlobalFocusListener();
116   public static JabRefPreferences prefs = null;
117  public static HelpDialog helpDiag = null;
118   public static String osName = System.getProperty("os.name", "def");
119   public static boolean ON_MAC = (osName.equals(MAC)),
120       ON_WIN = osName.startsWith("Windows");
121
122
123   public static String[] SKIP_WORDS = {"a", "an", "the", "for", "on"};
124     public static SidePaneManager sidePaneManager;
125   public static final String NEWLINE = System.getProperty("line.separator");
126     public static final boolean UNIX_NEWLINE = NEWLINE.equals("\n"); // true if we have unix newlines.
127
128     public static final String BIBTEX_STRING = "__string";
129     // "Fieldname" to indicate that a field should be treated as a bibtex string. Used when writing database to file.
130
131     public static void logger(String s) {
132     Logger.global.info(s);
133   }
134
135   public static void turnOffLogging() { // only log exceptions
136     Logger.global.setLevel(java.util.logging.Level.SEVERE);
137   }
138
139   // should be only called once
140   public static void turnOnConsoleLogging() {
141     Logger.global.addHandler(consoleHandler);
142
143   }
144
145
146
147   public static void turnOnFileLogging() {
148     Logger.global.setLevel(java.util.logging.Level.ALL);
149     java.util.logging.Handler handler;
150     handler = new ConsoleHandler();
151     /*try {
152       handler = new FileHandler(logfile); // this will overwrite
153     }
154     catch (IOException e) { //can't open log file so use console
155         e.printStackTrace();
156
157     } */
158     Logger.global.addHandler(handler);
159
160     handler.setFilter(new Filter() { // select what gets logged
161       public boolean isLoggable(LogRecord record) {
162         return true;
163       }
164     });
165   }
166
167   /**
168    * String constants.
169    */
170   public static final String
171       KEY_FIELD = "bibtexkey",
172       SEARCH = "__search",
173       GROUPSEARCH = "__groupsearch",
174       MARKED = "__markedentry",
175       OWNER = "owner",
176         // Using this when I have no database open when I read
177       // non bibtex file formats (used byte ImportFormatReader.java
178       DEFAULT_BIBTEXENTRY_ID = "__ID";
179
180   public static void setLanguage(String language, String country) {
181     locale = new Locale(language, country);
182     messages = ResourceBundle.getBundle(resourcePrefix, locale);
183     menuTitles = ResourceBundle.getBundle(menuResourcePrefix, locale);
184     intMessages = ResourceBundle.getBundle(integrityResourcePrefix, locale);
185     Locale.setDefault(locale);
186     javax.swing.JComponent.setDefaultLocale(locale);
187   }
188
189
190     public static JournalAbbreviations journalAbbrev;
191
192
193   public static String lang(String key, String[] params) {
194     String translation = null;
195     try {
196       if (Globals.messages != null) {
197         translation = Globals.messages.getString(key.replaceAll(" ", "_"));
198       }
199     }
200     catch (MissingResourceException ex) {
201       translation = key;
202       //logger("Warning: could not get translation for \""
203       //                   + key + "\"");
204     }
205     if ((translation != null) && (translation.length() != 0)) {
206       translation = translation.replaceAll("_", " ");
207       StringBuffer sb = new StringBuffer();
208       boolean b = false;
209       char c;
210       for (int i = 0; i < translation.length(); ++i) {
211           c = translation.charAt(i);
212           if (c == '%') {
213               b = true;
214           } else {
215               if (!b) {
216                   sb.append(c);
217               } else {
218                   b = false;
219                   try {
220                       int index = Integer.parseInt(String.valueOf(c));
221                       if (params != null && index >= 0 && index <= params.length)
222                           sb.append(params[index]);
223                   } catch (NumberFormatException e) {
224                       // append literally (for quoting) or insert special symbol
225                       switch (c) {
226                       case 'c': // colon
227                           sb.append(':');
228                           break;
229                       case 'e': // equal
230                           sb.append('=');
231                           break;
232                       default: // anything else, e.g. %
233                           sb.append(c);
234                       }
235                   }
236               }
237           }
238       }
239       return sb.toString();
240     }
241     return key;
242   }
243
244   public static String lang(String key) {
245       return lang(key, (String[])null);
246   }
247
248   public static String lang(String key, String s1) {
249       return lang(key, new String[]{s1});
250   }
251
252   public static String lang(String key, String s1, String s2) {
253       return lang(key, new String[]{s1, s2});
254   }
255
256   public static String lang(String key, String s1, String s2, String s3) {
257       return lang(key, new String[]{s1, s2, s3});
258   }
259
260   public static String menuTitle(String key) {
261     String translation = null;
262     try {
263       if (Globals.messages != null) {
264         translation = Globals.menuTitles.getString(key.replaceAll(" ", "_"));
265       }
266     }
267     catch (MissingResourceException ex) {
268       translation = key;
269
270       //System.err.println("Warning: could not get menu item translation for \""
271       //                   + key + "\"");
272
273     }
274     if ((translation != null) && (translation.length() != 0)) {
275       return translation.replaceAll("_", " ");
276     }
277     else {
278       return key;
279     }
280   }
281
282   public static String getIntegrityMessage(String key)
283   {
284     String translation = null;
285     try {
286       if (Globals.intMessages != null) {
287         translation = Globals.intMessages.getString(key);
288       }
289     }
290     catch (MissingResourceException ex) {
291       translation = key;
292
293 //      System.err.println("Warning: could not get menu item translation for \""
294 //                         + key + "\"");
295     }
296     if ((translation != null) && (translation.length() != 0)) {
297       return translation ;
298     }
299     else {
300       return key;
301     }
302   }
303
304
305   //============================================================
306   // Using the hashmap of entry types found in BibtexEntryType
307   //============================================================
308   public static BibtexEntryType getEntryType(String type) {
309     // decide which entryType object to return
310     Object o = BibtexEntryType.ALL_TYPES.get(type);
311     if (o != null) {
312       return (BibtexEntryType) o;
313     }
314     else {
315       return BibtexEntryType.OTHER;
316     }
317     /*
318       if(type.equals("article"))
319         return BibtexEntryType.ARTICLE;
320       else if(type.equals("book"))
321         return BibtexEntryType.BOOK;
322       else if(type.equals("inproceedings"))
323         return BibtexEntryType.INPROCEEDINGS;
324      */
325   }
326
327     /**
328      * This method provides the correct opening brace to use when writing a field
329      * to BibTeX format.
330      * @return A String containing the braces to use.
331      */
332     public static String getOpeningBrace() {
333         return "{";
334         /*
335             As of version 2.0, storing all fields with double braces is no longer supported, because
336             it causes problems with e.g. the author field.
337
338         if (prefs.getBoolean("autoDoubleBraces"))
339             return "{{";
340         else
341             return "{";
342         */
343     }
344
345     /**
346      * This method provides the correct closing brace to use when writing a field
347      * to BibTeX format.
348      * @return A String containing the braces to use.
349      */
350     public static String getClosingBrace() {
351         return "}";
352         /*
353             As of version 2.0, storing all fields with double braces is no longer supported, because
354             it causes problems with e.g. the author field.
355
356         if (prefs.getBoolean("autoDoubleBraces"))
357             return "}}";
358         else
359         */
360
361     }
362
363     /*    public static void setupKeyBindings(JabRefPreferences prefs) {
364     }*/
365
366   public static String getNewFile(JFrame owner, JabRefPreferences prefs,
367                                   File directory, String extension,
368                                   int dialogType,
369                                   boolean updateWorkingDirectory) {
370     return getNewFile(owner, prefs, directory, extension, null, dialogType,
371                       updateWorkingDirectory, false);
372   }
373
374     
375   public static String getNewFile(JFrame owner, JabRefPreferences prefs,
376                                   File directory, String extension,
377                                   String description,
378                                   int dialogType,
379                                   boolean updateWorkingDirectory) {
380     return getNewFile(owner, prefs, directory, extension, description, dialogType,
381                       updateWorkingDirectory, false);
382   }
383
384     
385   public static String getNewFile(JFrame owner, JabRefPreferences prefs,
386                                   File directory, String extension, OpenFileFilter off,
387                                   int dialogType,
388                                   boolean updateWorkingDirectory) {
389     return getNewFile(owner, prefs, directory, extension, null, off, dialogType,
390                       updateWorkingDirectory, false);
391   }
392
393   public static String getNewDir(JFrame owner, JabRefPreferences prefs,
394                                  File directory, String extension,
395                                  int dialogType, boolean updateWorkingDirectory) {
396     return getNewFile(owner, prefs, directory, extension, null, dialogType,
397                       updateWorkingDirectory, true);
398   }
399
400   public static String getNewDir(JFrame owner, JabRefPreferences prefs,
401                                  File directory, String extension,
402                                  String description,
403                                  int dialogType, boolean updateWorkingDirectory) {
404     return getNewFile(owner, prefs, directory, extension, description, dialogType,
405                       updateWorkingDirectory, true);
406   }
407
408   private static String getNewFile(JFrame owner, JabRefPreferences prefs,
409                                    File directory, String extension,
410                                    String description,
411                                    int dialogType,
412                                    boolean updateWorkingDirectory,
413                                    boolean dirOnly) {
414
415     OpenFileFilter off = null;
416
417     if (extension == null)
418       off = new OpenFileFilter();
419     else if (!extension.equals(NONE))
420       off = new OpenFileFilter(extension);
421
422     return getNewFile(owner, prefs, directory, extension, description, off, dialogType, updateWorkingDirectory, dirOnly);
423   }
424
425   private static String getNewFile(JFrame owner, JabRefPreferences prefs,
426                                    File directory, String extension, 
427                                    String description,
428                                    OpenFileFilter off,
429                                    int dialogType,
430                                    boolean updateWorkingDirectory,
431                                    boolean dirOnly) {
432
433     if (ON_MAC) {
434       return getNewFileForMac(owner, directory, extension, dialogType,
435                               updateWorkingDirectory, dirOnly, off);
436     }
437
438     JFileChooser fc = null;
439     try {
440         fc = new JabRefFileChooser(directory);
441     } catch (InternalError errl) {
442         // This try/catch clause was added because a user reported an
443         // InternalError getting thrown on WinNT, presumably because of a
444         // bug in JGoodies Windows PLAF. This clause can be removed if the
445         // bug is fixed, but for now we just resort to the native file
446         // dialog, using the same method as is always used on Mac:
447         return getNewFileForMac(owner, directory, extension, dialogType,
448                                 updateWorkingDirectory, dirOnly, off);
449     }
450
451     if (dirOnly) {
452       fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
453
454     }
455     fc.addChoosableFileFilter(off);
456     fc.setDialogType(dialogType);
457     int dialogResult = JFileChooser.CANCEL_OPTION ;
458     if (dialogType == JFileChooser.OPEN_DIALOG) {
459       dialogResult = fc.showOpenDialog(owner);
460     }
461     else if (dialogType == JFileChooser.SAVE_DIALOG){
462       dialogResult = fc.showSaveDialog(owner);
463     }
464     else {
465       dialogResult = fc.showDialog(owner, description);
466     }
467
468      // the getSelectedFile method returns a valid fileselection
469      // (if something is selected) indepentently from dialog return status
470     if (dialogResult != JFileChooser.APPROVE_OPTION)
471       return null ;
472
473     // okay button
474     File selectedFile = fc.getSelectedFile();
475     if (selectedFile == null) { // cancel
476       return null;
477     }
478
479     // If this is a save dialog, and the user has not chosen "All files" as filter
480     // we enforce the given extension. But only if extension is not null.
481     if ((extension != null) && (dialogType == JFileChooser.SAVE_DIALOG) && (fc.getFileFilter() == off) &&
482         !off.accept(selectedFile)) {
483
484       // add the first extension if there are multiple extensions
485       selectedFile = new File(selectedFile.getPath() + extension.split("[, ]+",0)[0]);
486     }
487
488     if (updateWorkingDirectory) {
489       prefs.put("workingDirectory", selectedFile.getPath());
490     }
491     return selectedFile.getAbsolutePath();
492   }
493
494   private static String getNewFileForMac(JFrame owner,
495                                          File directory, String extensions,
496                                          int dialogType,
497                                          boolean updateWorkingDirectory,
498                                          boolean dirOnly,
499                                          FilenameFilter filter) {
500
501     FileDialog fc = new FileDialog(owner);
502     //fc.setFilenameFilter(filter);
503     if (directory != null) {
504       fc.setDirectory(directory.getParent());
505     }
506     if (dialogType == JFileChooser.OPEN_DIALOG) {
507       fc.setMode(FileDialog.LOAD);
508     }
509     else {
510       fc.setMode(FileDialog.SAVE);
511     }
512
513     fc.show();
514
515     if (fc.getFile() != null) {
516       Globals.prefs.put("workingDirectory", fc.getDirectory() + fc.getFile());
517       return fc.getDirectory() + fc.getFile();
518     }
519     else {
520       return null;
521     }
522   }
523
524
525   public static String SPECIAL_COMMAND_CHARS = "\"`^~'c";
526   public static HashMap HTML_CHARS = new HashMap(),
527           HTMLCHARS = new HashMap(),
528       XML_CHARS = new HashMap(),
529       UNICODE_CHARS = new HashMap(),
530       RTFCHARS = new HashMap();
531   static {
532       
533       //System.out.println(journalAbbrev.getAbbreviatedName("Journal of Fish Biology", true));
534       //System.out.println(journalAbbrev.getAbbreviatedName("Journal of Fish Biology", false));
535       //System.out.println(journalAbbrev.getFullName("Aquaculture Eng."));
536       /*for (Iterator i=journalAbbrev.fullNameIterator(); i.hasNext();) {
537           String s = (String)i.next();
538           System.out.println(journalAbbrev.getFullName(s)+" : "+journalAbbrev.getAbbreviatedName(s, true));
539       } */
540
541     // Start the thread that monitors file time stamps.
542     //Util.pr("Starting FileUpdateMonitor thread. Globals line 293.");
543     fileUpdateMonitor.start();
544
545     try {
546       SHORTCUT_MASK = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
547     } catch (Throwable t) {
548
549     }
550     /*
551     HTML_CHARS.put("\\{\\\\\\\"\\{a\\}\\}", "&auml;");
552     HTML_CHARS.put("\\{\\\\\\\"\\{A\\}\\}", "&Auml;");
553     HTML_CHARS.put("\\{\\\\\\\"\\{e\\}\\}", "&euml;");
554     HTML_CHARS.put("\\{\\\\\\\"\\{E\\}\\}", "&Euml;");
555     HTML_CHARS.put("\\{\\\\\\\"\\{i\\}\\}", "&iuml;");
556     HTML_CHARS.put("\\{\\\\\\\"\\{I\\}\\}", "&Iuml;");
557     HTML_CHARS.put("\\{\\\\\\\"\\{o\\}\\}", "&ouml;");
558     HTML_CHARS.put("\\{\\\\\\\"\\{O\\}\\}", "&Ouml;");
559     HTML_CHARS.put("\\{\\\\\\\"\\{u\\}\\}", "&uuml;");
560     HTML_CHARS.put("\\{\\\\\\\"\\{U\\}\\}", "&Uuml;");
561
562     HTML_CHARS.put("\\{\\\\\\`\\{e\\}\\}", "&egrave;");
563     HTML_CHARS.put("\\{\\\\\\`\\{E\\}\\}", "&Egrave;");
564     HTML_CHARS.put("\\{\\\\\\`\\{i\\}\\}", "&igrave;");
565     HTML_CHARS.put("\\{\\\\\\`\\{I\\}\\}", "&Igrave;");
566     HTML_CHARS.put("\\{\\\\\\`\\{o\\}\\}", "&ograve;");
567     HTML_CHARS.put("\\{\\\\\\`\\{O\\}\\}", "&Ograve;");
568     HTML_CHARS.put("\\{\\\\\\`\\{u\\}\\}", "&ugrave;");
569     HTML_CHARS.put("\\{\\\\\\`\\{U\\}\\}", "&Ugrave;");
570
571     HTML_CHARS.put("\\{\\\\\\'\\{e\\}\\}", "&eacute;");
572     HTML_CHARS.put("\\{\\\\\\'\\{E\\}\\}", "&Eacute;");
573     HTML_CHARS.put("\\{\\\\\\'\\{i\\}\\}", "&iacute;");
574     HTML_CHARS.put("\\{\\\\\\'\\{I\\}\\}", "&Iacute;");
575     HTML_CHARS.put("\\{\\\\\\'\\{o\\}\\}", "&oacute;");
576     HTML_CHARS.put("\\{\\\\\\'\\{O\\}\\}", "&Oacute;");
577     HTML_CHARS.put("\\{\\\\\\'\\{u\\}\\}", "&uacute;");
578     HTML_CHARS.put("\\{\\\\\\'\\{U\\}\\}", "&Uacute;");
579     HTML_CHARS.put("\\{\\\\\\'\\{a\\}\\}", "&aacute;");
580     HTML_CHARS.put("\\{\\\\\\'\\{A\\}\\}", "&Aacute;");
581     HTML_CHARS.put("\\{\\\\\\^\\{o\\}\\}", "&ocirc;");
582     HTML_CHARS.put("\\{\\\\\\^\\{O\\}\\}", "&Ocirc;");
583     HTML_CHARS.put("\\{\\\\\\^\\{u\\}\\}", "&ucirc;");
584     HTML_CHARS.put("\\{\\\\\\^\\{U\\}\\}", "&Ucirc;");
585     HTML_CHARS.put("\\{\\\\\\^\\{e\\}\\}", "&ecirc;");
586     HTML_CHARS.put("\\{\\\\\\^\\{E\\}\\}", "&Ecirc;");
587     HTML_CHARS.put("\\{\\\\\\^\\{i\\}\\}", "&icirc;");
588     HTML_CHARS.put("\\{\\\\\\^\\{I\\}\\}", "&Icirc;");
589     HTML_CHARS.put("\\{\\\\\\~\\{o\\}\\}", "&otilde;");
590     HTML_CHARS.put("\\{\\\\\\~\\{O\\}\\}", "&Otilde;");
591     HTML_CHARS.put("\\{\\\\\\~\\{n\\}\\}", "&ntilde;");
592     HTML_CHARS.put("\\{\\\\\\~\\{N\\}\\}", "&Ntilde;");
593     HTML_CHARS.put("\\{\\\\\\~\\{a\\}\\}", "&atilde;");
594     HTML_CHARS.put("\\{\\\\\\~\\{A\\}\\}", "&Atilde;");
595     */
596
597     HTMLCHARS.put("\"a", "&auml;");
598     HTMLCHARS.put("\"A", "&Auml;");
599     HTMLCHARS.put("\"e", "&euml;");
600     HTMLCHARS.put("\"E", "&Euml;");
601     HTMLCHARS.put("\"i", "&iuml;");
602     HTMLCHARS.put("\"I", "&Iuml;");
603     HTMLCHARS.put("\"o", "&ouml;");
604     HTMLCHARS.put("\"O", "&Ouml;");
605     HTMLCHARS.put("\"u", "&uuml;");
606     HTMLCHARS.put("\"U", "&Uuml;");
607     HTMLCHARS.put("`a", "&agrave;");
608     HTMLCHARS.put("`A", "&Agrave;");
609     HTMLCHARS.put("`e", "&egrave;");
610     HTMLCHARS.put("`E", "&Egrave;");
611     HTMLCHARS.put("`i", "&igrave;");
612     HTMLCHARS.put("`I", "&Igrave;");
613     HTMLCHARS.put("`o", "&ograve;");
614     HTMLCHARS.put("`O", "&Ograve;");
615     HTMLCHARS.put("`u", "&ugrave;");
616     HTMLCHARS.put("`U", "&Ugrave;");
617     HTMLCHARS.put("'e", "&eacute;");
618     HTMLCHARS.put("'E", "&Eacute;");
619     HTMLCHARS.put("'i", "&iacute;");
620     HTMLCHARS.put("'I", "&Iacute;");
621     HTMLCHARS.put("'o", "&oacute;");
622     HTMLCHARS.put("'O", "&Oacute;");
623     HTMLCHARS.put("'u", "&uacute;");
624     HTMLCHARS.put("'U", "&Uacute;");
625     HTMLCHARS.put("'a", "&aacute;");
626     HTMLCHARS.put("'A", "&Aacute;");
627     HTMLCHARS.put("^o", "&ocirc;");
628     HTMLCHARS.put("^O", "&Ocirc;");
629     HTMLCHARS.put("^u", "&ucirc;");
630     HTMLCHARS.put("^U", "&Ucirc;");
631     HTMLCHARS.put("^e", "&ecirc;");
632     HTMLCHARS.put("^E", "&Ecirc;");
633     HTMLCHARS.put("^i", "&icirc;");
634     HTMLCHARS.put("^I", "&Icirc;");
635     HTMLCHARS.put("~o", "&otilde;");
636     HTMLCHARS.put("~O", "&Otilde;");
637     HTMLCHARS.put("~n", "&ntilde;");
638     HTMLCHARS.put("~N", "&Ntilde;");
639     HTMLCHARS.put("~a", "&atilde;");
640     HTMLCHARS.put("~A", "&Atilde;");
641     HTMLCHARS.put("cc", "&ccedil;");
642     HTMLCHARS.put("cC", "&Ccedil;");
643     /*
644     HTML_CHARS.put("\\{\\\\\\\"a\\}", "&auml;");
645     HTML_CHARS.put("\\{\\\\\\\"A\\}", "&Auml;");
646     HTML_CHARS.put("\\{\\\\\\\"e\\}", "&euml;");
647     HTML_CHARS.put("\\{\\\\\\\"E\\}", "&Euml;");
648     HTML_CHARS.put("\\{\\\\\\\"i\\}", "&iuml;");
649     HTML_CHARS.put("\\{\\\\\\\"I\\}", "&Iuml;");
650     HTML_CHARS.put("\\{\\\\\\\"o\\}", "&ouml;");
651     HTML_CHARS.put("\\{\\\\\\\"O\\}", "&Ouml;");
652     HTML_CHARS.put("\\{\\\\\\\"u\\}", "&uuml;");
653     HTML_CHARS.put("\\{\\\\\\\"U\\}", "&Uuml;");
654
655     HTML_CHARS.put("\\{\\\\\\`e\\}", "&egrave;");
656     HTML_CHARS.put("\\{\\\\\\`E\\}", "&Egrave;");
657     HTML_CHARS.put("\\{\\\\\\`i\\}", "&igrave;");
658     HTML_CHARS.put("\\{\\\\\\`I\\}", "&Igrave;");
659     HTML_CHARS.put("\\{\\\\\\`o\\}", "&ograve;");
660     HTML_CHARS.put("\\{\\\\\\`O\\}", "&Ograve;");
661     HTML_CHARS.put("\\{\\\\\\`u\\}", "&ugrave;");
662     HTML_CHARS.put("\\{\\\\\\`U\\}", "&Ugrave;");
663     HTML_CHARS.put("\\{\\\\\\'A\\}", "&eacute;");
664     HTML_CHARS.put("\\{\\\\\\'E\\}", "&Eacute;");
665     HTML_CHARS.put("\\{\\\\\\'i\\}", "&iacute;");
666     HTML_CHARS.put("\\{\\\\\\'I\\}", "&Iacute;");
667     HTML_CHARS.put("\\{\\\\\\'o\\}", "&oacute;");
668     HTML_CHARS.put("\\{\\\\\\'O\\}", "&Oacute;");
669     HTML_CHARS.put("\\{\\\\\\'u\\}", "&uacute;");
670     HTML_CHARS.put("\\{\\\\\\'U\\}", "&Uacute;");
671     HTML_CHARS.put("\\{\\\\\\'a\\}", "&aacute;");
672     HTML_CHARS.put("\\{\\\\\\'A\\}", "&Aacute;");
673
674     HTML_CHARS.put("\\{\\\\\\^o\\}", "&ocirc;");
675     HTML_CHARS.put("\\{\\\\\\^O\\}", "&Ocirc;");
676     HTML_CHARS.put("\\{\\\\\\^u\\}", "&ucirc;");
677     HTML_CHARS.put("\\{\\\\\\^U\\}", "&Ucirc;");
678     HTML_CHARS.put("\\{\\\\\\^e\\}", "&ecirc;");
679     HTML_CHARS.put("\\{\\\\\\^E\\}", "&Ecirc;");
680     HTML_CHARS.put("\\{\\\\\\^i\\}", "&icirc;");
681     HTML_CHARS.put("\\{\\\\\\^I\\}", "&Icirc;");
682     HTML_CHARS.put("\\{\\\\\\~o\\}", "&otilde;");
683     HTML_CHARS.put("\\{\\\\\\~O\\}", "&Otilde;");
684     HTML_CHARS.put("\\{\\\\\\~n\\}", "&ntilde;");
685     HTML_CHARS.put("\\{\\\\\\~N\\}", "&Ntilde;");
686     HTML_CHARS.put("\\{\\\\\\~a\\}", "&atilde;");
687     HTML_CHARS.put("\\{\\\\\\~A\\}", "&Atilde;");
688
689     HTML_CHARS.put("\\{\\\\c c\\}", "&ccedil;");
690     HTML_CHARS.put("\\{\\\\c C\\}", "&Ccedil;");
691     */
692
693     XML_CHARS.put("\\{\\\\\\\"\\{a\\}\\}", "&#x00E4;");
694     XML_CHARS.put("\\{\\\\\\\"\\{A\\}\\}", "&#x00C4;");
695     XML_CHARS.put("\\{\\\\\\\"\\{e\\}\\}", "&#x00EB;");
696     XML_CHARS.put("\\{\\\\\\\"\\{E\\}\\}", "&#x00CB;");
697     XML_CHARS.put("\\{\\\\\\\"\\{i\\}\\}", "&#x00EF;");
698     XML_CHARS.put("\\{\\\\\\\"\\{I\\}\\}", "&#x00CF;");
699     XML_CHARS.put("\\{\\\\\\\"\\{o\\}\\}", "&#x00F6;");
700     XML_CHARS.put("\\{\\\\\\\"\\{O\\}\\}", "&#x00D6;");
701     XML_CHARS.put("\\{\\\\\\\"\\{u\\}\\}", "&#x00FC;");
702     XML_CHARS.put("\\{\\\\\\\"\\{U\\}\\}", "&#x00DC;");
703
704     XML_CHARS.put("\\{\\\\\\`\\{e\\}\\}", "&#x00E8;");
705     XML_CHARS.put("\\{\\\\\\`\\{E\\}\\}", "&#x00C8;");
706     XML_CHARS.put("\\{\\\\\\`\\{i\\}\\}", "&#x00EC;");
707     XML_CHARS.put("\\{\\\\\\`\\{I\\}\\}", "&#x00CC;");
708     XML_CHARS.put("\\{\\\\\\`\\{o\\}\\}", "&#x00F2;");
709     XML_CHARS.put("\\{\\\\\\`\\{O\\}\\}", "&#x00D2;");
710     XML_CHARS.put("\\{\\\\\\`\\{u\\}\\}", "&#x00F9;");
711     XML_CHARS.put("\\{\\\\\\`\\{U\\}\\}", "&#x00D9;");
712     XML_CHARS.put("\\{\\\\\\'\\{e\\}\\}", "&#x00E9;");
713     XML_CHARS.put("\\{\\\\\\\uFFFD\\{E\\}\\}", "&#x00C9;");
714     XML_CHARS.put("\\{\\\\\\\uFFFD\\{i\\}\\}", "&#x00ED;");
715     XML_CHARS.put("\\{\\\\\\\uFFFD\\{I\\}\\}", "&#x00CD;");
716     XML_CHARS.put("\\{\\\\\\\uFFFD\\{o\\}\\}", "&#x00F3;");
717     XML_CHARS.put("\\{\\\\\\\uFFFD\\{O\\}\\}", "&#x00D3;");
718     XML_CHARS.put("\\{\\\\\\\uFFFD\\{u\\}\\}", "&#x00FA;");
719     XML_CHARS.put("\\{\\\\\\\uFFFD\\{U\\}\\}", "&#x00DA;");
720     XML_CHARS.put("\\{\\\\\\\uFFFD\\{a\\}\\}", "&#x00E1;");
721     XML_CHARS.put("\\{\\\\\\\uFFFD\\{A\\}\\}", "&#x00C1;");
722
723     XML_CHARS.put("\\{\\\\\\^\\{o\\}\\}", "&#x00F4;");
724     XML_CHARS.put("\\{\\\\\\^\\{O\\}\\}", "&#x00D4;");
725     XML_CHARS.put("\\{\\\\\\^\\{u\\}\\}", "&#x00F9;");
726     XML_CHARS.put("\\{\\\\\\^\\{U\\}\\}", "&#x00D9;");
727     XML_CHARS.put("\\{\\\\\\^\\{e\\}\\}", "&#x00EA;");
728     XML_CHARS.put("\\{\\\\\\^\\{E\\}\\}", "&#x00CA;");
729     XML_CHARS.put("\\{\\\\\\^\\{i\\}\\}", "&#x00EE;");
730     XML_CHARS.put("\\{\\\\\\^\\{I\\}\\}", "&#x00CE;");
731     XML_CHARS.put("\\{\\\\\\~\\{o\\}\\}", "&#x00F5;");
732     XML_CHARS.put("\\{\\\\\\~\\{O\\}\\}", "&#x00D5;");
733     XML_CHARS.put("\\{\\\\\\~\\{n\\}\\}", "&#x00F1;");
734     XML_CHARS.put("\\{\\\\\\~\\{N\\}\\}", "&#x00D1;");
735     XML_CHARS.put("\\{\\\\\\~\\{a\\}\\}", "&#x00E3;");
736     XML_CHARS.put("\\{\\\\\\~\\{A\\}\\}", "&#x00C3;");
737
738
739     XML_CHARS.put("\\{\\\\\\\"a\\}", "&#x00E4;");
740     XML_CHARS.put("\\{\\\\\\\"A\\}", "&#x00C4;");
741     XML_CHARS.put("\\{\\\\\\\"e\\}", "&#x00EB;");
742     XML_CHARS.put("\\{\\\\\\\"E\\}", "&#x00CB;");
743     XML_CHARS.put("\\{\\\\\\\"i\\}", "&#x00EF;");
744     XML_CHARS.put("\\{\\\\\\\"I\\}", "&#x00CF;");
745     XML_CHARS.put("\\{\\\\\\\"o\\}", "&#x00F6;");
746     XML_CHARS.put("\\{\\\\\\\"O\\}", "&#x00D6;");
747     XML_CHARS.put("\\{\\\\\\\"u\\}", "&#x00FC;");
748     XML_CHARS.put("\\{\\\\\\\"U\\}", "&#x00DC;");
749
750     XML_CHARS.put("\\{\\\\\\`e\\}", "&#x00E8;");
751     XML_CHARS.put("\\{\\\\\\`E\\}", "&#x00C8;");
752     XML_CHARS.put("\\{\\\\\\`i\\}", "&#x00EC;");
753     XML_CHARS.put("\\{\\\\\\`I\\}", "&#x00CC;");
754     XML_CHARS.put("\\{\\\\\\`o\\}", "&#x00F2;");
755     XML_CHARS.put("\\{\\\\\\`O\\}", "&#x00D2;");
756     XML_CHARS.put("\\{\\\\\\`u\\}", "&#x00F9;");
757     XML_CHARS.put("\\{\\\\\\`U\\}", "&#x00D9;");
758     XML_CHARS.put("\\{\\\\\\'e\\}", "&#x00E9;");
759     XML_CHARS.put("\\{\\\\\\'E\\}", "&#x00C9;");
760     XML_CHARS.put("\\{\\\\\\'i\\}", "&#x00ED;");
761     XML_CHARS.put("\\{\\\\\\'I\\}", "&#x00CD;");
762     XML_CHARS.put("\\{\\\\\\'o\\}", "&#x00F3;");
763     XML_CHARS.put("\\{\\\\\\'O\\}", "&#x00D3;");
764     XML_CHARS.put("\\{\\\\\\'u\\}", "&#x00FA;");
765     XML_CHARS.put("\\{\\\\\\'U\\}", "&#x00DA;");
766     XML_CHARS.put("\\{\\\\\\'a\\}", "&#x00E1;");
767     XML_CHARS.put("\\{\\\\\\'A\\}", "&#x00C1;");
768
769     XML_CHARS.put("\\{\\\\\\^o\\}", "&#x00F4;");
770     XML_CHARS.put("\\{\\\\\\^O\\}", "&#x00D4;");
771     XML_CHARS.put("\\{\\\\\\^u\\}", "&#x00F9;");
772     XML_CHARS.put("\\{\\\\\\^U\\}", "&#x00D9;");
773     XML_CHARS.put("\\{\\\\\\^e\\}", "&#x00EA;");
774     XML_CHARS.put("\\{\\\\\\^E\\}", "&#x00CA;");
775     XML_CHARS.put("\\{\\\\\\^i\\}", "&#x00EE;");
776     XML_CHARS.put("\\{\\\\\\^I\\}", "&#x00CE;");
777     XML_CHARS.put("\\{\\\\\\~o\\}", "&#x00F5;");
778     XML_CHARS.put("\\{\\\\\\~O\\}", "&#x00D5;");
779     XML_CHARS.put("\\{\\\\\\~n\\}", "&#x00F1;");
780     XML_CHARS.put("\\{\\\\\\~N\\}", "&#x00D1;");
781     XML_CHARS.put("\\{\\\\\\~a\\}", "&#x00E3;");
782     XML_CHARS.put("\\{\\\\\\~A\\}", "&#x00C3;");
783
784     UNICODE_CHARS.put("\u00C0", "A");
785     UNICODE_CHARS.put("\u00C1", "A");
786     UNICODE_CHARS.put("\u00C2", "A");
787     UNICODE_CHARS.put("\u00C3", "A");
788     UNICODE_CHARS.put("\u00C4", "A");
789     UNICODE_CHARS.put("\u00C5", "Aa");
790     UNICODE_CHARS.put("\u00C6", "Ae");
791     UNICODE_CHARS.put("\u00C7", "C");
792     UNICODE_CHARS.put("\u00C8", "E");
793     UNICODE_CHARS.put("\u00C9", "E");
794     UNICODE_CHARS.put("\u00CA", "E");
795     UNICODE_CHARS.put("\u00CB", "E");
796     UNICODE_CHARS.put("\u00CC", "I");
797     UNICODE_CHARS.put("\u00CD", "I");
798     UNICODE_CHARS.put("\u00CE", "I");
799     UNICODE_CHARS.put("\u00CF", "I");
800     UNICODE_CHARS.put("\u00D0", "D");
801     UNICODE_CHARS.put("\u00D1", "N");
802     UNICODE_CHARS.put("\u00D2", "O");
803     UNICODE_CHARS.put("\u00D3", "O");
804     UNICODE_CHARS.put("\u00D4", "O");
805     UNICODE_CHARS.put("\u00D5", "O");
806     UNICODE_CHARS.put("\u00D6", "Oe");
807     UNICODE_CHARS.put("\u00D8", "Oe");
808     UNICODE_CHARS.put("\u00D9", "U");
809     UNICODE_CHARS.put("\u00DA", "U");
810     UNICODE_CHARS.put("\u00DB", "U");
811     UNICODE_CHARS.put("\u00DC", "Ue"); // U umlaut ..
812     UNICODE_CHARS.put("\u00DD", "Y");
813     UNICODE_CHARS.put("\u00DF", "ss");
814     UNICODE_CHARS.put("\u00E0", "a");
815     UNICODE_CHARS.put("\u00E1", "a");
816     UNICODE_CHARS.put("\u00E2", "a");
817     UNICODE_CHARS.put("\u00E3", "a");
818     UNICODE_CHARS.put("\u00E4", "ae");
819     UNICODE_CHARS.put("\u00E5", "aa");
820     UNICODE_CHARS.put("\u00E6", "ae");
821     UNICODE_CHARS.put("\u00E7", "c");
822     UNICODE_CHARS.put("\u00E8", "e");
823     UNICODE_CHARS.put("\u00E9", "e");
824     UNICODE_CHARS.put("\u00EA", "e");
825     UNICODE_CHARS.put("\u00EB", "e");
826     UNICODE_CHARS.put("\u00EC", "i");
827     UNICODE_CHARS.put("\u00ED", "i");
828     UNICODE_CHARS.put("\u00EE", "i");
829     UNICODE_CHARS.put("\u00EF", "i");
830     UNICODE_CHARS.put("\u00F0", "o");
831     UNICODE_CHARS.put("\u00F1", "n");
832     UNICODE_CHARS.put("\u00F2", "o");
833     UNICODE_CHARS.put("\u00F3", "o");
834     UNICODE_CHARS.put("\u00F4", "o");
835     UNICODE_CHARS.put("\u00F5", "o");
836     UNICODE_CHARS.put("\u00F6", "oe");
837     UNICODE_CHARS.put("\u00F8", "oe");
838     UNICODE_CHARS.put("\u00F9", "u");
839     UNICODE_CHARS.put("\u00FA", "u");
840     UNICODE_CHARS.put("\u00FB", "u");
841     UNICODE_CHARS.put("\u00FC", "ue"); // u umlaut...
842     UNICODE_CHARS.put("\u00FD", "y");
843     UNICODE_CHARS.put("\u00FF", "y");
844     UNICODE_CHARS.put("\u0100", "A");
845     UNICODE_CHARS.put("\u0101", "a");
846     UNICODE_CHARS.put("\u0102", "A");
847     UNICODE_CHARS.put("\u0103", "a");
848     UNICODE_CHARS.put("\u0104", "A");
849     UNICODE_CHARS.put("\u0105", "a");
850     UNICODE_CHARS.put("\u0106", "C");
851     UNICODE_CHARS.put("\u0107", "c");
852     UNICODE_CHARS.put("\u0108", "C");
853     UNICODE_CHARS.put("\u0109", "c");
854     UNICODE_CHARS.put("\u010A", "C");
855     UNICODE_CHARS.put("\u010B", "c");
856     UNICODE_CHARS.put("\u010C", "C");
857     UNICODE_CHARS.put("\u010D", "c");
858     UNICODE_CHARS.put("\u010E", "D");
859     UNICODE_CHARS.put("\u010F", "d");
860     UNICODE_CHARS.put("\u0110", "D");
861     UNICODE_CHARS.put("\u0111", "d");
862     UNICODE_CHARS.put("\u0112", "E");
863     UNICODE_CHARS.put("\u0113", "e");
864     UNICODE_CHARS.put("\u0114", "E");
865     UNICODE_CHARS.put("\u0115", "e");
866     UNICODE_CHARS.put("\u0116", "E");
867     UNICODE_CHARS.put("\u0117", "e");
868     UNICODE_CHARS.put("\u0118", "E");
869     UNICODE_CHARS.put("\u0119", "e");
870     UNICODE_CHARS.put("\u011A", "E");
871     UNICODE_CHARS.put("\u011B", "e");
872     UNICODE_CHARS.put("\u011C", "G");
873     UNICODE_CHARS.put("\u011D", "g");
874     UNICODE_CHARS.put("\u011E", "G");
875     UNICODE_CHARS.put("\u011F", "g");
876     UNICODE_CHARS.put("\u0120", "G");
877     UNICODE_CHARS.put("\u0121", "g");
878     UNICODE_CHARS.put("\u0122", "G");
879     UNICODE_CHARS.put("\u0123", "g");
880     UNICODE_CHARS.put("\u0124", "H");
881     UNICODE_CHARS.put("\u0125", "h");
882     UNICODE_CHARS.put("\u0127", "h");
883     UNICODE_CHARS.put("\u0128", "I");
884     UNICODE_CHARS.put("\u0129", "i");
885     UNICODE_CHARS.put("\u012A", "I");
886     UNICODE_CHARS.put("\u012B", "i");
887     UNICODE_CHARS.put("\u012C", "I");
888     UNICODE_CHARS.put("\u012D", "i");
889     //UNICODE_CHARS.put("\u0100", "");
890
891     RTFCHARS.put("`a", "\\'e0");
892     RTFCHARS.put("`e", "\\'e8");
893     RTFCHARS.put("`i", "\\'ec");
894     RTFCHARS.put("`o", "\\'f2");
895     RTFCHARS.put("`u", "\\'f9");
896     RTFCHARS.put("?a", "\\'e1");
897     RTFCHARS.put("?e", "\\'e9");
898     RTFCHARS.put("?i", "\\'ed");
899     RTFCHARS.put("?o", "\\'f3");
900     RTFCHARS.put("?u", "\\'fa");
901     RTFCHARS.put("^a", "\\'e2");
902     RTFCHARS.put("^e", "\\'ea");
903     RTFCHARS.put("^i", "\\'ee");
904     RTFCHARS.put("^o", "\\'f4");
905     RTFCHARS.put("^u", "\\'fa");
906     RTFCHARS.put("\"a", "\\'e4");
907     RTFCHARS.put("\"e", "\\'eb");
908     RTFCHARS.put("\"i", "\\'ef");
909     RTFCHARS.put("\"o", "\\'f6");
910     RTFCHARS.put("\"u", "\\'fc");
911     RTFCHARS.put("~n", "\\'f1");
912     RTFCHARS.put("`A", "\\'c0");
913     RTFCHARS.put("`E", "\\'c8");
914     RTFCHARS.put("`I", "\\'cc");
915     RTFCHARS.put("`O", "\\'d2");
916     RTFCHARS.put("`U", "\\'d9");
917     RTFCHARS.put("?A", "\\'c1");
918     RTFCHARS.put("?E", "\\'c9");
919     RTFCHARS.put("?I", "\\'cd");
920     RTFCHARS.put("?O", "\\'d3");
921     RTFCHARS.put("?U", "\\'da");
922     RTFCHARS.put("^A", "\\'c2");
923     RTFCHARS.put("^E", "\\'ca");
924     RTFCHARS.put("^I", "\\'ce");
925     RTFCHARS.put("^O", "\\'d4");
926     RTFCHARS.put("^U", "\\'db");
927     RTFCHARS.put("\"A", "\\'c4");
928     RTFCHARS.put("\"E", "\\'cb");
929     RTFCHARS.put("\"I", "\\'cf");
930     RTFCHARS.put("\"O", "\\'d6");
931     RTFCHARS.put("\"U", "\\'dc");
932
933     //XML_CHARS.put("\\u00E1", "&#x00E1;");
934   }
935
936     public static void initializeJournalNames() {
937         journalAbbrev = new JournalAbbreviations();//"/resource/journalList.txt");
938
939         // Read external lists, if any (in reverse order, so the upper lists override the lower):
940         String[] lists = prefs.getStringArray("externalJournalLists");
941         if ((lists != null) && (lists.length > 0)) {
942             for (int i=lists.length-1; i>=0; i--) {
943                 try {
944                     journalAbbrev.readJournalList(new File(lists[i]));
945                 } catch (FileNotFoundException e) {
946                     // The file couldn't be found... should we tell anyone?
947                     Globals.logger(e.getMessage());
948                 }
949             }
950         }
951
952         // Read personal list, if set up:
953         if (prefs.get("personalJournalList") != null) {
954             try {
955                 journalAbbrev.readJournalList(new File(prefs.get("personalJournalList")));
956             } catch (FileNotFoundException e) {
957                 Globals.logger("Personal journal list file '"+prefs.get("personalJournalList")+
958                     "' not found.");
959             }
960         }
961
962
963     }
964
965 }