Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
More Jobs
Recent
Arrays, loops, strings...
Similar virtual attributes and their getters/setter
Check type is XML Serializable
Serena Collage slideshow
Shortest regular expression for matching a subdomain.
Caching Methods
Tab-Switching in jQuery
Apache log file sorting
How to find max, min of three numbers?
repeated code in rspec model test
Popular
Caching Methods
How to find max, min of three numbers?
Similar virtual attributes and their getters/setter
Arrays, loops, strings...
Check type is XML Serializable
Shortest regular expression for matching a subdomain.
Apache log file sorting
Tab-Switching in jQuery
Serena Collage slideshow
A simple factorial program.
Pastable version of
Internationalize Exceptions
<div style="overflow:auto;border:solid 1px #ccc;background:#000;color:#F8F8F8"> <div class="section"> <pre style="float:left;margin:0 10px;border-right:0;color:#666;">1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61</pre> <pre class="sunburst"><span style="color:#99CF50;">public abstract </span><span style="color:#99CF50;">class</span> <span style="text-decoration:underline;">I18NException</span> <span style="color:#99CF50;">extends</span> <span style="color:#9B859D;">Exception</span> { <span style="color:#99CF50;">public</span> enum <span style="color:#99CF50;">Message</span> <span style="color:#99CF50;">implements</span> <span style="color:#99CF50;">ExceptionMessage</span> { <span style="color:#3387CC;">DEFAULT</span>(<span style="color:#65B042;"><span style="color:#65B042;">"</span>default.error<span style="color:#65B042;">"</span></span>); <span style="color:#99CF50;">private</span> <span style="color:#9B859D;">String</span> key; <span style="color:#99CF50;">private </span><span style="color:#89BDFF;">Message</span>(<span style="color:#9B859D;">String</span> argKey) { key = argKey; } <span style="color:#99CF50;">public </span><span style="color:#99CF50;">String</span> <span style="color:#89BDFF;">getLocalizedMessage</span>(<span style="color:#9B859D;">Locale</span> argLocale) { <span style="color:#E28964;">return</span> <span style="color:#9B859D;">ResourceBundle</span>.getBundle(<span style="color:#65B042;"><span style="color:#65B042;">"</span>ErrorResources<span style="color:#65B042;">"</span></span>, argLocale).getString(key); } } <span style="color:#99CF50;">private</span> <span style="color:#9B859D;">Locale</span> locale; <span style="color:#99CF50;">private</span> <span style="color:#99CF50;">Message</span> message; <span style="color:#99CF50;">public </span><span style="color:#89BDFF;">I18NException</span>(<span style="color:#9B859D;">Locale</span> argLocale, <span style="color:#99CF50;">Message</span> argMessage, <span style="color:#9B859D;">String</span> arg0, <span style="color:#9B859D;">Throwable</span> arg1) { <span style="color:#3E87E3;">super</span>(arg0, arg1); locale = argLocale; message = argMessage; } <span style="color:#AEAEAE;font-style:italic;"><span style="color:#AEAEAE;font-style:italic;"> /**</span> other constructors omitted *<span style="color:#AEAEAE;font-style:italic;">*/</span></span> <span style="color:#99CF50;">public </span><span style="color:#99CF50;">String</span> <span style="color:#89BDFF;">getLocalizedMessage</span>() { <span style="color:#E28964;">return</span> message.getLocalizedMessage(locale); } } <span style="color:#99CF50;">public </span><span style="color:#99CF50;">interface</span> <span style="text-decoration:underline;">ExceptionMessage</span> { <span style="color:#99CF50;">public</span> <span style="color:#9B859D;">String</span> getLocalizedMessage(<span style="color:#9B859D;">Locale</span> argLocale); } </pre> </div> </div> <a href="http://www.refactormycode.com/codes/339-internationalize-exceptions" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://www.refactormycode.com/images/small_logo.gif" style="border:0" /></a>