From a0c4e3dcdfdfa13c61f9646560f82894b6aa5582 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Mon, 1 Jul 2013 01:34:26 +0200 Subject: [PATCH] Normalize indentation. --- src/fr/devinsy/xidyn/URLPresenter.java | 91 ++++++++++++++++++-------- 1 file changed, 63 insertions(+), 28 deletions(-) diff --git a/src/fr/devinsy/xidyn/URLPresenter.java b/src/fr/devinsy/xidyn/URLPresenter.java index 59b45f7..e07b15d 100644 --- a/src/fr/devinsy/xidyn/URLPresenter.java +++ b/src/fr/devinsy/xidyn/URLPresenter.java @@ -13,7 +13,8 @@ import org.slf4j.LoggerFactory; /** * */ -public class URLPresenter extends DomPresenter { +public class URLPresenter extends DomPresenter +{ static private Logger logger = LoggerFactory.getLogger(URLPresenter.class); private String sourcePathname; @@ -24,7 +25,8 @@ public class URLPresenter extends DomPresenter { /** * */ - public URLPresenter() { + public URLPresenter() + { setSource((URL) null); } @@ -32,21 +34,24 @@ public class URLPresenter extends DomPresenter { * @throws MalformedURLException * */ - public URLPresenter(final String source) { + public URLPresenter(final String source) + { setSource(source); } /** * */ - public URLPresenter(final URL source) { + public URLPresenter(final URL source) + { setSource(source); } /** * No need to be synchronized. */ - public StringBuffer dynamize() throws Exception { + public StringBuffer dynamize() throws Exception + { StringBuffer result; result = dynamize((TagDataListById) null); @@ -59,31 +64,40 @@ public class URLPresenter extends DomPresenter { * No need to be synchronized. */ @Override - public StringBuffer dynamize(final TagDataListById datas) throws Exception { + public StringBuffer dynamize(final TagDataListById datas) throws Exception + { StringBuffer result; logger.info("dynamize URL [" + this.sourcePathname + "]"); - if (this.sourceURL == null) { + if (this.sourceURL == null) + { String errorMessage = "source file defined but not found (" + this.sourcePathname + ")"; logger.error(errorMessage); result = null; throw new Exception(errorMessage); - } else if (datas == null) { + } + else if (datas == null) + { result = new StringBuffer(sourceURL.openConnection().getContentLength()); BufferedReader in = new BufferedReader(new InputStreamReader(this.sourceURL.openStream())); String line; - while ((line = in.readLine()) != null) { + while ((line = in.readLine()) != null) + { result.append(line); } in.close(); - } else { + } + else + { long lastModified = sourceURL.openConnection().getLastModified(); - if ((this.doc == null) || (this.sourceFileTime != lastModified)) { + if ((this.doc == null) || (this.sourceFileTime != lastModified)) + { this.sourceFileTime = lastModified; this.doc = Presenter.buildTree(this.sourceURL.openStream()); this.doctype = ""; // TODO Made generic. - if (this.doc != null) { + if (this.doc != null) + { Presenter.addMetaTag(doc, "generator", "XID 0.0"); } } @@ -105,7 +119,8 @@ public class URLPresenter extends DomPresenter { * */ @Override - public StringBuffer dynamize(final TagDataManager datas) throws Exception { + public StringBuffer dynamize(final TagDataManager datas) throws Exception + { return (dynamize(datas.getIdsDataById())); } @@ -113,7 +128,8 @@ public class URLPresenter extends DomPresenter { * */ @Override - public String getSource() { + public String getSource() + { String result; result = this.sourceURL.toString(); @@ -125,18 +141,27 @@ public class URLPresenter extends DomPresenter { /** * */ - public void setSource(final String source) { + public void setSource(final String source) + { URL url; - if (source == null) { + if (source == null) + { url = null; - } else if (source.matches(".+://.+")) { - try { + } + else if (source.matches(".+://.+")) + { + try + { url = new URL(source); - } catch (final MalformedURLException exception) { + } + catch (final MalformedURLException exception) + { logger.warn("UNKNOWN PROTOCOL [" + source + "]"); url = null; } - } else { + } + else + { url = URLPresenter.class.getResource(source); } @@ -148,10 +173,14 @@ public class URLPresenter extends DomPresenter { * @param source * @throws MalformedURLException */ - public void setSource(final URL source) { - if (source == null) { + public void setSource(final URL source) + { + if (source == null) + { this.sourcePathname = null; - } else { + } + else + { this.sourcePathname = source.toString(); } this.sourceURL = source; @@ -163,7 +192,8 @@ public class URLPresenter extends DomPresenter { /** * Dynamize a file without data. */ - static public StringBuffer dynamize(final String filePathname) throws Exception { + static public StringBuffer dynamize(final String filePathname) throws Exception + { StringBuffer result; URLPresenter presenter = new URLPresenter(filePathname); @@ -177,7 +207,8 @@ public class URLPresenter extends DomPresenter { /** * Dynamize a file. */ - static public StringBuffer dynamize(final String filePathname, final TagDataManager datas) throws Exception { + static public StringBuffer dynamize(final String filePathname, final TagDataManager datas) throws Exception + { StringBuffer result; URLPresenter presenter = new URLPresenter(filePathname); @@ -194,7 +225,8 @@ public class URLPresenter extends DomPresenter { * @return * @throws Exception */ - static public String getDoctype(final String filePathname) throws Exception { + static public String getDoctype(final String filePathname) throws Exception + { String result; // @@ -205,9 +237,12 @@ public class URLPresenter extends DomPresenter { logger.info("doctype=[" + doctype + "]"); // - if ((doctype.startsWith("