Warning: INSERT command denied to user 'dbo161931756'@'212.227.109.31' for table 'dt_watchdog' query: INSERT INTO dt_watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/45/d161213570/htdocs/drupal/includes/unicode.inc on line 291.', 2, '', 'http://davidtanzer.net/', '', '54.166.48.3', 1480846143) in /homepages/45/d161213570/htdocs/drupal/includes/database.mysql.inc on line 120

Warning: INSERT command denied to user 'dbo161931756'@'212.227.109.31' for table 'dt_watchdog' query: INSERT INTO dt_watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/45/d161213570/htdocs/drupal/includes/unicode.inc on line 291.', 2, '', 'http://davidtanzer.net/', '', '54.166.48.3', 1480846143) in /homepages/45/d161213570/htdocs/drupal/includes/database.mysql.inc on line 120

Warning: INSERT command denied to user 'dbo161931756'@'212.227.109.31' for table 'dt_watchdog' query: INSERT INTO dt_watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/45/d161213570/htdocs/drupal/includes/unicode.inc on line 291.', 2, '', 'http://davidtanzer.net/', '', '54.166.48.3', 1480846143) in /homepages/45/d161213570/htdocs/drupal/includes/database.mysql.inc on line 120

Warning: INSERT command denied to user 'dbo161931756'@'212.227.109.31' for table 'dt_watchdog' query: INSERT INTO dt_watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/45/d161213570/htdocs/drupal/includes/unicode.inc on line 291.', 2, '', 'http://davidtanzer.net/', '', '54.166.48.3', 1480846143) in /homepages/45/d161213570/htdocs/drupal/includes/database.mysql.inc on line 120
davidtanzer.net - deltalabs.at
Warning: INSERT command denied to user 'dbo161931756'@'212.227.109.31' for table 'dt_watchdog' query: INSERT INTO dt_watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'date(): It is not safe to rely on the system\'s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected \'Europe/Berlin\' for \'CET/1.0/no DST\' instead in /homepages/45/d161213570/htdocs/drupal/themes/newdl/page.tpl.php on line 27.', 2, '', 'http://davidtanzer.net/', '', '54.166.48.3', 1480846143) in /homepages/45/d161213570/htdocs/drupal/includes/database.mysql.inc on line 120

Warning: INSERT command denied to user 'dbo161931756'@'212.227.109.31' for table 'dt_watchdog' query: INSERT INTO dt_watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'mktime(): It is not safe to rely on the system\'s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected \'Europe/Berlin\' for \'CET/1.0/no DST\' instead in /homepages/45/d161213570/htdocs/drupal/themes/newdl/page.tpl.php on line 27.', 2, '', 'http://davidtanzer.net/', '', '54.166.48.3', 1480846143) in /homepages/45/d161213570/htdocs/drupal/includes/database.mysql.inc on line 120

Warning: INSERT command denied to user 'dbo161931756'@'212.227.109.31' for table 'dt_watchdog' query: INSERT INTO dt_watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'date(): It is not safe to rely on the system\'s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected \'Europe/Berlin\' for \'CET/1.0/no DST\' instead in /homepages/45/d161213570/htdocs/drupal/themes/newdl/page.tpl.php on line 27.', 2, '', 'http://davidtanzer.net/', '', '54.166.48.3', 1480846143) in /homepages/45/d161213570/htdocs/drupal/includes/database.mysql.inc on line 120

Warning: INSERT command denied to user 'dbo161931756'@'212.227.109.31' for table 'dt_watchdog' query: INSERT INTO dt_watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'date(): It is not safe to rely on the system\'s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected \'Europe/Berlin\' for \'CET/1.0/no DST\' instead in /homepages/45/d161213570/htdocs/drupal/themes/newdl/page.tpl.php on line 28.', 2, '', 'http://davidtanzer.net/', '', '54.166.48.3', 1480846143) in /homepages/45/d161213570/htdocs/drupal/includes/database.mysql.inc on line 120

