1 /* (C) 2003 Nizar N. Batada, Morten O. Alver
3 All programs in this directory and
4 subdirectories are published under the GNU General Public License as
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.
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.
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
22 Further information about the GNU GPL is available at:
23 http://www.gnu.org/copyleft/gpl.ja.html
26 package net.sf.jabref;
30 import java.util.logging.* ;
31 import java.util.logging.Filter ;
34 import javax.swing.* ;
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;
41 public class Globals {
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. :-)
47 STANDARD_EXPORT_COUNT = 5, // The number of standard export formats.
48 METADATA_LINE_LENGTH = 70; // The line length used to wrap metadata.
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();
61 public static String VERSION,
67 TBuildInfo bi = new TBuildInfo(buildInfos) ;
68 VERSION = bi.getBUILD_VERSION() ;
69 BUILD = bi.getBUILD_NUMBER() ;
70 BUILD_DATE = bi.getBUILD_DATE() ;
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/",
81 DOI_LOOKUP_PREFIX = "http://dx.doi.org/",
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"};
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"};
97 // Map that maps from month string labels to
98 public static Map MONTH_STRINGS = new HashMap();
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");
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");
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.
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.
131 public static void logger(String s) {
132 Logger.global.info(s);
135 public static void turnOffLogging() { // only log exceptions
136 Logger.global.setLevel(java.util.logging.Level.SEVERE);
139 // should be only called once
140 public static void turnOnConsoleLogging() {
141 Logger.global.addHandler(consoleHandler);
147 public static void turnOnFileLogging() {
148 Logger.global.setLevel(java.util.logging.Level.ALL);
149 java.util.logging.Handler handler;
150 handler = new ConsoleHandler();
152 handler = new FileHandler(logfile); // this will overwrite
154 catch (IOException e) { //can't open log file so use console
158 Logger.global.addHandler(handler);
160 handler.setFilter(new Filter() { // select what gets logged
161 public boolean isLoggable(LogRecord record) {
170 public static final String
171 KEY_FIELD = "bibtexkey",
173 GROUPSEARCH = "__groupsearch",
174 MARKED = "__markedentry",
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";
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);
190 public static JournalAbbreviations journalAbbrev;
193 public static String lang(String key, String[] params) {
194 String translation = null;
196 if (Globals.messages != null) {
197 translation = Globals.messages.getString(key.replaceAll(" ", "_"));
200 catch (MissingResourceException ex) {
202 //logger("Warning: could not get translation for \""
205 if ((translation != null) && (translation.length() != 0)) {
206 translation = translation.replaceAll("_", " ");
207 StringBuffer sb = new StringBuffer();
210 for (int i = 0; i < translation.length(); ++i) {
211 c = translation.charAt(i);
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
232 default: // anything else, e.g. %
239 return sb.toString();
244 public static String lang(String key) {
245 return lang(key, (String[])null);
248 public static String lang(String key, String s1) {
249 return lang(key, new String[]{s1});
252 public static String lang(String key, String s1, String s2) {
253 return lang(key, new String[]{s1, s2});
256 public static String lang(String key, String s1, String s2, String s3) {
257 return lang(key, new String[]{s1, s2, s3});
260 public static String menuTitle(String key) {
261 String translation = null;
263 if (Globals.messages != null) {
264 translation = Globals.menuTitles.getString(key.replaceAll(" ", "_"));
267 catch (MissingResourceException ex) {
270 //System.err.println("Warning: could not get menu item translation for \""
274 if ((translation != null) && (translation.length() != 0)) {
275 return translation.replaceAll("_", " ");
282 public static String getIntegrityMessage(String key)
284 String translation = null;
286 if (Globals.intMessages != null) {
287 translation = Globals.intMessages.getString(key);
290 catch (MissingResourceException ex) {
293 // System.err.println("Warning: could not get menu item translation for \""
296 if ((translation != null) && (translation.length() != 0)) {
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);
312 return (BibtexEntryType) o;
315 return BibtexEntryType.OTHER;
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;
328 * This method provides the correct opening brace to use when writing a field
330 * @return A String containing the braces to use.
332 public static String getOpeningBrace() {
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.
338 if (prefs.getBoolean("autoDoubleBraces"))
346 * This method provides the correct closing brace to use when writing a field
348 * @return A String containing the braces to use.
350 public static String getClosingBrace() {
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.
356 if (prefs.getBoolean("autoDoubleBraces"))
363 /* public static void setupKeyBindings(JabRefPreferences prefs) {
366 public static String getNewFile(JFrame owner, JabRefPreferences prefs,
367 File directory, String extension,
369 boolean updateWorkingDirectory) {
370 return getNewFile(owner, prefs, directory, extension, null, dialogType,
371 updateWorkingDirectory, false);
375 public static String getNewFile(JFrame owner, JabRefPreferences prefs,
376 File directory, String extension,
379 boolean updateWorkingDirectory) {
380 return getNewFile(owner, prefs, directory, extension, description, dialogType,
381 updateWorkingDirectory, false);
385 public static String getNewFile(JFrame owner, JabRefPreferences prefs,
386 File directory, String extension, OpenFileFilter off,
388 boolean updateWorkingDirectory) {
389 return getNewFile(owner, prefs, directory, extension, null, off, dialogType,
390 updateWorkingDirectory, false);
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);
400 public static String getNewDir(JFrame owner, JabRefPreferences prefs,
401 File directory, String extension,
403 int dialogType, boolean updateWorkingDirectory) {
404 return getNewFile(owner, prefs, directory, extension, description, dialogType,
405 updateWorkingDirectory, true);
408 private static String getNewFile(JFrame owner, JabRefPreferences prefs,
409 File directory, String extension,
412 boolean updateWorkingDirectory,
415 OpenFileFilter off = null;
417 if (extension == null)
418 off = new OpenFileFilter();
419 else if (!extension.equals(NONE))
420 off = new OpenFileFilter(extension);
422 return getNewFile(owner, prefs, directory, extension, description, off, dialogType, updateWorkingDirectory, dirOnly);
425 private static String getNewFile(JFrame owner, JabRefPreferences prefs,
426 File directory, String extension,
430 boolean updateWorkingDirectory,
434 return getNewFileForMac(owner, directory, extension, dialogType,
435 updateWorkingDirectory, dirOnly, off);
438 JFileChooser fc = null;
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);
452 fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
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);
461 else if (dialogType == JFileChooser.SAVE_DIALOG){
462 dialogResult = fc.showSaveDialog(owner);
465 dialogResult = fc.showDialog(owner, description);
468 // the getSelectedFile method returns a valid fileselection
469 // (if something is selected) indepentently from dialog return status
470 if (dialogResult != JFileChooser.APPROVE_OPTION)
474 File selectedFile = fc.getSelectedFile();
475 if (selectedFile == null) { // cancel
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)) {
484 // add the first extension if there are multiple extensions
485 selectedFile = new File(selectedFile.getPath() + extension.split("[, ]+",0)[0]);
488 if (updateWorkingDirectory) {
489 prefs.put("workingDirectory", selectedFile.getPath());
491 return selectedFile.getAbsolutePath();
494 private static String getNewFileForMac(JFrame owner,
495 File directory, String extensions,
497 boolean updateWorkingDirectory,
499 FilenameFilter filter) {
501 FileDialog fc = new FileDialog(owner);
502 //fc.setFilenameFilter(filter);
503 if (directory != null) {
504 fc.setDirectory(directory.getParent());
506 if (dialogType == JFileChooser.OPEN_DIALOG) {
507 fc.setMode(FileDialog.LOAD);
510 fc.setMode(FileDialog.SAVE);
515 if (fc.getFile() != null) {
516 Globals.prefs.put("workingDirectory", fc.getDirectory() + fc.getFile());
517 return fc.getDirectory() + fc.getFile();
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();
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));
541 // Start the thread that monitors file time stamps.
542 //Util.pr("Starting FileUpdateMonitor thread. Globals line 293.");
543 fileUpdateMonitor.start();
546 SHORTCUT_MASK = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
547 } catch (Throwable t) {
551 HTML_CHARS.put("\\{\\\\\\\"\\{a\\}\\}", "ä");
552 HTML_CHARS.put("\\{\\\\\\\"\\{A\\}\\}", "Ä");
553 HTML_CHARS.put("\\{\\\\\\\"\\{e\\}\\}", "ë");
554 HTML_CHARS.put("\\{\\\\\\\"\\{E\\}\\}", "Ë");
555 HTML_CHARS.put("\\{\\\\\\\"\\{i\\}\\}", "ï");
556 HTML_CHARS.put("\\{\\\\\\\"\\{I\\}\\}", "Ï");
557 HTML_CHARS.put("\\{\\\\\\\"\\{o\\}\\}", "ö");
558 HTML_CHARS.put("\\{\\\\\\\"\\{O\\}\\}", "Ö");
559 HTML_CHARS.put("\\{\\\\\\\"\\{u\\}\\}", "ü");
560 HTML_CHARS.put("\\{\\\\\\\"\\{U\\}\\}", "Ü");
562 HTML_CHARS.put("\\{\\\\\\`\\{e\\}\\}", "è");
563 HTML_CHARS.put("\\{\\\\\\`\\{E\\}\\}", "È");
564 HTML_CHARS.put("\\{\\\\\\`\\{i\\}\\}", "ì");
565 HTML_CHARS.put("\\{\\\\\\`\\{I\\}\\}", "Ì");
566 HTML_CHARS.put("\\{\\\\\\`\\{o\\}\\}", "ò");
567 HTML_CHARS.put("\\{\\\\\\`\\{O\\}\\}", "Ò");
568 HTML_CHARS.put("\\{\\\\\\`\\{u\\}\\}", "ù");
569 HTML_CHARS.put("\\{\\\\\\`\\{U\\}\\}", "Ù");
571 HTML_CHARS.put("\\{\\\\\\'\\{e\\}\\}", "é");
572 HTML_CHARS.put("\\{\\\\\\'\\{E\\}\\}", "É");
573 HTML_CHARS.put("\\{\\\\\\'\\{i\\}\\}", "í");
574 HTML_CHARS.put("\\{\\\\\\'\\{I\\}\\}", "Í");
575 HTML_CHARS.put("\\{\\\\\\'\\{o\\}\\}", "ó");
576 HTML_CHARS.put("\\{\\\\\\'\\{O\\}\\}", "Ó");
577 HTML_CHARS.put("\\{\\\\\\'\\{u\\}\\}", "ú");
578 HTML_CHARS.put("\\{\\\\\\'\\{U\\}\\}", "Ú");
579 HTML_CHARS.put("\\{\\\\\\'\\{a\\}\\}", "á");
580 HTML_CHARS.put("\\{\\\\\\'\\{A\\}\\}", "Á");
581 HTML_CHARS.put("\\{\\\\\\^\\{o\\}\\}", "ô");
582 HTML_CHARS.put("\\{\\\\\\^\\{O\\}\\}", "Ô");
583 HTML_CHARS.put("\\{\\\\\\^\\{u\\}\\}", "û");
584 HTML_CHARS.put("\\{\\\\\\^\\{U\\}\\}", "Û");
585 HTML_CHARS.put("\\{\\\\\\^\\{e\\}\\}", "ê");
586 HTML_CHARS.put("\\{\\\\\\^\\{E\\}\\}", "Ê");
587 HTML_CHARS.put("\\{\\\\\\^\\{i\\}\\}", "î");
588 HTML_CHARS.put("\\{\\\\\\^\\{I\\}\\}", "Î");
589 HTML_CHARS.put("\\{\\\\\\~\\{o\\}\\}", "õ");
590 HTML_CHARS.put("\\{\\\\\\~\\{O\\}\\}", "Õ");
591 HTML_CHARS.put("\\{\\\\\\~\\{n\\}\\}", "ñ");
592 HTML_CHARS.put("\\{\\\\\\~\\{N\\}\\}", "Ñ");
593 HTML_CHARS.put("\\{\\\\\\~\\{a\\}\\}", "ã");
594 HTML_CHARS.put("\\{\\\\\\~\\{A\\}\\}", "Ã");
597 HTMLCHARS.put("\"a", "ä");
598 HTMLCHARS.put("\"A", "Ä");
599 HTMLCHARS.put("\"e", "ë");
600 HTMLCHARS.put("\"E", "Ë");
601 HTMLCHARS.put("\"i", "ï");
602 HTMLCHARS.put("\"I", "Ï");
603 HTMLCHARS.put("\"o", "ö");
604 HTMLCHARS.put("\"O", "Ö");
605 HTMLCHARS.put("\"u", "ü");
606 HTMLCHARS.put("\"U", "Ü");
607 HTMLCHARS.put("`a", "à");
608 HTMLCHARS.put("`A", "À");
609 HTMLCHARS.put("`e", "è");
610 HTMLCHARS.put("`E", "È");
611 HTMLCHARS.put("`i", "ì");
612 HTMLCHARS.put("`I", "Ì");
613 HTMLCHARS.put("`o", "ò");
614 HTMLCHARS.put("`O", "Ò");
615 HTMLCHARS.put("`u", "ù");
616 HTMLCHARS.put("`U", "Ù");
617 HTMLCHARS.put("'e", "é");
618 HTMLCHARS.put("'E", "É");
619 HTMLCHARS.put("'i", "í");
620 HTMLCHARS.put("'I", "Í");
621 HTMLCHARS.put("'o", "ó");
622 HTMLCHARS.put("'O", "Ó");
623 HTMLCHARS.put("'u", "ú");
624 HTMLCHARS.put("'U", "Ú");
625 HTMLCHARS.put("'a", "á");
626 HTMLCHARS.put("'A", "Á");
627 HTMLCHARS.put("^o", "ô");
628 HTMLCHARS.put("^O", "Ô");
629 HTMLCHARS.put("^u", "û");
630 HTMLCHARS.put("^U", "Û");
631 HTMLCHARS.put("^e", "ê");
632 HTMLCHARS.put("^E", "Ê");
633 HTMLCHARS.put("^i", "î");
634 HTMLCHARS.put("^I", "Î");
635 HTMLCHARS.put("~o", "õ");
636 HTMLCHARS.put("~O", "Õ");
637 HTMLCHARS.put("~n", "ñ");
638 HTMLCHARS.put("~N", "Ñ");
639 HTMLCHARS.put("~a", "ã");
640 HTMLCHARS.put("~A", "Ã");
641 HTMLCHARS.put("cc", "ç");
642 HTMLCHARS.put("cC", "Ç");
644 HTML_CHARS.put("\\{\\\\\\\"a\\}", "ä");
645 HTML_CHARS.put("\\{\\\\\\\"A\\}", "Ä");
646 HTML_CHARS.put("\\{\\\\\\\"e\\}", "ë");
647 HTML_CHARS.put("\\{\\\\\\\"E\\}", "Ë");
648 HTML_CHARS.put("\\{\\\\\\\"i\\}", "ï");
649 HTML_CHARS.put("\\{\\\\\\\"I\\}", "Ï");
650 HTML_CHARS.put("\\{\\\\\\\"o\\}", "ö");
651 HTML_CHARS.put("\\{\\\\\\\"O\\}", "Ö");
652 HTML_CHARS.put("\\{\\\\\\\"u\\}", "ü");
653 HTML_CHARS.put("\\{\\\\\\\"U\\}", "Ü");
655 HTML_CHARS.put("\\{\\\\\\`e\\}", "è");
656 HTML_CHARS.put("\\{\\\\\\`E\\}", "È");
657 HTML_CHARS.put("\\{\\\\\\`i\\}", "ì");
658 HTML_CHARS.put("\\{\\\\\\`I\\}", "Ì");
659 HTML_CHARS.put("\\{\\\\\\`o\\}", "ò");
660 HTML_CHARS.put("\\{\\\\\\`O\\}", "Ò");
661 HTML_CHARS.put("\\{\\\\\\`u\\}", "ù");
662 HTML_CHARS.put("\\{\\\\\\`U\\}", "Ù");
663 HTML_CHARS.put("\\{\\\\\\'A\\}", "é");
664 HTML_CHARS.put("\\{\\\\\\'E\\}", "É");
665 HTML_CHARS.put("\\{\\\\\\'i\\}", "í");
666 HTML_CHARS.put("\\{\\\\\\'I\\}", "Í");
667 HTML_CHARS.put("\\{\\\\\\'o\\}", "ó");
668 HTML_CHARS.put("\\{\\\\\\'O\\}", "Ó");
669 HTML_CHARS.put("\\{\\\\\\'u\\}", "ú");
670 HTML_CHARS.put("\\{\\\\\\'U\\}", "Ú");
671 HTML_CHARS.put("\\{\\\\\\'a\\}", "á");
672 HTML_CHARS.put("\\{\\\\\\'A\\}", "Á");
674 HTML_CHARS.put("\\{\\\\\\^o\\}", "ô");
675 HTML_CHARS.put("\\{\\\\\\^O\\}", "Ô");
676 HTML_CHARS.put("\\{\\\\\\^u\\}", "û");
677 HTML_CHARS.put("\\{\\\\\\^U\\}", "Û");
678 HTML_CHARS.put("\\{\\\\\\^e\\}", "ê");
679 HTML_CHARS.put("\\{\\\\\\^E\\}", "Ê");
680 HTML_CHARS.put("\\{\\\\\\^i\\}", "î");
681 HTML_CHARS.put("\\{\\\\\\^I\\}", "Î");
682 HTML_CHARS.put("\\{\\\\\\~o\\}", "õ");
683 HTML_CHARS.put("\\{\\\\\\~O\\}", "Õ");
684 HTML_CHARS.put("\\{\\\\\\~n\\}", "ñ");
685 HTML_CHARS.put("\\{\\\\\\~N\\}", "Ñ");
686 HTML_CHARS.put("\\{\\\\\\~a\\}", "ã");
687 HTML_CHARS.put("\\{\\\\\\~A\\}", "Ã");
689 HTML_CHARS.put("\\{\\\\c c\\}", "ç");
690 HTML_CHARS.put("\\{\\\\c C\\}", "Ç");
693 XML_CHARS.put("\\{\\\\\\\"\\{a\\}\\}", "ä");
694 XML_CHARS.put("\\{\\\\\\\"\\{A\\}\\}", "Ä");
695 XML_CHARS.put("\\{\\\\\\\"\\{e\\}\\}", "ë");
696 XML_CHARS.put("\\{\\\\\\\"\\{E\\}\\}", "Ë");
697 XML_CHARS.put("\\{\\\\\\\"\\{i\\}\\}", "ï");
698 XML_CHARS.put("\\{\\\\\\\"\\{I\\}\\}", "Ï");
699 XML_CHARS.put("\\{\\\\\\\"\\{o\\}\\}", "ö");
700 XML_CHARS.put("\\{\\\\\\\"\\{O\\}\\}", "Ö");
701 XML_CHARS.put("\\{\\\\\\\"\\{u\\}\\}", "ü");
702 XML_CHARS.put("\\{\\\\\\\"\\{U\\}\\}", "Ü");
704 XML_CHARS.put("\\{\\\\\\`\\{e\\}\\}", "è");
705 XML_CHARS.put("\\{\\\\\\`\\{E\\}\\}", "È");
706 XML_CHARS.put("\\{\\\\\\`\\{i\\}\\}", "ì");
707 XML_CHARS.put("\\{\\\\\\`\\{I\\}\\}", "Ì");
708 XML_CHARS.put("\\{\\\\\\`\\{o\\}\\}", "ò");
709 XML_CHARS.put("\\{\\\\\\`\\{O\\}\\}", "Ò");
710 XML_CHARS.put("\\{\\\\\\`\\{u\\}\\}", "ù");
711 XML_CHARS.put("\\{\\\\\\`\\{U\\}\\}", "Ù");
712 XML_CHARS.put("\\{\\\\\\'\\{e\\}\\}", "é");
713 XML_CHARS.put("\\{\\\\\\\uFFFD\\{E\\}\\}", "É");
714 XML_CHARS.put("\\{\\\\\\\uFFFD\\{i\\}\\}", "í");
715 XML_CHARS.put("\\{\\\\\\\uFFFD\\{I\\}\\}", "Í");
716 XML_CHARS.put("\\{\\\\\\\uFFFD\\{o\\}\\}", "ó");
717 XML_CHARS.put("\\{\\\\\\\uFFFD\\{O\\}\\}", "Ó");
718 XML_CHARS.put("\\{\\\\\\\uFFFD\\{u\\}\\}", "ú");
719 XML_CHARS.put("\\{\\\\\\\uFFFD\\{U\\}\\}", "Ú");
720 XML_CHARS.put("\\{\\\\\\\uFFFD\\{a\\}\\}", "á");
721 XML_CHARS.put("\\{\\\\\\\uFFFD\\{A\\}\\}", "Á");
723 XML_CHARS.put("\\{\\\\\\^\\{o\\}\\}", "ô");
724 XML_CHARS.put("\\{\\\\\\^\\{O\\}\\}", "Ô");
725 XML_CHARS.put("\\{\\\\\\^\\{u\\}\\}", "ù");
726 XML_CHARS.put("\\{\\\\\\^\\{U\\}\\}", "Ù");
727 XML_CHARS.put("\\{\\\\\\^\\{e\\}\\}", "ê");
728 XML_CHARS.put("\\{\\\\\\^\\{E\\}\\}", "Ê");
729 XML_CHARS.put("\\{\\\\\\^\\{i\\}\\}", "î");
730 XML_CHARS.put("\\{\\\\\\^\\{I\\}\\}", "Î");
731 XML_CHARS.put("\\{\\\\\\~\\{o\\}\\}", "õ");
732 XML_CHARS.put("\\{\\\\\\~\\{O\\}\\}", "Õ");
733 XML_CHARS.put("\\{\\\\\\~\\{n\\}\\}", "ñ");
734 XML_CHARS.put("\\{\\\\\\~\\{N\\}\\}", "Ñ");
735 XML_CHARS.put("\\{\\\\\\~\\{a\\}\\}", "ã");
736 XML_CHARS.put("\\{\\\\\\~\\{A\\}\\}", "Ã");
739 XML_CHARS.put("\\{\\\\\\\"a\\}", "ä");
740 XML_CHARS.put("\\{\\\\\\\"A\\}", "Ä");
741 XML_CHARS.put("\\{\\\\\\\"e\\}", "ë");
742 XML_CHARS.put("\\{\\\\\\\"E\\}", "Ë");
743 XML_CHARS.put("\\{\\\\\\\"i\\}", "ï");
744 XML_CHARS.put("\\{\\\\\\\"I\\}", "Ï");
745 XML_CHARS.put("\\{\\\\\\\"o\\}", "ö");
746 XML_CHARS.put("\\{\\\\\\\"O\\}", "Ö");
747 XML_CHARS.put("\\{\\\\\\\"u\\}", "ü");
748 XML_CHARS.put("\\{\\\\\\\"U\\}", "Ü");
750 XML_CHARS.put("\\{\\\\\\`e\\}", "è");
751 XML_CHARS.put("\\{\\\\\\`E\\}", "È");
752 XML_CHARS.put("\\{\\\\\\`i\\}", "ì");
753 XML_CHARS.put("\\{\\\\\\`I\\}", "Ì");
754 XML_CHARS.put("\\{\\\\\\`o\\}", "ò");
755 XML_CHARS.put("\\{\\\\\\`O\\}", "Ò");
756 XML_CHARS.put("\\{\\\\\\`u\\}", "ù");
757 XML_CHARS.put("\\{\\\\\\`U\\}", "Ù");
758 XML_CHARS.put("\\{\\\\\\'e\\}", "é");
759 XML_CHARS.put("\\{\\\\\\'E\\}", "É");
760 XML_CHARS.put("\\{\\\\\\'i\\}", "í");
761 XML_CHARS.put("\\{\\\\\\'I\\}", "Í");
762 XML_CHARS.put("\\{\\\\\\'o\\}", "ó");
763 XML_CHARS.put("\\{\\\\\\'O\\}", "Ó");
764 XML_CHARS.put("\\{\\\\\\'u\\}", "ú");
765 XML_CHARS.put("\\{\\\\\\'U\\}", "Ú");
766 XML_CHARS.put("\\{\\\\\\'a\\}", "á");
767 XML_CHARS.put("\\{\\\\\\'A\\}", "Á");
769 XML_CHARS.put("\\{\\\\\\^o\\}", "ô");
770 XML_CHARS.put("\\{\\\\\\^O\\}", "Ô");
771 XML_CHARS.put("\\{\\\\\\^u\\}", "ù");
772 XML_CHARS.put("\\{\\\\\\^U\\}", "Ù");
773 XML_CHARS.put("\\{\\\\\\^e\\}", "ê");
774 XML_CHARS.put("\\{\\\\\\^E\\}", "Ê");
775 XML_CHARS.put("\\{\\\\\\^i\\}", "î");
776 XML_CHARS.put("\\{\\\\\\^I\\}", "Î");
777 XML_CHARS.put("\\{\\\\\\~o\\}", "õ");
778 XML_CHARS.put("\\{\\\\\\~O\\}", "Õ");
779 XML_CHARS.put("\\{\\\\\\~n\\}", "ñ");
780 XML_CHARS.put("\\{\\\\\\~N\\}", "Ñ");
781 XML_CHARS.put("\\{\\\\\\~a\\}", "ã");
782 XML_CHARS.put("\\{\\\\\\~A\\}", "Ã");
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", "");
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");
933 //XML_CHARS.put("\\u00E1", "á");
936 public static void initializeJournalNames() {
937 journalAbbrev = new JournalAbbreviations();//"/resource/journalList.txt");
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--) {
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());
952 // Read personal list, if set up:
953 if (prefs.get("personalJournalList") != null) {
955 journalAbbrev.readJournalList(new File(prefs.get("personalJournalList")));
956 } catch (FileNotFoundException e) {
957 Globals.logger("Personal journal list file '"+prefs.get("personalJournalList")+