/*
 * Copyright 2013 Erwin Müller <erwin.mueller@deventm.org>
 *
 * This file is part of globalpom-utils.
 *
 * globalpom-utils is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 *
 * globalpom-utils is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with globalpom-utils. If not, see <http://www.gnu.org/licenses/>.
 */
package com.anrisoftware.globalpom.format.inetsocketaddress;

import java.net.URI;
import java.net.URISyntaxException;
import java.text.ParseException;
import java.text.ParsePosition;

import com.anrisoftware.globalpom.log.AbstractLogger;

/**
 * Logging messages for {@link InetSocketAddressFormat}.
 * 
 * @author Erwin Mueller, erwin.mueller@deventm.org
 * @since 1.0
 */
class InetSocketAddressFormatLogger extends AbstractLogger {

	/**
	 * Create logger for {@link InetSocketAddressFormat}.
	 */
	InetSocketAddressFormatLogger() {
		super(InetSocketAddressFormat.class);
	}

	ParseException errorParseAddress(String source, ParsePosition pos) {
		ParseException ex = new ParseException(String.format(
				"Unparseable socket address: '%s'", source),
				pos.getErrorIndex());
		log.error(ex.getLocalizedMessage());
		return ex;
	}

	URISyntaxException errorURISyntax(URI uri) {
		URISyntaxException ex = new URISyntaxException(uri.toString(),
				"URI must have a host part");
		log.error(ex.getLocalizedMessage());
		return ex;
	}

	URISyntaxException errorURISyntax(String hostName, URISyntaxException e) {
		log.error("Syntax error for URI {}: {}", hostName,
				e.getLocalizedMessage());
		return e;
	}

}

@@ -835,16 +835,56 @@
 dress;%0A%0A
+import static java.lang.String.format;%0A%0A
 import j
@@ -1250,16 +1250,450 @@
 gger %7B%0A%0A
+%09private static final String SYNTAX_ERROR = %22Syntax error for URI %7B%7D: %7B%7D%22;%0A%09private static final String URI_HOST_PART_MESSAGE = %22URI '%7B%7D' must have a host part.%22;%0A%09private static final String URI_HOST_PART = %22URI must have a host part%22;%0A%09private static final String UNPARSEABLE_SOCKET_ADDRESS_MESSAGE = %22Unparseable socket address: '%7B%7D'%22;%0A%09private static final String UNPARSEABLE_SOCKET_ADDRESS = %22Unparseable socket address: '%25s'%22;%0A%0A
 %09/**%0A%09 *
@@ -1900,21 +1900,26 @@
 os) %7B%0A%09%09
-Parse
+return log
 Exceptio
@@ -1915,30 +1915,30 @@
 logException
- ex = 
+(%0A%09%09%09%09
 new ParseExc
@@ -1948,61 +1948,41 @@
 ion(
-String.format(%0A%09%09%09%09%22Unparseable socket address: '%25s'%22
+format(UNPARSEABLE_SOCKET_ADDRESS
 , so
@@ -1992,16 +1992,18 @@
 e),%0A%09%09%09%09
+%09%09
 pos.getE
@@ -2018,60 +2018,57 @@
 x())
-;%0A%09%09log.error(ex.getLocalizedMessage());%0A%09%09return ex
+,%0A%09%09%09%09UNPARSEABLE_SOCKET_ADDRESS_MESSAGE, source)
 ;%0A%09%7D
@@ -2117,25 +2117,26 @@
 ri) %7B%0A%09%09
-URISyntax
+return log
 Exceptio
@@ -2140,14 +2140,9 @@
 tion
- ex = 
+(
 new 
@@ -2184,88 +2184,51 @@
 %09%09%09%09
-%22URI must have a host part%22);%0A%09%09log.error(ex.getLocalizedMessage());%0A%09%09return ex
+URI_HOST_PART), URI_HOST_PART_MESSAGE, uri)
 ;%0A%09%7D
@@ -2321,37 +2321,20 @@
 ror(
-%22Syntax error for URI %7B%7D: %7B%7D%22
+SYNTAX_ERROR
 , ho
@@ -2340,21 +2340,17 @@
 ostName,
-%0A%09%09%09%09
+ 
 e.getLoc

Update logging