From ef9af291584c4ef04ac304e56854050e39d74406 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 29 Jul 2015 14:54:19 +0200 Subject: [PATCH 01/23] Delete unused variable STANDARD_EXPORT_COUNT --- src/main/java/net/sf/jabref/Globals.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/net/sf/jabref/Globals.java b/src/main/java/net/sf/jabref/Globals.java index 278e198982d..171cbab88ad 100644 --- a/src/main/java/net/sf/jabref/Globals.java +++ b/src/main/java/net/sf/jabref/Globals.java @@ -105,7 +105,6 @@ public ResourceBundle newBundle(String baseName, Locale locale, private static int SHORTCUT_MASK = -1; - public static int STANDARD_EXPORT_COUNT = 5; // The number of standard export formats. public static final int METADATA_LINE_LENGTH = 70; // The line length used to wrap metadata. // used at highlighting in preview area. From 8a37c11a6f1c1e98b4b08a6ecd1778cbf9649033 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 29 Jul 2015 14:56:24 +0200 Subject: [PATCH 02/23] Move METADATA_LINE_LENGTH to MetaData --- src/main/java/net/sf/jabref/Globals.java | 2 -- src/main/java/net/sf/jabref/MetaData.java | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/sf/jabref/Globals.java b/src/main/java/net/sf/jabref/Globals.java index 171cbab88ad..9164488ac9b 100644 --- a/src/main/java/net/sf/jabref/Globals.java +++ b/src/main/java/net/sf/jabref/Globals.java @@ -105,8 +105,6 @@ public ResourceBundle newBundle(String baseName, Locale locale, private static int SHORTCUT_MASK = -1; - public static final int METADATA_LINE_LENGTH = 70; // The line length used to wrap metadata. - // used at highlighting in preview area. // Color chosen similar to JTextComponent.getSelectionColor(), which is // used at highlighting words at the editor diff --git a/src/main/java/net/sf/jabref/MetaData.java b/src/main/java/net/sf/jabref/MetaData.java index 4dfa8090834..14a1b330cb3 100644 --- a/src/main/java/net/sf/jabref/MetaData.java +++ b/src/main/java/net/sf/jabref/MetaData.java @@ -29,6 +29,8 @@ public class MetaData implements Iterable { private static final String PREFIX_KEYPATTERN = "keypattern_"; private static final String KEYPATTERNDEFAULT = "keypatterndefault"; + + private static final int METADATA_LINE_LENGTH = 70; // The line length used to wrap metadata. private final HashMap> metaData = new HashMap>(); private GroupTreeNode groupsRoot = null; @@ -263,7 +265,7 @@ public void writeMetaData(Writer out) throws IOException { sb.append(StringUtil.quote(orderedData.elementAt(j), ";", '\\')).append(";"); } sb.append("}"); - wrapStringBuffer(sb, Globals.METADATA_LINE_LENGTH); + wrapStringBuffer(sb, METADATA_LINE_LENGTH); sb.append(Globals.NEWLINE); sb.append(Globals.NEWLINE); @@ -290,7 +292,7 @@ public void writeMetaData(Writer out) throws IOException { while (tok.hasMoreTokens()) { StringBuffer s = new StringBuffer(StringUtil.quote(tok.nextToken(), ";", '\\') + ";"); - wrapStringBuffer(s, Globals.METADATA_LINE_LENGTH); + wrapStringBuffer(s, METADATA_LINE_LENGTH); sb.append(s); sb.append(Globals.NEWLINE); } From 46edd29c6aece3c1b9e2969417012d35d2499404 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 29 Jul 2015 14:59:28 +0200 Subject: [PATCH 03/23] Move highlightColor to LayoutEntry --- src/main/java/net/sf/jabref/Globals.java | 5 ----- .../java/net/sf/jabref/export/layout/LayoutEntry.java | 8 ++++++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/sf/jabref/Globals.java b/src/main/java/net/sf/jabref/Globals.java index 9164488ac9b..990db024ef1 100644 --- a/src/main/java/net/sf/jabref/Globals.java +++ b/src/main/java/net/sf/jabref/Globals.java @@ -105,11 +105,6 @@ public ResourceBundle newBundle(String baseName, Locale locale, private static int SHORTCUT_MASK = -1; - // used at highlighting in preview area. - // Color chosen similar to JTextComponent.getSelectionColor(), which is - // used at highlighting words at the editor - public static final String highlightColor = "#3399FF"; - private static final String RESOURCE_PREFIX = "resource/JabRef", MENU_RESOURCE_PREFIX = "resource/Menu", INTEGRITY_RESOURCE_PREFIX = "resource/IntegrityMessage"; diff --git a/src/main/java/net/sf/jabref/export/layout/LayoutEntry.java b/src/main/java/net/sf/jabref/export/layout/LayoutEntry.java index 95dc1baf8b9..b876e1b15b9 100644 --- a/src/main/java/net/sf/jabref/export/layout/LayoutEntry.java +++ b/src/main/java/net/sf/jabref/export/layout/LayoutEntry.java @@ -46,7 +46,11 @@ class LayoutEntry { private final String classPrefix; private ArrayList invalidFormatter = null; - + + // used at highlighting in preview area. + // Color chosen similar to JTextComponent.getSelectionColor(), which is + // used at highlighting words at the editor + public static final String HIGHLIGHT_COLOR = "#3399FF"; public LayoutEntry(StringInt si, String classPrefix_) throws Exception { type = si.i; @@ -536,7 +540,7 @@ private String highlightWords(String text, ArrayList toHighlight) { Matcher matcher = Globals.getPatternForWords(toHighlight).matcher(text); if (Character.isLetterOrDigit(text.charAt(0))) { - String hlColor = Globals.highlightColor; + String hlColor = HIGHLIGHT_COLOR; StringBuffer sb = new StringBuffer(); boolean foundSomething = false; From 7c9db6391e355ab9d29a08e9c10ca9048b783a56 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 29 Jul 2015 15:03:45 +0200 Subject: [PATCH 04/23] Move additionalFields to BibtexFields and resort members in Globals --- src/main/java/net/sf/jabref/BibtexFields.java | 12 ++++++++---- src/main/java/net/sf/jabref/Globals.java | 15 +++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/main/java/net/sf/jabref/BibtexFields.java b/src/main/java/net/sf/jabref/BibtexFields.java index b6ca5e6f0ad..def975cc5d5 100644 --- a/src/main/java/net/sf/jabref/BibtexFields.java +++ b/src/main/java/net/sf/jabref/BibtexFields.java @@ -41,8 +41,7 @@ import org.w3c.dom.Element; import org.w3c.dom.NodeList; -public class BibtexFields -{ +public class BibtexFields { public static final String KEY_FIELD = "bibtexkey"; @@ -53,7 +52,12 @@ public class BibtexFields public static final String MARKED = "__markedentry"; public static final String OWNER = "owner"; public static final String TIMESTAMP = "timestamp"; // it's also definied at the JabRefPreferences class - private static final String ENTRYTYPE = "entrytype"; + private static final String ENTRYTYPE = "entrytype"; + + /* + * some extra field definitions + */ + private static final String ADDITIONAL_FIELDS = "/resource/fields/fields.xml"; public static final String// Using this when I have no database open or when I read // non bibtex file formats (used by the ImportFormatReader.java) @@ -241,7 +245,7 @@ private BibtexFields() add(dummy); // read external field definitions - readXML(Globals.additionalFields); + readXML(ADDITIONAL_FIELDS); // collect all public fields for the PUBLIC_FIELDS array Vector pFields = new Vector(fieldSet.size()); diff --git a/src/main/java/net/sf/jabref/Globals.java b/src/main/java/net/sf/jabref/Globals.java index 990db024ef1..90254ebcc9b 100644 --- a/src/main/java/net/sf/jabref/Globals.java +++ b/src/main/java/net/sf/jabref/Globals.java @@ -50,10 +50,6 @@ public class Globals { - - public static final String JOURNALS_IEEE_INTERNAL_LIST = "/resource/IEEEJournalList.txt"; - public static RemoteListenerServerLifecycle remoteListener = new RemoteListenerServerLifecycle(); - /** * {@link Control} class allowing properties bundles to be in different encodings. * @@ -101,7 +97,8 @@ public ResourceBundle newBundle(String baseName, Locale locale, return bundle; } } - + + public static RemoteListenerServerLifecycle remoteListener = new RemoteListenerServerLifecycle(); private static int SHORTCUT_MASK = -1; @@ -109,11 +106,9 @@ public ResourceBundle newBundle(String baseName, Locale locale, INTEGRITY_RESOURCE_PREFIX = "resource/IntegrityMessage"; public static final String JOURNALS_FILE_BUILTIN = "/resource/journalList.txt"; - /* - * some extra field definitions - */ - public static final String additionalFields = "/resource/fields/fields.xml"; - + + public static final String JOURNALS_IEEE_INTERNAL_LIST = "/resource/IEEEJournalList.txt"; + private static ResourceBundle messages; private static ResourceBundle menuTitles; private static ResourceBundle intMessages; From de65d084922507cf2c884d43f35c5c5f0e1bd7cd Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 29 Jul 2015 15:06:56 +0200 Subject: [PATCH 05/23] Inline locale to the only method where it is used --- src/main/java/net/sf/jabref/Globals.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/sf/jabref/Globals.java b/src/main/java/net/sf/jabref/Globals.java index 90254ebcc9b..683849fb555 100644 --- a/src/main/java/net/sf/jabref/Globals.java +++ b/src/main/java/net/sf/jabref/Globals.java @@ -122,8 +122,6 @@ public ResourceBundle newBundle(String baseName, Locale locale, public static final BuildInfo BUILD_INFO = new BuildInfo(); - private static Locale locale; - public static final String FILETYPE_PREFS_EXT = "_dir", SELECTOR_META_PREFIX = "selector_", PROTECTED_FLAG_META = "protectedFlag", LAYOUT_PREFIX = "/resource/layout/", MAC = "Mac OS X", @@ -254,12 +252,12 @@ public static void stopAutoSaveManager() { } public static void setLanguage(String language, String country) { - Globals.locale = new Locale(language, country); - Globals.messages = ResourceBundle.getBundle(Globals.RESOURCE_PREFIX, Globals.locale, new EncodingControl("UTF-8")); - Globals.menuTitles = ResourceBundle.getBundle(Globals.MENU_RESOURCE_PREFIX, Globals.locale, new EncodingControl("UTF-8")); - Globals.intMessages = ResourceBundle.getBundle(Globals.INTEGRITY_RESOURCE_PREFIX, Globals.locale, new EncodingControl("UTF-8")); - Locale.setDefault(Globals.locale); - javax.swing.JComponent.setDefaultLocale(Globals.locale); + Locale locale = new Locale(language, country); + Globals.messages = ResourceBundle.getBundle(Globals.RESOURCE_PREFIX, locale, new EncodingControl("UTF-8")); + Globals.menuTitles = ResourceBundle.getBundle(Globals.MENU_RESOURCE_PREFIX, locale, new EncodingControl("UTF-8")); + Globals.intMessages = ResourceBundle.getBundle(Globals.INTEGRITY_RESOURCE_PREFIX, locale, new EncodingControl("UTF-8")); + Locale.setDefault(locale); + javax.swing.JComponent.setDefaultLocale(locale); } From 7d221fec900f1ce23313262b9e39ea11779b96ed Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 29 Jul 2015 15:08:50 +0200 Subject: [PATCH 06/23] Move Layout_PREFIX to ExportFormat --- src/main/java/net/sf/jabref/Globals.java | 2 +- src/main/java/net/sf/jabref/export/ExportFormat.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/sf/jabref/Globals.java b/src/main/java/net/sf/jabref/Globals.java index 683849fb555..efd609b1932 100644 --- a/src/main/java/net/sf/jabref/Globals.java +++ b/src/main/java/net/sf/jabref/Globals.java @@ -124,7 +124,7 @@ public ResourceBundle newBundle(String baseName, Locale locale, public static final String FILETYPE_PREFS_EXT = "_dir", SELECTOR_META_PREFIX = "selector_", PROTECTED_FLAG_META = "protectedFlag", - LAYOUT_PREFIX = "/resource/layout/", MAC = "Mac OS X", + MAC = "Mac OS X", DOI_LOOKUP_PREFIX = "http://dx.doi.org/", NONE = "_non__", ARXIV_LOOKUP_PREFIX = "http://arxiv.org/abs/", FORMATTER_PACKAGE = "net.sf.jabref.export.layout.format."; diff --git a/src/main/java/net/sf/jabref/export/ExportFormat.java b/src/main/java/net/sf/jabref/export/ExportFormat.java index 1a0b9e1d105..05bb1bb376a 100644 --- a/src/main/java/net/sf/jabref/export/ExportFormat.java +++ b/src/main/java/net/sf/jabref/export/ExportFormat.java @@ -45,7 +45,7 @@ public class ExportFormat implements IExportFormat { private FileFilter fileFilter; private boolean customExport = false; - + private final String LAYOUT_PREFIX = "/resource/layout/"; /** * Initialize another export format based on templates stored in dir with @@ -136,7 +136,7 @@ Reader getReader(String filename) throws IOException { if (customExport) { dir = ""; } else { - dir = Globals.LAYOUT_PREFIX + dir = LAYOUT_PREFIX + (directory == null ? "" : directory + '/'); } return FileActions.getReader(dir + filename); From 8b26c041df7f8371d08b51f77b9b145072a184c8 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 29 Jul 2015 15:10:22 +0200 Subject: [PATCH 07/23] Move ARXIV_LOOKUP_PREFIX to Util --- src/main/java/net/sf/jabref/Globals.java | 1 - src/main/java/net/sf/jabref/util/Util.java | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/sf/jabref/Globals.java b/src/main/java/net/sf/jabref/Globals.java index efd609b1932..e4ee83c3b19 100644 --- a/src/main/java/net/sf/jabref/Globals.java +++ b/src/main/java/net/sf/jabref/Globals.java @@ -126,7 +126,6 @@ public ResourceBundle newBundle(String baseName, Locale locale, PROTECTED_FLAG_META = "protectedFlag", MAC = "Mac OS X", DOI_LOOKUP_PREFIX = "http://dx.doi.org/", NONE = "_non__", - ARXIV_LOOKUP_PREFIX = "http://arxiv.org/abs/", FORMATTER_PACKAGE = "net.sf.jabref.export.layout.format."; public static final String[] ENCODINGS; diff --git a/src/main/java/net/sf/jabref/util/Util.java b/src/main/java/net/sf/jabref/util/Util.java index 85bc01fbb75..2042098239b 100644 --- a/src/main/java/net/sf/jabref/util/Util.java +++ b/src/main/java/net/sf/jabref/util/Util.java @@ -118,6 +118,8 @@ public class Util { private static final EasyDateFormat dateFormatter = new EasyDateFormat(); private static final Log LOGGER = LogFactory.getLog(Util.class); + + private static final String ARXIV_LOOKUP_PREFIX = "http://arxiv.org/abs/"; /** * This method sets the location of a Dialog such that it is centered with @@ -373,7 +375,7 @@ public static void openExternalViewer(MetaData metaData, String link, String fie // Check to see if link field already contains a well formated URL if (!link.startsWith("http://")) { - link = Globals.ARXIV_LOOKUP_PREFIX + link; + link = ARXIV_LOOKUP_PREFIX + link; } } From 3cdad303195c22675004ffc57f508ff25c07aed8 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 29 Jul 2015 15:13:22 +0200 Subject: [PATCH 08/23] Move SKIP_WORDS to LabelPatternUtil --- src/main/java/net/sf/jabref/Globals.java | 2 -- .../java/net/sf/jabref/labelPattern/LabelPatternUtil.java | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/sf/jabref/Globals.java b/src/main/java/net/sf/jabref/Globals.java index e4ee83c3b19..0c2484a73fd 100644 --- a/src/main/java/net/sf/jabref/Globals.java +++ b/src/main/java/net/sf/jabref/Globals.java @@ -195,8 +195,6 @@ public ResourceBundle newBundle(String baseName, Locale locale, public static final boolean ON_MAC = (Globals.osName.equals(Globals.MAC)), ON_WIN = Globals.osName.startsWith("Windows"), ON_LINUX = Globals.osName.startsWith("Linux"); - public static final String[] SKIP_WORDS = {"a", "an", "the", "for", "on", "of"}; - public static final String SEPARATING_CHARS = ";,\n "; public static final String SEPARATING_CHARS_NOSPACE = ";,\n"; diff --git a/src/main/java/net/sf/jabref/labelPattern/LabelPatternUtil.java b/src/main/java/net/sf/jabref/labelPattern/LabelPatternUtil.java index 3f1c69b75b9..fff3e66b080 100644 --- a/src/main/java/net/sf/jabref/labelPattern/LabelPatternUtil.java +++ b/src/main/java/net/sf/jabref/labelPattern/LabelPatternUtil.java @@ -44,6 +44,8 @@ public class LabelPatternUtil { private static final String CHARS = "abcdefghijklmnopqrstuvwxyz"; private static final Log LOGGER = LogFactory.getLog(LabelPatternUtil.class); + + private static final String[] SKIP_WORDS = {"a", "an", "the", "for", "on", "of"}; public static ArrayList DEFAULT_LABELPATTERN; @@ -864,8 +866,8 @@ private static String getTitleWords(int number, BibtexEntry _entry) { if (word.length() == 0) { continue; } - for (int _i = 0; _i < Globals.SKIP_WORDS.length; _i++) { - if (word.equalsIgnoreCase(Globals.SKIP_WORDS[_i])) { + for (int _i = 0; _i < SKIP_WORDS.length; _i++) { + if (word.equalsIgnoreCase(SKIP_WORDS[_i])) { continue mainl; } } From 6ecfc106dc8f56cc746ea920ed2ecac34b8f814d Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 29 Jul 2015 15:14:51 +0200 Subject: [PATCH 09/23] Move SEPARATING_CHARS to DefaultAutoCompleter --- src/main/java/net/sf/jabref/Globals.java | 1 - .../net/sf/jabref/autocompleter/DefaultAutoCompleter.java | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/sf/jabref/Globals.java b/src/main/java/net/sf/jabref/Globals.java index 0c2484a73fd..dd7204d9674 100644 --- a/src/main/java/net/sf/jabref/Globals.java +++ b/src/main/java/net/sf/jabref/Globals.java @@ -195,7 +195,6 @@ public ResourceBundle newBundle(String baseName, Locale locale, public static final boolean ON_MAC = (Globals.osName.equals(Globals.MAC)), ON_WIN = Globals.osName.startsWith("Windows"), ON_LINUX = Globals.osName.startsWith("Linux"); - public static final String SEPARATING_CHARS = ";,\n "; public static final String SEPARATING_CHARS_NOSPACE = ";,\n"; public static SidePaneManager sidePaneManager; diff --git a/src/main/java/net/sf/jabref/autocompleter/DefaultAutoCompleter.java b/src/main/java/net/sf/jabref/autocompleter/DefaultAutoCompleter.java index e2fdfc8523e..d77d802b0a8 100644 --- a/src/main/java/net/sf/jabref/autocompleter/DefaultAutoCompleter.java +++ b/src/main/java/net/sf/jabref/autocompleter/DefaultAutoCompleter.java @@ -29,6 +29,8 @@ class DefaultAutoCompleter extends AbstractAutoCompleter { private final String fieldName; + + private final String SEPARATING_CHARS = ";,\n "; /** * @see AutoCompleterFactory @@ -50,7 +52,7 @@ public void addBibtexEntry(BibtexEntry entry) { String fieldValue = entry.getField(fieldName); if (fieldValue != null) { - StringTokenizer tok = new StringTokenizer(fieldValue, Globals.SEPARATING_CHARS); + StringTokenizer tok = new StringTokenizer(fieldValue, SEPARATING_CHARS); while (tok.hasMoreTokens()) { String word = tok.nextToken(); addWordToIndex(word); From 953040cfe88ec70a02471aa36157e3e08b9dd037 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 29 Jul 2015 15:15:54 +0200 Subject: [PATCH 10/23] Move SEPARATING_CHARS_NOSPACE to Util --- src/main/java/net/sf/jabref/Globals.java | 2 -- src/main/java/net/sf/jabref/util/Util.java | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/sf/jabref/Globals.java b/src/main/java/net/sf/jabref/Globals.java index dd7204d9674..d8a63037177 100644 --- a/src/main/java/net/sf/jabref/Globals.java +++ b/src/main/java/net/sf/jabref/Globals.java @@ -195,8 +195,6 @@ public ResourceBundle newBundle(String baseName, Locale locale, public static final boolean ON_MAC = (Globals.osName.equals(Globals.MAC)), ON_WIN = Globals.osName.startsWith("Windows"), ON_LINUX = Globals.osName.startsWith("Linux"); - public static final String SEPARATING_CHARS_NOSPACE = ";,\n"; - public static SidePaneManager sidePaneManager; // will be overridden in initialization due to feature #857 diff --git a/src/main/java/net/sf/jabref/util/Util.java b/src/main/java/net/sf/jabref/util/Util.java index 2042098239b..1d45ef54fac 100644 --- a/src/main/java/net/sf/jabref/util/Util.java +++ b/src/main/java/net/sf/jabref/util/Util.java @@ -120,6 +120,8 @@ public class Util { private static final Log LOGGER = LogFactory.getLog(Util.class); private static final String ARXIV_LOOKUP_PREFIX = "http://arxiv.org/abs/"; + + private static final String SEPARATING_CHARS_NOSPACE = ";,\n"; /** * This method sets the location of a Dialog such that it is centered with @@ -1597,7 +1599,7 @@ public static ArrayList getSeparatedKeywords(String keywords) { // a more intelligent algorithm would check for the separator chosen (SEPARATING_CHARS_NOSPACE) // if nothing is found, " " is likely to be the separating char. // solution by RisKeywords.java: s.split(",[ ]*") - StringTokenizer tok = new StringTokenizer(keywords, Globals.SEPARATING_CHARS_NOSPACE); + StringTokenizer tok = new StringTokenizer(keywords, SEPARATING_CHARS_NOSPACE); while (tok.hasMoreTokens()) { String word = tok.nextToken().trim(); res.add(word); From 42a5269d9c415bf23c6e0df65ce9ca26ae99c74b Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 29 Jul 2015 15:17:04 +0200 Subject: [PATCH 11/23] Remove unnecessary UNIX_NEWLINE --- src/main/java/net/sf/jabref/Globals.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/net/sf/jabref/Globals.java b/src/main/java/net/sf/jabref/Globals.java index d8a63037177..c5d4361dd3e 100644 --- a/src/main/java/net/sf/jabref/Globals.java +++ b/src/main/java/net/sf/jabref/Globals.java @@ -203,11 +203,6 @@ public ResourceBundle newBundle(String baseName, Locale locale, // Instantiate logger: private static final Log LOGGER = LogFactory.getLog(Globals.class); - - /** - * true if we have unix newlines - */ - public static final boolean UNIX_NEWLINE = Globals.NEWLINE.equals("\n"); /** * "Fieldname" to indicate that a field should be treated as a bibtex From 465f26bf9c1eafa73f47da7bdc101859d22bf7fd Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 29 Jul 2015 15:22:04 +0200 Subject: [PATCH 12/23] Use varargs to remove overloaded lang methods --- src/main/java/net/sf/jabref/Globals.java | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/main/java/net/sf/jabref/Globals.java b/src/main/java/net/sf/jabref/Globals.java index c5d4361dd3e..ece7b9fa239 100644 --- a/src/main/java/net/sf/jabref/Globals.java +++ b/src/main/java/net/sf/jabref/Globals.java @@ -203,6 +203,8 @@ public ResourceBundle newBundle(String baseName, Locale locale, // Instantiate logger: private static final Log LOGGER = LogFactory.getLog(Globals.class); + + public static JournalAbbreviationRepository journalAbbrev; /** * "Fieldname" to indicate that a field should be treated as a bibtex @@ -249,10 +251,7 @@ public static void setLanguage(String language, String country) { javax.swing.JComponent.setDefaultLocale(locale); } - - public static JournalAbbreviationRepository journalAbbrev; - - public static String lang(String key, String[] params) { + public static String lang(String key, String... params) { String translation = null; try { if (Globals.messages != null) { @@ -310,18 +309,6 @@ public static String lang(String key) { return Globals.lang(key, (String[]) null); } - public static String lang(String key, String s1) { - return Globals.lang(key, new String[] {s1}); - } - - public static String lang(String key, String s1, String s2) { - return Globals.lang(key, new String[] {s1, s2}); - } - - public static String lang(String key, String s1, String s2, String s3) { - return Globals.lang(key, new String[] {s1, s2, s3}); - } - public static String menuTitle(String key) { String translation = null; try { From 423b545f82ba7f0ea8f3f0a445f7f324b61c9e24 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 29 Jul 2015 15:24:43 +0200 Subject: [PATCH 13/23] Remove URL_CHARS since they are not used anywhere --- src/main/java/net/sf/jabref/Globals.java | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/main/java/net/sf/jabref/Globals.java b/src/main/java/net/sf/jabref/Globals.java index ece7b9fa239..e3ff271e9f2 100644 --- a/src/main/java/net/sf/jabref/Globals.java +++ b/src/main/java/net/sf/jabref/Globals.java @@ -366,13 +366,11 @@ public static BibtexEntryType getEntryType(String type) { public static final String SPECIAL_COMMAND_CHARS = "\"`^~'c="; - public static final HashMap HTMLCHARS = new HashMap(); public static final HashMap XML_CHARS = new HashMap(); public static final HashMap ASCII2XML_CHARS = new HashMap(); public static final HashMap UNICODE_CHARS = new HashMap(); public static final HashMap RTFCHARS = new HashMap(); - private static final HashMap URL_CHARS = new HashMap(); public static int getShortcutMask() { @@ -389,17 +387,6 @@ public static int getShortcutMask() { static { - - // Special characters in URLs need to be replaced to ensure that the URL - // opens properly on all platforms: - Globals.URL_CHARS.put("<", "%3c"); - Globals.URL_CHARS.put(">", "%3e"); - Globals.URL_CHARS.put("(", "%28"); - Globals.URL_CHARS.put(")", "%29"); - Globals.URL_CHARS.put(" ", "%20"); - Globals.URL_CHARS.put("&", "%26"); - Globals.URL_CHARS.put("$", "%24"); - // Following character definitions contributed by Ervin Kolenovic: // HTML named entities from #192 - #255 (UNICODE Latin-1) Globals.HTMLCHARS.put("`A", "À"); // #192 From 8e8ef0683f67071c5b929e9b61913a7f8b2c5066 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 29 Jul 2015 15:27:23 +0200 Subject: [PATCH 14/23] Move getShortcutMask to JabRefPreferences --- src/main/java/net/sf/jabref/Globals.java | 16 ---------------- .../java/net/sf/jabref/JabRefPreferences.java | 17 ++++++++++++++++- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/main/java/net/sf/jabref/Globals.java b/src/main/java/net/sf/jabref/Globals.java index e3ff271e9f2..846a8b3abe9 100644 --- a/src/main/java/net/sf/jabref/Globals.java +++ b/src/main/java/net/sf/jabref/Globals.java @@ -100,8 +100,6 @@ public ResourceBundle newBundle(String baseName, Locale locale, public static RemoteListenerServerLifecycle remoteListener = new RemoteListenerServerLifecycle(); - private static int SHORTCUT_MASK = -1; - private static final String RESOURCE_PREFIX = "resource/JabRef", MENU_RESOURCE_PREFIX = "resource/Menu", INTEGRITY_RESOURCE_PREFIX = "resource/IntegrityMessage"; @@ -372,20 +370,6 @@ public static BibtexEntryType getEntryType(String type) { public static final HashMap UNICODE_CHARS = new HashMap(); public static final HashMap RTFCHARS = new HashMap(); - - public static int getShortcutMask() { - if (Globals.SHORTCUT_MASK == -1) { - try { - Globals.SHORTCUT_MASK = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); - } catch (Throwable ignored) { - - } - } - - return Globals.SHORTCUT_MASK; - } - - static { // Following character definitions contributed by Ervin Kolenovic: // HTML named entities from #192 - #255 (UNICODE Latin-1) diff --git a/src/main/java/net/sf/jabref/JabRefPreferences.java b/src/main/java/net/sf/jabref/JabRefPreferences.java index dff5856301c..1917c34da17 100644 --- a/src/main/java/net/sf/jabref/JabRefPreferences.java +++ b/src/main/java/net/sf/jabref/JabRefPreferences.java @@ -16,6 +16,7 @@ package net.sf.jabref; import java.awt.Color; +import java.awt.Toolkit; import java.awt.event.InputEvent; import java.io.File; import java.io.FileInputStream; @@ -346,6 +347,8 @@ public class JabRefPreferences { public String WRAPPED_USERNAME; public final String MARKING_WITH_NUMBER_PATTERN; + + private int SHORTCUT_MASK = -1; private final Preferences prefs; @@ -1147,8 +1150,20 @@ private KeyStroke getKeyForMac(KeyStroke ks) { modifiers = modifiers | InputEvent.ALT_MASK; } - return KeyStroke.getKeyStroke(keyCode, Globals.getShortcutMask() + modifiers); + return KeyStroke.getKeyStroke(keyCode, getShortcutMask() + modifiers); + } + } + + private int getShortcutMask() { + if (SHORTCUT_MASK == -1) { + try { + SHORTCUT_MASK = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); + } catch (Throwable ignored) { + + } } + + return SHORTCUT_MASK; } /** From 399465cf2bbc60c70f897528b4ddf85d53f5f643 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 29 Jul 2015 15:29:09 +0200 Subject: [PATCH 15/23] Fix formatting issues (via auto-format) --- src/main/java/net/sf/jabref/Globals.java | 41 ++++++++++++------------ 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/main/java/net/sf/jabref/Globals.java b/src/main/java/net/sf/jabref/Globals.java index 846a8b3abe9..c345133a0b4 100644 --- a/src/main/java/net/sf/jabref/Globals.java +++ b/src/main/java/net/sf/jabref/Globals.java @@ -15,7 +15,6 @@ */ package net.sf.jabref; -import java.awt.Toolkit; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; @@ -53,7 +52,9 @@ public class Globals { /** * {@link Control} class allowing properties bundles to be in different encodings. * - * @see utf-8 and property files + * @see utf-8 + * and property files */ private static class EncodingControl extends Control { @@ -97,16 +98,17 @@ public ResourceBundle newBundle(String baseName, Locale locale, return bundle; } } - + + public static RemoteListenerServerLifecycle remoteListener = new RemoteListenerServerLifecycle(); private static final String RESOURCE_PREFIX = "resource/JabRef", MENU_RESOURCE_PREFIX = "resource/Menu", INTEGRITY_RESOURCE_PREFIX = "resource/IntegrityMessage"; public static final String JOURNALS_FILE_BUILTIN = "/resource/journalList.txt"; - + public static final String JOURNALS_IEEE_INTERNAL_LIST = "/resource/IEEEJournalList.txt"; - + private static ResourceBundle messages; private static ResourceBundle menuTitles; private static ResourceBundle intMessages; @@ -128,14 +130,14 @@ public ResourceBundle newBundle(String baseName, Locale locale, public static final String[] ENCODINGS; private static final String[] ALL_ENCODINGS = // (String[]) - // Charset.availableCharsets().keySet().toArray(new - // String[]{}); - new String[] {"ISO8859_1", "UTF8", "UTF-16", "ASCII", "Cp1250", "Cp1251", "Cp1252", - "Cp1253", "Cp1254", "Cp1257", "SJIS", - "KOI8_R", // Cyrillic - "EUC_JP", // Added Japanese encodings. - "Big5", "Big5_HKSCS", "GBK", "ISO8859_2", "ISO8859_3", "ISO8859_4", "ISO8859_5", - "ISO8859_6", "ISO8859_7", "ISO8859_8", "ISO8859_9", "ISO8859_13", "ISO8859_15"}; + // Charset.availableCharsets().keySet().toArray(new + // String[]{}); + new String[] {"ISO8859_1", "UTF8", "UTF-16", "ASCII", "Cp1250", "Cp1251", "Cp1252", + "Cp1253", "Cp1254", "Cp1257", "SJIS", + "KOI8_R", // Cyrillic + "EUC_JP", // Added Japanese encodings. + "Big5", "Big5_HKSCS", "GBK", "ISO8859_2", "ISO8859_3", "ISO8859_4", "ISO8859_5", + "ISO8859_6", "ISO8859_7", "ISO8859_8", "ISO8859_9", "ISO8859_13", "ISO8859_15"}; public static final Map ENCODING_NAMES_LOOKUP; static { @@ -190,7 +192,8 @@ public ResourceBundle newBundle(String baseName, Locale locale, public static final String osName = System.getProperty("os.name", "def"); - public static final boolean ON_MAC = (Globals.osName.equals(Globals.MAC)), ON_WIN = Globals.osName.startsWith("Windows"), + public static final boolean ON_MAC = (Globals.osName.equals(Globals.MAC)), + ON_WIN = Globals.osName.startsWith("Windows"), ON_LINUX = Globals.osName.startsWith("Linux"); public static SidePaneManager sidePaneManager; @@ -201,12 +204,11 @@ public ResourceBundle newBundle(String baseName, Locale locale, // Instantiate logger: private static final Log LOGGER = LogFactory.getLog(Globals.class); - + public static JournalAbbreviationRepository journalAbbrev; /** - * "Fieldname" to indicate that a field should be treated as a bibtex - * string. Used when writing database to file. + * "Fieldname" to indicate that a field should be treated as a bibtex string. Used when writing database to file. */ public static final String BIBTEX_STRING = "__string"; @@ -222,6 +224,7 @@ public static void startBackgroundTasks() { /** * Initialize and start the autosave manager. + * * @param frame The main frame. */ public static void startAutoSaveManager(JabRefFrame frame) { @@ -1227,8 +1230,7 @@ public static void initializeJournalNames() { } /** - * Returns a reg exp pattern in the form (w1)|(w2)| ... - * wi are escaped if no regex search is enabled + * Returns a reg exp pattern in the form (w1)|(w2)| ... wi are escaped if no regex search is enabled */ public static Pattern getPatternForWords(ArrayList words) { if ((words == null) || (words.isEmpty()) || (words.get(0).isEmpty())) { @@ -1253,5 +1255,4 @@ public static Pattern getPatternForWords(ArrayList words) { return pattern; } - } From 2b055d8c550c9c3bde99abb372912f0b566f0659 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 29 Jul 2015 15:57:14 +0200 Subject: [PATCH 16/23] Extract html map from Globals --- src/main/java/net/sf/jabref/Globals.java | 204 +---------------- ...{HTMLChars.java => HTMLCharFormatter.java} | 18 +- .../export/layout/format/HtmlCharsMap.java | 213 ++++++++++++++++++ .../jabref/export/layout/HTMLCharsTest.java | 6 +- .../jabref/export/layout/LayoutEntryTest.java | 10 +- 5 files changed, 232 insertions(+), 219 deletions(-) rename src/main/java/net/sf/jabref/export/layout/format/{HTMLChars.java => HTMLCharFormatter.java} (93%) create mode 100644 src/main/java/net/sf/jabref/export/layout/format/HtmlCharsMap.java diff --git a/src/main/java/net/sf/jabref/Globals.java b/src/main/java/net/sf/jabref/Globals.java index c345133a0b4..36706ac04ce 100644 --- a/src/main/java/net/sf/jabref/Globals.java +++ b/src/main/java/net/sf/jabref/Globals.java @@ -367,215 +367,13 @@ public static BibtexEntryType getEntryType(String type) { public static final String SPECIAL_COMMAND_CHARS = "\"`^~'c="; - public static final HashMap HTMLCHARS = new HashMap(); public static final HashMap XML_CHARS = new HashMap(); public static final HashMap ASCII2XML_CHARS = new HashMap(); public static final HashMap UNICODE_CHARS = new HashMap(); public static final HashMap RTFCHARS = new HashMap(); static { - // Following character definitions contributed by Ervin Kolenovic: - // HTML named entities from #192 - #255 (UNICODE Latin-1) - Globals.HTMLCHARS.put("`A", "À"); // #192 - Globals.HTMLCHARS.put("'A", "Á"); // #193 - Globals.HTMLCHARS.put("^A", "Â"); // #194 - Globals.HTMLCHARS.put("~A", "Ã"); // #195 - Globals.HTMLCHARS.put("\"A", "Ä"); // #196 - Globals.HTMLCHARS.put("AA", "Å"); // #197 - Globals.HTMLCHARS.put("AE", "Æ"); // #198 - Globals.HTMLCHARS.put("cC", "Ç"); // #199 - Globals.HTMLCHARS.put("`E", "È"); // #200 - Globals.HTMLCHARS.put("'E", "É"); // #201 - Globals.HTMLCHARS.put("^E", "Ê"); // #202 - Globals.HTMLCHARS.put("\"E", "Ë"); // #203 - Globals.HTMLCHARS.put("`I", "Ì"); // #204 - Globals.HTMLCHARS.put("'I", "Í"); // #205 - Globals.HTMLCHARS.put("^I", "Î"); // #206 - Globals.HTMLCHARS.put("\"I", "Ï"); // #207 - Globals.HTMLCHARS.put("DH", "Ð"); // #208 - Globals.HTMLCHARS.put("~N", "Ñ"); // #209 - Globals.HTMLCHARS.put("`O", "Ò"); // #210 - Globals.HTMLCHARS.put("'O", "Ó"); // #211 - Globals.HTMLCHARS.put("^O", "Ô"); // #212 - Globals.HTMLCHARS.put("~O", "Õ"); // #213 - Globals.HTMLCHARS.put("\"O", "Ö"); // #214 - // According to ISO 8859-1 the "\times" symbol should be placed here - // (#215). - // Omitting this, because it is a mathematical symbol. - Globals.HTMLCHARS.put("O", "Ø"); // #216 - Globals.HTMLCHARS.put("`U", "Ù"); // #217 - Globals.HTMLCHARS.put("'U", "Ú"); // #218 - Globals.HTMLCHARS.put("^U", "Û"); // #219 - Globals.HTMLCHARS.put("\"U", "Ü"); // #220 - Globals.HTMLCHARS.put("'Y", "Ý"); // #221 - Globals.HTMLCHARS.put("TH", "Þ"); // #222 - Globals.HTMLCHARS.put("ss", "ß"); // #223 - Globals.HTMLCHARS.put("`a", "à"); // #224 - Globals.HTMLCHARS.put("'a", "á"); // #225 - Globals.HTMLCHARS.put("^a", "â"); // #226 - Globals.HTMLCHARS.put("~a", "ã"); // #227 - Globals.HTMLCHARS.put("\"a", "ä"); // #228 - Globals.HTMLCHARS.put("aa", "å"); // #229 - Globals.HTMLCHARS.put("ae", "æ"); // #230 - Globals.HTMLCHARS.put("cc", "ç"); // #231 - Globals.HTMLCHARS.put("`e", "è"); // #232 - Globals.HTMLCHARS.put("'e", "é"); // #233 - Globals.HTMLCHARS.put("^e", "ê"); // #234 - Globals.HTMLCHARS.put("\"e", "ë"); // #235 - Globals.HTMLCHARS.put("`i", "ì"); // #236 - Globals.HTMLCHARS.put("'i", "í"); // #237 - Globals.HTMLCHARS.put("^i", "î"); // #238 - Globals.HTMLCHARS.put("\"i", "ï"); // #239 - Globals.HTMLCHARS.put("dh", "ð"); // #240 - Globals.HTMLCHARS.put("~n", "ñ"); // #241 - Globals.HTMLCHARS.put("`o", "ò"); // #242 - Globals.HTMLCHARS.put("'o", "ó"); // #243 - Globals.HTMLCHARS.put("^o", "ô"); // #244 - Globals.HTMLCHARS.put("~o", "õ"); // #245 - Globals.HTMLCHARS.put("\"o", "ö"); // #246 - // According to ISO 8859-1 the "\div" symbol should be placed here - // (#247). - // Omitting this, because it is a mathematical symbol. - Globals.HTMLCHARS.put("o", "ø"); // #248 - Globals.HTMLCHARS.put("`u", "ù"); // #249 - Globals.HTMLCHARS.put("'u", "ú"); // #250 - Globals.HTMLCHARS.put("^u", "û"); // #251 - Globals.HTMLCHARS.put("\"u", "ü"); // #252 - Globals.HTMLCHARS.put("'y", "ý"); // #253 - Globals.HTMLCHARS.put("th", "þ"); // #254 - Globals.HTMLCHARS.put("\"y", "ÿ"); // #255 - - // HTML special characters without names (UNICODE Latin Extended-A), - // indicated by UNICODE number - Globals.HTMLCHARS.put("=A", "Ā"); // "Amacr" - Globals.HTMLCHARS.put("=a", "ā"); // "amacr" - Globals.HTMLCHARS.put("uA", "Ă"); // "Abreve" - Globals.HTMLCHARS.put("ua", "ă"); // "abreve" - Globals.HTMLCHARS.put("kA", "Ą"); // "Aogon" - Globals.HTMLCHARS.put("ka", "ą"); // "aogon" - Globals.HTMLCHARS.put("'C", "Ć"); // "Cacute" - Globals.HTMLCHARS.put("'c", "ć"); // "cacute" - Globals.HTMLCHARS.put("^C", "Ĉ"); // "Ccirc" - Globals.HTMLCHARS.put("^c", "ĉ"); // "ccirc" - Globals.HTMLCHARS.put(".C", "Ċ"); // "Cdot" - Globals.HTMLCHARS.put(".c", "ċ"); // "cdot" - Globals.HTMLCHARS.put("vC", "Č"); // "Ccaron" - Globals.HTMLCHARS.put("vc", "č"); // "ccaron" - Globals.HTMLCHARS.put("vD", "Ď"); // "Dcaron" - // Symbol #271 (d) has no special Latex command - Globals.HTMLCHARS.put("DJ", "Đ"); // "Dstrok" - Globals.HTMLCHARS.put("dj", "đ"); // "dstrok" - Globals.HTMLCHARS.put("=E", "Ē"); // "Emacr" - Globals.HTMLCHARS.put("=e", "ē"); // "emacr" - Globals.HTMLCHARS.put("uE", "Ĕ"); // "Ebreve" - Globals.HTMLCHARS.put("ue", "ĕ"); // "ebreve" - Globals.HTMLCHARS.put(".E", "Ė"); // "Edot" - Globals.HTMLCHARS.put(".e", "ė"); // "edot" - Globals.HTMLCHARS.put("kE", "Ę"); // "Eogon" - Globals.HTMLCHARS.put("ke", "ę"); // "eogon" - Globals.HTMLCHARS.put("vE", "Ě"); // "Ecaron" - Globals.HTMLCHARS.put("ve", "ě"); // "ecaron" - Globals.HTMLCHARS.put("^G", "Ĝ"); // "Gcirc" - Globals.HTMLCHARS.put("^g", "ĝ"); // "gcirc" - Globals.HTMLCHARS.put("uG", "Ğ"); // "Gbreve" - Globals.HTMLCHARS.put("ug", "ğ"); // "gbreve" - Globals.HTMLCHARS.put(".G", "Ġ"); // "Gdot" - Globals.HTMLCHARS.put(".g", "ġ"); // "gdot" - Globals.HTMLCHARS.put("cG", "Ģ"); // "Gcedil" - Globals.HTMLCHARS.put("'g", "ģ"); // "gacute" - Globals.HTMLCHARS.put("^H", "Ĥ"); // "Hcirc" - Globals.HTMLCHARS.put("^h", "ĥ"); // "hcirc" - Globals.HTMLCHARS.put("Hstrok", "Ħ"); // "Hstrok" - Globals.HTMLCHARS.put("hstrok", "ħ"); // "hstrok" - Globals.HTMLCHARS.put("~I", "Ĩ"); // "Itilde" - Globals.HTMLCHARS.put("~i", "ĩ"); // "itilde" - Globals.HTMLCHARS.put("=I", "Ī"); // "Imacr" - Globals.HTMLCHARS.put("=i", "ī"); // "imacr" - Globals.HTMLCHARS.put("uI", "Ĭ"); // "Ibreve" - Globals.HTMLCHARS.put("ui", "ĭ"); // "ibreve" - Globals.HTMLCHARS.put("kI", "Į"); // "Iogon" - Globals.HTMLCHARS.put("ki", "į"); // "iogon" - Globals.HTMLCHARS.put(".I", "İ"); // "Idot" - Globals.HTMLCHARS.put("i", "ı"); // "inodot" - // Symbol #306 (IJ) has no special Latex command - // Symbol #307 (ij) has no special Latex command - Globals.HTMLCHARS.put("^J", "Ĵ"); // "Jcirc" - Globals.HTMLCHARS.put("^j", "ĵ"); // "jcirc" - Globals.HTMLCHARS.put("cK", "Ķ"); // "Kcedil" - Globals.HTMLCHARS.put("ck", "ķ"); // "kcedil" - // Symbol #312 (k) has no special Latex command - Globals.HTMLCHARS.put("'L", "Ĺ"); // "Lacute" - Globals.HTMLCHARS.put("'l", "ĺ"); // "lacute" - Globals.HTMLCHARS.put("cL", "Ļ"); // "Lcedil" - Globals.HTMLCHARS.put("cl", "ļ"); // "lcedil" - // Symbol #317 (L) has no special Latex command - // Symbol #318 (l) has no special Latex command - Globals.HTMLCHARS.put("Lmidot", "Ŀ"); // "Lmidot" - Globals.HTMLCHARS.put("lmidot", "ŀ"); // "lmidot" - Globals.HTMLCHARS.put("L", "Ł"); // "Lstrok" - Globals.HTMLCHARS.put("l", "ł"); // "lstrok" - Globals.HTMLCHARS.put("'N", "Ń"); // "Nacute" - Globals.HTMLCHARS.put("'n", "ń"); // "nacute" - Globals.HTMLCHARS.put("cN", "Ņ"); // "Ncedil" - Globals.HTMLCHARS.put("cn", "ņ"); // "ncedil" - Globals.HTMLCHARS.put("vN", "Ň"); // "Ncaron" - Globals.HTMLCHARS.put("vn", "ň"); // "ncaron" - // Symbol #329 (n) has no special Latex command - Globals.HTMLCHARS.put("NG", "Ŋ"); // "ENG" - Globals.HTMLCHARS.put("ng", "ŋ"); // "eng" - Globals.HTMLCHARS.put("=O", "Ō"); // "Omacr" - Globals.HTMLCHARS.put("=o", "ō"); // "omacr" - Globals.HTMLCHARS.put("uO", "Ŏ"); // "Obreve" - Globals.HTMLCHARS.put("uo", "ŏ"); // "obreve" - Globals.HTMLCHARS.put("HO", "Ő"); // "Odblac" - Globals.HTMLCHARS.put("Ho", "ő"); // "odblac" - Globals.HTMLCHARS.put("OE", "Œ"); // "OElig" - Globals.HTMLCHARS.put("oe", "œ"); // "oelig" - Globals.HTMLCHARS.put("'R", "Ŕ"); // "Racute" - Globals.HTMLCHARS.put("'r", "ŕ"); // "racute" - Globals.HTMLCHARS.put("cR", "Ŗ"); // "Rcedil" - Globals.HTMLCHARS.put("cr", "ŗ"); // "rcedil" - Globals.HTMLCHARS.put("vR", "Ř"); // "Rcaron" - Globals.HTMLCHARS.put("vr", "ř"); // "rcaron" - Globals.HTMLCHARS.put("'S", "Ś"); // "Sacute" - Globals.HTMLCHARS.put("'s", "ś"); // "sacute" - Globals.HTMLCHARS.put("^S", "Ŝ"); // "Scirc" - Globals.HTMLCHARS.put("^s", "ŝ"); // "scirc" - Globals.HTMLCHARS.put("cS", "Ş"); // "Scedil" - Globals.HTMLCHARS.put("cs", "ş"); // "scedil" - Globals.HTMLCHARS.put("vS", "Š"); // "Scaron" - Globals.HTMLCHARS.put("vs", "š"); // "scaron" - Globals.HTMLCHARS.put("cT", "Ţ"); // "Tcedil" - Globals.HTMLCHARS.put("ct", "ţ"); // "tcedil" - Globals.HTMLCHARS.put("vT", "Ť"); // "Tcaron" - // Symbol #357 (t) has no special Latex command - Globals.HTMLCHARS.put("Tstrok", "Ŧ"); // "Tstrok" - Globals.HTMLCHARS.put("tstrok", "ŧ"); // "tstrok" - Globals.HTMLCHARS.put("~U", "Ũ"); // "Utilde" - Globals.HTMLCHARS.put("~u", "ũ"); // "utilde" - Globals.HTMLCHARS.put("=U", "Ū"); // "Umacr" - Globals.HTMLCHARS.put("=u", "ū"); // "umacr" - Globals.HTMLCHARS.put("uU", "Ŭ"); // "Ubreve" - Globals.HTMLCHARS.put("uu", "ŭ"); // "ubreve" - Globals.HTMLCHARS.put("rU", "Ů"); // "Uring" - Globals.HTMLCHARS.put("ru", "ů"); // "uring" - Globals.HTMLCHARS.put("HU", "Ű"); // "Odblac" - Globals.HTMLCHARS.put("Hu", "ű"); // "odblac" - Globals.HTMLCHARS.put("kU", "Ų"); // "Uogon" - Globals.HTMLCHARS.put("ku", "ų"); // "uogon" - Globals.HTMLCHARS.put("^W", "Ŵ"); // "Wcirc" - Globals.HTMLCHARS.put("^w", "ŵ"); // "wcirc" - Globals.HTMLCHARS.put("^Y", "Ŷ"); // "Ycirc" - Globals.HTMLCHARS.put("^y", "ŷ"); // "ycirc" - Globals.HTMLCHARS.put("\"Y", "Ÿ"); // "Yuml" - Globals.HTMLCHARS.put("'Z", "Ź"); // "Zacute" - Globals.HTMLCHARS.put("'z", "ź"); // "zacute" - Globals.HTMLCHARS.put(".Z", "Ż"); // "Zdot" - Globals.HTMLCHARS.put(".z", "ż"); // "zdot" - Globals.HTMLCHARS.put("vZ", "Ž"); // "Zcaron" - Globals.HTMLCHARS.put("vz", "ž"); // "zcaron" - // Symbol #383 (f) has no special Latex command - Globals.HTMLCHARS.put("%", "%"); // percent sign + Globals.XML_CHARS.put("\\{\\\\\\\"\\{a\\}\\}", "ä"); Globals.XML_CHARS.put("\\{\\\\\\\"\\{A\\}\\}", "Ä"); diff --git a/src/main/java/net/sf/jabref/export/layout/format/HTMLChars.java b/src/main/java/net/sf/jabref/export/layout/format/HTMLCharFormatter.java similarity index 93% rename from src/main/java/net/sf/jabref/export/layout/format/HTMLChars.java rename to src/main/java/net/sf/jabref/export/layout/format/HTMLCharFormatter.java index ccb513f06f8..ba4c86319af 100644 --- a/src/main/java/net/sf/jabref/export/layout/format/HTMLChars.java +++ b/src/main/java/net/sf/jabref/export/layout/format/HTMLCharFormatter.java @@ -16,13 +16,15 @@ package net.sf.jabref.export.layout.format; import net.sf.jabref.Globals; -import net.sf.jabref.util.StringUtil; import net.sf.jabref.export.layout.LayoutFormatter; +import net.sf.jabref.util.StringUtil; /** * This formatter escapes characters so they are suitable for HTML. */ -public class HTMLChars implements LayoutFormatter { +public class HTMLCharFormatter implements LayoutFormatter { + + private static HtmlCharsMap htmlChars= new HtmlCharsMap(); @Override public String format(String field) { @@ -45,7 +47,7 @@ public String format(String field) { if (incommand) { /* Close Command */ String command = currentCommand.toString(); - Object result = Globals.HTMLCHARS.get(command); + Object result = htmlChars.get(command); if (result != null) { sb.append((String) result); } else { @@ -86,7 +88,7 @@ public String format(String field) { combody = field.substring(i, i + 1); // System.out.println("... "+combody); } - Object result = Globals.HTMLCHARS.get(command + combody); + Object result = htmlChars.get(command + combody); if (result != null) { sb.append((String) result); @@ -98,7 +100,7 @@ public String format(String field) { // Are we already at the end of the string? if ((i + 1) == field.length()) { String command = currentCommand.toString(); - Object result = Globals.HTMLCHARS.get(command); + Object result = htmlChars.get(command); /* If found, then use translated version. If not, * then keep * the text of the parameter intact. @@ -142,7 +144,7 @@ public String format(String field) { argument = part; if (argument != null) { // handle common case of general latex command - Object result = Globals.HTMLCHARS.get(command + argument); + Object result = htmlChars.get(command + argument); // System.out.print("command: "+command+", arg: "+argument); // System.out.print(", result: "); // If found, then use translated version. If not, then keep @@ -158,7 +160,7 @@ public String format(String field) { // This end brace terminates a command. This can be the case in // constructs like {\aa}. The correct behaviour should be to // substitute the evaluated command and swallow the brace: - Object result = Globals.HTMLCHARS.get(command); + Object result = htmlChars.get(command); if (result != null) { sb.append((String) result); } else { @@ -166,7 +168,7 @@ public String format(String field) { sb.append(command); } } else { - Object result = Globals.HTMLCHARS.get(command); + Object result = htmlChars.get(command); if (result != null) { sb.append((String) result); } else { diff --git a/src/main/java/net/sf/jabref/export/layout/format/HtmlCharsMap.java b/src/main/java/net/sf/jabref/export/layout/format/HtmlCharsMap.java new file mode 100644 index 00000000000..df522ee57d5 --- /dev/null +++ b/src/main/java/net/sf/jabref/export/layout/format/HtmlCharsMap.java @@ -0,0 +1,213 @@ +package net.sf.jabref.export.layout.format; + +import java.util.HashMap; + +public class HtmlCharsMap extends HashMap { + + private static final long serialVersionUID = 1L; + + public HtmlCharsMap() { + // HTML named entities from #192 - #255 (UNICODE Latin-1) + put("`A", "À"); // #192 + put("'A", "Á"); // #193 + put("^A", "Â"); // #194 + put("~A", "Ã"); // #195 + put("\"A", "Ä"); // #196 + put("AA", "Å"); // #197 + put("AE", "Æ"); // #198 + put("cC", "Ç"); // #199 + put("`E", "È"); // #200 + put("'E", "É"); // #201 + put("^E", "Ê"); // #202 + put("\"E", "Ë"); // #203 + put("`I", "Ì"); // #204 + put("'I", "Í"); // #205 + put("^I", "Î"); // #206 + put("\"I", "Ï"); // #207 + put("DH", "Ð"); // #208 + put("~N", "Ñ"); // #209 + put("`O", "Ò"); // #210 + put("'O", "Ó"); // #211 + put("^O", "Ô"); // #212 + put("~O", "Õ"); // #213 + put("\"O", "Ö"); // #214 + // According to ISO 8859-1 the "\times" symbol should be placed here + // (#215). + // Omitting this, because it is a mathematical symbol. + put("O", "Ø"); // #216 + put("`U", "Ù"); // #217 + put("'U", "Ú"); // #218 + put("^U", "Û"); // #219 + put("\"U", "Ü"); // #220 + put("'Y", "Ý"); // #221 + put("TH", "Þ"); // #222 + put("ss", "ß"); // #223 + put("`a", "à"); // #224 + put("'a", "á"); // #225 + put("^a", "â"); // #226 + put("~a", "ã"); // #227 + put("\"a", "ä"); // #228 + put("aa", "å"); // #229 + put("ae", "æ"); // #230 + put("cc", "ç"); // #231 + put("`e", "è"); // #232 + put("'e", "é"); // #233 + put("^e", "ê"); // #234 + put("\"e", "ë"); // #235 + put("`i", "ì"); // #236 + put("'i", "í"); // #237 + put("^i", "î"); // #238 + put("\"i", "ï"); // #239 + put("dh", "ð"); // #240 + put("~n", "ñ"); // #241 + put("`o", "ò"); // #242 + put("'o", "ó"); // #243 + put("^o", "ô"); // #244 + put("~o", "õ"); // #245 + put("\"o", "ö"); // #246 + // According to ISO 8859-1 the "\div" symbol should be placed here + // (#247). + // Omitting this, because it is a mathematical symbol. + put("o", "ø"); // #248 + put("`u", "ù"); // #249 + put("'u", "ú"); // #250 + put("^u", "û"); // #251 + put("\"u", "ü"); // #252 + put("'y", "ý"); // #253 + put("th", "þ"); // #254 + put("\"y", "ÿ"); // #255 + + // HTML special characters without names (UNICODE Latin Extended-A), + // indicated by UNICODE number + put("=A", "Ā"); // "Amacr" + put("=a", "ā"); // "amacr" + put("uA", "Ă"); // "Abreve" + put("ua", "ă"); // "abreve" + put("kA", "Ą"); // "Aogon" + put("ka", "ą"); // "aogon" + put("'C", "Ć"); // "Cacute" + put("'c", "ć"); // "cacute" + put("^C", "Ĉ"); // "Ccirc" + put("^c", "ĉ"); // "ccirc" + put(".C", "Ċ"); // "Cdot" + put(".c", "ċ"); // "cdot" + put("vC", "Č"); // "Ccaron" + put("vc", "č"); // "ccaron" + put("vD", "Ď"); // "Dcaron" + // Symbol #271 (d) has no special Latex command + put("DJ", "Đ"); // "Dstrok" + put("dj", "đ"); // "dstrok" + put("=E", "Ē"); // "Emacr" + put("=e", "ē"); // "emacr" + put("uE", "Ĕ"); // "Ebreve" + put("ue", "ĕ"); // "ebreve" + put(".E", "Ė"); // "Edot" + put(".e", "ė"); // "edot" + put("kE", "Ę"); // "Eogon" + put("ke", "ę"); // "eogon" + put("vE", "Ě"); // "Ecaron" + put("ve", "ě"); // "ecaron" + put("^G", "Ĝ"); // "Gcirc" + put("^g", "ĝ"); // "gcirc" + put("uG", "Ğ"); // "Gbreve" + put("ug", "ğ"); // "gbreve" + put(".G", "Ġ"); // "Gdot" + put(".g", "ġ"); // "gdot" + put("cG", "Ģ"); // "Gcedil" + put("'g", "ģ"); // "gacute" + put("^H", "Ĥ"); // "Hcirc" + put("^h", "ĥ"); // "hcirc" + put("Hstrok", "Ħ"); // "Hstrok" + put("hstrok", "ħ"); // "hstrok" + put("~I", "Ĩ"); // "Itilde" + put("~i", "ĩ"); // "itilde" + put("=I", "Ī"); // "Imacr" + put("=i", "ī"); // "imacr" + put("uI", "Ĭ"); // "Ibreve" + put("ui", "ĭ"); // "ibreve" + put("kI", "Į"); // "Iogon" + put("ki", "į"); // "iogon" + put(".I", "İ"); // "Idot" + put("i", "ı"); // "inodot" + // Symbol #306 (IJ) has no special Latex command + // Symbol #307 (ij) has no special Latex command + put("^J", "Ĵ"); // "Jcirc" + put("^j", "ĵ"); // "jcirc" + put("cK", "Ķ"); // "Kcedil" + put("ck", "ķ"); // "kcedil" + // Symbol #312 (k) has no special Latex command + put("'L", "Ĺ"); // "Lacute" + put("'l", "ĺ"); // "lacute" + put("cL", "Ļ"); // "Lcedil" + put("cl", "ļ"); // "lcedil" + // Symbol #317 (L) has no special Latex command + // Symbol #318 (l) has no special Latex command + put("Lmidot", "Ŀ"); // "Lmidot" + put("lmidot", "ŀ"); // "lmidot" + put("L", "Ł"); // "Lstrok" + put("l", "ł"); // "lstrok" + put("'N", "Ń"); // "Nacute" + put("'n", "ń"); // "nacute" + put("cN", "Ņ"); // "Ncedil" + put("cn", "ņ"); // "ncedil" + put("vN", "Ň"); // "Ncaron" + put("vn", "ň"); // "ncaron" + // Symbol #329 (n) has no special Latex command + put("NG", "Ŋ"); // "ENG" + put("ng", "ŋ"); // "eng" + put("=O", "Ō"); // "Omacr" + put("=o", "ō"); // "omacr" + put("uO", "Ŏ"); // "Obreve" + put("uo", "ŏ"); // "obreve" + put("HO", "Ő"); // "Odblac" + put("Ho", "ő"); // "odblac" + put("OE", "Œ"); // "OElig" + put("oe", "œ"); // "oelig" + put("'R", "Ŕ"); // "Racute" + put("'r", "ŕ"); // "racute" + put("cR", "Ŗ"); // "Rcedil" + put("cr", "ŗ"); // "rcedil" + put("vR", "Ř"); // "Rcaron" + put("vr", "ř"); // "rcaron" + put("'S", "Ś"); // "Sacute" + put("'s", "ś"); // "sacute" + put("^S", "Ŝ"); // "Scirc" + put("^s", "ŝ"); // "scirc" + put("cS", "Ş"); // "Scedil" + put("cs", "ş"); // "scedil" + put("vS", "Š"); // "Scaron" + put("vs", "š"); // "scaron" + put("cT", "Ţ"); // "Tcedil" + put("ct", "ţ"); // "tcedil" + put("vT", "Ť"); // "Tcaron" + // Symbol #357 (t) has no special Latex command + put("Tstrok", "Ŧ"); // "Tstrok" + put("tstrok", "ŧ"); // "tstrok" + put("~U", "Ũ"); // "Utilde" + put("~u", "ũ"); // "utilde" + put("=U", "Ū"); // "Umacr" + put("=u", "ū"); // "umacr" + put("uU", "Ŭ"); // "Ubreve" + put("uu", "ŭ"); // "ubreve" + put("rU", "Ů"); // "Uring" + put("ru", "ů"); // "uring" + put("HU", "Ű"); // "Odblac" + put("Hu", "ű"); // "odblac" + put("kU", "Ų"); // "Uogon" + put("ku", "ų"); // "uogon" + put("^W", "Ŵ"); // "Wcirc" + put("^w", "ŵ"); // "wcirc" + put("^Y", "Ŷ"); // "Ycirc" + put("^y", "ŷ"); // "ycirc" + put("\"Y", "Ÿ"); // "Yuml" + put("'Z", "Ź"); // "Zacute" + put("'z", "ź"); // "zacute" + put(".Z", "Ż"); // "Zdot" + put(".z", "ż"); // "zdot" + put("vZ", "Ž"); // "Zcaron" + put("vz", "ž"); // "zcaron" + // Symbol #383 (f) has no special Latex command + put("%", "%"); // percent sign + } + +} diff --git a/src/test/java/net/sf/jabref/export/layout/HTMLCharsTest.java b/src/test/java/net/sf/jabref/export/layout/HTMLCharsTest.java index 2045f19db20..9f192174378 100644 --- a/src/test/java/net/sf/jabref/export/layout/HTMLCharsTest.java +++ b/src/test/java/net/sf/jabref/export/layout/HTMLCharsTest.java @@ -1,6 +1,6 @@ package net.sf.jabref.export.layout; -import net.sf.jabref.export.layout.format.HTMLChars; +import net.sf.jabref.export.layout.format.HTMLCharFormatter; import org.junit.Assert; import org.junit.Test; @@ -12,7 +12,7 @@ public class HTMLCharsTest { @Test public void testBasicFormat() { - LayoutFormatter layout = new HTMLChars(); + LayoutFormatter layout = new HTMLCharFormatter(); Assert.assertEquals("", layout.format("")); @@ -36,7 +36,7 @@ public void testBasicFormat() { @Test public void testLaTeXHighlighting() { - LayoutFormatter layout = new HTMLChars(); + LayoutFormatter layout = new HTMLCharFormatter(); Assert.assertEquals("hallo", layout.format("\\emph{hallo}")); Assert.assertEquals("hallo", layout.format("{\\emph hallo}")); diff --git a/src/test/java/net/sf/jabref/export/layout/LayoutEntryTest.java b/src/test/java/net/sf/jabref/export/layout/LayoutEntryTest.java index 2d9448e53c5..2a9c8f91423 100644 --- a/src/test/java/net/sf/jabref/export/layout/LayoutEntryTest.java +++ b/src/test/java/net/sf/jabref/export/layout/LayoutEntryTest.java @@ -105,7 +105,7 @@ public void testNoHighlighting() throws Exception { // define the highlighting settings Globals.prefs.putBoolean("caseSensitiveSearch", false); - String result = this.layout("\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract}\\end{abstract}
", mBTE, new ArrayList()); + String result = this.layout("\\begin{abstract}

Abstract: \\format[HTMLCharFormatter]{\\abstract}\\end{abstract}
", mBTE, new ArrayList()); String expecting = "

Abstract: In this paper, we initiate a formal study of security on Android: Google's new open-source platform for mobile devices. Tags: Paper android google Open-Source Devices
"; Assert.assertEquals(expecting, result); @@ -126,7 +126,7 @@ public void testHighlightingOneWordCaseInsesitive() throws Exception { // define the highlighting settings Globals.prefs.putBoolean("caseSensitiveSearch", false); - String result = this.layout("\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract}\\end{abstract}
", mBTE, words); + String result = this.layout("\\begin{abstract}

