Kaydet (Commit) 973eb2f6 authored tarafından Noel Grandin's avatar Noel Grandin

java: reduce the depth of some deeply nested if blocks

Change-Id: I3c0c7f08d4d8ea594e72fc0d9b93d085d4ab4bf5
üst fa652cdd
......@@ -352,9 +352,12 @@ public class InterfaceContainer implements Cloneable
*/
synchronized public int indexOf(Object elem)
{
if (elementData == null || elem == null) {
return -1;
}
int index= -1;
if (elementData != null && elem != null)
{
for (int i = 0; i < size; i++)
{
if (elem == elementData[i])
......@@ -375,7 +378,6 @@ public class InterfaceContainer implements Cloneable
}
}
}
}
return index;
}
/**
......@@ -408,9 +410,12 @@ public class InterfaceContainer implements Cloneable
*/
synchronized public int lastIndexOf(Object elem)
{
if (elementData == null || elem == null) {
return -1;
}
int index= -1;
if (elementData != null && elem != null)
{
for (int i = size-1; i >= 0; i--)
{
if (elem == elementData[i])
......@@ -430,7 +435,6 @@ public class InterfaceContainer implements Cloneable
}
}
}
}
return index;
}
......@@ -535,9 +539,11 @@ public class InterfaceContainer implements Cloneable
synchronized public boolean retainAll(Collection collection)
{
if (elementData == null || collection == null) {
return false;
}
boolean retVal= false;
if (elementData != null && collection != null)
{
// iterate over data
Object[] arRetained= new Object[size];
int indexRetained= 0;
......@@ -581,7 +587,6 @@ public class InterfaceContainer implements Cloneable
elementData= arRetained;
size= indexRetained;
}
}
return retVal;
}
......
......@@ -84,7 +84,9 @@ public class JavaLoader implements XImplementationLoader,
*/
private String expand_url( String url ) throws RuntimeException
{
if (url != null && url.startsWith( EXPAND_PROTOCOL_PREFIX )) {
if (url == null || !url.startsWith( EXPAND_PROTOCOL_PREFIX )) {
return url;
}
try {
if (m_xMacroExpander == null) {
XPropertySet xProps =
......@@ -126,8 +128,6 @@ public class JavaLoader implements XImplementationLoader,
exc.getMessage(), this );
}
}
return url;
}
/**
* Default constructor.
......
......@@ -89,7 +89,9 @@ public final class NativeLibraryLoader {
// (scheme://auth/dir1/name). The second step is important in a typical
// OOo installation, where the JAR files are in the program/classes
// directory while the shared libraries are in the program directory.
if (loader instanceof URLClassLoader) {
if (!(loader instanceof URLClassLoader)) {
return null;
}
URL[] urls = ((URLClassLoader) loader).getURLs();
for (int i = 0; i < urls.length; ++i) {
File path = UrlToFileMapper.mapUrlToFile(urls[i]);
......@@ -120,7 +122,6 @@ public final class NativeLibraryLoader {
}
}
}
}
return null;
}
......
......@@ -80,11 +80,16 @@ final class InstallationFinder {
// com.sun.star.lib.loader.unopath
// (all platforms)
path = getPathFromProperty( SYSPROP_NAME );
if ( path == null ) {
if ( path != null ) {
return path;
}
// get the installation path from the UNO_PATH environment variable
// (all platforms, not working for Java 1.3.1 and Java 1.4)
path = getPathFromEnvVar( ENVVAR_NAME );
if ( path == null ) {
if ( path != null ) {
return path;
}
String osname = null;
try {
osname = System.getProperty( "os.name" );
......@@ -93,7 +98,10 @@ final class InstallationFinder {
// return <code>null</code>
return null;
}
if ( osname != null ) {
if ( osname == null ) {
return null;
}
if ( osname.startsWith( "Windows" ) ) {
// get the installation path from the Windows Registry
// (Windows platform only)
......@@ -115,9 +123,6 @@ final class InstallationFinder {
}
}
}
}
}
}
return path;
}
......
......@@ -76,8 +76,10 @@ public class TestParameters extends HashMap<String,Object> {
* @return The value of this key, cast to a boolean type.
*/
public boolean getBool(Object key) {
Object val = super.get(key);
if (val != null) {
final Object val = super.get(key);
if (val == null) {
return false;
}
if (val instanceof String) {
String sVal = (String)val;
if (sVal.equalsIgnoreCase("true") ||
......@@ -89,9 +91,8 @@ public class TestParameters extends HashMap<String,Object> {
return false;
}
}
if (val instanceof Boolean)
else if (val instanceof Boolean)
return ((Boolean)val).booleanValue();
}
return false;
}
......
......@@ -143,8 +143,9 @@ public class ChartRawReportTarget extends OfficeDocumentReportTarget
return;
}
final String namespace = ReportTargetUtil.getNamespaceFromAttribute(attrs);
if (!isFilteredNamespace(namespace))
{
if (isFilteredNamespace(namespace))
return;
final String elementType = ReportTargetUtil.getElemenTypeFromAttribute(attrs);
// if this is the report namespace, write out a table definition ..
if (OfficeNamespaces.TABLE_NS.equals(namespace))
......@@ -174,7 +175,6 @@ public class ChartRawReportTarget extends OfficeDocumentReportTarget
xmlWriter.writeCloseTag();
--closeTags;
}
}
@Override
public void processContent(final DataFlags value)
......
......@@ -331,10 +331,11 @@ 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 )
{
......@@ -363,7 +364,6 @@ public class Helper
{
ex.printStackTrace();
}
}
return sResultURL;
......
......@@ -243,11 +243,13 @@ public class AccessibilityTree
public boolean popupTrigger( MouseEvent e )
{
boolean bIsPopup = e.isPopupTrigger();
if( bIsPopup )
{
if( !bIsPopup )
return false;
int selRow = maTree.getComponent().getRowForLocation(e.getX(), e.getY());
if (selRow != -1)
{
if (selRow == -1)
return bIsPopup;
TreePath aPath = maTree.getComponent().getPathForLocation(e.getX(), e.getY());
// check for actions
......@@ -288,8 +290,6 @@ public class AccessibilityTree
if (aMenu != null)
aMenu.show (maTree.getComponent(),
e.getX(), e.getY());
}
}
return bIsPopup;
}
......
......@@ -27,9 +27,10 @@ class AccessibleCellHandler extends NodeHandler
@Override
public NodeHandler createHandler (XAccessibleContext xContext)
{
if (xContext == null)
return null;
AccessibleCellHandler aCellHandler = null;
if (xContext != null)
{
XAccessible xParent = xContext.getAccessibleParent();
if (xParent != null)
{
......@@ -39,9 +40,7 @@ class AccessibleCellHandler extends NodeHandler
if (xTable != null)
aCellHandler = new AccessibleCellHandler (xTable);
}
}
return aCellHandler;
}
public AccessibleCellHandler ()
......
......@@ -51,14 +51,15 @@ class AccessibleSelectionHandler
public AccessibleTreeNode createChild( AccessibleTreeNode aParent,
int nIndex )
{
if( !(aParent instanceof AccTreeNode) )
return null;
XAccessibleSelection xSelection = ((AccTreeNode)aParent).getSelection();
if( xSelection == null )
return null;
AccessibleTreeNode aChild = null;
if( aParent instanceof AccTreeNode )
{
XAccessibleSelection xSelection =
((AccTreeNode)aParent).getSelection();
if( xSelection != null )
{
switch( nIndex )
{
case 0:
......@@ -115,8 +116,6 @@ class AccessibleSelectionHandler
aChild = new StringNode( "ERROR", aParent );
break;
}
}
}
return aChild;
}
......
......@@ -82,8 +82,9 @@ public class CommandName
{
try
{
if (this.setMetaDataAttributes())
{
if (!setMetaDataAttributes())
return;
this.DisplayName = _DisplayName;
int iIndex;
if (oCommandMetaData.xDBMetaData.supportsCatalogsInDataManipulation())
......@@ -124,7 +125,6 @@ public class CommandName
}
setComposedCommandName();
}
}
catch (Exception exception)
{
exception.printStackTrace(System.err);
......
......@@ -151,28 +151,20 @@ public final class Record {
*/
@Override
public boolean equals(Object obj) {
boolean bool = false;
if (obj instanceof Record) {
if (!(obj instanceof Record)) {
return false;
}
Record rec = (Record) obj;
checkLabel: {
if (rec.getAttributes() != attributes) {
break checkLabel;
return false;
}
if (rec.getSize() == data.length) {
for (int i = 0; i < data.length; i++) {
if (data[i] != rec.data[i]) {
break checkLabel;
}
}
bool = true;
return false;
}
}
}
return bool;
return false;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment