Fix bad pathname settings.

This commit is contained in:
Christian P. MOMON 2013-08-30 18:26:25 +02:00
parent 5912bf9079
commit 9daeb06fc4

View file

@ -197,31 +197,51 @@ public class URLPresenter extends StringPresenter
public void setSource(final String source) public void setSource(final String source)
{ {
// //
URL url;
if (source == null) if (source == null)
{ {
url = null; this.source = null;
} this.sourcePathname = null;
else if (source.matches(".+://.+")) this.sourceTime = 0;
{ super.setSource(null);
try
{
url = new URL(source);
}
catch (final MalformedURLException exception)
{
// TODO
logger.warn("UNKNOWN PROTOCOL [" + source + "]");
url = null;
}
} }
else else
{ {
url = URLPresenter.class.getResource(source); //
} URL url;
if (source.matches(".+://.+"))
{
try
{
url = new URL(source);
}
catch (final MalformedURLException exception)
{
// TODO
logger.warn("UNKNOWN PROTOCOL [" + source + "]");
url = null;
}
}
else
{
url = URLPresenter.class.getResource(source);
}
// //
setSource(url); if (url == null)
{
this.source = null;
this.sourcePathname = source;
this.sourceTime = 0;
super.setSource(null);
}
else
{
this.source = url;
this.sourcePathname = source;
this.sourceTime = 0;
super.setSource(null);
}
}
} }
/** /**
@ -282,7 +302,7 @@ public class URLPresenter extends StringPresenter
// //
if (this.source == null) if (this.source == null)
{ {
String errorMessage = "source not defined"; String errorMessage = "source not defined (" + this.sourcePathname + ")";
logger.error(errorMessage); logger.error(errorMessage);
throw new NullPointerException(errorMessage); throw new NullPointerException(errorMessage);
} }