]> git.somenet.org - irc/pjirc-ng.git/blob - src/main/java/irc/IRCConfiguration.java
Pjirc 2.2.1 as available on the net, reformatted and made it compile.
[irc/pjirc-ng.git] / src / main / java / irc / IRCConfiguration.java
1 /*****************************************************/\r
2 /*          This java file is a part of the          */\r
3 /*                                                   */\r
4 /*           -  Plouf's Java IRC Client  -           */\r
5 /*                                                   */\r
6 /*   Copyright (C)  2002 - 2005 Philippe Detournay   */\r
7 /*                                                   */\r
8 /*         All contacts : theplouf@yahoo.com         */\r
9 /*                                                   */\r
10 /*  PJIRC is free software; you can redistribute     */\r
11 /*  it and/or modify it under the terms of the GNU   */\r
12 /*  General Public License as published by the       */\r
13 /*  Free Software Foundation; version 2 or later of  */\r
14 /*  the License.                                     */\r
15 /*                                                   */\r
16 /*  PJIRC is distributed in the hope that it will    */\r
17 /*  be useful, but WITHOUT ANY WARRANTY; without     */\r
18 /*  even the implied warranty of MERCHANTABILITY or  */\r
19 /*  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU   */\r
20 /*  General Public License for more details.         */\r
21 /*                                                   */\r
22 /*  You should have received a copy of the GNU       */\r
23 /*  General Public License along with PJIRC; if      */\r
24 /*  not, write to the Free Software Foundation,      */\r
25 /*  Inc., 59 Temple Place, Suite 330, Boston,        */\r
26 /*  MA  02111-1307  USA                              */\r
27 /*                                                   */\r
28 /*****************************************************/\r
29 \r
30 package irc;\r
31 \r
32 import irc.security.SecurityProvider;\r
33 \r
34 import java.awt.Color;\r
35 import java.awt.Font;\r
36 import java.awt.Image;\r
37 import java.util.Hashtable;\r
38 \r
39 /**\r
40  * NullItem.\r
41  */\r
42 class NullItem {\r
43         // empty\r
44 }\r
45 \r
46 /**\r
47  * Global IRC configuration. Any call is synchronized and can be performed from\r
48  * any thread.\r
49  */\r
50 public class IRCConfiguration {\r
51         /**\r
52          * Image is centered.\r
53          */\r
54         public static final int TILING_CENTER = 0;\r
55         /**\r
56          * Image is stretched.\r
57          */\r
58         public static final int TILING_STRETCH = 1;\r
59         /**\r
60          * Image is tiled.\r
61          */\r
62         public static final int TILING_TILE = 2;\r
63         /**\r
64          * Image position is fixed.\r
65          */\r
66         public static final int TILING_FIXED = 3;\r
67 \r
68         /**\r
69          * Image position is fixed on the left.\r
70          */\r
71         public static final int TILING_HORIZONTAL_LEFT = 0;\r
72         /**\r
73          * Image position is fixed on the right.\r
74          */\r
75         public static final int TILING_HORIZONTAL_RIGHT = 256;\r
76         /**\r
77          * Image position if fixed upside.\r
78          */\r
79         public static final int TILING_VERTICAL_UP = 0;\r
80         /**\r
81          * Image position is fixed downside.\r
82          */\r
83         public static final int TILING_VERTICAL_DOWN = 512;\r
84 \r
85         private NullItem NULL_ITEM = new NullItem();\r
86 \r
87         private TextProvider _textProvider;\r
88         private ImageLoader _loader;\r
89         private URLHandler _handler;\r
90         private FileHandler _file;\r
91         private AudioConfiguration _audioConfig;\r
92 \r
93         private RuleList _backgroundImageRules;\r
94         private RuleList _backgroundTilingRules;\r
95         private RuleList _colorsRules;\r
96         private RuleList _fontRules;\r
97 \r
98         private SmileyTable _table;\r
99         private ListHandler _mayJoinList;\r
100         private ListHandler _mayLeaveList;\r
101         private ListHandler _mayCommandList;\r
102         private Hashtable _htable;\r
103         private SecurityProvider _provider;\r
104         private ParameterProvider _paramProvider;\r
105         private ParameterProvider _interfaceParamProvider;\r
106 \r
107         private String _guiInfoString;\r
108 \r
109         private String[] _initCommands;\r
110 \r
111         /**\r
112          * Create a new IRCConfiguration.\r
113          * \r
114          * @param text\r
115          *          text provider to use.\r
116          * @param handler\r
117          *          URL handler to use.\r
118          * @param loader\r
119          *          image loader to use.\r
120          * @param sound\r
121          *          sound handler to use.\r
122          * @param file\r
123          *          file handler to use.\r
124          * @param paramProvider\r
125          *          parameter provider.\r
126          * @param interfaceParamProvider\r
127          *          interface parameter provider.\r
128          */\r
129         public IRCConfiguration(TextProvider text, URLHandler handler, ImageLoader loader, SoundHandler sound,\r
130                         FileHandler file, ParameterProvider paramProvider, ParameterProvider interfaceParamProvider) {\r
131                 _provider = new SecurityProvider();\r
132 \r
133                 _paramProvider = paramProvider;\r
134                 _interfaceParamProvider = interfaceParamProvider;\r
135 \r
136                 _htable = new Hashtable();\r
137 \r
138                 _backgroundImageRules = new RuleList();\r
139                 _backgroundTilingRules = new RuleList();\r
140                 _backgroundTilingRules.setDefaultValue(new Integer(0));\r
141 \r
142                 _fontRules = new RuleList();\r
143                 _fontRules.setDefaultValue(new Font("Monospaced", Font.PLAIN, 12));\r
144 \r
145                 _colorsRules = new RuleList();\r
146                 Color[] def = new Color[16];\r
147                 loadDefaultColors(def);\r
148                 _colorsRules.setDefaultValue(def);\r
149 \r
150                 _audioConfig = new AudioConfiguration(sound);\r
151                 _table = new SmileyTable();\r
152 \r
153                 _file = file;\r
154                 _loader = loader;\r
155                 _textProvider = text;\r
156                 _handler = handler;\r
157 \r
158                 _guiInfoString = "";\r
159 \r
160                 _initCommands = new String[0];\r
161         }\r
162 \r
163         /**\r
164          * Create a new dummy IRCConfiguration. All parameters are set to default.\r
165          * Note that the 'gui' parameter is not set.\r
166          * \r
167          * @return a new IRCConfiguration instance.\r
168          */\r
169         public static IRCConfiguration createDummyIRCConfiguration() {\r
170                 try {\r
171                         FileHandler file = new LocalFileHandler();\r
172                         StreamParameterProvider provider = new StreamParameterProvider(null);\r
173                         ConfigurationLoader loader = new ConfigurationLoader(provider, new NullURLHandler(), new AWTImageLoader(),\r
174                                         new NullSoundHandler(), file);\r
175                         return loader.loadIRCConfiguration();\r
176                 } catch (Exception ex) {\r
177                         /* should not reach here : bug */\r
178                         throw new Error("Error creating dummy IRCConfiguration : " + ex);\r
179                 }\r
180         }\r
181 \r
182         /**\r
183          * Get the initialisation commands.\r
184          * \r
185          * @return the initialisation commands.\r
186          */\r
187         public String[] getInitialization() {\r
188                 return _initCommands;\r
189         }\r
190 \r
191         /**\r
192          * Set the initialisation commands.\r
193          * \r
194          * @param init\r
195          *          the initialisation commands.\r
196          */\r
197         public void setInitialisation(String[] init) {\r
198                 _initCommands = init;\r
199         }\r
200 \r
201         /**\r
202          * Get the GUI information string.\r
203          * \r
204          * @return the GUI info string.\r
205          */\r
206         public String getGUIInfoString() {\r
207                 return _guiInfoString;\r
208         }\r
209 \r
210         /**\r
211          * Set the GUI information string.\r
212          * \r
213          * @param string\r
214          *          the GUI information string.\r
215          */\r
216         public void setGUIInfoString(String string) {\r
217                 _guiInfoString = string;\r
218         }\r
219 \r
220         /**\r
221          * Get the file handler.\r
222          * \r
223          * @return the file handler.\r
224          */\r
225         public FileHandler getFileHandler() {\r
226                 return _file;\r
227         }\r
228 \r
229         /**\r
230          * Display the about page.\r
231          */\r
232         public void displayAboutPage() {\r
233                 new AboutDialog(this);\r
234         }\r
235 \r
236         /**\r
237          * Get the parameter provider used for creating this IRCConfiguration.\r
238          * \r
239          * @return the parameter provider.\r
240          */\r
241         public ParameterProvider getParameterProvider() {\r
242                 return _paramProvider;\r
243         }\r
244 \r
245         /**\r
246          * Get the parameter provider whose should be used by an user interface.\r
247          * \r
248          * @return the interface parameter provider.\r
249          */\r
250         public ParameterProvider getInterfaceParameterProvider() {\r
251                 return _interfaceParamProvider;\r
252         }\r
253 \r
254         /**\r
255          * Get the high version number.\r
256          * \r
257          * @return the high version number.\r
258          */\r
259         public int getVersionHigh() {\r
260                 return 2;\r
261         }\r
262 \r
263         /**\r
264          * Get the middle version number.\r
265          * \r
266          * @return the middle version number.\r
267          */\r
268         public int getVersionMed() {\r
269                 return 2;\r
270         }\r
271 \r
272         /**\r
273          * Get the low version number.\r
274          * \r
275          * @return the low version number.\r
276          */\r
277         public int getVersionLow() {\r
278                 return 1;\r
279         }\r
280 \r
281         /**\r
282          * Get the version modifiers.\r
283          * \r
284          * @return version modifiers.\r
285          */\r
286         public String getVersionModifiers() {\r
287                 return "";\r
288         }\r
289 \r
290         /**\r
291          * Get version number as a string.\r
292          * \r
293          * @return high.med.lowmod version number.\r
294          */\r
295         public String getVersion() {\r
296                 return getVersionHigh() + "." + getVersionMed() + "." + getVersionLow() + getVersionModifiers();\r
297         }\r
298 \r
299         /**\r
300          * Get the security provider.\r
301          * \r
302          * @return the security provider.\r
303          */\r
304         public SecurityProvider getSecurityProvider() {\r
305                 return _provider;\r
306         }\r
307 \r
308         /**\r
309          * Set the given property to the given value. This value may be null.\r
310          * \r
311          * @param key\r
312          *          property name.\r
313          * @param obj\r
314          *          property value.\r
315          */\r
316         public synchronized void set(String key, Object obj) {\r
317                 if (obj == null)\r
318                         obj = NULL_ITEM;\r
319                 _htable.put(key.toLowerCase(java.util.Locale.ENGLISH), obj);\r
320         }\r
321 \r
322         /**\r
323          * Set the given property to the given int value.\r
324          * \r
325          * @param key\r
326          *          property name.\r
327          * @param val\r
328          *          property value.\r
329          */\r
330         public synchronized void set(String key, int val) {\r
331                 set(key, new Integer(val));\r
332         }\r
333 \r
334         /**\r
335          * Set the given property to the given boolean value.\r
336          * \r
337          * @param key\r
338          *          property name.\r
339          * @param val\r
340          *          property value.\r
341          */\r
342         public synchronized void set(String key, boolean val) {\r
343                 set(key, new Boolean(val));\r
344         }\r
345 \r
346         /**\r
347          * Get the given property value.\r
348          * \r
349          * @param key\r
350          *          property name.\r
351          * @return the property value.\r
352          * @throws RuntimeException\r
353          *           if the property is unknown.\r
354          */\r
355         public synchronized Object get(String key) {\r
356                 Object v = _htable.get(key.toLowerCase(java.util.Locale.ENGLISH));\r
357                 if (v == null)\r
358                         throw new RuntimeException("Unknown configuration property " + key);\r
359                 if (v == NULL_ITEM)\r
360                         v = null;\r
361                 return v;\r
362         }\r
363 \r
364         /**\r
365          * Get the given property value as an int value.\r
366          * \r
367          * @param key\r
368          *          property name.\r
369          * @return the property value.\r
370          * @throws RuntimeException\r
371          *           if the property is unknown.\r
372          */\r
373         public synchronized int getI(String key) {\r
374                 Integer i = (Integer) get(key);\r
375                 return i.intValue();\r
376         }\r
377 \r
378         /**\r
379          * Get the given property value as a boolean value.\r
380          * \r
381          * @param key\r
382          *          property name.\r
383          * @return the property value.\r
384          * @throws RuntimeException\r
385          *           if the property is unknown.\r
386          */\r
387         public synchronized boolean getB(String key) {\r
388                 Boolean b = (Boolean) get(key);\r
389                 return b.booleanValue();\r
390         }\r
391 \r
392         /**\r
393          * Get the given property value as String value.\r
394          * \r
395          * @param key\r
396          *          property name.\r
397          * @return the property value.\r
398          * @throws RuntimeException\r
399          *           if the property is unknown.\r
400          */\r
401         public synchronized String getS(String key) {\r
402                 return (String) get(key);\r
403         }\r
404 \r
405         /**\r
406          * Test wether the given channel may be left.\r
407          * \r
408          * @param channel\r
409          *          channel to be left.\r
410          * @return true if channel may be left, false otherwise.\r
411          */\r
412         public synchronized boolean mayLeave(String channel) {\r
413                 return _mayLeaveList.inList(channel);\r
414         }\r
415 \r
416         /**\r
417          * Test wether the given channel may be joined.\r
418          * \r
419          * @param channel\r
420          *          channel to be joined.\r
421          * @return true if channel may be joined, false otherwise.\r
422          */\r
423         public synchronized boolean mayJoin(String channel) {\r
424                 return _mayJoinList.inList(channel);\r
425         }\r
426 \r
427         /**\r
428          * Set the "may join" list.\r
429          * \r
430          * @param list\r
431          *          join list.\r
432          */\r
433         public synchronized void setJoinList(String list) {\r
434                 _mayJoinList = new ListHandler(list);\r
435         }\r
436 \r
437         /**\r
438          * Set the "may leave" list.\r
439          * \r
440          * @param list\r
441          *          leave list.\r
442          */\r
443         public synchronized void setLeaveList(String list) {\r
444                 _mayLeaveList = new ListHandler(list);\r
445         }\r
446 \r
447         /**\r
448          * Set the authorized command list.\r
449          * \r
450          * @param list\r
451          *          authorized command list.\r
452          */\r
453         public synchronized void setCommandList(String list) {\r
454                 _mayCommandList = new ListHandler(list);\r
455         }\r
456 \r
457         /**\r
458          * Check wether the given command may be executed by the user.\r
459          * \r
460          * @param cmd\r
461          *          command to test, not prefixed by /.\r
462          * @return true if command may be executed, false otherwise.\r
463          */\r
464         public synchronized boolean mayCommand(String cmd) {\r
465                 if (cmd.startsWith("/"))\r
466                         cmd = cmd.substring(1);\r
467                 return _mayCommandList.inList(cmd);\r
468         }\r
469 \r
470         /**\r
471          * Get the background image associated with the given source type and name.\r
472          * \r
473          * @param type\r
474          *          source type.\r
475          * @param name\r
476          *          source name.\r
477          * @return background image, or null if no image is to be displayed.\r
478          */\r
479         public synchronized Image getBackgroundImage(String type, String name) {\r
480                 if (!getB("style:backgroundImage"))\r
481                         return null;\r
482                 return (Image) _backgroundImageRules.findValue(new String[] { type, name });\r
483         }\r
484 \r
485         /**\r
486          * Get the background image tiling associated with the given source type and\r
487          * name.\r
488          * \r
489          * @param type\r
490          *          source type.\r
491          * @param name\r
492          *          source name.\r
493          * @return tiling mode for background image.\r
494          */\r
495         public synchronized int getBackgroundTiling(String type, String name) {\r
496                 return ((Integer) _backgroundTilingRules.findValue(new String[] { type, name })).intValue();\r
497         }\r
498 \r
499         /**\r
500          * Set the background image to be used for the given source type and name.\r
501          * \r
502          * @param type\r
503          *          source type.\r
504          * @param name\r
505          *          source name.\r
506          * @param image\r
507          *          image name.\r
508          */\r
509         public synchronized void setBackgroundImage(String type, String name, String image) {\r
510                 _backgroundImageRules.addRule(new String[] { type, name }, getImageLoader().getImage(image));\r
511         }\r
512 \r
513         /**\r
514          * Set the background image tiling to be used for the given source type and\r
515          * name.\r
516          * \r
517          * @param type\r
518          *          source type.\r
519          * @param name\r
520          *          source name.\r
521          * @param tiling\r
522          *          tiling mode to be used.\r
523          */\r
524         public synchronized void setBackgroundTiling(String type, String name, int tiling) {\r
525                 _backgroundTilingRules.addRule(new String[] { type, name }, new Integer(tiling));\r
526         }\r
527 \r
528         /**\r
529          * Set the font to be used for the given source type and name.\r
530          * \r
531          * @param type\r
532          *          source type.\r
533          * @param name\r
534          *          source name.\r
535          * @param f\r
536          *          font to be used.\r
537          */\r
538         public synchronized void setFont(String type, String name, Font f) {\r
539                 _fontRules.addRule(new String[] { type, name }, f);\r
540         }\r
541 \r
542         /**\r
543          * Format a string given asl info and current settings.\r
544          * \r
545          * @param info\r
546          *          user whois information.\r
547          * @return formatted asl information. An empty string shouldn't be displayed.\r
548          */\r
549         public synchronized String formatASL(String info) {\r
550                 String noprefix = getS("noasldisplayprefix");\r
551                 if ((noprefix.length() > 0) && (info.startsWith(noprefix)))\r
552                         return "";\r
553 \r
554                 String separator = getS("aslseparatorstring");\r
555                 if (separator.length() > 0) {\r
556                         int pos = info.indexOf(separator);\r
557                         if (pos >= 0)\r
558                                 info = info.substring(0, pos);\r
559                 }\r
560 \r
561                 String orig = info;\r
562                 int pos = info.indexOf(' ');\r
563                 if (pos < 0)\r
564                         return orig;\r
565 \r
566                 String age = info.substring(0, pos).trim();\r
567                 info = info.substring(pos + 1).trim();\r
568                 pos = info.indexOf(' ');\r
569                 if (pos < 0)\r
570                         return orig;\r
571                 String gender = info.substring(0, pos).trim().toLowerCase(java.util.Locale.ENGLISH);\r
572                 String location = info.substring(pos + 1).trim();\r
573 \r
574                 int text;\r
575                 if (gender.equals(getS("aslmale").toLowerCase(java.util.Locale.ENGLISH)))\r
576                         text = IRCTextProvider.ASL_MALE;\r
577                 else if (gender.equals(getS("aslfemale").toLowerCase(java.util.Locale.ENGLISH)))\r
578                         text = IRCTextProvider.ASL_FEMALE;\r
579                 else if (gender.equals(getS("aslunknown").toLowerCase(java.util.Locale.ENGLISH)))\r
580                         text = IRCTextProvider.ASL_UNKNOWN;\r
581                 else\r
582                         return orig;\r
583 \r
584                 return getText(text, age, location);\r
585         }\r
586 \r
587         /**\r
588          * Find the correct ASL color for the given info.\r
589          * \r
590          * @param info\r
591          *          user whois information.\r
592          * @param male\r
593          *          male color.\r
594          * @param femeale\r
595          *          femeale color.\r
596          * @param undef\r
597          *          undefined gender color.\r
598          * @return asl color.\r
599          */\r
600         public synchronized Color getASLColor(String info, Color male, Color femeale, Color undef) {\r
601                 int pos = info.indexOf(' ');\r
602                 if (pos < 0)\r
603                         return undef;\r
604                 info = info.substring(pos).trim();\r
605                 pos = info.indexOf(' ');\r
606                 if (pos < 0)\r
607                         return undef;\r
608                 info = info.substring(0, pos).trim().toLowerCase(java.util.Locale.ENGLISH);\r
609                 if (info.equals(getS("aslmale").toLowerCase(java.util.Locale.ENGLISH)))\r
610                         return male;\r
611                 if (info.equals(getS("aslfemale").toLowerCase(java.util.Locale.ENGLISH)))\r
612                         return femeale;\r
613                 return undef;\r
614         }\r
615 \r
616         /**\r
617          * Get the audio configuration.\r
618          * \r
619          * @return the audio configuration.\r
620          */\r
621         public AudioConfiguration getAudioConfiguration() {\r
622                 return _audioConfig;\r
623         }\r
624 \r
625         /**\r
626          * Get the default style context.\r
627          * \r
628          * @return the default style context.\r
629          */\r
630         public synchronized StyleContext getDefaultStyleContext() {\r
631                 return getStyleContext("", "");\r
632         }\r
633 \r
634         /**\r
635          * Get the style context associated with the given source type and name.\r
636          * \r
637          * @param type\r
638          *          source name.\r
639          * @param name\r
640          *          source name.\r
641          * @return associated style context.\r
642          */\r
643         public synchronized StyleContext getStyleContext(String type, String name) {\r
644                 StyleContext ctx = new StyleContext();\r
645                 ctx.type = type;\r
646                 ctx.name = name;\r
647                 return ctx;\r
648         }\r
649 \r
650         /**\r
651          * Load the given color array with the default source colors. The array must\r
652          * be of length 16.\r
653          * \r
654          * @param cols\r
655          *          color array to be filled.\r
656          */\r
657         public synchronized void loadDefaultColors(Color[] cols) {\r
658                 cols[0] = new Color(0xFFFFFF);\r
659                 cols[1] = new Color(0x000000);\r
660                 cols[2] = new Color(0x00007F);\r
661                 cols[3] = new Color(0x009300);\r
662                 cols[4] = new Color(0xFF0000);\r
663                 cols[5] = new Color(0x7F0000);\r
664                 cols[6] = new Color(0x9C009C);\r
665                 cols[7] = new Color(0xFC7F00);\r
666                 cols[8] = new Color(0xFFFF00);\r
667                 cols[9] = new Color(0x00FC00);\r
668                 cols[10] = new Color(0x009393);\r
669                 cols[11] = new Color(0x00FFFF);\r
670                 cols[12] = new Color(0x0000FC);\r
671                 cols[13] = new Color(0xFF00FF);\r
672                 cols[14] = new Color(0x7F7F7F);\r
673                 cols[15] = new Color(0xD2D2D2);\r
674         }\r
675 \r
676         /**\r
677          * Set the source colors.\r
678          * \r
679          * @param type\r
680          *          source type.\r
681          * @param name\r
682          *          source name.\r
683          * @param c\r
684          *          color array.\r
685          */\r
686         public synchronized void setSourceColor(String type, String name, Color c[]) {\r
687                 _colorsRules.addRule(new String[] { type, name }, c);\r
688         }\r
689 \r
690         /**\r
691          * Get the colors associated with the given style context.\r
692          * \r
693          * @param context\r
694          *          the context to get colors from.\r
695          * @return color array for the given context.\r
696          */\r
697         public synchronized Color[] getStyleColors(StyleContext context) {\r
698                 return (Color[]) _colorsRules.findValue(new String[] { context.type, context.name });\r
699         }\r
700 \r
701         /**\r
702          * Get the font associated with the given style context.\r
703          * \r
704          * @param context\r
705          *          the context to get font from.\r
706          * @return font for the given context.\r
707          */\r
708         public synchronized Font getStyleFont(StyleContext context) {\r
709                 return (Font) _fontRules.findValue(new String[] { context.type, context.name });\r
710         }\r
711 \r
712         /**\r
713          * Get the image background associated with the given style context.\r
714          * \r
715          * @param context\r
716          *          the context to get background from.\r
717          * @return image for the given context.\r
718          */\r
719         public synchronized Image getStyleBackgroundImage(StyleContext context) {\r
720                 return getBackgroundImage(context.type, context.name);\r
721         }\r
722 \r
723         /**\r
724          * Get the tiling background associated with the given style context.\r
725          * \r
726          * @param context\r
727          *          the context to get tiling from.\r
728          * @return tiling for the given context.\r
729          */\r
730         public synchronized int getStyleBackgroundTiling(StyleContext context) {\r
731                 return getBackgroundTiling(context.type, context.name);\r
732         }\r
733 \r
734         /**\r
735          * Add a smiley in the smiley table.\r
736          * \r
737          * @param match\r
738          *          the matching text to replace.\r
739          * @param file\r
740          *          image file name.\r
741          */\r
742         public synchronized void addSmiley(String match, String file) {\r
743                 _table.addSmiley(match, _loader.getImage(file));\r
744         }\r
745 \r
746         /**\r
747          * Get the image loader.\r
748          * \r
749          * @return the image loader.\r
750          */\r
751         public ImageLoader getImageLoader() {\r
752                 return _loader;\r
753         }\r
754 \r
755         /**\r
756          * Get the smileys table.\r
757          * \r
758          * @return the smiley table.\r
759          */\r
760         public SmileyTable getSmileyTable() {\r
761                 return _table;\r
762         }\r
763 \r
764         /**\r
765          * Return wether asl should be processed, because asl field is enabled or\r
766          * floating asl is enabled.\r
767          * \r
768          * @return master asl status.\r
769          */\r
770         public synchronized boolean getASLMaster() {\r
771                 return getB("asl") | getB("style:floatingasl");\r
772         }\r
773 \r
774         /**\r
775          * Get URLHandler.\r
776          * \r
777          * @return URLHandler.\r
778          */\r
779         public URLHandler getURLHandler() {\r
780                 return _handler;\r
781         }\r
782 \r
783         /**\r
784          * Get text provider.\r
785          * \r
786          * @return text provider.\r
787          */\r
788         public TextProvider getTextProvider() {\r
789                 return _textProvider;\r
790         }\r
791 \r
792         /**\r
793          * Report an internal error.\r
794          * \r
795          * @param message\r
796          *          error message.\r
797          * @param ex\r
798          *          optional (can be null) cause exception.\r
799          * @param mail\r
800          *          mail address where the bug report should be sent.\r
801          */\r
802         public void internalError(String message, Throwable ex, String mail) {\r
803                 System.err.println("************ Internal error ************");\r
804                 System.err.println("Please submit a bug report to " + mail + " including the following information:");\r
805                 System.err.println("Message:");\r
806                 System.err.println(message);\r
807 \r
808                 if (ex != null) {\r
809                         System.err.println("Root cause:");\r
810                         ex.printStackTrace();\r
811                 }\r
812                 System.err.println("Stack trace:");\r
813                 Thread.dumpStack();\r
814         }\r
815 \r
816         /**\r
817          * Get formatted text associated with the given text code, with no parameter.\r
818          * \r
819          * @param code\r
820          *          text code.\r
821          * @return formatted text.\r
822          */\r
823         public synchronized String getText(int code) {\r
824                 return _textProvider.getString(code);\r
825         }\r
826 \r
827         /**\r
828          * Get formatted text associated with the given text code, with one parameter.\r
829          * \r
830          * @param code\r
831          *          text code.\r
832          * @param p1\r
833          *          first parameter.\r
834          * @return formatted text.\r
835          */\r
836         public synchronized String getText(int code, String p1) {\r
837                 return _textProvider.getString(code, p1);\r
838         }\r
839 \r
840         /**\r
841          * Get formatted text associated with the given text code, with two\r
842          * parameters.\r
843          * \r
844          * @param code\r
845          *          text code.\r
846          * @param p1\r
847          *          first parameter.\r
848          * @param p2\r
849          *          second parameter.\r
850          * @return formatted text.\r
851          */\r
852         public synchronized String getText(int code, String p1, String p2) {\r
853                 return _textProvider.getString(code, p1, p2);\r
854         }\r
855 \r
856         /**\r
857          * Get formatted text associated with the given text code, with three\r
858          * parameters.\r
859          * \r
860          * @param code\r
861          *          text code.\r
862          * @param p1\r
863          *          first parameter.\r
864          * @param p2\r
865          *          second parameter.\r
866          * @param p3\r
867          *          third parameter.\r
868          * @return formatted text.\r
869          */\r
870         public synchronized String getText(int code, String p1, String p2, String p3) {\r
871                 return _textProvider.getString(code, p1, p2, p3);\r
872         }\r
873 \r
874 }\r