From 973eb2f6db60c0939299a968a3121e3310e6d1f5 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 15 Oct 2014 14:43:35 +0200 Subject: java: reduce the depth of some deeply nested if blocks Change-Id: I3c0c7f08d4d8ea594e72fc0d9b93d085d4ab4bf5 --- swext/mediawiki/src/com/sun/star/wiki/Helper.java | 50 +++++++++++------------ 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'swext') diff --git a/swext/mediawiki/src/com/sun/star/wiki/Helper.java b/swext/mediawiki/src/com/sun/star/wiki/Helper.java index 1eb42040139b..9d58de7a3b90 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/Helper.java +++ b/swext/mediawiki/src/com/sun/star/wiki/Helper.java @@ -331,39 +331,39 @@ public class Helper //scrape the HTML source and find the EditURL // TODO/LATER: Use parser in future - String sResultURL = ""; int nInd = sWebPage.indexOf( "http-equiv=\"refresh\"" ); - if ( nInd != -1 ) + if ( nInd == -1 ) + return ""; + + String sResultURL = ""; + int nContent = sWebPage.indexOf( "content=", nInd ); + if ( nContent > 0 ) { - int nContent = sWebPage.indexOf( "content=", nInd ); - if ( nContent > 0 ) + int nURL = sWebPage.indexOf( "URL=", nContent ); + if ( nURL > 0 ) { - int nURL = sWebPage.indexOf( "URL=", nContent ); - if ( nURL > 0 ) - { - int nEndURL = sWebPage.indexOf('"', nURL ); - if ( nEndURL > 0 ) - sResultURL = sWebPage.substring( nURL + 4, nEndURL ); - } + int nEndURL = sWebPage.indexOf('"', nURL ); + if ( nEndURL > 0 ) + sResultURL = sWebPage.substring( nURL + 4, nEndURL ); } + } - try - { - URL aURL = new URL( sURL ); - if ( !sResultURL.startsWith( aURL.getProtocol() )) - { - //if the url is only relative then complete it - if ( sResultURL.startsWith( "/" ) ) - sResultURL = aURL.getProtocol() + "://" + aURL.getHost() + sResultURL; - else - sResultURL = aURL.getProtocol() + "://" + aURL.getHost() + aURL.getPath() + sResultURL; - } - } - catch ( MalformedURLException ex ) + try + { + URL aURL = new URL( sURL ); + if ( !sResultURL.startsWith( aURL.getProtocol() )) { - ex.printStackTrace(); + //if the url is only relative then complete it + if ( sResultURL.startsWith( "/" ) ) + sResultURL = aURL.getProtocol() + "://" + aURL.getHost() + sResultURL; + else + sResultURL = aURL.getProtocol() + "://" + aURL.getHost() + aURL.getPath() + sResultURL; } } + catch ( MalformedURLException ex ) + { + ex.printStackTrace(); + } return sResultURL; -- cgit