Abstract: \\format[HTMLCharFormatter]{\\abstract}\\end{abstract}
", mBTE, words); String containing = "Google"; // check @@ -149,7 +149,7 @@ public void testHighlightingTwoWordsCaseInsesitive() throws Exception { // define the highlighting settings Globals.prefs.putBoolean("caseSensitiveSearch", false); - String result = this.layout("\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract}\\end{abstract}
", mBTE, words); + String result = this.layout("\\begin{abstract}

Abstract: \\format[HTMLCharFormatter]{\\abstract}\\end{abstract}
", mBTE, words); String containing = "Android"; String containing2 = "study"; @@ -174,7 +174,7 @@ public void testHighlightingOneWordCaseSesitive() throws Exception { // define the highlighting settings Globals.prefs.putBoolean("caseSensitiveSearch", true); - String result = this.layout("\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract}\\end{abstract}
", mBTE, words); + String result = this.layout("\\begin{abstract}

Abstract: \\format[HTMLCharFormatter]{\\abstract}\\end{abstract}
", mBTE, words); String expected = "

Abstract: In this paper, we initiate a formal study of security on Android: Google's new open-source platform for mobile devices. Tags: Paper android google Open-Source Devices
"; // check @@ -199,7 +199,7 @@ public void testHighlightingMoreWordsCaseSesitive() throws Exception { Globals.prefs.putBoolean("caseSensitiveSearch", false); String highlightColor = "#3399FF;"; - String result = this.layout("\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract}\\end{abstract}
", mBTE, words); + String result = this.layout("\\begin{abstract}

Abstract: \\format[HTMLCharFormatter]{\\abstract}\\end{abstract}
", mBTE, words); String expected = "

Abstract: In this paper, we initiate a formal study of security on Android: Google's new open-source platform for mobile devices. Tags: Paper android google Open-Source Devices
"; // check From 733c54c4d06eb38a3f71c37ed16314647d2f9ab5 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 29 Jul 2015 16:02:03 +0200 Subject: [PATCH 17/23] Extract XML char map from Globals --- src/main/java/net/sf/jabref/Globals.java | 130 ----------------- .../layout/format/CreateDocBookAuthors.java | 2 +- .../{XMLChars.java => XMLCharFormatter.java} | 7 +- .../export/layout/format/XmlCharsMap.java | 138 ++++++++++++++++++ .../java/net/sf/jabref/mods/MODSEntry.java | 6 +- .../java/net/sf/jabref/msbib/MSBibEntry.java | 4 +- 6 files changed, 149 insertions(+), 138 deletions(-) rename src/main/java/net/sf/jabref/export/layout/format/{XMLChars.java => XMLCharFormatter.java} (95%) create mode 100644 src/main/java/net/sf/jabref/export/layout/format/XmlCharsMap.java diff --git a/src/main/java/net/sf/jabref/Globals.java b/src/main/java/net/sf/jabref/Globals.java index 36706ac04ce..9d052e10f9c 100644 --- a/src/main/java/net/sf/jabref/Globals.java +++ b/src/main/java/net/sf/jabref/Globals.java @@ -367,141 +367,11 @@ public static BibtexEntryType getEntryType(String type) { public static final String SPECIAL_COMMAND_CHARS = "\"`^~'c="; - public static final HashMap XML_CHARS = new HashMap(); public static final HashMap ASCII2XML_CHARS = new HashMap(); public static final HashMap UNICODE_CHARS = new HashMap(); public static final HashMap RTFCHARS = new HashMap(); static { - - - Globals.XML_CHARS.put("\\{\\\\\\\"\\{a\\}\\}", "ä"); - Globals.XML_CHARS.put("\\{\\\\\\\"\\{A\\}\\}", "Ä"); - Globals.XML_CHARS.put("\\{\\\\\\\"\\{e\\}\\}", "ë"); - Globals.XML_CHARS.put("\\{\\\\\\\"\\{E\\}\\}", "Ë"); - Globals.XML_CHARS.put("\\{\\\\\\\"\\{i\\}\\}", "ï"); - Globals.XML_CHARS.put("\\{\\\\\\\"\\{I\\}\\}", "Ï"); - Globals.XML_CHARS.put("\\{\\\\\\\"\\{o\\}\\}", "ö"); - Globals.XML_CHARS.put("\\{\\\\\\\"\\{O\\}\\}", "Ö"); - Globals.XML_CHARS.put("\\{\\\\\\\"\\{u\\}\\}", "ü"); - Globals.XML_CHARS.put("\\{\\\\\\\"\\{U\\}\\}", "Ü"); - - //next 2 rows were missing... - Globals.XML_CHARS.put("\\{\\\\\\`\\{a\\}\\}", "à"); - Globals.XML_CHARS.put("\\{\\\\\\`\\{A\\}\\}", "À"); - - Globals.XML_CHARS.put("\\{\\\\\\`\\{e\\}\\}", "è"); - Globals.XML_CHARS.put("\\{\\\\\\`\\{E\\}\\}", "È"); - Globals.XML_CHARS.put("\\{\\\\\\`\\{i\\}\\}", "ì"); - Globals.XML_CHARS.put("\\{\\\\\\`\\{I\\}\\}", "Ì"); - Globals.XML_CHARS.put("\\{\\\\\\`\\{o\\}\\}", "ò"); - Globals.XML_CHARS.put("\\{\\\\\\`\\{O\\}\\}", "Ò"); - Globals.XML_CHARS.put("\\{\\\\\\`\\{u\\}\\}", "ù"); - Globals.XML_CHARS.put("\\{\\\\\\`\\{U\\}\\}", "Ù"); - - //corrected these 10 lines below... - Globals.XML_CHARS.put("\\{\\\\\\'\\{a\\}\\}", "á"); - Globals.XML_CHARS.put("\\{\\\\\\'\\{A\\}\\}", "Á"); - Globals.XML_CHARS.put("\\{\\\\\\'\\{e\\}\\}", "é"); - Globals.XML_CHARS.put("\\{\\\\\\'\\{E\\}\\}", "É"); - Globals.XML_CHARS.put("\\{\\\\\\'\\{i\\}\\}", "í"); - Globals.XML_CHARS.put("\\{\\\\\\'\\{I\\}\\}", "Í"); - Globals.XML_CHARS.put("\\{\\\\\\'\\{o\\}\\}", "ó"); - Globals.XML_CHARS.put("\\{\\\\\\'\\{O\\}\\}", "Ó"); - Globals.XML_CHARS.put("\\{\\\\\\'\\{u\\}\\}", "ú"); - Globals.XML_CHARS.put("\\{\\\\\\'\\{U\\}\\}", "Ú"); - //added next four chars... - Globals.XML_CHARS.put("\\{\\\\\\'\\{c\\}\\}", "ć"); - Globals.XML_CHARS.put("\\{\\\\\\'\\{C\\}\\}", "Ć"); - Globals.XML_CHARS.put("\\{\\\\c\\{c\\}\\}", "ç"); - Globals.XML_CHARS.put("\\{\\\\c\\{C\\}\\}", "Ç"); - - Globals.XML_CHARS.put("\\{\\\\\\\uFFFD\\{E\\}\\}", "É"); - Globals.XML_CHARS.put("\\{\\\\\\\uFFFD\\{i\\}\\}", "í"); - Globals.XML_CHARS.put("\\{\\\\\\\uFFFD\\{I\\}\\}", "Í"); - Globals.XML_CHARS.put("\\{\\\\\\\uFFFD\\{o\\}\\}", "ó"); - Globals.XML_CHARS.put("\\{\\\\\\\uFFFD\\{O\\}\\}", "Ó"); - Globals.XML_CHARS.put("\\{\\\\\\\uFFFD\\{u\\}\\}", "ú"); - Globals.XML_CHARS.put("\\{\\\\\\\uFFFD\\{U\\}\\}", "Ú"); - Globals.XML_CHARS.put("\\{\\\\\\\uFFFD\\{a\\}\\}", "á"); - Globals.XML_CHARS.put("\\{\\\\\\\uFFFD\\{A\\}\\}", "Á"); - - //next 2 rows were missing... - Globals.XML_CHARS.put("\\{\\\\\\^\\{a\\}\\}", "â"); - Globals.XML_CHARS.put("\\{\\\\\\^\\{A\\}\\}", "Â"); - - Globals.XML_CHARS.put("\\{\\\\\\^\\{o\\}\\}", "ô"); - Globals.XML_CHARS.put("\\{\\\\\\^\\{O\\}\\}", "Ô"); - Globals.XML_CHARS.put("\\{\\\\\\^\\{u\\}\\}", "ù"); - Globals.XML_CHARS.put("\\{\\\\\\^\\{U\\}\\}", "Ù"); - Globals.XML_CHARS.put("\\{\\\\\\^\\{e\\}\\}", "ê"); - Globals.XML_CHARS.put("\\{\\\\\\^\\{E\\}\\}", "Ê"); - Globals.XML_CHARS.put("\\{\\\\\\^\\{i\\}\\}", "î"); - Globals.XML_CHARS.put("\\{\\\\\\^\\{I\\}\\}", "Î"); - - Globals.XML_CHARS.put("\\{\\\\\\~\\{o\\}\\}", "õ"); - Globals.XML_CHARS.put("\\{\\\\\\~\\{O\\}\\}", "Õ"); - Globals.XML_CHARS.put("\\{\\\\\\~\\{n\\}\\}", "ñ"); - Globals.XML_CHARS.put("\\{\\\\\\~\\{N\\}\\}", "Ñ"); - Globals.XML_CHARS.put("\\{\\\\\\~\\{a\\}\\}", "ã"); - Globals.XML_CHARS.put("\\{\\\\\\~\\{A\\}\\}", "Ã"); - - Globals.XML_CHARS.put("\\{\\\\\\\"a\\}", "ä"); - Globals.XML_CHARS.put("\\{\\\\\\\"A\\}", "Ä"); - Globals.XML_CHARS.put("\\{\\\\\\\"e\\}", "ë"); - Globals.XML_CHARS.put("\\{\\\\\\\"E\\}", "Ë"); - Globals.XML_CHARS.put("\\{\\\\\\\"i\\}", "ï"); - Globals.XML_CHARS.put("\\{\\\\\\\"I\\}", "Ï"); - Globals.XML_CHARS.put("\\{\\\\\\\"o\\}", "ö"); - Globals.XML_CHARS.put("\\{\\\\\\\"O\\}", "Ö"); - Globals.XML_CHARS.put("\\{\\\\\\\"u\\}", "ü"); - Globals.XML_CHARS.put("\\{\\\\\\\"U\\}", "Ü"); - - //next 2 rows were missing... - Globals.XML_CHARS.put("\\{\\\\\\`a\\}", "à"); - Globals.XML_CHARS.put("\\{\\\\\\`A\\}", "À"); - - Globals.XML_CHARS.put("\\{\\\\\\`e\\}", "è"); - Globals.XML_CHARS.put("\\{\\\\\\`E\\}", "È"); - Globals.XML_CHARS.put("\\{\\\\\\`i\\}", "ì"); - Globals.XML_CHARS.put("\\{\\\\\\`I\\}", "Ì"); - Globals.XML_CHARS.put("\\{\\\\\\`o\\}", "ò"); - Globals.XML_CHARS.put("\\{\\\\\\`O\\}", "Ò"); - Globals.XML_CHARS.put("\\{\\\\\\`u\\}", "ù"); - Globals.XML_CHARS.put("\\{\\\\\\`U\\}", "Ù"); - Globals.XML_CHARS.put("\\{\\\\\\'e\\}", "é"); - Globals.XML_CHARS.put("\\{\\\\\\'E\\}", "É"); - Globals.XML_CHARS.put("\\{\\\\\\'i\\}", "í"); - Globals.XML_CHARS.put("\\{\\\\\\'I\\}", "Í"); - Globals.XML_CHARS.put("\\{\\\\\\'o\\}", "ó"); - Globals.XML_CHARS.put("\\{\\\\\\'O\\}", "Ó"); - Globals.XML_CHARS.put("\\{\\\\\\'u\\}", "ú"); - Globals.XML_CHARS.put("\\{\\\\\\'U\\}", "Ú"); - Globals.XML_CHARS.put("\\{\\\\\\'a\\}", "á"); - Globals.XML_CHARS.put("\\{\\\\\\'A\\}", "Á"); - //added next two chars... - Globals.XML_CHARS.put("\\{\\\\\\'c\\}", "ć"); - Globals.XML_CHARS.put("\\{\\\\\\'C\\}", "Ć"); - - //next two lines were wrong... - Globals.XML_CHARS.put("\\{\\\\\\^a\\}", "â"); - Globals.XML_CHARS.put("\\{\\\\\\^A\\}", "Â"); - - Globals.XML_CHARS.put("\\{\\\\\\^o\\}", "ô"); - Globals.XML_CHARS.put("\\{\\\\\\^O\\}", "Ô"); - Globals.XML_CHARS.put("\\{\\\\\\^u\\}", "ù"); - Globals.XML_CHARS.put("\\{\\\\\\^U\\}", "Ù"); - Globals.XML_CHARS.put("\\{\\\\\\^e\\}", "ê"); - Globals.XML_CHARS.put("\\{\\\\\\^E\\}", "Ê"); - Globals.XML_CHARS.put("\\{\\\\\\^i\\}", "î"); - Globals.XML_CHARS.put("\\{\\\\\\^I\\}", "Î"); - Globals.XML_CHARS.put("\\{\\\\\\~o\\}", "õ"); - Globals.XML_CHARS.put("\\{\\\\\\~O\\}", "Õ"); - Globals.XML_CHARS.put("\\{\\\\\\~n\\}", "ñ"); - Globals.XML_CHARS.put("\\{\\\\\\~N\\}", "Ñ"); - Globals.XML_CHARS.put("\\{\\\\\\~a\\}", "ã"); - Globals.XML_CHARS.put("\\{\\\\\\~A\\}", "Ã"); - Globals.ASCII2XML_CHARS.put("<", "<"); Globals.ASCII2XML_CHARS.put("\"", """); Globals.ASCII2XML_CHARS.put(">", ">"); diff --git a/src/main/java/net/sf/jabref/export/layout/format/CreateDocBookAuthors.java b/src/main/java/net/sf/jabref/export/layout/format/CreateDocBookAuthors.java index 042b4ac8a50..830e2c8d58b 100644 --- a/src/main/java/net/sf/jabref/export/layout/format/CreateDocBookAuthors.java +++ b/src/main/java/net/sf/jabref/export/layout/format/CreateDocBookAuthors.java @@ -49,7 +49,7 @@ public class CreateDocBookAuthors implements LayoutFormatter { - private static final XMLChars xc = new XMLChars(); + private static final XMLCharFormatter xc = new XMLCharFormatter(); @Override diff --git a/src/main/java/net/sf/jabref/export/layout/format/XMLChars.java b/src/main/java/net/sf/jabref/export/layout/format/XMLCharFormatter.java similarity index 95% rename from src/main/java/net/sf/jabref/export/layout/format/XMLChars.java rename to src/main/java/net/sf/jabref/export/layout/format/XMLCharFormatter.java index e169b0ea7de..ca8d2069c5f 100644 --- a/src/main/java/net/sf/jabref/export/layout/format/XMLChars.java +++ b/src/main/java/net/sf/jabref/export/layout/format/XMLCharFormatter.java @@ -45,14 +45,17 @@ /** * Changes {\^o} or {\^{o}} to ? */ -public class XMLChars implements LayoutFormatter { +public class XMLCharFormatter implements LayoutFormatter { + + private static XmlCharsMap xmlChars = new XmlCharsMap(); + @Override public String format(String fieldText) { fieldText = firstFormat(fieldText); - for (Map.Entry entry : Globals.XML_CHARS.entrySet()) { + for (Map.Entry entry : xmlChars.entrySet()) { String s = entry.getKey(); String repl = entry.getValue(); if (repl != null) { diff --git a/src/main/java/net/sf/jabref/export/layout/format/XmlCharsMap.java b/src/main/java/net/sf/jabref/export/layout/format/XmlCharsMap.java new file mode 100644 index 00000000000..33fc812c6af --- /dev/null +++ b/src/main/java/net/sf/jabref/export/layout/format/XmlCharsMap.java @@ -0,0 +1,138 @@ +package net.sf.jabref.export.layout.format; + +import java.util.HashMap; + +public class XmlCharsMap extends HashMap { + + private static final long serialVersionUID = 1L; + + public XmlCharsMap() { + put("\\{\\\\\\\"\\{a\\}\\}", "ä"); + put("\\{\\\\\\\"\\{A\\}\\}", "Ä"); + put("\\{\\\\\\\"\\{e\\}\\}", "ë"); + put("\\{\\\\\\\"\\{E\\}\\}", "Ë"); + put("\\{\\\\\\\"\\{i\\}\\}", "ï"); + put("\\{\\\\\\\"\\{I\\}\\}", "Ï"); + put("\\{\\\\\\\"\\{o\\}\\}", "ö"); + put("\\{\\\\\\\"\\{O\\}\\}", "Ö"); + put("\\{\\\\\\\"\\{u\\}\\}", "ü"); + put("\\{\\\\\\\"\\{U\\}\\}", "Ü"); + + //next 2 rows were missing... + put("\\{\\\\\\`\\{a\\}\\}", "à"); + put("\\{\\\\\\`\\{A\\}\\}", "À"); + + put("\\{\\\\\\`\\{e\\}\\}", "è"); + put("\\{\\\\\\`\\{E\\}\\}", "È"); + put("\\{\\\\\\`\\{i\\}\\}", "ì"); + put("\\{\\\\\\`\\{I\\}\\}", "Ì"); + put("\\{\\\\\\`\\{o\\}\\}", "ò"); + put("\\{\\\\\\`\\{O\\}\\}", "Ò"); + put("\\{\\\\\\`\\{u\\}\\}", "ù"); + put("\\{\\\\\\`\\{U\\}\\}", "Ù"); + + //corrected these 10 lines below... + put("\\{\\\\\\'\\{a\\}\\}", "á"); + put("\\{\\\\\\'\\{A\\}\\}", "Á"); + put("\\{\\\\\\'\\{e\\}\\}", "é"); + put("\\{\\\\\\'\\{E\\}\\}", "É"); + put("\\{\\\\\\'\\{i\\}\\}", "í"); + put("\\{\\\\\\'\\{I\\}\\}", "Í"); + put("\\{\\\\\\'\\{o\\}\\}", "ó"); + put("\\{\\\\\\'\\{O\\}\\}", "Ó"); + put("\\{\\\\\\'\\{u\\}\\}", "ú"); + put("\\{\\\\\\'\\{U\\}\\}", "Ú"); + //added next four chars... + put("\\{\\\\\\'\\{c\\}\\}", "ć"); + put("\\{\\\\\\'\\{C\\}\\}", "Ć"); + put("\\{\\\\c\\{c\\}\\}", "ç"); + put("\\{\\\\c\\{C\\}\\}", "Ç"); + + put("\\{\\\\\\\uFFFD\\{E\\}\\}", "É"); + put("\\{\\\\\\\uFFFD\\{i\\}\\}", "í"); + put("\\{\\\\\\\uFFFD\\{I\\}\\}", "Í"); + put("\\{\\\\\\\uFFFD\\{o\\}\\}", "ó"); + put("\\{\\\\\\\uFFFD\\{O\\}\\}", "Ó"); + put("\\{\\\\\\\uFFFD\\{u\\}\\}", "ú"); + put("\\{\\\\\\\uFFFD\\{U\\}\\}", "Ú"); + put("\\{\\\\\\\uFFFD\\{a\\}\\}", "á"); + put("\\{\\\\\\\uFFFD\\{A\\}\\}", "Á"); + + //next 2 rows were missing... + put("\\{\\\\\\^\\{a\\}\\}", "â"); + put("\\{\\\\\\^\\{A\\}\\}", "Â"); + + put("\\{\\\\\\^\\{o\\}\\}", "ô"); + put("\\{\\\\\\^\\{O\\}\\}", "Ô"); + put("\\{\\\\\\^\\{u\\}\\}", "ù"); + put("\\{\\\\\\^\\{U\\}\\}", "Ù"); + put("\\{\\\\\\^\\{e\\}\\}", "ê"); + put("\\{\\\\\\^\\{E\\}\\}", "Ê"); + put("\\{\\\\\\^\\{i\\}\\}", "î"); + put("\\{\\\\\\^\\{I\\}\\}", "Î"); + + put("\\{\\\\\\~\\{o\\}\\}", "õ"); + put("\\{\\\\\\~\\{O\\}\\}", "Õ"); + put("\\{\\\\\\~\\{n\\}\\}", "ñ"); + put("\\{\\\\\\~\\{N\\}\\}", "Ñ"); + put("\\{\\\\\\~\\{a\\}\\}", "ã"); + put("\\{\\\\\\~\\{A\\}\\}", "Ã"); + + put("\\{\\\\\\\"a\\}", "ä"); + put("\\{\\\\\\\"A\\}", "Ä"); + put("\\{\\\\\\\"e\\}", "ë"); + put("\\{\\\\\\\"E\\}", "Ë"); + put("\\{\\\\\\\"i\\}", "ï"); + put("\\{\\\\\\\"I\\}", "Ï"); + put("\\{\\\\\\\"o\\}", "ö"); + put("\\{\\\\\\\"O\\}", "Ö"); + put("\\{\\\\\\\"u\\}", "ü"); + put("\\{\\\\\\\"U\\}", "Ü"); + + //next 2 rows were missing... + put("\\{\\\\\\`a\\}", "à"); + put("\\{\\\\\\`A\\}", "À"); + + put("\\{\\\\\\`e\\}", "è"); + put("\\{\\\\\\`E\\}", "È"); + put("\\{\\\\\\`i\\}", "ì"); + put("\\{\\\\\\`I\\}", "Ì"); + put("\\{\\\\\\`o\\}", "ò"); + put("\\{\\\\\\`O\\}", "Ò"); + put("\\{\\\\\\`u\\}", "ù"); + put("\\{\\\\\\`U\\}", "Ù"); + put("\\{\\\\\\'e\\}", "é"); + put("\\{\\\\\\'E\\}", "É"); + put("\\{\\\\\\'i\\}", "í"); + put("\\{\\\\\\'I\\}", "Í"); + put("\\{\\\\\\'o\\}", "ó"); + put("\\{\\\\\\'O\\}", "Ó"); + put("\\{\\\\\\'u\\}", "ú"); + put("\\{\\\\\\'U\\}", "Ú"); + put("\\{\\\\\\'a\\}", "á"); + put("\\{\\\\\\'A\\}", "Á"); + //added next two chars... + put("\\{\\\\\\'c\\}", "ć"); + put("\\{\\\\\\'C\\}", "Ć"); + + //next two lines were wrong... + put("\\{\\\\\\^a\\}", "â"); + put("\\{\\\\\\^A\\}", "Â"); + + put("\\{\\\\\\^o\\}", "ô"); + put("\\{\\\\\\^O\\}", "Ô"); + put("\\{\\\\\\^u\\}", "ù"); + put("\\{\\\\\\^U\\}", "Ù"); + put("\\{\\\\\\^e\\}", "ê"); + put("\\{\\\\\\^E\\}", "Ê"); + put("\\{\\\\\\^i\\}", "î"); + put("\\{\\\\\\^I\\}", "Î"); + put("\\{\\\\\\~o\\}", "õ"); + put("\\{\\\\\\~O\\}", "Õ"); + put("\\{\\\\\\~n\\}", "ñ"); + put("\\{\\\\\\~N\\}", "Ñ"); + put("\\{\\\\\\~a\\}", "ã"); + put("\\{\\\\\\~A\\}", "Ã"); + } + +} diff --git a/src/main/java/net/sf/jabref/mods/MODSEntry.java b/src/main/java/net/sf/jabref/mods/MODSEntry.java index a1d298f20c8..eb5e9cea217 100644 --- a/src/main/java/net/sf/jabref/mods/MODSEntry.java +++ b/src/main/java/net/sf/jabref/mods/MODSEntry.java @@ -29,7 +29,7 @@ import net.sf.jabref.BibtexEntry; import net.sf.jabref.BibtexEntryType; import net.sf.jabref.export.layout.LayoutFormatter; -import net.sf.jabref.export.layout.format.XMLChars; +import net.sf.jabref.export.layout.format.XMLCharFormatter; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -83,7 +83,7 @@ public MODSEntry(BibtexEntry bibtex) { } private void populateFromBibtex(BibtexEntry bibtex) { - LayoutFormatter chars = new XMLChars(); + LayoutFormatter chars = new XMLCharFormatter(); if (bibtex.getField("title") != null) { if (CHARFORMAT) { title = chars.format(bibtex.getField("title")); @@ -149,7 +149,7 @@ private void populateExtensionFields(BibtexEntry e) { private List getAuthors(String authors) { List result = new LinkedList(); - LayoutFormatter chars = new XMLChars(); + LayoutFormatter chars = new XMLCharFormatter(); if (!authors.contains(" and ")) { if (CHARFORMAT) { diff --git a/src/main/java/net/sf/jabref/msbib/MSBibEntry.java b/src/main/java/net/sf/jabref/msbib/MSBibEntry.java index 5da9890afc5..b40d62fe6c3 100644 --- a/src/main/java/net/sf/jabref/msbib/MSBibEntry.java +++ b/src/main/java/net/sf/jabref/msbib/MSBibEntry.java @@ -34,7 +34,7 @@ import net.sf.jabref.BibtexEntryType; import net.sf.jabref.BibtexFields; import net.sf.jabref.export.layout.LayoutFormatter; -import net.sf.jabref.export.layout.format.XMLChars; +import net.sf.jabref.export.layout.format.XMLCharFormatter; import net.sf.jabref.mods.PageNumbers; import net.sf.jabref.mods.PersonName; @@ -566,7 +566,7 @@ private String format(String value) return null; } String result = null; - LayoutFormatter chars = new XMLChars(); + LayoutFormatter chars = new XMLCharFormatter(); result = chars.format(value); return result; } From 272256272a8cfa88da236e89357ad858ccd87fae Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 29 Jul 2015 16:05:01 +0200 Subject: [PATCH 18/23] Move ASCII2XML_CHARS to XMLCharFormatter --- src/main/java/net/sf/jabref/Globals.java | 5 ----- .../jabref/export/layout/format/XMLCharFormatter.java | 10 +++++++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/sf/jabref/Globals.java b/src/main/java/net/sf/jabref/Globals.java index 9d052e10f9c..0aaf1f89c3c 100644 --- a/src/main/java/net/sf/jabref/Globals.java +++ b/src/main/java/net/sf/jabref/Globals.java @@ -367,15 +367,10 @@ public static BibtexEntryType getEntryType(String type) { public static final String SPECIAL_COMMAND_CHARS = "\"`^~'c="; - public static final HashMap ASCII2XML_CHARS = new HashMap(); public static final HashMap UNICODE_CHARS = new HashMap(); public static final HashMap RTFCHARS = new HashMap(); static { - Globals.ASCII2XML_CHARS.put("<", "<"); - Globals.ASCII2XML_CHARS.put("\"", """); - Globals.ASCII2XML_CHARS.put(">", ">"); - Globals.UNICODE_CHARS.put("\u00C0", "A"); Globals.UNICODE_CHARS.put("\u00C1", "A"); Globals.UNICODE_CHARS.put("\u00C2", "A"); diff --git a/src/main/java/net/sf/jabref/export/layout/format/XMLCharFormatter.java b/src/main/java/net/sf/jabref/export/layout/format/XMLCharFormatter.java index ca8d2069c5f..3df35025a65 100644 --- a/src/main/java/net/sf/jabref/export/layout/format/XMLCharFormatter.java +++ b/src/main/java/net/sf/jabref/export/layout/format/XMLCharFormatter.java @@ -37,6 +37,7 @@ package net.sf.jabref.export.layout.format; +import java.util.HashMap; import java.util.Map; import net.sf.jabref.Globals; @@ -48,7 +49,14 @@ public class XMLCharFormatter implements LayoutFormatter { private static XmlCharsMap xmlChars = new XmlCharsMap(); + + private static Map asciiToXmlChars = new HashMap(); + static { + asciiToXmlChars.put("<", "<"); + asciiToXmlChars.put("\"", """); + asciiToXmlChars.put(">", ">"); + } @Override public String format(String fieldText) { @@ -116,7 +124,7 @@ private String restFormat(String toFormat) { fieldText = buffer.toString(); // use common abbreviations for <, > instead of code - for (Map.Entry entry : Globals.ASCII2XML_CHARS.entrySet()) { + for (Map.Entry entry : asciiToXmlChars.entrySet()) { String s = entry.getKey(); String repl = entry.getValue(); From 55ae2fe4d2bf7e325199d4944526ebe41a498a09 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 29 Jul 2015 16:09:10 +0200 Subject: [PATCH 19/23] Extract map of unicode chars from Globals --- src/main/java/net/sf/jabref/Globals.java | 234 +---------------- .../net/sf/jabref/util/UnicodeCharMap.java | 245 ++++++++++++++++++ src/main/java/net/sf/jabref/util/Util.java | 4 +- 3 files changed, 249 insertions(+), 234 deletions(-) create mode 100644 src/main/java/net/sf/jabref/util/UnicodeCharMap.java diff --git a/src/main/java/net/sf/jabref/Globals.java b/src/main/java/net/sf/jabref/Globals.java index 0aaf1f89c3c..6a834d47270 100644 --- a/src/main/java/net/sf/jabref/Globals.java +++ b/src/main/java/net/sf/jabref/Globals.java @@ -367,242 +367,10 @@ public static BibtexEntryType getEntryType(String type) { public static final String SPECIAL_COMMAND_CHARS = "\"`^~'c="; - public static final HashMap UNICODE_CHARS = new HashMap(); public static final HashMap RTFCHARS = new HashMap(); static { - Globals.UNICODE_CHARS.put("\u00C0", "A"); - Globals.UNICODE_CHARS.put("\u00C1", "A"); - Globals.UNICODE_CHARS.put("\u00C2", "A"); - Globals.UNICODE_CHARS.put("\u00C3", "A"); - Globals.UNICODE_CHARS.put("\u00C4", "Ae"); - Globals.UNICODE_CHARS.put("\u00C5", "Aa"); - Globals.UNICODE_CHARS.put("\u00C6", "Ae"); - Globals.UNICODE_CHARS.put("\u00C7", "C"); - Globals.UNICODE_CHARS.put("\u00C8", "E"); - Globals.UNICODE_CHARS.put("\u00C9", "E"); - Globals.UNICODE_CHARS.put("\u00CA", "E"); - Globals.UNICODE_CHARS.put("\u00CB", "E"); - Globals.UNICODE_CHARS.put("\u00CC", "I"); - Globals.UNICODE_CHARS.put("\u00CD", "I"); - Globals.UNICODE_CHARS.put("\u00CE", "I"); - Globals.UNICODE_CHARS.put("\u00CF", "I"); - Globals.UNICODE_CHARS.put("\u00D0", "D"); - Globals.UNICODE_CHARS.put("\u00D1", "N"); - Globals.UNICODE_CHARS.put("\u00D2", "O"); - Globals.UNICODE_CHARS.put("\u00D3", "O"); - Globals.UNICODE_CHARS.put("\u00D4", "O"); - Globals.UNICODE_CHARS.put("\u00D5", "O"); - Globals.UNICODE_CHARS.put("\u00D6", "Oe"); - Globals.UNICODE_CHARS.put("\u00D8", "Oe"); - Globals.UNICODE_CHARS.put("\u00D9", "U"); - Globals.UNICODE_CHARS.put("\u00DA", "U"); - Globals.UNICODE_CHARS.put("\u00DB", "U"); - Globals.UNICODE_CHARS.put("\u00DC", "Ue"); // U umlaut .. - Globals.UNICODE_CHARS.put("\u00DD", "Y"); - Globals.UNICODE_CHARS.put("\u00DF", "ss"); - Globals.UNICODE_CHARS.put("\u00E0", "a"); - Globals.UNICODE_CHARS.put("\u00E1", "a"); - Globals.UNICODE_CHARS.put("\u00E2", "a"); - Globals.UNICODE_CHARS.put("\u00E3", "a"); - Globals.UNICODE_CHARS.put("\u00E4", "ae"); - Globals.UNICODE_CHARS.put("\u00E5", "aa"); - Globals.UNICODE_CHARS.put("\u00E6", "ae"); - Globals.UNICODE_CHARS.put("\u00E7", "c"); - Globals.UNICODE_CHARS.put("\u00E8", "e"); - Globals.UNICODE_CHARS.put("\u00E9", "e"); - Globals.UNICODE_CHARS.put("\u00EA", "e"); - Globals.UNICODE_CHARS.put("\u00EB", "e"); - Globals.UNICODE_CHARS.put("\u00EC", "i"); - Globals.UNICODE_CHARS.put("\u00ED", "i"); - Globals.UNICODE_CHARS.put("\u00EE", "i"); - Globals.UNICODE_CHARS.put("\u00EF", "i"); - Globals.UNICODE_CHARS.put("\u00F0", "o"); - Globals.UNICODE_CHARS.put("\u00F1", "n"); - Globals.UNICODE_CHARS.put("\u00F2", "o"); - Globals.UNICODE_CHARS.put("\u00F3", "o"); - Globals.UNICODE_CHARS.put("\u00F4", "o"); - Globals.UNICODE_CHARS.put("\u00F5", "o"); - Globals.UNICODE_CHARS.put("\u00F6", "oe"); - Globals.UNICODE_CHARS.put("\u00F8", "oe"); - Globals.UNICODE_CHARS.put("\u00F9", "u"); - Globals.UNICODE_CHARS.put("\u00FA", "u"); - Globals.UNICODE_CHARS.put("\u00FB", "u"); - Globals.UNICODE_CHARS.put("\u00FC", "ue"); // u umlaut... - Globals.UNICODE_CHARS.put("\u00FD", "y"); - Globals.UNICODE_CHARS.put("\u00FF", "y"); - Globals.UNICODE_CHARS.put("\u0100", "A"); - Globals.UNICODE_CHARS.put("\u0101", "a"); - Globals.UNICODE_CHARS.put("\u0102", "A"); - Globals.UNICODE_CHARS.put("\u0103", "a"); - Globals.UNICODE_CHARS.put("\u0104", "A"); - Globals.UNICODE_CHARS.put("\u0105", "a"); - Globals.UNICODE_CHARS.put("\u0106", "C"); - Globals.UNICODE_CHARS.put("\u0107", "c"); - Globals.UNICODE_CHARS.put("\u0108", "C"); - Globals.UNICODE_CHARS.put("\u0109", "c"); - Globals.UNICODE_CHARS.put("\u010A", "C"); - Globals.UNICODE_CHARS.put("\u010B", "c"); - Globals.UNICODE_CHARS.put("\u010C", "C"); - Globals.UNICODE_CHARS.put("\u010D", "c"); - Globals.UNICODE_CHARS.put("\u010E", "D"); - Globals.UNICODE_CHARS.put("\u010F", "d"); - Globals.UNICODE_CHARS.put("\u0110", "D"); - Globals.UNICODE_CHARS.put("\u0111", "d"); - Globals.UNICODE_CHARS.put("\u0112", "E"); - Globals.UNICODE_CHARS.put("\u0113", "e"); - Globals.UNICODE_CHARS.put("\u0114", "E"); - Globals.UNICODE_CHARS.put("\u0115", "e"); - Globals.UNICODE_CHARS.put("\u0116", "E"); - Globals.UNICODE_CHARS.put("\u0117", "e"); - Globals.UNICODE_CHARS.put("\u0118", "E"); - Globals.UNICODE_CHARS.put("\u0119", "e"); - Globals.UNICODE_CHARS.put("\u011A", "E"); - Globals.UNICODE_CHARS.put("\u011B", "e"); - Globals.UNICODE_CHARS.put("\u011C", "G"); - Globals.UNICODE_CHARS.put("\u011D", "g"); - Globals.UNICODE_CHARS.put("\u011E", "G"); - Globals.UNICODE_CHARS.put("\u011F", "g"); - Globals.UNICODE_CHARS.put("\u0120", "G"); - Globals.UNICODE_CHARS.put("\u0121", "g"); - Globals.UNICODE_CHARS.put("\u0122", "G"); - Globals.UNICODE_CHARS.put("\u0123", "g"); - Globals.UNICODE_CHARS.put("\u0124", "H"); - Globals.UNICODE_CHARS.put("\u0125", "h"); - Globals.UNICODE_CHARS.put("\u0127", "h"); - Globals.UNICODE_CHARS.put("\u0128", "I"); - Globals.UNICODE_CHARS.put("\u0129", "i"); - Globals.UNICODE_CHARS.put("\u012A", "I"); - Globals.UNICODE_CHARS.put("\u012B", "i"); - Globals.UNICODE_CHARS.put("\u012C", "I"); - Globals.UNICODE_CHARS.put("\u012D", "i"); - Globals.UNICODE_CHARS.put("\u012E", "I"); - Globals.UNICODE_CHARS.put("\u012F", "i"); - Globals.UNICODE_CHARS.put("\u0130", "I"); - Globals.UNICODE_CHARS.put("\u0131", "i"); - Globals.UNICODE_CHARS.put("\u0132", "IJ"); - Globals.UNICODE_CHARS.put("\u0133", "ij"); - Globals.UNICODE_CHARS.put("\u0134", "J"); - Globals.UNICODE_CHARS.put("\u0135", "j"); - Globals.UNICODE_CHARS.put("\u0136", "K"); - Globals.UNICODE_CHARS.put("\u0137", "k"); - Globals.UNICODE_CHARS.put("\u0138", "k"); - Globals.UNICODE_CHARS.put("\u0139", "L"); - Globals.UNICODE_CHARS.put("\u013A", "l"); - Globals.UNICODE_CHARS.put("\u013B", "L"); - Globals.UNICODE_CHARS.put("\u013C", "l"); - Globals.UNICODE_CHARS.put("\u013D", "L"); - Globals.UNICODE_CHARS.put("\u013E", "l"); - Globals.UNICODE_CHARS.put("\u013F", "L"); - Globals.UNICODE_CHARS.put("\u0140", "l"); - Globals.UNICODE_CHARS.put("\u0141", "L"); - Globals.UNICODE_CHARS.put("\u0142", "l"); - Globals.UNICODE_CHARS.put("\u0143", "N"); - Globals.UNICODE_CHARS.put("\u0144", "n"); - Globals.UNICODE_CHARS.put("\u0145", "N"); - Globals.UNICODE_CHARS.put("\u0146", "n"); - Globals.UNICODE_CHARS.put("\u0147", "N"); - Globals.UNICODE_CHARS.put("\u0148", "n"); - Globals.UNICODE_CHARS.put("\u0149", "n"); - Globals.UNICODE_CHARS.put("\u014A", "N"); - Globals.UNICODE_CHARS.put("\u014B", "n"); - Globals.UNICODE_CHARS.put("\u014C", "O"); - Globals.UNICODE_CHARS.put("\u014D", "o"); - Globals.UNICODE_CHARS.put("\u014E", "O"); - Globals.UNICODE_CHARS.put("\u014F", "o"); - Globals.UNICODE_CHARS.put("\u0150", "Oe"); - Globals.UNICODE_CHARS.put("\u0151", "oe"); - Globals.UNICODE_CHARS.put("\u0152", "OE"); - Globals.UNICODE_CHARS.put("\u0153", "oe"); - Globals.UNICODE_CHARS.put("\u0154", "R"); - Globals.UNICODE_CHARS.put("\u0155", "r"); - Globals.UNICODE_CHARS.put("\u0156", "R"); - Globals.UNICODE_CHARS.put("\u0157", "r"); - Globals.UNICODE_CHARS.put("\u0158", "R"); - Globals.UNICODE_CHARS.put("\u0159", "r"); - Globals.UNICODE_CHARS.put("\u015A", "S"); - Globals.UNICODE_CHARS.put("\u015B", "s"); - Globals.UNICODE_CHARS.put("\u015C", "S"); - Globals.UNICODE_CHARS.put("\u015D", "s"); - Globals.UNICODE_CHARS.put("\u015E", "S"); - Globals.UNICODE_CHARS.put("\u015F", "s"); - Globals.UNICODE_CHARS.put("\u0160", "S"); - Globals.UNICODE_CHARS.put("\u0161", "s"); - Globals.UNICODE_CHARS.put("\u0162", "T"); - Globals.UNICODE_CHARS.put("\u0163", "t"); - Globals.UNICODE_CHARS.put("\u0164", "T"); - Globals.UNICODE_CHARS.put("\u0165", "t"); - Globals.UNICODE_CHARS.put("\u0166", "T"); - Globals.UNICODE_CHARS.put("\u0167", "t"); - Globals.UNICODE_CHARS.put("\u0168", "U"); - Globals.UNICODE_CHARS.put("\u0169", "u"); - Globals.UNICODE_CHARS.put("\u016A", "U"); - Globals.UNICODE_CHARS.put("\u016B", "u"); - Globals.UNICODE_CHARS.put("\u016C", "U"); - Globals.UNICODE_CHARS.put("\u016D", "u"); - Globals.UNICODE_CHARS.put("\u016E", "UU"); - Globals.UNICODE_CHARS.put("\u016F", "uu"); - Globals.UNICODE_CHARS.put("\u0170", "Ue"); - Globals.UNICODE_CHARS.put("\u0171", "ue"); - Globals.UNICODE_CHARS.put("\u0172", "U"); - Globals.UNICODE_CHARS.put("\u0173", "u"); - Globals.UNICODE_CHARS.put("\u0174", "W"); - Globals.UNICODE_CHARS.put("\u0175", "w"); - Globals.UNICODE_CHARS.put("\u0176", "Y"); - Globals.UNICODE_CHARS.put("\u0177", "y"); - Globals.UNICODE_CHARS.put("\u0178", "Y"); - Globals.UNICODE_CHARS.put("\u0179", "Z"); - Globals.UNICODE_CHARS.put("\u017A", "z"); - Globals.UNICODE_CHARS.put("\u017B", "Z"); - Globals.UNICODE_CHARS.put("\u017C", "z"); - Globals.UNICODE_CHARS.put("\u017D", "Z"); - Globals.UNICODE_CHARS.put("\u017E", "z"); - Globals.UNICODE_CHARS.put("\u1EBC", "E"); - Globals.UNICODE_CHARS.put("\u1EBD", "e"); - Globals.UNICODE_CHARS.put("\u1EF8", "Y"); - Globals.UNICODE_CHARS.put("\u1EF9", "y"); - Globals.UNICODE_CHARS.put("\u01CD", "A"); - Globals.UNICODE_CHARS.put("\u01CE", "a"); - Globals.UNICODE_CHARS.put("\u01CF", "I"); - Globals.UNICODE_CHARS.put("\u01D0", "i"); - Globals.UNICODE_CHARS.put("\u01D1", "O"); - Globals.UNICODE_CHARS.put("\u01D2", "o"); - Globals.UNICODE_CHARS.put("\u01D3", "U"); - Globals.UNICODE_CHARS.put("\u01D4", "u"); - Globals.UNICODE_CHARS.put("\u0232", "Y"); - Globals.UNICODE_CHARS.put("\u0233", "y"); - Globals.UNICODE_CHARS.put("\u01EA", "O"); - Globals.UNICODE_CHARS.put("\u01EB", "o"); - Globals.UNICODE_CHARS.put("\u1E0C", "D"); - Globals.UNICODE_CHARS.put("\u1E0D", "d"); - Globals.UNICODE_CHARS.put("\u1E24", "H"); - Globals.UNICODE_CHARS.put("\u1E25", "h"); - Globals.UNICODE_CHARS.put("\u1E36", "L"); - Globals.UNICODE_CHARS.put("\u1E37", "l"); - Globals.UNICODE_CHARS.put("\u1E38", "L"); - Globals.UNICODE_CHARS.put("\u1E39", "l"); - Globals.UNICODE_CHARS.put("\u1E42", "M"); - Globals.UNICODE_CHARS.put("\u1E43", "m"); - Globals.UNICODE_CHARS.put("\u1E46", "N"); - Globals.UNICODE_CHARS.put("\u1E47", "n"); - Globals.UNICODE_CHARS.put("\u1E5A", "R"); - Globals.UNICODE_CHARS.put("\u1E5B", "r"); - Globals.UNICODE_CHARS.put("\u1E5C", "R"); - Globals.UNICODE_CHARS.put("\u1E5D", "r"); - Globals.UNICODE_CHARS.put("\u1E62", "S"); - Globals.UNICODE_CHARS.put("\u1E63", "s"); - Globals.UNICODE_CHARS.put("\u1E6C", "T"); - Globals.UNICODE_CHARS.put("\u1E6D", "t"); - Globals.UNICODE_CHARS.put("\u00CF", "I"); - - Globals.UNICODE_CHARS.put("\u008C", "AE"); // doesn't work? - Globals.UNICODE_CHARS.put("\u016E", "U"); - Globals.UNICODE_CHARS.put("\u016F", "u"); - - Globals.UNICODE_CHARS.put("\u0178", "Y"); - Globals.UNICODE_CHARS.put("\u00FE", ""); // thorn character - - // UNICODE_CHARS.put("\u0100", ""); + Globals.RTFCHARS.put("`a", "\\'e0"); Globals.RTFCHARS.put("`e", "\\'e8"); diff --git a/src/main/java/net/sf/jabref/util/UnicodeCharMap.java b/src/main/java/net/sf/jabref/util/UnicodeCharMap.java new file mode 100644 index 00000000000..cbe06b207f0 --- /dev/null +++ b/src/main/java/net/sf/jabref/util/UnicodeCharMap.java @@ -0,0 +1,245 @@ +package net.sf.jabref.util; + +import java.util.HashMap; + +public class UnicodeCharMap extends HashMap { + + private static final long serialVersionUID = 1L; + + + public UnicodeCharMap() { + put("\u00C0", "A"); + put("\u00C1", "A"); + put("\u00C2", "A"); + put("\u00C3", "A"); + put("\u00C4", "Ae"); + put("\u00C5", "Aa"); + put("\u00C6", "Ae"); + put("\u00C7", "C"); + put("\u00C8", "E"); + put("\u00C9", "E"); + put("\u00CA", "E"); + put("\u00CB", "E"); + put("\u00CC", "I"); + put("\u00CD", "I"); + put("\u00CE", "I"); + put("\u00CF", "I"); + put("\u00D0", "D"); + put("\u00D1", "N"); + put("\u00D2", "O"); + put("\u00D3", "O"); + put("\u00D4", "O"); + put("\u00D5", "O"); + put("\u00D6", "Oe"); + put("\u00D8", "Oe"); + put("\u00D9", "U"); + put("\u00DA", "U"); + put("\u00DB", "U"); + put("\u00DC", "Ue"); // U umlaut .. + put("\u00DD", "Y"); + put("\u00DF", "ss"); + put("\u00E0", "a"); + put("\u00E1", "a"); + put("\u00E2", "a"); + put("\u00E3", "a"); + put("\u00E4", "ae"); + put("\u00E5", "aa"); + put("\u00E6", "ae"); + put("\u00E7", "c"); + put("\u00E8", "e"); + put("\u00E9", "e"); + put("\u00EA", "e"); + put("\u00EB", "e"); + put("\u00EC", "i"); + put("\u00ED", "i"); + put("\u00EE", "i"); + put("\u00EF", "i"); + put("\u00F0", "o"); + put("\u00F1", "n"); + put("\u00F2", "o"); + put("\u00F3", "o"); + put("\u00F4", "o"); + put("\u00F5", "o"); + put("\u00F6", "oe"); + put("\u00F8", "oe"); + put("\u00F9", "u"); + put("\u00FA", "u"); + put("\u00FB", "u"); + put("\u00FC", "ue"); // u umlaut... + put("\u00FD", "y"); + put("\u00FF", "y"); + put("\u0100", "A"); + put("\u0101", "a"); + put("\u0102", "A"); + put("\u0103", "a"); + put("\u0104", "A"); + put("\u0105", "a"); + put("\u0106", "C"); + put("\u0107", "c"); + put("\u0108", "C"); + put("\u0109", "c"); + put("\u010A", "C"); + put("\u010B", "c"); + put("\u010C", "C"); + put("\u010D", "c"); + put("\u010E", "D"); + put("\u010F", "d"); + put("\u0110", "D"); + put("\u0111", "d"); + put("\u0112", "E"); + put("\u0113", "e"); + put("\u0114", "E"); + put("\u0115", "e"); + put("\u0116", "E"); + put("\u0117", "e"); + put("\u0118", "E"); + put("\u0119", "e"); + put("\u011A", "E"); + put("\u011B", "e"); + put("\u011C", "G"); + put("\u011D", "g"); + put("\u011E", "G"); + put("\u011F", "g"); + put("\u0120", "G"); + put("\u0121", "g"); + put("\u0122", "G"); + put("\u0123", "g"); + put("\u0124", "H"); + put("\u0125", "h"); + put("\u0127", "h"); + put("\u0128", "I"); + put("\u0129", "i"); + put("\u012A", "I"); + put("\u012B", "i"); + put("\u012C", "I"); + put("\u012D", "i"); + put("\u012E", "I"); + put("\u012F", "i"); + put("\u0130", "I"); + put("\u0131", "i"); + put("\u0132", "IJ"); + put("\u0133", "ij"); + put("\u0134", "J"); + put("\u0135", "j"); + put("\u0136", "K"); + put("\u0137", "k"); + put("\u0138", "k"); + put("\u0139", "L"); + put("\u013A", "l"); + put("\u013B", "L"); + put("\u013C", "l"); + put("\u013D", "L"); + put("\u013E", "l"); + put("\u013F", "L"); + put("\u0140", "l"); + put("\u0141", "L"); + put("\u0142", "l"); + put("\u0143", "N"); + put("\u0144", "n"); + put("\u0145", "N"); + put("\u0146", "n"); + put("\u0147", "N"); + put("\u0148", "n"); + put("\u0149", "n"); + put("\u014A", "N"); + put("\u014B", "n"); + put("\u014C", "O"); + put("\u014D", "o"); + put("\u014E", "O"); + put("\u014F", "o"); + put("\u0150", "Oe"); + put("\u0151", "oe"); + put("\u0152", "OE"); + put("\u0153", "oe"); + put("\u0154", "R"); + put("\u0155", "r"); + put("\u0156", "R"); + put("\u0157", "r"); + put("\u0158", "R"); + put("\u0159", "r"); + put("\u015A", "S"); + put("\u015B", "s"); + put("\u015C", "S"); + put("\u015D", "s"); + put("\u015E", "S"); + put("\u015F", "s"); + put("\u0160", "S"); + put("\u0161", "s"); + put("\u0162", "T"); + put("\u0163", "t"); + put("\u0164", "T"); + put("\u0165", "t"); + put("\u0166", "T"); + put("\u0167", "t"); + put("\u0168", "U"); + put("\u0169", "u"); + put("\u016A", "U"); + put("\u016B", "u"); + put("\u016C", "U"); + put("\u016D", "u"); + put("\u016E", "UU"); + put("\u016F", "uu"); + put("\u0170", "Ue"); + put("\u0171", "ue"); + put("\u0172", "U"); + put("\u0173", "u"); + put("\u0174", "W"); + put("\u0175", "w"); + put("\u0176", "Y"); + put("\u0177", "y"); + put("\u0178", "Y"); + put("\u0179", "Z"); + put("\u017A", "z"); + put("\u017B", "Z"); + put("\u017C", "z"); + put("\u017D", "Z"); + put("\u017E", "z"); + put("\u1EBC", "E"); + put("\u1EBD", "e"); + put("\u1EF8", "Y"); + put("\u1EF9", "y"); + put("\u01CD", "A"); + put("\u01CE", "a"); + put("\u01CF", "I"); + put("\u01D0", "i"); + put("\u01D1", "O"); + put("\u01D2", "o"); + put("\u01D3", "U"); + put("\u01D4", "u"); + put("\u0232", "Y"); + put("\u0233", "y"); + put("\u01EA", "O"); + put("\u01EB", "o"); + put("\u1E0C", "D"); + put("\u1E0D", "d"); + put("\u1E24", "H"); + put("\u1E25", "h"); + put("\u1E36", "L"); + put("\u1E37", "l"); + put("\u1E38", "L"); + put("\u1E39", "l"); + put("\u1E42", "M"); + put("\u1E43", "m"); + put("\u1E46", "N"); + put("\u1E47", "n"); + put("\u1E5A", "R"); + put("\u1E5B", "r"); + put("\u1E5C", "R"); + put("\u1E5D", "r"); + put("\u1E62", "S"); + put("\u1E63", "s"); + put("\u1E6C", "T"); + put("\u1E6D", "t"); + put("\u00CF", "I"); + + put("\u008C", "AE"); // doesn't work? + put("\u016E", "U"); + put("\u016F", "u"); + + put("\u0178", "Y"); + put("\u00FE", ""); // thorn character + + // UNICODE_CHARS.put("\u0100", ""); + } + +} diff --git a/src/main/java/net/sf/jabref/util/Util.java b/src/main/java/net/sf/jabref/util/Util.java index 1d45ef54fac..91c6ee57dab 100644 --- a/src/main/java/net/sf/jabref/util/Util.java +++ b/src/main/java/net/sf/jabref/util/Util.java @@ -122,6 +122,8 @@ public class Util { private static final String ARXIV_LOOKUP_PREFIX = "http://arxiv.org/abs/"; private static final String SEPARATING_CHARS_NOSPACE = ";,\n"; + + private static final UnicodeCharMap UNICODE_CHAR_MAP = new UnicodeCharMap(); /** * This method sets the location of a Dialog such that it is centered with @@ -252,7 +254,7 @@ public static String checkLegalKey(String key) { * is the HashMap GLobals.UNICODE_CHARS. */ public static String replaceSpecialCharacters(String s) { - for (Map.Entry chrAndReplace : Globals.UNICODE_CHARS.entrySet()) { + for (Map.Entry chrAndReplace : UNICODE_CHAR_MAP.entrySet()) { s = s.replaceAll(chrAndReplace.getKey(), chrAndReplace.getValue()); } return s; From a86b9a6ecf04f6012266d2444348fd620bcb0f8a Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 29 Jul 2015 16:10:56 +0200 Subject: [PATCH 20/23] Turn char maps into constants --- .../export/layout/format/HTMLCharFormatter.java | 14 +++++++------- .../export/layout/format/XMLCharFormatter.java | 15 +++++++-------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/main/java/net/sf/jabref/export/layout/format/HTMLCharFormatter.java b/src/main/java/net/sf/jabref/export/layout/format/HTMLCharFormatter.java index ba4c86319af..9756d79acf0 100644 --- a/src/main/java/net/sf/jabref/export/layout/format/HTMLCharFormatter.java +++ b/src/main/java/net/sf/jabref/export/layout/format/HTMLCharFormatter.java @@ -24,7 +24,7 @@ */ public class HTMLCharFormatter implements LayoutFormatter { - private static HtmlCharsMap htmlChars= new HtmlCharsMap(); + private static final HtmlCharsMap HTML_CHARS = new HtmlCharsMap(); @Override public String format(String field) { @@ -47,7 +47,7 @@ public String format(String field) { if (incommand) { /* Close Command */ String command = currentCommand.toString(); - Object result = htmlChars.get(command); + Object result = HTML_CHARS.get(command); if (result != null) { sb.append((String) result); } else { @@ -88,7 +88,7 @@ public String format(String field) { combody = field.substring(i, i + 1); // System.out.println("... "+combody); } - Object result = htmlChars.get(command + combody); + Object result = HTML_CHARS.get(command + combody); if (result != null) { sb.append((String) result); @@ -100,7 +100,7 @@ public String format(String field) { // Are we already at the end of the string? if ((i + 1) == field.length()) { String command = currentCommand.toString(); - Object result = htmlChars.get(command); + Object result = HTML_CHARS.get(command); /* If found, then use translated version. If not, * then keep * the text of the parameter intact. @@ -144,7 +144,7 @@ public String format(String field) { argument = part; if (argument != null) { // handle common case of general latex command - Object result = htmlChars.get(command + argument); + Object result = HTML_CHARS.get(command + argument); // System.out.print("command: "+command+", arg: "+argument); // System.out.print(", result: "); // If found, then use translated version. If not, then keep @@ -160,7 +160,7 @@ public String format(String field) { // This end brace terminates a command. This can be the case in // constructs like {\aa}. The correct behaviour should be to // substitute the evaluated command and swallow the brace: - Object result = htmlChars.get(command); + Object result = HTML_CHARS.get(command); if (result != null) { sb.append((String) result); } else { @@ -168,7 +168,7 @@ public String format(String field) { sb.append(command); } } else { - Object result = htmlChars.get(command); + Object result = HTML_CHARS.get(command); if (result != null) { sb.append((String) result); } else { diff --git a/src/main/java/net/sf/jabref/export/layout/format/XMLCharFormatter.java b/src/main/java/net/sf/jabref/export/layout/format/XMLCharFormatter.java index 3df35025a65..d6ec4c115e0 100644 --- a/src/main/java/net/sf/jabref/export/layout/format/XMLCharFormatter.java +++ b/src/main/java/net/sf/jabref/export/layout/format/XMLCharFormatter.java @@ -40,7 +40,6 @@ import java.util.HashMap; import java.util.Map; -import net.sf.jabref.Globals; import net.sf.jabref.export.layout.LayoutFormatter; /** @@ -48,14 +47,14 @@ */ public class XMLCharFormatter implements LayoutFormatter { - private static XmlCharsMap xmlChars = new XmlCharsMap(); + private final static XmlCharsMap XML_CHARS = new XmlCharsMap(); - private static Map asciiToXmlChars = new HashMap(); + private final static Map ASCII_TO_XML_CHARS = new HashMap(); static { - asciiToXmlChars.put("<", "<"); - asciiToXmlChars.put("\"", """); - asciiToXmlChars.put(">", ">"); + ASCII_TO_XML_CHARS.put("<", "<"); + ASCII_TO_XML_CHARS.put("\"", """); + ASCII_TO_XML_CHARS.put(">", ">"); } @Override @@ -63,7 +62,7 @@ public String format(String fieldText) { fieldText = firstFormat(fieldText); - for (Map.Entry entry : xmlChars.entrySet()) { + for (Map.Entry entry : XML_CHARS.entrySet()) { String s = entry.getKey(); String repl = entry.getValue(); if (repl != null) { @@ -124,7 +123,7 @@ private String restFormat(String toFormat) { fieldText = buffer.toString(); // use common abbreviations for <, > instead of code - for (Map.Entry entry : asciiToXmlChars.entrySet()) { + for (Map.Entry entry : ASCII_TO_XML_CHARS.entrySet()) { String s = entry.getKey(); String repl = entry.getValue(); From 51b6365335de234184bcd6bc9f62e99ff30f29dd Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 29 Jul 2015 16:14:40 +0200 Subject: [PATCH 21/23] Extract rtf char map from Globals --- src/main/java/net/sf/jabref/Globals.java | 257 ----------------- .../{RTFChars.java => RTFCharFormatter.java} | 8 +- .../export/layout/format/RtfCharMap.java | 263 ++++++++++++++++++ .../sf/jabref/export/layout/RTFCharsTest.java | 10 +- 4 files changed, 273 insertions(+), 265 deletions(-) rename src/main/java/net/sf/jabref/export/layout/format/{RTFChars.java => RTFCharFormatter.java} (97%) create mode 100644 src/main/java/net/sf/jabref/export/layout/format/RtfCharMap.java diff --git a/src/main/java/net/sf/jabref/Globals.java b/src/main/java/net/sf/jabref/Globals.java index 6a834d47270..1821971100a 100644 --- a/src/main/java/net/sf/jabref/Globals.java +++ b/src/main/java/net/sf/jabref/Globals.java @@ -367,263 +367,6 @@ public static BibtexEntryType getEntryType(String type) { public static final String SPECIAL_COMMAND_CHARS = "\"`^~'c="; - public static final HashMap RTFCHARS = new HashMap(); - - static { - - - Globals.RTFCHARS.put("`a", "\\'e0"); - Globals.RTFCHARS.put("`e", "\\'e8"); - Globals.RTFCHARS.put("`i", "\\'ec"); - Globals.RTFCHARS.put("`o", "\\'f2"); - Globals.RTFCHARS.put("`u", "\\'f9"); - Globals.RTFCHARS.put("?a", "\\'e1"); - Globals.RTFCHARS.put("?e", "\\'e9"); - Globals.RTFCHARS.put("?i", "\\'ed"); - Globals.RTFCHARS.put("?o", "\\'f3"); - Globals.RTFCHARS.put("?u", "\\'fa"); - Globals.RTFCHARS.put("^a", "\\'e2"); - Globals.RTFCHARS.put("^e", "\\'ea"); - Globals.RTFCHARS.put("^i", "\\'ee"); - Globals.RTFCHARS.put("^o", "\\'f4"); - Globals.RTFCHARS.put("^u", "\\'fa"); - Globals.RTFCHARS.put("\"a", "\\'e4"); - Globals.RTFCHARS.put("\"e", "\\'eb"); - Globals.RTFCHARS.put("\"i", "\\'ef"); - Globals.RTFCHARS.put("\"o", "\\'f6"); - Globals.RTFCHARS.put("\"u", "\\u252u"); - Globals.RTFCHARS.put("~n", "\\'f1"); - Globals.RTFCHARS.put("`A", "\\'c0"); - Globals.RTFCHARS.put("`E", "\\'c8"); - Globals.RTFCHARS.put("`I", "\\'cc"); - Globals.RTFCHARS.put("`O", "\\'d2"); - Globals.RTFCHARS.put("`U", "\\'d9"); - Globals.RTFCHARS.put("?A", "\\'c1"); - Globals.RTFCHARS.put("?E", "\\'c9"); - Globals.RTFCHARS.put("?I", "\\'cd"); - Globals.RTFCHARS.put("?O", "\\'d3"); - Globals.RTFCHARS.put("?U", "\\'da"); - Globals.RTFCHARS.put("^A", "\\'c2"); - Globals.RTFCHARS.put("^E", "\\'ca"); - Globals.RTFCHARS.put("^I", "\\'ce"); - Globals.RTFCHARS.put("^O", "\\'d4"); - Globals.RTFCHARS.put("^U", "\\'db"); - Globals.RTFCHARS.put("\"A", "\\'c4"); - Globals.RTFCHARS.put("\"E", "\\'cb"); - Globals.RTFCHARS.put("\"I", "\\'cf"); - Globals.RTFCHARS.put("\"O", "\\'d6"); - Globals.RTFCHARS.put("\"U", "\\'dc"); - - // Use UNICODE characters for RTF-Chars which can not be found in the - // standard codepage - - Globals.RTFCHARS.put("`A", "\\u192A"); // "Agrave" - Globals.RTFCHARS.put("'A", "\\u193A"); // "Aacute" - Globals.RTFCHARS.put("^A", "\\u194A"); // "Acirc" - Globals.RTFCHARS.put("~A", "\\u195A"); // "Atilde" - Globals.RTFCHARS.put("\"A", "\\u196A"); // "Auml" - Globals.RTFCHARS.put("AA", "\\u197A"); // "Aring" - // RTFCHARS.put("AE", "{\\uc2\\u198AE}"); // "AElig" -Globals.RTFCHARS.put("AE", "{\\u198A}"); // "AElig" - Globals.RTFCHARS.put("cC", "\\u199C"); // "Ccedil" - Globals.RTFCHARS.put("`E", "\\u200E"); // "Egrave" - Globals.RTFCHARS.put("'E", "\\u201E"); // "Eacute" - Globals.RTFCHARS.put("^E", "\\u202E"); // "Ecirc" - Globals.RTFCHARS.put("\"E", "\\u203E"); // "Euml" - Globals.RTFCHARS.put("`I", "\\u204I"); // "Igrave - Globals.RTFCHARS.put("'I", "\\u205I"); // "Iacute" - Globals.RTFCHARS.put("^I", "\\u206I"); // "Icirc" - Globals.RTFCHARS.put("\"I", "\\u207I"); // "Iuml" - Globals.RTFCHARS.put("DH", "\\u208D"); // "ETH" - Globals.RTFCHARS.put("~N", "\\u209N"); // "Ntilde" - Globals.RTFCHARS.put("`O", "\\u210O"); // "Ograve" - Globals.RTFCHARS.put("'O", "\\u211O"); // "Oacute" - Globals.RTFCHARS.put("^O", "\\u212O"); // "Ocirc" - Globals.RTFCHARS.put("~O", "\\u213O"); // "Otilde" - Globals.RTFCHARS.put("\"O", "\\u214O"); // "Ouml" - // According to ISO 8859-1 the "\times" symbol should be placed here - // (#215). - // Omitting this, because it is a mathematical symbol. - Globals.RTFCHARS.put("O", "\\u216O"); // "Oslash" - // RTFCHARS.put("O", "\\'d8"); - Globals.RTFCHARS.put("o", "\\'f8"); - Globals.RTFCHARS.put("`U", "\\u217U"); // "Ugrave" - Globals.RTFCHARS.put("'U", "\\u218U"); // "Uacute" - Globals.RTFCHARS.put("^U", "\\u219U"); // "Ucirc" - Globals.RTFCHARS.put("\"U", "\\u220U"); // "Uuml" - Globals.RTFCHARS.put("'Y", "\\u221Y"); // "Yacute" - Globals.RTFCHARS.put("TH", "{\\uc2\\u222TH}"); // "THORN" - Globals.RTFCHARS.put("ss", "{\\uc2\\u223ss}"); // "szlig" - //RTFCHARS.put("ss", "AFFEN"); // "szlig" - Globals.RTFCHARS.put("`a", "\\u224a"); // "agrave" - Globals.RTFCHARS.put("'a", "\\u225a"); // "aacute" - Globals.RTFCHARS.put("^a", "\\u226a"); // "acirc" - Globals.RTFCHARS.put("~a", "\\u227a"); // "atilde" - Globals.RTFCHARS.put("\"a", "\\u228a"); // "auml" - Globals.RTFCHARS.put("aa", "\\u229a"); // "aring" - // RTFCHARS.put("ae", "{\\uc2\\u230ae}"); // "aelig" \\u230e6 -Globals.RTFCHARS.put("ae", "{\\u230a}"); // "aelig" \\u230e6 - Globals.RTFCHARS.put("cc", "\\u231c"); // "ccedil" - Globals.RTFCHARS.put("`e", "\\u232e"); // "egrave" - Globals.RTFCHARS.put("'e", "\\u233e"); // "eacute" - Globals.RTFCHARS.put("^e", "\\u234e"); // "ecirc" - Globals.RTFCHARS.put("\"e", "\\u235e"); // "euml" - Globals.RTFCHARS.put("`i", "\\u236i"); // "igrave" - Globals.RTFCHARS.put("'i", "\\u237i"); // "iacute" - Globals.RTFCHARS.put("^i", "\\u238i"); // "icirc" - Globals.RTFCHARS.put("\"i", "\\u239i"); // "iuml" - Globals.RTFCHARS.put("dh", "\\u240d"); // "eth" - Globals.RTFCHARS.put("~n", "\\u241n"); // "ntilde" - Globals.RTFCHARS.put("`o", "\\u242o"); // "ograve" - Globals.RTFCHARS.put("'o", "\\u243o"); // "oacute" - Globals.RTFCHARS.put("^o", "\\u244o"); // "ocirc" - Globals.RTFCHARS.put("~o", "\\u245o"); // "otilde" - Globals.RTFCHARS.put("\"o", "\\u246o"); // "ouml" - // According to ISO 8859-1 the "\div" symbol should be placed here - // (#247). - // Omitting this, because it is a mathematical symbol. - Globals.RTFCHARS.put("o", "\\u248o"); // "oslash" - Globals.RTFCHARS.put("`u", "\\u249u"); // "ugrave" - Globals.RTFCHARS.put("'u", "\\u250u"); // "uacute" - Globals.RTFCHARS.put("^u", "\\u251u"); // "ucirc" - // RTFCHARS.put("\"u", "\\u252"); // "uuml" exists in standard -// codepage - Globals.RTFCHARS.put("'y", "\\u253y"); // "yacute" - Globals.RTFCHARS.put("th", "{\\uc2\\u254th}"); // "thorn" - Globals.RTFCHARS.put("\"y", "\\u255y"); // "yuml" - - Globals.RTFCHARS.put("=A", "\\u256A"); // "Amacr" - Globals.RTFCHARS.put("=a", "\\u257a"); // "amacr" - Globals.RTFCHARS.put("uA", "\\u258A"); // "Abreve" - Globals.RTFCHARS.put("ua", "\\u259a"); // "abreve" - Globals.RTFCHARS.put("kA", "\\u260A"); // "Aogon" - Globals.RTFCHARS.put("ka", "\\u261a"); // "aogon" - Globals.RTFCHARS.put("'C", "\\u262C"); // "Cacute" - Globals.RTFCHARS.put("'c", "\\u263c"); // "cacute" - Globals.RTFCHARS.put("^C", "\\u264C"); // "Ccirc" - Globals.RTFCHARS.put("^c", "\\u265c"); // "ccirc" - Globals.RTFCHARS.put(".C", "\\u266C"); // "Cdot" - Globals.RTFCHARS.put(".c", "\\u267c"); // "cdot" - Globals.RTFCHARS.put("vC", "\\u268C"); // "Ccaron" - Globals.RTFCHARS.put("vc", "\\u269c"); // "ccaron" - Globals.RTFCHARS.put("vD", "\\u270D"); // "Dcaron" - // Symbol #271 (d) has no special Latex command - Globals.RTFCHARS.put("DJ", "\\u272D"); // "Dstrok" - Globals.RTFCHARS.put("dj", "\\u273d"); // "dstrok" - Globals.RTFCHARS.put("=E", "\\u274E"); // "Emacr" - Globals.RTFCHARS.put("=e", "\\u275e"); // "emacr" - Globals.RTFCHARS.put("uE", "\\u276E"); // "Ebreve" - Globals.RTFCHARS.put("ue", "\\u277e"); // "ebreve" - Globals.RTFCHARS.put(".E", "\\u278E"); // "Edot" - Globals.RTFCHARS.put(".e", "\\u279e"); // "edot" - Globals.RTFCHARS.put("kE", "\\u280E"); // "Eogon" - Globals.RTFCHARS.put("ke", "\\u281e"); // "eogon" - Globals.RTFCHARS.put("vE", "\\u282E"); // "Ecaron" - Globals.RTFCHARS.put("ve", "\\u283e"); // "ecaron" - Globals.RTFCHARS.put("^G", "\\u284G"); // "Gcirc" - Globals.RTFCHARS.put("^g", "\\u285g"); // "gcirc" - Globals.RTFCHARS.put("uG", "\\u286G"); // "Gbreve" - Globals.RTFCHARS.put("ug", "\\u287g"); // "gbreve" - Globals.RTFCHARS.put(".G", "\\u288G"); // "Gdot" - Globals.RTFCHARS.put(".g", "\\u289g"); // "gdot" - Globals.RTFCHARS.put("cG", "\\u290G"); // "Gcedil" - Globals.RTFCHARS.put("'g", "\\u291g"); // "gacute" - Globals.RTFCHARS.put("^H", "\\u292H"); // "Hcirc" - Globals.RTFCHARS.put("^h", "\\u293h"); // "hcirc" - Globals.RTFCHARS.put("Hstrok", "\\u294H"); // "Hstrok" - Globals.RTFCHARS.put("hstrok", "\\u295h"); // "hstrok" - Globals.RTFCHARS.put("~I", "\\u296I"); // "Itilde" - Globals.RTFCHARS.put("~i", "\\u297i"); // "itilde" - Globals.RTFCHARS.put("=I", "\\u298I"); // "Imacr" - Globals.RTFCHARS.put("=i", "\\u299i"); // "imacr" - Globals.RTFCHARS.put("uI", "\\u300I"); // "Ibreve" - Globals.RTFCHARS.put("ui", "\\u301i"); // "ibreve" - Globals.RTFCHARS.put("kI", "\\u302I"); // "Iogon" - Globals.RTFCHARS.put("ki", "\\u303i"); // "iogon" - Globals.RTFCHARS.put(".I", "\\u304I"); // "Idot" - Globals.RTFCHARS.put("i", "\\u305i"); // "inodot" - // Symbol #306 (IJ) has no special Latex command - // Symbol #307 (ij) has no special Latex command - Globals.RTFCHARS.put("^J", "\\u308J"); // "Jcirc" - Globals.RTFCHARS.put("^j", "\\u309j"); // "jcirc" - Globals.RTFCHARS.put("cK", "\\u310K"); // "Kcedil" - Globals.RTFCHARS.put("ck", "\\u311k"); // "kcedil" - // Symbol #312 (k) has no special Latex command - Globals.RTFCHARS.put("'L", "\\u313L"); // "Lacute" - Globals.RTFCHARS.put("'l", "\\u314l"); // "lacute" - Globals.RTFCHARS.put("cL", "\\u315L"); // "Lcedil" - Globals.RTFCHARS.put("cl", "\\u316l"); // "lcedil" - // Symbol #317 (L) has no special Latex command - // Symbol #318 (l) has no special Latex command - Globals.RTFCHARS.put("Lmidot", "\\u319L"); // "Lmidot" - Globals.RTFCHARS.put("lmidot", "\\u320l"); // "lmidot" - Globals.RTFCHARS.put("L", "\\u321L"); // "Lstrok" - Globals.RTFCHARS.put("l", "\\u322l"); // "lstrok" - Globals.RTFCHARS.put("'N", "\\u323N"); // "Nacute" - Globals.RTFCHARS.put("'n", "\\u324n"); // "nacute" - Globals.RTFCHARS.put("cN", "\\u325N"); // "Ncedil" - Globals.RTFCHARS.put("cn", "\\u326n"); // "ncedil" - Globals.RTFCHARS.put("vN", "\\u327N"); // "Ncaron" - Globals.RTFCHARS.put("vn", "\\u328n"); // "ncaron" - // Symbol #329 (n) has no special Latex command - Globals.RTFCHARS.put("NG", "\\u330G"); // "ENG" - Globals.RTFCHARS.put("ng", "\\u331g"); // "eng" - Globals.RTFCHARS.put("=O", "\\u332O"); // "Omacr" - Globals.RTFCHARS.put("=o", "\\u333o"); // "omacr" - Globals.RTFCHARS.put("uO", "\\u334O"); // "Obreve" - Globals.RTFCHARS.put("uo", "\\u335o"); // "obreve" - Globals.RTFCHARS.put("HO", "\\u336?"); // "Odblac" - Globals.RTFCHARS.put("Ho", "\\u337?"); // "odblac" - Globals.RTFCHARS.put("OE", "{\\uc2\\u338OE}"); // "OElig" - Globals.RTFCHARS.put("oe", "{\\uc2\\u339oe}"); // "oelig" - Globals.RTFCHARS.put("'R", "\\u340R"); // "Racute" - Globals.RTFCHARS.put("'r", "\\u341r"); // "racute" - Globals.RTFCHARS.put("cR", "\\u342R"); // "Rcedil" - Globals.RTFCHARS.put("cr", "\\u343r"); // "rcedil" - Globals.RTFCHARS.put("vR", "\\u344R"); // "Rcaron" - Globals.RTFCHARS.put("vr", "\\u345r"); // "rcaron" - Globals.RTFCHARS.put("'S", "\\u346S"); // "Sacute" - Globals.RTFCHARS.put("'s", "\\u347s"); // "sacute" - Globals.RTFCHARS.put("^S", "\\u348S"); // "Scirc" - Globals.RTFCHARS.put("^s", "\\u349s"); // "scirc" - Globals.RTFCHARS.put("cS", "\\u350S"); // "Scedil" - Globals.RTFCHARS.put("cs", "\\u351s"); // "scedil" - Globals.RTFCHARS.put("vS", "\\u352S"); // "Scaron" - Globals.RTFCHARS.put("vs", "\\u353s"); // "scaron" - Globals.RTFCHARS.put("cT", "\\u354T"); // "Tcedil" - Globals.RTFCHARS.put("ct", "\\u355t"); // "tcedil" - Globals.RTFCHARS.put("vT", "\\u356T"); // "Tcaron" - // Symbol #357 (t) has no special Latex command - Globals.RTFCHARS.put("Tstrok", "\\u358T"); // "Tstrok" - Globals.RTFCHARS.put("tstrok", "\\u359t"); // "tstrok" - Globals.RTFCHARS.put("~U", "\\u360U"); // "Utilde" - Globals.RTFCHARS.put("~u", "\\u361u"); // "utilde" - Globals.RTFCHARS.put("=U", "\\u362U"); // "Umacr" - Globals.RTFCHARS.put("=u", "\\u363u"); // "umacr" - Globals.RTFCHARS.put("uU", "\\u364U"); // "Ubreve" - Globals.RTFCHARS.put("uu", "\\u365u"); // "ubreve" - Globals.RTFCHARS.put("rU", "\\u366U"); // "Uring" - Globals.RTFCHARS.put("ru", "\\u367u"); // "uring" - Globals.RTFCHARS.put("HU", "\\u368?"); // "Odblac" - Globals.RTFCHARS.put("Hu", "\\u369?"); // "odblac" - Globals.RTFCHARS.put("kU", "\\u370U"); // "Uogon" - Globals.RTFCHARS.put("ku", "\\u371u"); // "uogon" - Globals.RTFCHARS.put("^W", "\\u372W"); // "Wcirc" - Globals.RTFCHARS.put("^w", "\\u373w"); // "wcirc" - Globals.RTFCHARS.put("^Y", "\\u374Y"); // "Ycirc" - Globals.RTFCHARS.put("^y", "\\u375y"); // "ycirc" - Globals.RTFCHARS.put("\"Y", "\\u376Y"); // "Yuml" - Globals.RTFCHARS.put("'Z", "\\u377Z"); // "Zacute" - Globals.RTFCHARS.put("'z", "\\u378z"); // "zacute" - Globals.RTFCHARS.put(".Z", "\\u379Z"); // "Zdot" - Globals.RTFCHARS.put(".z", "\\u380z"); // "zdot" - Globals.RTFCHARS.put("vZ", "\\u381Z"); // "Zcaron" - Globals.RTFCHARS.put("vz", "\\u382z"); // "zcaron" - // Symbol #383 (f) has no special Latex command - - // XML_CHARS.put("\\u00E1", "á"); - } - public static void initializeJournalNames() { diff --git a/src/main/java/net/sf/jabref/export/layout/format/RTFChars.java b/src/main/java/net/sf/jabref/export/layout/format/RTFCharFormatter.java similarity index 97% rename from src/main/java/net/sf/jabref/export/layout/format/RTFChars.java rename to src/main/java/net/sf/jabref/export/layout/format/RTFCharFormatter.java index 31bd5523368..895d2f4f5af 100644 --- a/src/main/java/net/sf/jabref/export/layout/format/RTFChars.java +++ b/src/main/java/net/sf/jabref/export/layout/format/RTFCharFormatter.java @@ -35,10 +35,12 @@ * * 5.) Replace --- by \emdash and -- by \endash. */ -public class RTFChars implements LayoutFormatter { +public class RTFCharFormatter implements LayoutFormatter { // Instantiate logger: private static final Log LOGGER = LogFactory.getLog(LayoutFormatter.class); + + private static final RtfCharMap RTF_CHARS = new RtfCharMap(); @Override @@ -96,7 +98,7 @@ else if (c == '\\') { combody = field.substring(i, i + 1); } - String result = Globals.RTFCHARS.get(command + combody); + String result = RTF_CHARS.get(command + combody); if (result != null) { sb.append(result); @@ -125,7 +127,7 @@ else if (c == '\\') { } else if ((c == '}') && (currentCommand.length() > 0)) { // Seems to be the end of a command like \{aa}. Look it up: String command = currentCommand.toString(); - String result = Globals.RTFCHARS.get(command); + String result = RTF_CHARS.get(command); if (result != null) { sb.append(result); } diff --git a/src/main/java/net/sf/jabref/export/layout/format/RtfCharMap.java b/src/main/java/net/sf/jabref/export/layout/format/RtfCharMap.java new file mode 100644 index 00000000000..2023aa076bb --- /dev/null +++ b/src/main/java/net/sf/jabref/export/layout/format/RtfCharMap.java @@ -0,0 +1,263 @@ +package net.sf.jabref.export.layout.format; + +import java.util.HashMap; + + +public class RtfCharMap extends HashMap { + + private static final long serialVersionUID = 1L; + + public RtfCharMap () { + + + put("`a", "\\'e0"); + put("`e", "\\'e8"); + put("`i", "\\'ec"); + put("`o", "\\'f2"); + put("`u", "\\'f9"); + put("?a", "\\'e1"); + put("?e", "\\'e9"); + put("?i", "\\'ed"); + put("?o", "\\'f3"); + put("?u", "\\'fa"); + put("^a", "\\'e2"); + put("^e", "\\'ea"); + put("^i", "\\'ee"); + put("^o", "\\'f4"); + put("^u", "\\'fa"); + put("\"a", "\\'e4"); + put("\"e", "\\'eb"); + put("\"i", "\\'ef"); + put("\"o", "\\'f6"); + put("\"u", "\\u252u"); + put("~n", "\\'f1"); + put("`A", "\\'c0"); + put("`E", "\\'c8"); + put("`I", "\\'cc"); + put("`O", "\\'d2"); + put("`U", "\\'d9"); + put("?A", "\\'c1"); + put("?E", "\\'c9"); + put("?I", "\\'cd"); + put("?O", "\\'d3"); + put("?U", "\\'da"); + put("^A", "\\'c2"); + put("^E", "\\'ca"); + put("^I", "\\'ce"); + put("^O", "\\'d4"); + put("^U", "\\'db"); + put("\"A", "\\'c4"); + put("\"E", "\\'cb"); + put("\"I", "\\'cf"); + put("\"O", "\\'d6"); + put("\"U", "\\'dc"); + + // Use UNICODE characters for RTF-Chars which can not be found in the + // standard codepage + + put("`A", "\\u192A"); // "Agrave" + put("'A", "\\u193A"); // "Aacute" + put("^A", "\\u194A"); // "Acirc" + put("~A", "\\u195A"); // "Atilde" + put("\"A", "\\u196A"); // "Auml" + put("AA", "\\u197A"); // "Aring" + // RTFCHARS.put("AE", "{\\uc2\\u198AE}"); // "AElig" +put("AE", "{\\u198A}"); // "AElig" + put("cC", "\\u199C"); // "Ccedil" + put("`E", "\\u200E"); // "Egrave" + put("'E", "\\u201E"); // "Eacute" + put("^E", "\\u202E"); // "Ecirc" + put("\"E", "\\u203E"); // "Euml" + put("`I", "\\u204I"); // "Igrave + put("'I", "\\u205I"); // "Iacute" + put("^I", "\\u206I"); // "Icirc" + put("\"I", "\\u207I"); // "Iuml" + put("DH", "\\u208D"); // "ETH" + put("~N", "\\u209N"); // "Ntilde" + put("`O", "\\u210O"); // "Ograve" + put("'O", "\\u211O"); // "Oacute" + put("^O", "\\u212O"); // "Ocirc" + put("~O", "\\u213O"); // "Otilde" + put("\"O", "\\u214O"); // "Ouml" + // According to ISO 8859-1 the "\times" symbol should be placed here + // (#215). + // Omitting this, because it is a mathematical symbol. + put("O", "\\u216O"); // "Oslash" + // RTFCHARS.put("O", "\\'d8"); + put("o", "\\'f8"); + put("`U", "\\u217U"); // "Ugrave" + put("'U", "\\u218U"); // "Uacute" + put("^U", "\\u219U"); // "Ucirc" + put("\"U", "\\u220U"); // "Uuml" + put("'Y", "\\u221Y"); // "Yacute" + put("TH", "{\\uc2\\u222TH}"); // "THORN" + put("ss", "{\\uc2\\u223ss}"); // "szlig" + //RTFCHARS.put("ss", "AFFEN"); // "szlig" + put("`a", "\\u224a"); // "agrave" + put("'a", "\\u225a"); // "aacute" + put("^a", "\\u226a"); // "acirc" + put("~a", "\\u227a"); // "atilde" + put("\"a", "\\u228a"); // "auml" + put("aa", "\\u229a"); // "aring" + // RTFCHARS.put("ae", "{\\uc2\\u230ae}"); // "aelig" \\u230e6 +put("ae", "{\\u230a}"); // "aelig" \\u230e6 + put("cc", "\\u231c"); // "ccedil" + put("`e", "\\u232e"); // "egrave" + put("'e", "\\u233e"); // "eacute" + put("^e", "\\u234e"); // "ecirc" + put("\"e", "\\u235e"); // "euml" + put("`i", "\\u236i"); // "igrave" + put("'i", "\\u237i"); // "iacute" + put("^i", "\\u238i"); // "icirc" + put("\"i", "\\u239i"); // "iuml" + put("dh", "\\u240d"); // "eth" + put("~n", "\\u241n"); // "ntilde" + put("`o", "\\u242o"); // "ograve" + put("'o", "\\u243o"); // "oacute" + put("^o", "\\u244o"); // "ocirc" + put("~o", "\\u245o"); // "otilde" + put("\"o", "\\u246o"); // "ouml" + // According to ISO 8859-1 the "\div" symbol should be placed here + // (#247). + // Omitting this, because it is a mathematical symbol. + put("o", "\\u248o"); // "oslash" + put("`u", "\\u249u"); // "ugrave" + put("'u", "\\u250u"); // "uacute" + put("^u", "\\u251u"); // "ucirc" + // RTFCHARS.put("\"u", "\\u252"); // "uuml" exists in standard +// codepage + put("'y", "\\u253y"); // "yacute" + put("th", "{\\uc2\\u254th}"); // "thorn" + put("\"y", "\\u255y"); // "yuml" + + put("=A", "\\u256A"); // "Amacr" + put("=a", "\\u257a"); // "amacr" + put("uA", "\\u258A"); // "Abreve" + put("ua", "\\u259a"); // "abreve" + put("kA", "\\u260A"); // "Aogon" + put("ka", "\\u261a"); // "aogon" + put("'C", "\\u262C"); // "Cacute" + put("'c", "\\u263c"); // "cacute" + put("^C", "\\u264C"); // "Ccirc" + put("^c", "\\u265c"); // "ccirc" + put(".C", "\\u266C"); // "Cdot" + put(".c", "\\u267c"); // "cdot" + put("vC", "\\u268C"); // "Ccaron" + put("vc", "\\u269c"); // "ccaron" + put("vD", "\\u270D"); // "Dcaron" + // Symbol #271 (d) has no special Latex command + put("DJ", "\\u272D"); // "Dstrok" + put("dj", "\\u273d"); // "dstrok" + put("=E", "\\u274E"); // "Emacr" + put("=e", "\\u275e"); // "emacr" + put("uE", "\\u276E"); // "Ebreve" + put("ue", "\\u277e"); // "ebreve" + put(".E", "\\u278E"); // "Edot" + put(".e", "\\u279e"); // "edot" + put("kE", "\\u280E"); // "Eogon" + put("ke", "\\u281e"); // "eogon" + put("vE", "\\u282E"); // "Ecaron" + put("ve", "\\u283e"); // "ecaron" + put("^G", "\\u284G"); // "Gcirc" + put("^g", "\\u285g"); // "gcirc" + put("uG", "\\u286G"); // "Gbreve" + put("ug", "\\u287g"); // "gbreve" + put(".G", "\\u288G"); // "Gdot" + put(".g", "\\u289g"); // "gdot" + put("cG", "\\u290G"); // "Gcedil" + put("'g", "\\u291g"); // "gacute" + put("^H", "\\u292H"); // "Hcirc" + put("^h", "\\u293h"); // "hcirc" + put("Hstrok", "\\u294H"); // "Hstrok" + put("hstrok", "\\u295h"); // "hstrok" + put("~I", "\\u296I"); // "Itilde" + put("~i", "\\u297i"); // "itilde" + put("=I", "\\u298I"); // "Imacr" + put("=i", "\\u299i"); // "imacr" + put("uI", "\\u300I"); // "Ibreve" + put("ui", "\\u301i"); // "ibreve" + put("kI", "\\u302I"); // "Iogon" + put("ki", "\\u303i"); // "iogon" + put(".I", "\\u304I"); // "Idot" + put("i", "\\u305i"); // "inodot" + // Symbol #306 (IJ) has no special Latex command + // Symbol #307 (ij) has no special Latex command + put("^J", "\\u308J"); // "Jcirc" + put("^j", "\\u309j"); // "jcirc" + put("cK", "\\u310K"); // "Kcedil" + put("ck", "\\u311k"); // "kcedil" + // Symbol #312 (k) has no special Latex command + put("'L", "\\u313L"); // "Lacute" + put("'l", "\\u314l"); // "lacute" + put("cL", "\\u315L"); // "Lcedil" + put("cl", "\\u316l"); // "lcedil" + // Symbol #317 (L) has no special Latex command + // Symbol #318 (l) has no special Latex command + put("Lmidot", "\\u319L"); // "Lmidot" + put("lmidot", "\\u320l"); // "lmidot" + put("L", "\\u321L"); // "Lstrok" + put("l", "\\u322l"); // "lstrok" + put("'N", "\\u323N"); // "Nacute" + put("'n", "\\u324n"); // "nacute" + put("cN", "\\u325N"); // "Ncedil" + put("cn", "\\u326n"); // "ncedil" + put("vN", "\\u327N"); // "Ncaron" + put("vn", "\\u328n"); // "ncaron" + // Symbol #329 (n) has no special Latex command + put("NG", "\\u330G"); // "ENG" + put("ng", "\\u331g"); // "eng" + put("=O", "\\u332O"); // "Omacr" + put("=o", "\\u333o"); // "omacr" + put("uO", "\\u334O"); // "Obreve" + put("uo", "\\u335o"); // "obreve" + put("HO", "\\u336?"); // "Odblac" + put("Ho", "\\u337?"); // "odblac" + put("OE", "{\\uc2\\u338OE}"); // "OElig" + put("oe", "{\\uc2\\u339oe}"); // "oelig" + put("'R", "\\u340R"); // "Racute" + put("'r", "\\u341r"); // "racute" + put("cR", "\\u342R"); // "Rcedil" + put("cr", "\\u343r"); // "rcedil" + put("vR", "\\u344R"); // "Rcaron" + put("vr", "\\u345r"); // "rcaron" + put("'S", "\\u346S"); // "Sacute" + put("'s", "\\u347s"); // "sacute" + put("^S", "\\u348S"); // "Scirc" + put("^s", "\\u349s"); // "scirc" + put("cS", "\\u350S"); // "Scedil" + put("cs", "\\u351s"); // "scedil" + put("vS", "\\u352S"); // "Scaron" + put("vs", "\\u353s"); // "scaron" + put("cT", "\\u354T"); // "Tcedil" + put("ct", "\\u355t"); // "tcedil" + put("vT", "\\u356T"); // "Tcaron" + // Symbol #357 (t) has no special Latex command + put("Tstrok", "\\u358T"); // "Tstrok" + put("tstrok", "\\u359t"); // "tstrok" + put("~U", "\\u360U"); // "Utilde" + put("~u", "\\u361u"); // "utilde" + put("=U", "\\u362U"); // "Umacr" + put("=u", "\\u363u"); // "umacr" + put("uU", "\\u364U"); // "Ubreve" + put("uu", "\\u365u"); // "ubreve" + put("rU", "\\u366U"); // "Uring" + put("ru", "\\u367u"); // "uring" + put("HU", "\\u368?"); // "Odblac" + put("Hu", "\\u369?"); // "odblac" + put("kU", "\\u370U"); // "Uogon" + put("ku", "\\u371u"); // "uogon" + put("^W", "\\u372W"); // "Wcirc" + put("^w", "\\u373w"); // "wcirc" + put("^Y", "\\u374Y"); // "Ycirc" + put("^y", "\\u375y"); // "ycirc" + put("\"Y", "\\u376Y"); // "Yuml" + put("'Z", "\\u377Z"); // "Zacute" + put("'z", "\\u378z"); // "zacute" + put(".Z", "\\u379Z"); // "Zdot" + put(".z", "\\u380z"); // "zdot" + put("vZ", "\\u381Z"); // "Zcaron" + put("vz", "\\u382z"); // "zcaron" + // Symbol #383 (f) has no special Latex command + } + +} diff --git a/src/test/java/net/sf/jabref/export/layout/RTFCharsTest.java b/src/test/java/net/sf/jabref/export/layout/RTFCharsTest.java index 2ad0705d4b5..ee29d2b6ccd 100644 --- a/src/test/java/net/sf/jabref/export/layout/RTFCharsTest.java +++ b/src/test/java/net/sf/jabref/export/layout/RTFCharsTest.java @@ -1,6 +1,6 @@ package net.sf.jabref.export.layout; -import net.sf.jabref.export.layout.format.RTFChars; +import net.sf.jabref.export.layout.format.RTFCharFormatter; import org.junit.Assert; import org.junit.Ignore; @@ -13,7 +13,7 @@ public class RTFCharsTest { @Test public void testBasicFormat() { - LayoutFormatter layout = new RTFChars(); + LayoutFormatter layout = new RTFCharFormatter(); Assert.assertEquals("", layout.format("")); @@ -29,7 +29,7 @@ public void testBasicFormat() { @Test public void testLaTeXHighlighting() { - LayoutFormatter layout = new RTFChars(); + LayoutFormatter layout = new RTFCharFormatter(); Assert.assertEquals("{\\i hallo}", layout.format("\\emph{hallo}")); Assert.assertEquals("{\\i hallo}", layout.format("{\\emph hallo}")); @@ -44,7 +44,7 @@ public void testLaTeXHighlighting() { @Test @Ignore public void testComplicated() { - LayoutFormatter layout = new RTFChars(); + LayoutFormatter layout = new RTFCharFormatter(); Assert.assertEquals("R\\u233eflexions sur le timing de la quantit\\u233e \\u230ae should be \\u230ae", layout.format("Réflexions sur le timing de la quantité \\ae should be æ")); @@ -55,7 +55,7 @@ public void testComplicated() { @Ignore public void testSpecialCharacters() { - LayoutFormatter layout = new RTFChars(); + LayoutFormatter layout = new RTFCharFormatter(); Assert.assertEquals("\\u243o", layout.format("\\'{o}")); // ó Assert.assertEquals("\\'f2", layout.format("\\`{o}")); // ò From c1ebdc1499316d41ec489ab8918a77944ab60e7f Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 29 Jul 2015 16:16:10 +0200 Subject: [PATCH 22/23] Reduce visibility of char maps --- .../java/net/sf/jabref/export/layout/format/HtmlCharsMap.java | 2 +- .../java/net/sf/jabref/export/layout/format/RtfCharMap.java | 2 +- .../java/net/sf/jabref/export/layout/format/XmlCharsMap.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/sf/jabref/export/layout/format/HtmlCharsMap.java b/src/main/java/net/sf/jabref/export/layout/format/HtmlCharsMap.java index df522ee57d5..881e639d51d 100644 --- a/src/main/java/net/sf/jabref/export/layout/format/HtmlCharsMap.java +++ b/src/main/java/net/sf/jabref/export/layout/format/HtmlCharsMap.java @@ -2,7 +2,7 @@ import java.util.HashMap; -public class HtmlCharsMap extends HashMap { +class HtmlCharsMap extends HashMap { private static final long serialVersionUID = 1L; diff --git a/src/main/java/net/sf/jabref/export/layout/format/RtfCharMap.java b/src/main/java/net/sf/jabref/export/layout/format/RtfCharMap.java index 2023aa076bb..ad7abf02aee 100644 --- a/src/main/java/net/sf/jabref/export/layout/format/RtfCharMap.java +++ b/src/main/java/net/sf/jabref/export/layout/format/RtfCharMap.java @@ -3,7 +3,7 @@ import java.util.HashMap; -public class RtfCharMap extends HashMap { +class RtfCharMap extends HashMap { private static final long serialVersionUID = 1L; diff --git a/src/main/java/net/sf/jabref/export/layout/format/XmlCharsMap.java b/src/main/java/net/sf/jabref/export/layout/format/XmlCharsMap.java index 33fc812c6af..77e8bf8541f 100644 --- a/src/main/java/net/sf/jabref/export/layout/format/XmlCharsMap.java +++ b/src/main/java/net/sf/jabref/export/layout/format/XmlCharsMap.java @@ -2,7 +2,7 @@ import java.util.HashMap; -public class XmlCharsMap extends HashMap { +class XmlCharsMap extends HashMap { private static final long serialVersionUID = 1L; From bff0d3e5368254a52d716b4282bd8f66e54bb51d Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 29 Jul 2015 16:30:16 +0200 Subject: [PATCH 23/23] Undo rename of Formatter classes since they might be loaded by forName() --- .../export/layout/format/CreateDocBookAuthors.java | 2 +- .../format/{HTMLCharFormatter.java => HTMLChars.java} | 2 +- .../format/{RTFCharFormatter.java => RTFChars.java} | 2 +- .../format/{XMLCharFormatter.java => XMLChars.java} | 2 +- src/main/java/net/sf/jabref/mods/MODSEntry.java | 6 +++--- src/main/java/net/sf/jabref/msbib/MSBibEntry.java | 4 ++-- .../net/sf/jabref/export/layout/HTMLCharsTest.java | 6 +++--- .../net/sf/jabref/export/layout/LayoutEntryTest.java | 10 +++++----- .../java/net/sf/jabref/export/layout/RTFCharsTest.java | 10 +++++----- 9 files changed, 22 insertions(+), 22 deletions(-) rename src/main/java/net/sf/jabref/export/layout/format/{HTMLCharFormatter.java => HTMLChars.java} (99%) rename src/main/java/net/sf/jabref/export/layout/format/{RTFCharFormatter.java => RTFChars.java} (99%) rename src/main/java/net/sf/jabref/export/layout/format/{XMLCharFormatter.java => XMLChars.java} (98%) diff --git a/src/main/java/net/sf/jabref/export/layout/format/CreateDocBookAuthors.java b/src/main/java/net/sf/jabref/export/layout/format/CreateDocBookAuthors.java index 830e2c8d58b..042b4ac8a50 100644 --- a/src/main/java/net/sf/jabref/export/layout/format/CreateDocBookAuthors.java +++ b/src/main/java/net/sf/jabref/export/layout/format/CreateDocBookAuthors.java @@ -49,7 +49,7 @@ public class CreateDocBookAuthors implements LayoutFormatter { - private static final XMLCharFormatter xc = new XMLCharFormatter(); + private static final XMLChars xc = new XMLChars(); @Override diff --git a/src/main/java/net/sf/jabref/export/layout/format/HTMLCharFormatter.java b/src/main/java/net/sf/jabref/export/layout/format/HTMLChars.java similarity index 99% rename from src/main/java/net/sf/jabref/export/layout/format/HTMLCharFormatter.java rename to src/main/java/net/sf/jabref/export/layout/format/HTMLChars.java index 9756d79acf0..b93612120da 100644 --- a/src/main/java/net/sf/jabref/export/layout/format/HTMLCharFormatter.java +++ b/src/main/java/net/sf/jabref/export/layout/format/HTMLChars.java @@ -22,7 +22,7 @@ /** * This formatter escapes characters so they are suitable for HTML. */ -public class HTMLCharFormatter implements LayoutFormatter { +public class HTMLChars implements LayoutFormatter { private static final HtmlCharsMap HTML_CHARS = new HtmlCharsMap(); diff --git a/src/main/java/net/sf/jabref/export/layout/format/RTFCharFormatter.java b/src/main/java/net/sf/jabref/export/layout/format/RTFChars.java similarity index 99% rename from src/main/java/net/sf/jabref/export/layout/format/RTFCharFormatter.java rename to src/main/java/net/sf/jabref/export/layout/format/RTFChars.java index 895d2f4f5af..4d754241cc7 100644 --- a/src/main/java/net/sf/jabref/export/layout/format/RTFCharFormatter.java +++ b/src/main/java/net/sf/jabref/export/layout/format/RTFChars.java @@ -35,7 +35,7 @@ * * 5.) Replace --- by \emdash and -- by \endash. */ -public class RTFCharFormatter implements LayoutFormatter { +public class RTFChars implements LayoutFormatter { // Instantiate logger: private static final Log LOGGER = LogFactory.getLog(LayoutFormatter.class); diff --git a/src/main/java/net/sf/jabref/export/layout/format/XMLCharFormatter.java b/src/main/java/net/sf/jabref/export/layout/format/XMLChars.java similarity index 98% rename from src/main/java/net/sf/jabref/export/layout/format/XMLCharFormatter.java rename to src/main/java/net/sf/jabref/export/layout/format/XMLChars.java index d6ec4c115e0..1996576e420 100644 --- a/src/main/java/net/sf/jabref/export/layout/format/XMLCharFormatter.java +++ b/src/main/java/net/sf/jabref/export/layout/format/XMLChars.java @@ -45,7 +45,7 @@ /** * Changes {\^o} or {\^{o}} to ? */ -public class XMLCharFormatter implements LayoutFormatter { +public class XMLChars implements LayoutFormatter { private final static XmlCharsMap XML_CHARS = new XmlCharsMap(); diff --git a/src/main/java/net/sf/jabref/mods/MODSEntry.java b/src/main/java/net/sf/jabref/mods/MODSEntry.java index eb5e9cea217..a1d298f20c8 100644 --- a/src/main/java/net/sf/jabref/mods/MODSEntry.java +++ b/src/main/java/net/sf/jabref/mods/MODSEntry.java @@ -29,7 +29,7 @@ import net.sf.jabref.BibtexEntry; import net.sf.jabref.BibtexEntryType; import net.sf.jabref.export.layout.LayoutFormatter; -import net.sf.jabref.export.layout.format.XMLCharFormatter; +import net.sf.jabref.export.layout.format.XMLChars; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -83,7 +83,7 @@ public MODSEntry(BibtexEntry bibtex) { } private void populateFromBibtex(BibtexEntry bibtex) { - LayoutFormatter chars = new XMLCharFormatter(); + LayoutFormatter chars = new XMLChars(); if (bibtex.getField("title") != null) { if (CHARFORMAT) { title = chars.format(bibtex.getField("title")); @@ -149,7 +149,7 @@ private void populateExtensionFields(BibtexEntry e) { private List getAuthors(String authors) { List result = new LinkedList(); - LayoutFormatter chars = new XMLCharFormatter(); + LayoutFormatter chars = new XMLChars(); if (!authors.contains(" and ")) { if (CHARFORMAT) { diff --git a/src/main/java/net/sf/jabref/msbib/MSBibEntry.java b/src/main/java/net/sf/jabref/msbib/MSBibEntry.java index b40d62fe6c3..5da9890afc5 100644 --- a/src/main/java/net/sf/jabref/msbib/MSBibEntry.java +++ b/src/main/java/net/sf/jabref/msbib/MSBibEntry.java @@ -34,7 +34,7 @@ import net.sf.jabref.BibtexEntryType; import net.sf.jabref.BibtexFields; import net.sf.jabref.export.layout.LayoutFormatter; -import net.sf.jabref.export.layout.format.XMLCharFormatter; +import net.sf.jabref.export.layout.format.XMLChars; import net.sf.jabref.mods.PageNumbers; import net.sf.jabref.mods.PersonName; @@ -566,7 +566,7 @@ private String format(String value) return null; } String result = null; - LayoutFormatter chars = new XMLCharFormatter(); + LayoutFormatter chars = new XMLChars(); result = chars.format(value); return result; } diff --git a/src/test/java/net/sf/jabref/export/layout/HTMLCharsTest.java b/src/test/java/net/sf/jabref/export/layout/HTMLCharsTest.java index 9f192174378..2045f19db20 100644 --- a/src/test/java/net/sf/jabref/export/layout/HTMLCharsTest.java +++ b/src/test/java/net/sf/jabref/export/layout/HTMLCharsTest.java @@ -1,6 +1,6 @@ package net.sf.jabref.export.layout; -import net.sf.jabref.export.layout.format.HTMLCharFormatter; +import net.sf.jabref.export.layout.format.HTMLChars; import org.junit.Assert; import org.junit.Test; @@ -12,7 +12,7 @@ public class HTMLCharsTest { @Test public void testBasicFormat() { - LayoutFormatter layout = new HTMLCharFormatter(); + LayoutFormatter layout = new HTMLChars(); Assert.assertEquals("", layout.format("")); @@ -36,7 +36,7 @@ public void testBasicFormat() { @Test public void testLaTeXHighlighting() { - LayoutFormatter layout = new HTMLCharFormatter(); + LayoutFormatter layout = new HTMLChars(); Assert.assertEquals("hallo", layout.format("\\emph{hallo}")); Assert.assertEquals("hallo", layout.format("{\\emph hallo}")); diff --git a/src/test/java/net/sf/jabref/export/layout/LayoutEntryTest.java b/src/test/java/net/sf/jabref/export/layout/LayoutEntryTest.java index 2a9c8f91423..2d9448e53c5 100644 --- a/src/test/java/net/sf/jabref/export/layout/LayoutEntryTest.java +++ b/src/test/java/net/sf/jabref/export/layout/LayoutEntryTest.java @@ -105,7 +105,7 @@ public void testNoHighlighting() throws Exception { // define the highlighting settings Globals.prefs.putBoolean("caseSensitiveSearch", false); - String result = this.layout("\\begin{abstract}

Abstract: \\format[HTMLCharFormatter]{\\abstract}\\end{abstract}
", mBTE, new ArrayList()); + String result = this.layout("\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract}\\end{abstract}
", mBTE, new ArrayList()); String expecting = "

Abstract: In this paper, we initiate a formal study of security on Android: Google's new open-source platform for mobile devices. Tags: Paper android google Open-Source Devices
"; Assert.assertEquals(expecting, result); @@ -126,7 +126,7 @@ public void testHighlightingOneWordCaseInsesitive() throws Exception { // define the highlighting settings Globals.prefs.putBoolean("caseSensitiveSearch", false); - String result = this.layout("\\begin{abstract}

Abstract: \\format[HTMLCharFormatter]{\\abstract}\\end{abstract}
", mBTE, words); + String result = this.layout("\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract}\\end{abstract}
", mBTE, words); String containing = "Google"; // check @@ -149,7 +149,7 @@ public void testHighlightingTwoWordsCaseInsesitive() throws Exception { // define the highlighting settings Globals.prefs.putBoolean("caseSensitiveSearch", false); - String result = this.layout("\\begin{abstract}

Abstract: \\format[HTMLCharFormatter]{\\abstract}\\end{abstract}
", mBTE, words); + String result = this.layout("\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract}\\end{abstract}
", mBTE, words); String containing = "Android"; String containing2 = "study"; @@ -174,7 +174,7 @@ public void testHighlightingOneWordCaseSesitive() throws Exception { // define the highlighting settings Globals.prefs.putBoolean("caseSensitiveSearch", true); - String result = this.layout("\\begin{abstract}