Warning: INSERT command denied to user 'dbo161931756'@'212.227.109.31' for table 'dt_watchdog' query: INSERT INTO dt_watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'mktime(): It is not safe to rely on the system\'s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected \'Europe/Berlin\' for \'CET/1.0/no DST\' instead in /homepages/45/d161213570/htdocs/drupal/themes/newdl/page.tpl.php on line 28.', 2, '', 'http://davidtanzer.net/', '', '54.166.48.3', 1480846143) in /homepages/45/d161213570/htdocs/drupal/includes/database.mysql.inc on line 120

Warning: INSERT command denied to user 'dbo161931756'@'212.227.109.31' for table 'dt_watchdog' query: INSERT INTO dt_watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'date(): It is not safe to rely on the system\'s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected \'Europe/Berlin\' for \'CET/1.0/no DST\' instead in /homepages/45/d161213570/htdocs/drupal/themes/newdl/page.tpl.php on line 28.', 2, '', 'http://davidtanzer.net/', '', '54.166.48.3', 1480846143) in /homepages/45/d161213570/htdocs/drupal/includes/database.mysql.inc on line 120

Warning: INSERT command denied to user 'dbo161931756'@'212.227.109.31' for table 'dt_watchdog' query: INSERT INTO dt_watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'date(): It is not safe to rely on the system\'s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected \'Europe/Berlin\' for \'CET/1.0/no DST\' instead in /homepages/45/d161213570/htdocs/drupal/themes/newdl/page.tpl.php on line 29.', 2, '', 'http://davidtanzer.net/', '', '54.166.48.3', 1480846143) in /homepages/45/d161213570/htdocs/drupal/includes/database.mysql.inc on line 120

Note: This is the archive of my old homepage. To continue to the new homepage, go to http://davidtanzer.net

This is the personal homepage of David Tanzer. Here you can find a blog-like collection of articles I write. The RSS newsfeed is available here. You can contact me via email: mail-AT-davidtanzer-DOT-net.

You may use everything I write in this blog (tagged as "Submitted by struppi") except the linked papers and some other parts with explicit exceptions to this license, in whole or in part, without asking as long as you give me credit (like for example: "David Tanzer (http://davidtanzer.net) wrote in his blog: [Some quote from this homepage]").

  • : preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/45/d161213570/htdocs/drupal/includes/unicode.inc on line 291.
  • : preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/45/d161213570/htdocs/drupal/includes/unicode.inc on line 291.
  • : preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/45/d161213570/htdocs/drupal/includes/unicode.inc on line 291.
  • : preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/45/d161213570/htdocs/drupal/includes/unicode.inc on line 291.

Never throw a NullPointerException. Ever.

NullPointerExceptions (NPEs) happen in Java. They indicate that the VM tried to de-reference a null - value. And that's OK. But it is not OK to write code like this:

