refactor duplicated code, add javadoc

git-svn-id: http://josm.openstreetmap.de/svn/trunk@6214 0c6e7542-c601-0410-84e7-c038aed88b3b
Merge branch 'master' into mirror