Abstract: \\format[HTMLCharFormatter]{\\abstract}\\end{abstract}
", mBTE, words); + String result = this.layout("\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract}\\end{abstract}
", mBTE, words); String expected = "

Abstract: In this paper, we initiate a formal study of security on Android: Google's new open-source platform for mobile devices. Tags: Paper android google Open-Source Devices
"; // check @@ -199,7 +199,7 @@ public void testHighlightingMoreWordsCaseSesitive() throws Exception { Globals.prefs.putBoolean("caseSensitiveSearch", false); String highlightColor = "#3399FF;"; - String result = this.layout("\\begin{abstract}

Abstract: \\format[HTMLCharFormatter]{\\abstract}\\end{abstract}
", mBTE, words); + String result = this.layout("\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract}\\end{abstract}
", mBTE, words); String expected = "

Abstract: In this paper, we initiate a formal study of security on Android: Google's new open-source platform for mobile devices. Tags: Paper android google Open-Source Devices
"; // check diff --git a/src/test/java/net/sf/jabref/export/layout/RTFCharsTest.java b/src/test/java/net/sf/jabref/export/layout/RTFCharsTest.java index ee29d2b6ccd..2ad0705d4b5 100644 --- a/src/test/java/net/sf/jabref/export/layout/RTFCharsTest.java +++ b/src/test/java/net/sf/jabref/export/layout/RTFCharsTest.java @@ -1,6 +1,6 @@ package net.sf.jabref.export.layout; -import net.sf.jabref.export.layout.format.RTFCharFormatter; +import net.sf.jabref.export.layout.format.RTFChars; import org.junit.Assert; import org.junit.Ignore; @@ -13,7 +13,7 @@ public class RTFCharsTest { @Test public void testBasicFormat() { - LayoutFormatter layout = new RTFCharFormatter(); + LayoutFormatter layout = new RTFChars(); Assert.assertEquals("", layout.format("")); @@ -29,7 +29,7 @@ public void testBasicFormat() { @Test public void testLaTeXHighlighting() { - LayoutFormatter layout = new RTFCharFormatter(); + LayoutFormatter layout = new RTFChars(); Assert.assertEquals("{\\i hallo}", layout.format("\\emph{hallo}")); Assert.assertEquals("{\\i hallo}", layout.format("{\\emph hallo}")); @@ -44,7 +44,7 @@ public void testLaTeXHighlighting() { @Test @Ignore public void testComplicated() { - LayoutFormatter layout = new RTFCharFormatter(); + LayoutFormatter layout = new RTFChars(); Assert.assertEquals("R\\u233eflexions sur le timing de la quantit\\u233e \\u230ae should be \\u230ae", layout.format("Réflexions sur le timing de la quantité \\ae should be æ")); @@ -55,7 +55,7 @@ public void testComplicated() { @Ignore public void testSpecialCharacters() { - LayoutFormatter layout = new RTFCharFormatter(); + LayoutFormatter layout = new RTFChars(); Assert.assertEquals("\\u243o", layout.format("\\'{o}")); // ó Assert.assertEquals("\\'f2", layout.format("\\`{o}")); // ò