Bug 490313 - Refactoring: reduce warnings
diff --git a/plugins/org.eclipse.actf.visualization.engines.lowvision/src/org/eclipse/actf/visualization/internal/engines/lowvision/io/PBMReader.java b/plugins/org.eclipse.actf.visualization.engines.lowvision/src/org/eclipse/actf/visualization/internal/engines/lowvision/io/PBMReader.java
index e68fa4f..4770643 100644
--- a/plugins/org.eclipse.actf.visualization.engines.lowvision/src/org/eclipse/actf/visualization/internal/engines/lowvision/io/PBMReader.java
+++ b/plugins/org.eclipse.actf.visualization.engines.lowvision/src/org/eclipse/actf/visualization/internal/engines/lowvision/io/PBMReader.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2008 IBM Corporation and Others
+ * Copyright (c) 2003, 2016 IBM Corporation and Others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -21,82 +21,84 @@
import org.eclipse.actf.visualization.engines.lowvision.LowVisionIOException;
import org.eclipse.actf.visualization.internal.engines.lowvision.image.BinaryImage;
-
-public class PBMReader{
- public static BinaryImage readBinaryImage( String _fileName ) throws LowVisionIOException{
+public class PBMReader {
+ public static BinaryImage readBinaryImage(String _fileName) throws LowVisionIOException {
FileInputStream fis = null;
- try{
- fis = new FileInputStream( _fileName );
- }catch( FileNotFoundException e ){
- e.printStackTrace();
- throw new LowVisionIOException( "The file was not found: " + _fileName ); //$NON-NLS-1$
+ try {
+ fis = new FileInputStream(_fileName);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ throw new LowVisionIOException("The file was not found: " + _fileName); //$NON-NLS-1$
}
- BufferedReader br = new BufferedReader( new InputStreamReader( fis ) );
+ BufferedReader br = new BufferedReader(new InputStreamReader(fis));
- try{
- char magic1 = (char)(br.read());
- char magic2 = (char)(br.read());
- // support "P1" (not "P4")
- if( magic1 != 'P' || magic2 != '1' ){
- throw new LowVisionIOException( "Bad magic number: " + magic1 + magic2 + "\n\"P4\" cannot be treated in this version.\n(Only \"P1\" is accepted.)" ); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }catch( IOException e ){
- throw new LowVisionIOException( "IOException occurred while reading the magic number." ); //$NON-NLS-1$
+ try {
+ char magic1 = (char) (br.read());
+ char magic2 = (char) (br.read());
+ // support "P1" (not "P4")
+ if (magic1 != 'P' || magic2 != '1') {
+ br.close();
+ throw new LowVisionIOException("Bad magic number: " + magic1 + magic2 //$NON-NLS-1$
+ + "\n\"P4\" cannot be treated in this version.\n(Only \"P1\" is accepted.)"); //$NON-NLS-1$
+ }
+ } catch (IOException e) {
+ throw new LowVisionIOException("IOException occurred while reading the magic number."); //$NON-NLS-1$
}
StringBuffer sb = new StringBuffer();
- try{
+ try {
// remove comments, etc.
- String oneLine = null;
- while( (oneLine=br.readLine()) != null ){
- int index = oneLine.indexOf("#"); //$NON-NLS-1$
- if( index == -1 )
- sb.append( oneLine + "\n" ); //$NON-NLS-1$
- else
- sb.append( oneLine.substring( 0, index ) + "\n" ); //$NON-NLS-1$
- }
- }catch( IOException e ){
- e.printStackTrace();
- throw new LowVisionIOException( "IO error occurred when reading." ); //$NON-NLS-1$
+ String oneLine = null;
+ while ((oneLine = br.readLine()) != null) {
+ int index = oneLine.indexOf("#"); //$NON-NLS-1$
+ if (index == -1)
+ sb.append(oneLine + "\n"); //$NON-NLS-1$
+ else
+ sb.append(oneLine.substring(0, index) + "\n"); //$NON-NLS-1$
+ }
+ br.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new LowVisionIOException("IO error occurred when reading."); //$NON-NLS-1$
}
String content = sb.toString();
- if( !Character.isWhitespace( content.charAt(0) ) ){
- throw new LowVisionIOException( "The magic number must be followed by a white space." ); //$NON-NLS-1$
+ if (!Character.isWhitespace(content.charAt(0))) {
+ throw new LowVisionIOException("The magic number must be followed by a white space."); //$NON-NLS-1$
}
content = content.substring(1);
- Pattern pat = Pattern.compile( "(\\d+)\\s(\\d+)\\s([01\\s]+)" ); //$NON-NLS-1$
- Matcher mat = pat.matcher( content );
- if( !(mat.find()) ){
- throw new LowVisionIOException( "Invalid data format (1)." ); //$NON-NLS-1$
+ Pattern pat = Pattern.compile("(\\d+)\\s(\\d+)\\s([01\\s]+)"); //$NON-NLS-1$
+ Matcher mat = pat.matcher(content);
+ if (!(mat.find())) {
+ throw new LowVisionIOException("Invalid data format (1)."); //$NON-NLS-1$
}
int count = mat.groupCount();
- if( count != 3 ){
- throw new LowVisionIOException( "Invalid data format (2). count = " + count ); //$NON-NLS-1$
+ if (count != 3) {
+ throw new LowVisionIOException("Invalid data format (2). count = " + count); //$NON-NLS-1$
}
int width = Integer.parseInt(mat.group(1));
int height = Integer.parseInt(mat.group(2));
String dataStr = mat.group(3);
- Pattern pat2 = Pattern.compile( "\\s+" ); //$NON-NLS-1$
- Matcher mat2 = pat2.matcher( dataStr );
- String data = mat2.replaceAll( "" ); //$NON-NLS-1$
+ Pattern pat2 = Pattern.compile("\\s+"); //$NON-NLS-1$
+ Matcher mat2 = pat2.matcher(dataStr);
+ String data = mat2.replaceAll(""); //$NON-NLS-1$
- if( data.length() != width*height ){
- throw new LowVisionIOException( "Data size does not equal to width*height" ); //$NON-NLS-1$
+ if (data.length() != width * height) {
+ throw new LowVisionIOException("Data size does not equal to width*height"); //$NON-NLS-1$
}
- BinaryImage bi = new BinaryImage( width, height );
+ BinaryImage bi = new BinaryImage(width, height);
byte[][] bidata = bi.getData();
- int k=0;
- for( int j=0; j<height; j++ ){
- for( int i=0; i<width; i++ ){
- if( data.charAt(k) == '1' )
- bidata[j][i] = 1;
+ int k = 0;
+ for (int j = 0; j < height; j++) {
+ for (int i = 0; i < width; i++) {
+ if (data.charAt(k) == '1')
+ bidata[j][i] = 1;
k++;
- }
+ }
}
- return( bi );
- }
+ return (bi);
+ }
}
diff --git a/plugins/org.eclipse.actf.visualization.engines.lowvision/src/org/eclipse/actf/visualization/internal/engines/lowvision/io/PBMWriter.java b/plugins/org.eclipse.actf.visualization.engines.lowvision/src/org/eclipse/actf/visualization/internal/engines/lowvision/io/PBMWriter.java
index fdb356b..09f6783 100644
--- a/plugins/org.eclipse.actf.visualization.engines.lowvision/src/org/eclipse/actf/visualization/internal/engines/lowvision/io/PBMWriter.java
+++ b/plugins/org.eclipse.actf.visualization.engines.lowvision/src/org/eclipse/actf/visualization/internal/engines/lowvision/io/PBMWriter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2008 IBM Corporation and Others
+ * Copyright (c) 2003, 2016 IBM Corporation and Others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -60,5 +60,6 @@
}
}
pw.println(sb.toString());
+ pw.close();
}
}
diff --git a/plugins/org.eclipse.actf.visualization.flash/src/org/eclipse/actf/visualization/flash/ui/actions/FlashFinderAdapterFactory.java b/plugins/org.eclipse.actf.visualization.flash/src/org/eclipse/actf/visualization/flash/ui/actions/FlashFinderAdapterFactory.java
index eeb01fe..dada284 100644
--- a/plugins/org.eclipse.actf.visualization.flash/src/org/eclipse/actf/visualization/flash/ui/actions/FlashFinderAdapterFactory.java
+++ b/plugins/org.eclipse.actf.visualization.flash/src/org/eclipse/actf/visualization/flash/ui/actions/FlashFinderAdapterFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2015 IBM Corporation and Others
+ * Copyright (c) 2007, 2016 IBM Corporation and Others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,12 +16,12 @@
public class FlashFinderAdapterFactory implements IAdapterFactory, IActionFilter {
- @SuppressWarnings("rawtypes")
+ @SuppressWarnings({ "rawtypes", "unchecked" })
public Class[] getAdapterList() {
return new Class[] { IActionFilter.class };
}
- @SuppressWarnings("rawtypes")
+ @SuppressWarnings({ "rawtypes", "unchecked" })
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (adaptableObject instanceof AccessibleObject && IActionFilter.class == adapterType) {
return this;
diff --git a/plugins/org.eclipse.actf.visualization.flash/src/org/eclipse/actf/visualization/flash/ui/properties/FlashPropertySourceAdapterFactory.java b/plugins/org.eclipse.actf.visualization.flash/src/org/eclipse/actf/visualization/flash/ui/properties/FlashPropertySourceAdapterFactory.java
index b5967a0..131cf6d 100644
--- a/plugins/org.eclipse.actf.visualization.flash/src/org/eclipse/actf/visualization/flash/ui/properties/FlashPropertySourceAdapterFactory.java
+++ b/plugins/org.eclipse.actf.visualization.flash/src/org/eclipse/actf/visualization/flash/ui/properties/FlashPropertySourceAdapterFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and Others
+ * Copyright (c) 2007, 2016 IBM Corporation and Others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -17,7 +17,7 @@
public class FlashPropertySourceAdapterFactory implements IAdapterFactory {
- @SuppressWarnings("rawtypes")
+ @SuppressWarnings({ "rawtypes", "unchecked" })
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (IPropertySource.class == adapterType) {
if (adaptableObject instanceof IFlashPlayer) {
@@ -31,7 +31,7 @@
return null;
}
- @SuppressWarnings("rawtypes")
+ @SuppressWarnings({ "rawtypes", "unchecked" })
public Class[] getAdapterList() {
return new Class[] { IPropertySource.class };
}
diff --git a/plugins/org.eclipse.actf.visualization.gui/src/org/eclipse/actf/accservice/swtbridge/internal/InternalAccessibleObject.java b/plugins/org.eclipse.actf.visualization.gui/src/org/eclipse/actf/accservice/swtbridge/internal/InternalAccessibleObject.java
index aa4704b..23dad44 100644
--- a/plugins/org.eclipse.actf.visualization.gui/src/org/eclipse/actf/accservice/swtbridge/internal/InternalAccessibleObject.java
+++ b/plugins/org.eclipse.actf.visualization.gui/src/org/eclipse/actf/accservice/swtbridge/internal/InternalAccessibleObject.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and Others
+ * Copyright (c) 2007, 2016 IBM Corporation and Others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -932,6 +932,7 @@
*
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
+ @SuppressWarnings({ "unchecked", "rawtypes" })
public Object getAdapter(Class adapter) {
return Platform.getAdapterManager().getAdapter(this, adapter);
}
diff --git a/plugins/org.eclipse.actf.visualization.gui/src/org/eclipse/actf/visualization/gui/msaa/properties/AccessibleObjectPropertySourceAdapterFactory.java b/plugins/org.eclipse.actf.visualization.gui/src/org/eclipse/actf/visualization/gui/msaa/properties/AccessibleObjectPropertySourceAdapterFactory.java
index 18e036a..8d7452c 100644
--- a/plugins/org.eclipse.actf.visualization.gui/src/org/eclipse/actf/visualization/gui/msaa/properties/AccessibleObjectPropertySourceAdapterFactory.java
+++ b/plugins/org.eclipse.actf.visualization.gui/src/org/eclipse/actf/visualization/gui/msaa/properties/AccessibleObjectPropertySourceAdapterFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and Others
+ * Copyright (c) 2007, 2016 IBM Corporation and Others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,20 +14,21 @@
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.ui.views.properties.IPropertySource;
-
public class AccessibleObjectPropertySourceAdapterFactory implements IAdapterFactory {
+ @SuppressWarnings({ "rawtypes", "unchecked" })
public Object getAdapter(Object adaptableObject, Class adapterType) {
- if( IPropertySource.class == adapterType ) {
- if( adaptableObject instanceof AccessibleObject ) {
- return new AccessibleObjectPropertySource((AccessibleObject)adaptableObject);
+ if (IPropertySource.class == adapterType) {
+ if (adaptableObject instanceof AccessibleObject) {
+ return new AccessibleObjectPropertySource((AccessibleObject) adaptableObject);
}
}
return null;
}
+ @SuppressWarnings({ "rawtypes", "unchecked" })
public Class[] getAdapterList() {
- return new Class[] {IPropertySource.class };
+ return new Class[] { IPropertySource.class };
}
}
diff --git a/plugins/org.eclipse.actf.visualization/src/org/eclipse/actf/visualization/util/html2view/Html2ViewMapMaker.java b/plugins/org.eclipse.actf.visualization/src/org/eclipse/actf/visualization/util/html2view/Html2ViewMapMaker.java
index 204b453..c14b305 100644
--- a/plugins/org.eclipse.actf.visualization/src/org/eclipse/actf/visualization/util/html2view/Html2ViewMapMaker.java
+++ b/plugins/org.eclipse.actf.visualization/src/org/eclipse/actf/visualization/util/html2view/Html2ViewMapMaker.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and Others
+ * Copyright (c) 2007, 2016 IBM Corporation and Others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -132,7 +132,7 @@
private Vector<Html2ViewMapData> makeMapLocal(String filename,
String resultFileName, String tmpDir, boolean useTmpDir) {
- PrintWriter htmlWriter;
+ PrintWriter htmlWriter=null;
FileInputStream fis = null;
String _tmpDir = "";
@@ -182,10 +182,10 @@
htmlWriter = new PrintWriter(bos);
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
- return new Vector<Html2ViewMapData>();
+ return new Vector<Html2ViewMapData>();
} catch (UnsupportedEncodingException uee) {
uee.printStackTrace();
- return new Vector<Html2ViewMapData>();
+ return new Vector<Html2ViewMapData>();
}
try {
@@ -237,6 +237,7 @@
}
} catch (Exception e2) {
e2.printStackTrace();
+ htmlWriter.close();
return (new Vector<Html2ViewMapData>());
}
} finally {