if(someVariable == null) {
    throw new NullPointerException("The value of \"someVariable" must not be null");
}

It is not OK to write code like this for 3 reasons:

  1. As I said before, the NPE indicates that some part of the program tried to de-reference a null value. This did not happen here.
  2. The exception class you use should indicate what happened. Otherwise we would have only 2 Exception classes in Java: Exception and RuntimeException.
  3. NPEs indicate a programming error and are quite useful to find bugs. You compromise this when you throw them for "normal" errors.

As for the second point: I can think of two reasons why the null value is not allowed here. The first would be that null is an illegal value for an argument of your method. Use "IllegalArgumentException" in this case. The other reason is that a null value would cause an illegal program state. In this case you can use "IllegalStateException". If both scenarios do not feel right for you, create your own exception class.

(Just another rant. Everything IMHO. This post is somewhat related to Exception Abuse. And yes, there is a reason why I wrote this.)

JSXP 0.3 Released

We have just released Version 0.3 of the JSXP web framework for java. The main improvement is the new validation architecture, and some minor bug fixes.

JSXP Community Pages

We have just created a new JSXP community website: jsxpcommunity.org. So far it hosts several JSXP-related forums and the project mailing lists. There might be more content in the future.

JSXP 0.2 Released

We have just released version 0.2 of JSXP - the simple web framework for Java. This release contains great improvements in the view flows implementations, and some minor bug fixes.

JSXP 0.1

Oliver Szymanski and I released JSXP 0.1 today. JSXP is a web application framework for Java. It's main features are: Compile-time safety when accessing elements of the pages, simple XHTML design, component orientation, human readable URLs, automatic server side state, and more.

AndroHUD - A heads up display for Android

I have just published my first little Android application: AndroHUD - A heads up display (HUD). It's really just playing around with the sensors a little bit, but the application also has some useful features:

AndroHUD is a simple heads up display (HUD) which displays your speed, heading, altitude, pitch, roll and the current g-Forces. You can activate a mirror mode if you want to put it at the dashboard of your car. You can also configure speed warnings: The HUD will warn you when you exceed certain speeds.

Openbakery Translation 0.3

There is a new version of openbakery translation. The changes include:

  • All properties files for a given locale are now grouped in a folder for the locale.
  • All translations have a context now, the default context is the class where the "translate" statement was written.
  • The java file parser is more sophisticated now.
  • Singular/Plural translations are now supported.
  • Lists of stuff can now be translated and the translation checker can recognize it.
  • Re-Written documentation with shorter, simple examples.

You can get the newest version and documentation from the project page at openbakery.org.

Apple Bugfixing

I filed this bug on 11-Apr-2007 (almost two years ago):

Title: Safari doesn't handle HTTP Content-Type header

11-Apr-2007 07:18 AM David Tanzer:
Summary: 
A HTML page which has the extension ".tar.gz" is automatically downloaded, even if the HTTP Content-Type 
header is "text/html". For example, the HTTP Headers for the page 
http://www.apache.org/dyn/closer.cgi/geronimo/2.0-M3/geronimo-tomcat6-jee5-2.0-M3-bin.tar.gz 
(which is a HTML page with the mirror list for the file) is automatically downloaded and NOT displayed as it 
should. The content type for this page is:

Content-Type: text/html; charset=iso-8859-1

Steps to Reproduce: 
1. Open the page http://www.apache.org/dyn/closer.cgi/geronimo/2.0-M3/geronimo-tomcat6-jee5-2.0-M3-bin.tar.gz

Expected Results: 
The mirror list for geronimo 2.0-M3 is displayed

Actual Results: 
The html file is downloaded and saved to the Desktop

Regression: 
N/A

It is still open, and the problem still exists in Safari 3.2.1 (5525.27.1). Good job, Apple.

Openbakery Translation Engine 0.2 released

I have just released the second version of the openbakery translation engine, which contains major feature enhancements:

  • Added support for multiple properties files: Now all properties files for the given locale are searched for translations (important for larger projects).
  • Better support for hierarchical locales: TranslationChecker now creates a list of indirectly defined translations.
  • Multiple calls to initialize are now allowed: All translations from all referenced properties files are searched when translating a string.
  • Enhanced output of TranslationChecker: It now tells you where it found a translation (the class or the properties file).

You can find a detailed example at the project page of openbakery translation.

Openbakery Translation Engine 0.1 released

Yesterday and today I created a translation engine for java which has several advantages over the default i18n using resource bundles:

  • The text in the default locale is the key for the translation
  • There is no properties file for the default locale, only for translations
  • There is a tool which analyzes a source tree and finds all translations which are missing in a certain properties file
  • This tool also finds entries in the properties file which are not used anymore and can be removed

Usage is really simple, you just call a static "translate" - method:

translate("This string should be translated"); //Simple translation
translate("This string has parameters: {0} and {1}", "Foo", "Bar"); //Translations can be parameterized
translate(File.class, "Open"); //Translations can have a context, which is the name of a Java class

You can find a complete example, download links, the bug tracker, and other information on the project page at openbakery.org. There is also a freshmeat project page for the project which should be available soon.


Warning: INSERT command denied to user 'dbo161931756'@'212.227.109.31' for table 'dt_watchdog' query: INSERT INTO dt_watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'INSERT command denied to user 'dbo161931756'@'212.227.109.31' for table 'dt_sessions'\nquery: INSERT INTO dt_sessions (sid, uid, cache, hostname, session, timestamp) VALUES ('9aa6e3cd87575b203ed55a0187ccfb7f', 0, 0, '54.166.48.3', 'messages|a:1:{s:5:\\"error\\";a:7:{i:0;s:445:\\"strict warning: date(): It is not safe to rely on the system\\'s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected \\'Europe/Berlin\\& in /homepages/45/d161213570/htdocs/drupal/includes/database.mysql.inc on line 120