diff options
author | Noel Grandin <noel@peralex.com> | 2014-11-12 09:55:57 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2014-11-12 11:03:29 +0000 |
commit | bb437029c1e5331bcc3f8fb2fc87837142a52f33 (patch) | |
tree | 56bde4059792a5284e90ae3b10ee4388cc913a54 /qadevOOo | |
parent | 84f7f412bfc9e18b1ff8b133ceda7757eae28c36 (diff) |
java: convert fields to local variables where possible
found by PMD
Change-Id: I05b45382b8fb1b734657ce9421a20e6ef6fbe542
Reviewed-on: https://gerrit.libreoffice.org/12376
Tested-by: LibreOffice gerrit bot <gerrit@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'qadevOOo')
18 files changed, 45 insertions, 73 deletions
diff --git a/qadevOOo/runner/complexlib/ComplexTestCase.java b/qadevOOo/runner/complexlib/ComplexTestCase.java index ff8b4fd7ad4d..2486692130bb 100644 --- a/qadevOOo/runner/complexlib/ComplexTestCase.java +++ b/qadevOOo/runner/complexlib/ComplexTestCase.java @@ -39,12 +39,6 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest * The method name which will be written into f.e. the data base **/ private String mTestMethodName = null; - /** Maximal time one method is allowed to execute - * Can be set with parameter 'ThreadTimeOut' - **/ - private int m_nThreadTimeOut = 0; - - private boolean m_bBeforeCalled; @@ -90,10 +84,13 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest private void test_method(DescEntry _entry) { - m_nThreadTimeOut = param.getInt("ThreadTimeOut"); - if (m_nThreadTimeOut == 0) + /* Maximal time one method is allowed to execute + * Can be set with parameter 'ThreadTimeOut' + **/ + int nThreadTimeOut = param.getInt("ThreadTimeOut"); + if (nThreadTimeOut == 0) { - m_nThreadTimeOut = 300000; + nThreadTimeOut = 300000; } for (int i = 0; i < _entry.SubEntries.length; i++) @@ -153,7 +150,7 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest int sleepingStep = 1000; int factor = 0; - while (th.isAlive() && (lastPing != newPing || factor * sleepingStep < m_nThreadTimeOut)) + while (th.isAlive() && (lastPing != newPing || factor * sleepingStep < nThreadTimeOut)) { Thread.sleep(sleepingStep); factor++; @@ -175,7 +172,7 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest { log.println("Destroy " + mTestMethodName); th.stopRunning(); - subEntry.State = "Test did sleep for " + (m_nThreadTimeOut / 1000) + " seconds and has been killed!"; + subEntry.State = "Test did sleep for " + (nThreadTimeOut / 1000) + " seconds and has been killed!"; subEntry.hasErrorMsg = true; subEntry.ErrorMsg = subEntry.State; continue; diff --git a/qadevOOo/runner/convwatch/BorderRemover.java b/qadevOOo/runner/convwatch/BorderRemover.java index 87ba90a42456..af7ee46a99bc 100644 --- a/qadevOOo/runner/convwatch/BorderRemover.java +++ b/qadevOOo/runner/convwatch/BorderRemover.java @@ -46,8 +46,6 @@ class Rect class BorderRemover { - private ImageHelper m_aImage; - // Helper values, filled after find Border // --------------------------------- test mode --------------------------------- @@ -121,12 +119,12 @@ class BorderRemover public boolean createNewImageWithoutBorder(String _sFilenameFrom, String _sFilenameTo) throws java.io.IOException { - m_aImage = ImageHelper.createImageHelper(_sFilenameFrom); + ImageHelper aImageHelper = ImageHelper.createImageHelper(_sFilenameFrom); - int nBorderColor = m_aImage.getPixel(0,0); - Rect aInnerRect = findBorder(m_aImage, nBorderColor); + int nBorderColor = aImageHelper.getPixel(0,0); + Rect aInnerRect = findBorder(aImageHelper, nBorderColor); - RenderedImage aImage = createImage(m_aImage, aInnerRect); + RenderedImage aImage = createImage(aImageHelper, aInnerRect); File aWriteFile = new File(_sFilenameTo); diff --git a/qadevOOo/runner/convwatch/ImageHelper.java b/qadevOOo/runner/convwatch/ImageHelper.java index 914c70ef7a4f..2644223e2ebb 100644 --- a/qadevOOo/runner/convwatch/ImageHelper.java +++ b/qadevOOo/runner/convwatch/ImageHelper.java @@ -29,7 +29,6 @@ class ImageHelper private Image m_aImage; private int[] m_aPixels; private int m_w = 0; - private int m_h = 0; private ImageHelper(Image _aImage) @@ -38,11 +37,11 @@ class ImageHelper // grab all (consume much memory) m_w = getWidth(); - m_h = getHeight(); + int h = getHeight(); int x = 0; int y = 0; - m_aPixels = new int[m_w * m_h]; - PixelGrabber pg = new PixelGrabber(m_aImage, x, y, m_w, m_h, m_aPixels, 0, m_w); + m_aPixels = new int[m_w * h]; + PixelGrabber pg = new PixelGrabber(m_aImage, x, y, m_w, h, m_aPixels, 0, m_w); try { pg.grabPixels(); } catch (InterruptedException e) { diff --git a/qadevOOo/runner/graphical/ImageHelper.java b/qadevOOo/runner/graphical/ImageHelper.java index b1ec0ca649de..8f4249697192 100644 --- a/qadevOOo/runner/graphical/ImageHelper.java +++ b/qadevOOo/runner/graphical/ImageHelper.java @@ -29,7 +29,6 @@ class ImageHelper private Image m_aImage; private int[] m_aPixels; private int m_w = 0; - private int m_h = 0; private ImageHelper(Image _aImage) @@ -38,11 +37,11 @@ class ImageHelper // grab all (consume much memory) m_w = getWidth(); - m_h = getHeight(); + int h = getHeight(); int x = 0; int y = 0; - m_aPixels = new int[m_w * m_h]; - PixelGrabber pg = new PixelGrabber(m_aImage, x, y, m_w, m_h, m_aPixels, 0, m_w); + m_aPixels = new int[m_w * h]; + PixelGrabber pg = new PixelGrabber(m_aImage, x, y, m_w, h, m_aPixels, 0, m_w); try { pg.grabPixels(); diff --git a/qadevOOo/runner/graphical/ParameterHelper.java b/qadevOOo/runner/graphical/ParameterHelper.java index 4e028583ac4d..0f3c06d8aa83 100644 --- a/qadevOOo/runner/graphical/ParameterHelper.java +++ b/qadevOOo/runner/graphical/ParameterHelper.java @@ -69,8 +69,6 @@ public class ParameterHelper private int m_nResolutionInDPI = 180; - private boolean m_bIncludeSubdirectories; - private String m_sInputPath = null; private String m_sOutputPath = null; @@ -126,7 +124,7 @@ public class ParameterHelper public boolean isIncludeSubDirectories() { - m_bIncludeSubdirectories = true; + boolean bIncludeSubdirectories = true; String sRECURSIVE = (String)getTestParameters().get( PropertyName.DOC_COMPARATOR_INCLUDE_SUBDIRS ); // TODO: I need to get the boolean value with get("name") because, if it is not given getBool() returns // with a default of 'false' which is not very helpful if the default should be 'true' @@ -138,9 +136,9 @@ public class ParameterHelper if (sRECURSIVE.equalsIgnoreCase("no") || sRECURSIVE.equalsIgnoreCase("false")) { - m_bIncludeSubdirectories = false; + bIncludeSubdirectories = false; } - return m_bIncludeSubdirectories; + return bIncludeSubdirectories; } public String getReferenceType() diff --git a/qadevOOo/runner/helper/ConfigHelper.java b/qadevOOo/runner/helper/ConfigHelper.java index cfa61a3bf15a..a373ce03d319 100644 --- a/qadevOOo/runner/helper/ConfigHelper.java +++ b/qadevOOo/runner/helper/ConfigHelper.java @@ -85,7 +85,6 @@ import com.sun.star.util.*; */ public class ConfigHelper { - private XMultiServiceFactory m_xSMGR = null; private XHierarchicalNameAccess m_xConfig = null; @@ -94,12 +93,9 @@ public class ConfigHelper boolean bReadOnly ) throws com.sun.star.uno.Exception { - m_xSMGR = xSMGR; - XMultiServiceFactory xConfigRoot = UnoRuntime.queryInterface( - XMultiServiceFactory.class, - m_xSMGR.createInstance( - "com.sun.star.configuration.ConfigurationProvider")); + XMultiServiceFactory.class, + xSMGR.createInstance("com.sun.star.configuration.ConfigurationProvider")); PropertyValue[] lParams = new PropertyValue[1]; lParams[0] = new PropertyValue(); diff --git a/qadevOOo/runner/helper/StreamSimulator.java b/qadevOOo/runner/helper/StreamSimulator.java index 7571ce6864cf..8e17e910b5bb 100644 --- a/qadevOOo/runner/helper/StreamSimulator.java +++ b/qadevOOo/runner/helper/StreamSimulator.java @@ -46,7 +46,6 @@ public class StreamSimulator implements com.sun.star.io.XInputStream , * @member m_bOutWasUsed indicates, that the output stream interface was used */ - private String m_sFileName ; private com.sun.star.io.XInputStream m_xInStream ; private com.sun.star.io.XOutputStream m_xOutStream ; private com.sun.star.io.XSeekable m_xSeek ; @@ -57,7 +56,7 @@ public class StreamSimulator implements com.sun.star.io.XInputStream , /** * construct a new instance of this class - * It set the name of the correspojnding file on disk, which + * It set the name of the corresponding file on disk, which * should be source or target for the following operations on * this object. And it regulate if it should function as * input or output stream. @@ -74,13 +73,11 @@ public class StreamSimulator implements com.sun.star.io.XInputStream , * * @throw com.sun.star.io.NotConnectedException * in case the internal streams to the file on disk couldn't established. - * They are necessary. Otherwhise this simulator can't really work. + * They are necessary. Otherwise this simulator can't really work. */ public StreamSimulator( String sFileName , boolean bInput , lib.TestParameters param ) throws com.sun.star.io.NotConnectedException { - m_sFileName = sFileName ; - try { XSimpleFileAccess xHelper = UnoRuntime.queryInterface(XSimpleFileAccess.class, @@ -91,14 +88,14 @@ public class StreamSimulator implements com.sun.star.io.XInputStream , if (bInput) { - m_xInStream = xHelper.openFileRead(m_sFileName); + m_xInStream = xHelper.openFileRead(sFileName); m_xSeek = UnoRuntime.queryInterface( com.sun.star.io.XSeekable.class, m_xInStream); } else { - m_xOutStream = xHelper.openFileWrite(m_sFileName); + m_xOutStream = xHelper.openFileWrite(sFileName); m_xSeek = UnoRuntime.queryInterface( com.sun.star.io.XSeekable.class, m_xOutStream); diff --git a/qadevOOo/runner/org/openoffice/Runner.java b/qadevOOo/runner/org/openoffice/Runner.java index ff1bff4109b5..42b77674fb37 100644 --- a/qadevOOo/runner/org/openoffice/Runner.java +++ b/qadevOOo/runner/org/openoffice/Runner.java @@ -21,7 +21,6 @@ import helper.CfgParser; import helper.ClParser; import java.util.Enumeration; -import java.util.Iterator; import java.util.Map; import java.util.Properties; import java.util.StringTokenizer; diff --git a/qadevOOo/runner/util/FrameDsc.java b/qadevOOo/runner/util/FrameDsc.java index 348cc8d5d3fb..644a2530c5e5 100644 --- a/qadevOOo/runner/util/FrameDsc.java +++ b/qadevOOo/runner/util/FrameDsc.java @@ -30,7 +30,6 @@ import com.sun.star.beans.XPropertySet; */ public class FrameDsc extends InstDescr { - private Size size = null; private int height = 2000; private int width = 2000; private String name = null; @@ -77,7 +76,7 @@ public class FrameDsc extends InstDescr { public XInterface createInstance( XMultiServiceFactory docMSF ) { Object SrvObj = null; - size = new Size(); + Size size = new Size(); size.Height = height; size.Width = width; diff --git a/qadevOOo/tests/java/ifc/frame/_XSynchronousFrameLoader.java b/qadevOOo/tests/java/ifc/frame/_XSynchronousFrameLoader.java index 2151d77957ba..109dfa5fbb4b 100644 --- a/qadevOOo/tests/java/ifc/frame/_XSynchronousFrameLoader.java +++ b/qadevOOo/tests/java/ifc/frame/_XSynchronousFrameLoader.java @@ -55,7 +55,6 @@ import com.sun.star.util.XURLTransformer; public class _XSynchronousFrameLoader extends MultiMethodTest { public XSynchronousFrameLoader oObj = null; // oObj filled by MultiMethodTest - private String url = null ; private XFrame frame = null ; private XComponent frameSup = null ; private PropertyValue[] descr = null; @@ -72,7 +71,7 @@ public class _XSynchronousFrameLoader extends MultiMethodTest { */ @Override public void before() { - url = (String) tEnv.getObjRelation("FrameLoader.URL") ; + String url = (String) tEnv.getObjRelation("FrameLoader.URL") ; frame = (XFrame) tEnv.getObjRelation("FrameLoader.Frame") ; if (url == null) { diff --git a/qadevOOo/tests/java/ifc/i18n/_XCollator.java b/qadevOOo/tests/java/ifc/i18n/_XCollator.java index e47e6a7f7166..48a3d7f50204 100644 --- a/qadevOOo/tests/java/ifc/i18n/_XCollator.java +++ b/qadevOOo/tests/java/ifc/i18n/_XCollator.java @@ -44,7 +44,6 @@ import com.sun.star.lang.Locale; public class _XCollator extends MultiMethodTest { public XCollator oObj = null; private String[] alg = null ; - private int[] opt = null ; Locale loc = new Locale("en", "EN", ""); /** @@ -75,7 +74,7 @@ public class _XCollator extends MultiMethodTest { */ public void _listCollatorOptions() { requiredMethod("listCollatorAlgorithms()") ; - opt = oObj.listCollatorOptions(alg[0]) ; + int[] opt = oObj.listCollatorOptions(alg[0]) ; log.println("Collator '" + alg[0] + "' options :"); if (opt != null) { for (int i = 0; i < opt.length; i++) { diff --git a/qadevOOo/tests/java/ifc/i18n/_XTransliteration.java b/qadevOOo/tests/java/ifc/i18n/_XTransliteration.java index 055f9c43fa66..17991b1429fe 100644 --- a/qadevOOo/tests/java/ifc/i18n/_XTransliteration.java +++ b/qadevOOo/tests/java/ifc/i18n/_XTransliteration.java @@ -48,7 +48,6 @@ import com.sun.star.lang.Locale; public class _XTransliteration extends MultiMethodTest { public XTransliteration oObj = null; - private String[] mod = null ; private Locale loc = new Locale("en", "EN", "") ; /** @@ -57,7 +56,7 @@ public class _XTransliteration extends MultiMethodTest { * one module name. */ public void _getAvailableModules() { - mod = oObj.getAvailableModules(loc, TransliterationType.ONE_TO_ONE); + String[] mod = oObj.getAvailableModules(loc, TransliterationType.ONE_TO_ONE); if (mod != null) { log.println("Available modules :") ; diff --git a/qadevOOo/tests/java/ifc/io/_XObjectInputStream.java b/qadevOOo/tests/java/ifc/io/_XObjectInputStream.java index 197a97086629..5f55f0b778d2 100644 --- a/qadevOOo/tests/java/ifc/io/_XObjectInputStream.java +++ b/qadevOOo/tests/java/ifc/io/_XObjectInputStream.java @@ -47,8 +47,6 @@ import com.sun.star.uno.UnoRuntime; public class _XObjectInputStream extends MultiMethodTest { public XObjectInputStream oObj = null; - private Object objRead = null ; - private Object objWrite = null ; /** * Test reads perisist object from stream and compares properties @@ -58,7 +56,7 @@ public class _XObjectInputStream extends MultiMethodTest { * of objects properties are equal. <p> */ public void _readObject() { - objWrite = tEnv.getObjRelation("PersistObject") ; + Object objWrite = tEnv.getObjRelation("PersistObject") ; if (objWrite == null) { log.println("PersistObject not found in relations") ; tRes.tested("readObject()", false) ; @@ -77,6 +75,7 @@ public class _XObjectInputStream extends MultiMethodTest { return; } + Object objRead = null ; try { objRead = oObj.readObject() ; } catch(com.sun.star.io.IOException e) { diff --git a/qadevOOo/tests/java/ifc/ucb/_XCachedDynamicResultSetStubFactory.java b/qadevOOo/tests/java/ifc/ucb/_XCachedDynamicResultSetStubFactory.java index 5d12bc102acd..41e8ff16917f 100644 --- a/qadevOOo/tests/java/ifc/ucb/_XCachedDynamicResultSetStubFactory.java +++ b/qadevOOo/tests/java/ifc/ucb/_XCachedDynamicResultSetStubFactory.java @@ -52,7 +52,6 @@ public class _XCachedDynamicResultSetStubFactory extends MultiMethodTest { */ public XCachedDynamicResultSetStubFactory oObj; private XDynamicResultSet resSet = null ; - private XDynamicResultSet resSetStub = null ; /** * Retrieves object relation. @@ -77,7 +76,7 @@ public class _XCachedDynamicResultSetStubFactory extends MultiMethodTest { public void _createCachedDynamicResultSetStub() { boolean result = true ; - resSetStub = oObj.createCachedDynamicResultSetStub(resSet) ; + XDynamicResultSet resSetStub = oObj.createCachedDynamicResultSetStub(resSet) ; if (resSetStub == null) { log.println("!!! Method returned null !!!") ; diff --git a/qadevOOo/tests/java/ifc/ui/dialogs/_XControlAccess.java b/qadevOOo/tests/java/ifc/ui/dialogs/_XControlAccess.java index 7d6bf621d2aa..e290ab4d9191 100644 --- a/qadevOOo/tests/java/ifc/ui/dialogs/_XControlAccess.java +++ b/qadevOOo/tests/java/ifc/ui/dialogs/_XControlAccess.java @@ -44,7 +44,6 @@ import com.sun.star.uno.UnoRuntime; public class _XControlAccess extends MultiMethodTest { public XControlAccess oObj = null; - private XControlInformation xCI = null ; private String[] supControls = null ; private String[][] supProperties = null ; @@ -58,7 +57,7 @@ public class _XControlAccess extends MultiMethodTest { */ @Override protected void before() { - xCI = UnoRuntime.queryInterface + XControlInformation xCI = UnoRuntime.queryInterface (XControlInformation.class, oObj); if (xCI == null) throw new StatusException diff --git a/qadevOOo/tests/java/mod/_dbaccess/ODatabaseSource.java b/qadevOOo/tests/java/mod/_dbaccess/ODatabaseSource.java index d27ad7b96001..bff1ecdf22c7 100644 --- a/qadevOOo/tests/java/mod/_dbaccess/ODatabaseSource.java +++ b/qadevOOo/tests/java/mod/_dbaccess/ODatabaseSource.java @@ -78,8 +78,6 @@ public class ODatabaseSource extends TestCase { private static int uniqueSuffixStat = 0 ; private int uniqueSuffix = 0 ; - private XNamingService xDBContextNameServ = null ; - private String databaseName = null ; private XOfficeDatabaseDocument xDBDoc = null; /** @@ -136,7 +134,7 @@ public class ODatabaseSource extends TestCase { throw new StatusException("Service not available", e) ; } - xDBContextNameServ = UnoRuntime.queryInterface(XNamingService.class, oInterface) ; + XNamingService xDBContextNameServ = UnoRuntime.queryInterface(XNamingService.class, oInterface) ; // retrieving temp directory for database String tmpDatabaseUrl = utils.getOfficeTempDir(Param.getMSF()); @@ -179,7 +177,7 @@ public class ODatabaseSource extends TestCase { throw new StatusException("Could not set property 'URL' ", e) ; } - databaseName = "NewDatabaseSource" + uniqueSuffix ; + String databaseName = "NewDatabaseSource" + uniqueSuffix ; // make sure that the DatabaseContext isn't already registered try { diff --git a/qadevOOo/tests/java/mod/_dbaccess/ORowSet.java b/qadevOOo/tests/java/mod/_dbaccess/ORowSet.java index dbb72469ea0a..5a6d42c972b5 100644 --- a/qadevOOo/tests/java/mod/_dbaccess/ORowSet.java +++ b/qadevOOo/tests/java/mod/_dbaccess/ORowSet.java @@ -134,7 +134,6 @@ public class ORowSet extends TestCase { private Object m_rowSet = null; private DataSource m_dataSource; private String m_tableFile; - private XMultiServiceFactory m_orb = null; /** * Initializes some class fields. Then creates DataSource, which serves @@ -160,13 +159,13 @@ public class ORowSet extends TestCase { protected void initialize ( TestParameters Param, PrintWriter _log) throws StatusException { - m_orb = Param.getMSF(); + XMultiServiceFactory orb = Param.getMSF(); - String tmpDir = utils.getOfficeTemp( m_orb ); + String tmpDir = utils.getOfficeTemp( orb ); origDB = util.utils.getFullTestDocName("TestDB/testDB.dbf"); - dbTools = new DBTools( m_orb ); + dbTools = new DBTools( orb ); // creating DataSource and registering it in DatabaseContext String dbURL = (String) Param.get("test.db.url"); @@ -174,7 +173,7 @@ public class ORowSet extends TestCase { String dbPassword = (String) Param.get("test.db.password"); log.println("Creating and registering DataSource ..."); - srcInf = new DataSourceDescriptor( m_orb ); + srcInf = new DataSourceDescriptor( orb ); if (dbURL != null && dbUser != null && dbPassword != null) { isMySQLDB = true; diff --git a/qadevOOo/tests/java/mod/_forms/GenericModelTest.java b/qadevOOo/tests/java/mod/_forms/GenericModelTest.java index 26d38a8a6719..ed7ba409d2ed 100644 --- a/qadevOOo/tests/java/mod/_forms/GenericModelTest.java +++ b/qadevOOo/tests/java/mod/_forms/GenericModelTest.java @@ -126,7 +126,6 @@ import util.utils; public class GenericModelTest extends TestCase { private XTextDocument m_xTextDoc; private Object m_dbSrc = null; - private DBTools.DataSourceInfo m_srcInf = null; /** * This is the name of the Data Base which the test uses: "APITestDatabase" */ @@ -403,11 +402,11 @@ public class GenericModelTest extends TestCase { m_dbTools = new DBTools( xMSF ); String tmpDir = utils.getOfficeTemp((xMSF)); - m_srcInf = m_dbTools.newDataSourceInfo(); - m_srcInf.URL = "sdbc:dbase:" + DBTools.dirToUrl(tmpDir); - log.println("data source: " + m_srcInf.URL); + DBTools.DataSourceInfo srcInf = m_dbTools.newDataSourceInfo(); + srcInf.URL = "sdbc:dbase:" + DBTools.dirToUrl(tmpDir); + log.println("data source: " + srcInf.URL); - m_dbSrc = m_srcInf.getDataSourceService(); + m_dbSrc = srcInf.getDataSourceService(); m_dbTools.reRegisterDB(m_dbSourceName, m_dbSrc); m_XFormLoader = FormTools.bindForm(m_xTextDoc, m_dbSourceName, |