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,27 +352,29 @@ 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++)
{
for (int i = 0; i < size; i++)
if (elem == elementData[i])
{
if (elem == elementData[i])
{
index= i;
break;
}
index= i;
break;
}
}
if (index == -1)
if (index == -1)
{
for (int i = 0; i < size; i++)
{
for (int i = 0; i < size; i++)
if (UnoRuntime.areSame(elem, elementData[i]))
{
if (UnoRuntime.areSame(elem, elementData[i]))
{
index= i;
break;
}
index= i;
break;
}
}
}
......@@ -408,28 +410,30 @@ 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])
{
index= i;
break;
}
}
if (index == -1)
{
for (int i = size-1; i >= 0; i--)
{
if (elem == elementData[i])
if (UnoRuntime.areSame(elem, elementData[i]))
{
index= i;
break;
}
}
if (index == -1)
{
for (int i = size-1; i >= 0; i--)
{
if (UnoRuntime.areSame(elem, elementData[i]))
{
index= i;
break;
}
}
}
}
return index;
}
......@@ -535,52 +539,53 @@ 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;
for(int i= 0; i < size; i++)
// iterate over data
Object[] arRetained= new Object[size];
int indexRetained= 0;
for(int i= 0; i < size; i++)
{
Object curElem= elementData[i];
// try to find the element in collection
Iterator itColl= collection.iterator();
boolean bExists= false;
while (itColl.hasNext())
{
Object curElem= elementData[i];
// try to find the element in collection
Iterator itColl= collection.iterator();
boolean bExists= false;
while (itColl.hasNext())
if (curElem == itColl.next())
{
if (curElem == itColl.next())
{
// current element is in collection
bExists= true;
break;
}
// current element is in collection
bExists= true;
break;
}
if (!bExists)
}
if (!bExists)
{
itColl= collection.iterator();
while (itColl.hasNext())
{
itColl= collection.iterator();
while (itColl.hasNext())
Object o= itColl.next();
if (o != null)
{
Object o= itColl.next();
if (o != null)
if (UnoRuntime.areSame(o, curElem))
{
if (UnoRuntime.areSame(o, curElem))
{
bExists= true;
break;
}
bExists= true;
break;
}
}
}
if (bExists)
arRetained[indexRetained++]= curElem;
}
retVal= size != indexRetained;
if (indexRetained > 0)
{
elementData= arRetained;
size= indexRetained;
}
if (bExists)
arRetained[indexRetained++]= curElem;
}
retVal= size != indexRetained;
if (indexRetained > 0)
{
elementData= arRetained;
size= indexRetained;
}
return retVal;
}
......
......@@ -84,49 +84,49 @@ public class JavaLoader implements XImplementationLoader,
*/
private String expand_url( String url ) throws RuntimeException
{
if (url != null && url.startsWith( EXPAND_PROTOCOL_PREFIX )) {
try {
if (m_xMacroExpander == null) {
XPropertySet xProps =
UnoRuntime.queryInterface(
XPropertySet.class, multiServiceFactory );
if (xProps == null) {
throw new com.sun.star.uno.RuntimeException(
"service manager does not support XPropertySet!",
this );
}
XComponentContext xContext = (XComponentContext)
AnyConverter.toObject(
new Type( XComponentContext.class ),
xProps.getPropertyValue( "DefaultContext" ) );
m_xMacroExpander = (XMacroExpander)AnyConverter.toObject(
new Type( XMacroExpander.class ),
xContext.getValueByName(
"/singletons/com.sun.star.util.theMacroExpander" )
);
}
// decode uric class chars
String macro = URLDecoder.decode(
StringHelper.replace(
url.substring( EXPAND_PROTOCOL_PREFIX.length() ),
'+', "%2B" ), "UTF-8" );
// expand macro string
String ret = m_xMacroExpander.expandMacros( macro );
if (DEBUG) {
System.err.println(
"JavaLoader.expand_url(): " + url + " => " +
macro + " => " + ret );
if (url == null || !url.startsWith( EXPAND_PROTOCOL_PREFIX )) {
return url;
}
try {
if (m_xMacroExpander == null) {
XPropertySet xProps =
UnoRuntime.queryInterface(
XPropertySet.class, multiServiceFactory );
if (xProps == null) {
throw new com.sun.star.uno.RuntimeException(
"service manager does not support XPropertySet!",
this );
}
return ret;
} catch (com.sun.star.uno.Exception exc) {
throw new com.sun.star.uno.RuntimeException(
exc.getMessage(), this );
} catch (java.lang.Exception exc) {
throw new com.sun.star.uno.RuntimeException(
exc.getMessage(), this );
XComponentContext xContext = (XComponentContext)
AnyConverter.toObject(
new Type( XComponentContext.class ),
xProps.getPropertyValue( "DefaultContext" ) );
m_xMacroExpander = (XMacroExpander)AnyConverter.toObject(
new Type( XMacroExpander.class ),
xContext.getValueByName(
"/singletons/com.sun.star.util.theMacroExpander" )
);
}
// decode uric class chars
String macro = URLDecoder.decode(
StringHelper.replace(
url.substring( EXPAND_PROTOCOL_PREFIX.length() ),
'+', "%2B" ), "UTF-8" );
// expand macro string
String ret = m_xMacroExpander.expandMacros( macro );
if (DEBUG) {
System.err.println(
"JavaLoader.expand_url(): " + url + " => " +
macro + " => " + ret );
}
return ret;
} catch (com.sun.star.uno.Exception exc) {
throw new com.sun.star.uno.RuntimeException(
exc.getMessage(), this );
} catch (java.lang.Exception exc) {
throw new com.sun.star.uno.RuntimeException(
exc.getMessage(), this );
}
return url;
}
/**
......
......@@ -89,33 +89,34 @@ 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) {
URL[] urls = ((URLClassLoader) loader).getURLs();
for (int i = 0; i < urls.length; ++i) {
File path = UrlToFileMapper.mapUrlToFile(urls[i]);
if (path != null) {
File dir = path.isDirectory() ? path : path.getParentFile();
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]);
if (path != null) {
File dir = path.isDirectory() ? path : path.getParentFile();
if (dir != null) {
path = new File(dir, name);
if (path.exists()) {
return path;
}
dir = dir.getParentFile();
if (dir != null) {
path = new File(dir, name);
if (path.exists()) {
return path;
}
dir = dir.getParentFile();
if (dir != null) {
path = new File(dir, name);
// On OS X, dir is now the Resources dir,
// we want to look in Frameworks
if (System.getProperty("os.name").startsWith("Mac")
&& dir.getName().equals("Resources")) {
dir = dir.getParentFile();
path = new File(dir, "Frameworks/" + name);
if (path.exists()) {
return path;
}
// On OS X, dir is now the Resources dir,
// we want to look in Frameworks
if (System.getProperty("os.name").startsWith("Mac")
&& dir.getName().equals("Resources")) {
dir = dir.getParentFile();
path = new File(dir, "Frameworks/" + name);
if (path.exists()) {
return path;
}
}
}
}
}
......
......@@ -80,41 +80,46 @@ final class InstallationFinder {
// com.sun.star.lib.loader.unopath
// (all platforms)
path = getPathFromProperty( SYSPROP_NAME );
if ( path == null ) {
// 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 ) {
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 ) {
return path;
}
String osname = null;
try {
osname = System.getProperty( "os.name" );
} catch ( SecurityException e ) {
// if a SecurityException was thrown,
// return <code>null</code>
return null;
}
if ( osname == null ) {
return null;
}
if ( osname.startsWith( "Windows" ) ) {
// get the installation path from the Windows Registry
// (Windows platform only)
path = getPathFromWindowsRegistry();
} else {
// get the installation path from the PATH environment
// variable (Unix/Linux platforms only, not working for
// Java 1.3.1 and Java 1.4)
path = getPathFromPathEnvVar();
if ( path == null ) {
String osname = null;
try {
osname = System.getProperty( "os.name" );
} catch ( SecurityException e ) {
// if a SecurityException was thrown,
// return <code>null</code>
return null;
}
if ( osname != null ) {
if ( osname.startsWith( "Windows" ) ) {
// get the installation path from the Windows Registry
// (Windows platform only)
path = getPathFromWindowsRegistry();
} else {
// get the installation path from the PATH environment
// variable (Unix/Linux platforms only, not working for
// Java 1.3.1 and Java 1.4)
path = getPathFromPathEnvVar();
if ( path == null ) {
// get the installation path from the 'which'
// command (Unix/Linux platforms only)
path = getPathFromWhich();
if ( path == null ) {
// get the installation path from the
// .sversionrc file (Unix/Linux platforms only,
// for older versions than OOo 2.0)
path = getPathFromSVersionFile();
}
}
}
// get the installation path from the 'which'
// command (Unix/Linux platforms only)
path = getPathFromWhich();
if ( path == null ) {
// get the installation path from the
// .sversionrc file (Unix/Linux platforms only,
// for older versions than OOo 2.0)
path = getPathFromSVersionFile();
}
}
}
......
......@@ -76,22 +76,23 @@ 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) {
if (val instanceof String) {
String sVal = (String)val;
if (sVal.equalsIgnoreCase("true") ||
sVal.equalsIgnoreCase("yes")) {
return true;
}
else if (sVal.equalsIgnoreCase("false") ||
sVal.equalsIgnoreCase("no")) {
return false;
}
final Object val = super.get(key);
if (val == null) {
return false;
}
if (val instanceof String) {
String sVal = (String)val;
if (sVal.equalsIgnoreCase("true") ||
sVal.equalsIgnoreCase("yes")) {
return true;
}
else if (sVal.equalsIgnoreCase("false") ||
sVal.equalsIgnoreCase("no")) {
return false;
}
if (val instanceof Boolean)
return ((Boolean)val).booleanValue();
}
else if (val instanceof Boolean)
return ((Boolean)val).booleanValue();
return false;
}
......
......@@ -143,37 +143,37 @@ 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))
{
final String elementType = ReportTargetUtil.getElemenTypeFromAttribute(attrs);
// if this is the report namespace, write out a table definition ..
if (OfficeNamespaces.TABLE_NS.equals(namespace))
{
if (OfficeToken.TABLE.equals(elementType) || OfficeToken.TABLE_ROWS.equals(elementType))
{
return;
}
else if (isFiltered(elementType))
{
inFilterElements = false;
if (tableCount > 1)
{
return;
}
}
}
else if (OfficeNamespaces.CHART_NS.equals(namespace) && "chart".equals(elementType))
if (OfficeToken.TABLE.equals(elementType) || OfficeToken.TABLE_ROWS.equals(elementType))
{
return;
}
if (inFilterElements && tableCount > 1)
else if (isFiltered(elementType))
{
return;
inFilterElements = false;
if (tableCount > 1)
{
return;
}
}
final XmlWriter xmlWriter = getXmlWriter();
xmlWriter.writeCloseTag();
--closeTags;
}
else if (OfficeNamespaces.CHART_NS.equals(namespace) && "chart".equals(elementType))
{
return;
}
if (inFilterElements && tableCount > 1)
{
return;
}
final XmlWriter xmlWriter = getXmlWriter();
xmlWriter.writeCloseTag();
--closeTags;
}
@Override
......
......@@ -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;
......
......@@ -243,53 +243,53 @@ 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)
return bIsPopup;
TreePath aPath = maTree.getComponent().getPathForLocation(e.getX(), e.getY());
// check for actions
Object aObject = aPath.getLastPathComponent();
JPopupMenu aMenu = new JPopupMenu();
if( aObject instanceof AccTreeNode )
{
AccTreeNode aNode = (AccTreeNode)aObject;
ArrayList<String> aActions = new ArrayList<String>();
aMenu.add (new AccessibilityTree.ShapeExpandAction(maTree, aNode));
aMenu.add (new AccessibilityTree.SubtreeExpandAction(maTree, aNode));
aNode.getActions(aActions);
for( int i = 0; i < aActions.size(); i++ )
{
aMenu.add( new NodeAction(
aActions.get(i),
aNode, i ) );
}
}
else if (aObject instanceof AccessibleTreeNode)
{
int selRow = maTree.getComponent().getRowForLocation(e.getX(), e.getY());
if (selRow != -1)
AccessibleTreeNode aNode = (AccessibleTreeNode)aObject;
String[] aActionNames = aNode.getActions();
int nCount=aActionNames.length;
if (nCount > 0)
{
TreePath aPath = maTree.getComponent().getPathForLocation(e.getX(), e.getY());
// check for actions
Object aObject = aPath.getLastPathComponent();
JPopupMenu aMenu = new JPopupMenu();
if( aObject instanceof AccTreeNode )
{
AccTreeNode aNode = (AccTreeNode)aObject;
ArrayList<String> aActions = new ArrayList<String>();
aMenu.add (new AccessibilityTree.ShapeExpandAction(maTree, aNode));
aMenu.add (new AccessibilityTree.SubtreeExpandAction(maTree, aNode));
aNode.getActions(aActions);
for( int i = 0; i < aActions.size(); i++ )
{
aMenu.add( new NodeAction(
aActions.get(i),
aNode, i ) );
}
}
else if (aObject instanceof AccessibleTreeNode)
{
AccessibleTreeNode aNode = (AccessibleTreeNode)aObject;
String[] aActionNames = aNode.getActions();
int nCount=aActionNames.length;
if (nCount > 0)
{
for (int i=0; i<nCount; i++)
aMenu.add( new NodeAction(
aActionNames[i],
aNode,
i));
}
else
aMenu = null;
}
if (aMenu != null)
aMenu.show (maTree.getComponent(),
e.getX(), e.getY());
for (int i=0; i<nCount; i++)
aMenu.add( new NodeAction(
aActionNames[i],
aNode,
i));
}
else
aMenu = null;
}
if (aMenu != null)
aMenu.show (maTree.getComponent(),
e.getX(), e.getY());
return bIsPopup;
}
......
......@@ -27,21 +27,20 @@ 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)
{
XAccessible xParent = xContext.getAccessibleParent();
if (xParent != null)
{
XAccessibleTable xTable =
UnoRuntime.queryInterface (
XAccessibleTable.class, xParent.getAccessibleContext());
if (xTable != null)
aCellHandler = new AccessibleCellHandler (xTable);
}
XAccessibleTable xTable =
UnoRuntime.queryInterface (
XAccessibleTable.class, xParent.getAccessibleContext());
if (xTable != null)
aCellHandler = new AccessibleCellHandler (xTable);
}
return aCellHandler;
}
public AccessibleCellHandler ()
......
......@@ -51,71 +51,70 @@ 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 )
switch( nIndex )
{
XAccessibleSelection xSelection =
((AccTreeNode)aParent).getSelection();
if( xSelection != null )
case 0:
aChild = new StringNode(
"getSelectedAccessibleChildCount: " +
xSelection.getSelectedAccessibleChildCount(),
aParent );
break;
case 1:
{
switch( nIndex )
VectorNode aVNode =
new VectorNode( "Selected Children", aParent);
int nSelected = 0;
int nCount = ((AccTreeNode)aParent).getContext().
getAccessibleChildCount();
try
{
case 0:
aChild = new StringNode(
"getSelectedAccessibleChildCount: " +
xSelection.getSelectedAccessibleChildCount(),
aParent );
break;
case 1:
for( int i = 0; i < nCount; i++ )
{
VectorNode aVNode =
new VectorNode( "Selected Children", aParent);
int nSelected = 0;
int nCount = ((AccTreeNode)aParent).getContext().
getAccessibleChildCount();
try
{
for( int i = 0; i < nCount; i++ )
if( xSelection.isAccessibleChildSelected( i ) )
{
try
{
if( xSelection.isAccessibleChildSelected( i ) )
{
XAccessible xSelChild = xSelection.
getSelectedAccessibleChild(nSelected);
XAccessible xNChild =
((AccTreeNode)aParent).
getContext().getAccessibleChild( i );
aVNode.addChild( new StringNode(
i + ": " +
xNChild.getAccessibleContext().
getAccessibleDescription() + " (" +
(xSelChild.equals(xNChild) ? "OK" : "XXX") +
")", aParent ) );
}
}
catch (com.sun.star.lang.DisposedException e)
{
aVNode.addChild( new StringNode(
i + ": caught DisposedException while creating",
aParent ));
}
XAccessible xSelChild = xSelection.
getSelectedAccessibleChild(nSelected);
XAccessible xNChild =
((AccTreeNode)aParent).
getContext().getAccessibleChild( i );
aVNode.addChild( new StringNode(
i + ": " +
xNChild.getAccessibleContext().
getAccessibleDescription() + " (" +
(xSelChild.equals(xNChild) ? "OK" : "XXX") +
")", aParent ) );
}
aChild = aVNode;
}
catch( IndexOutOfBoundsException e )
catch (com.sun.star.lang.DisposedException e)
{
aChild = new StringNode( "IndexOutOfBounds",
aParent );
aVNode.addChild( new StringNode(
i + ": caught DisposedException while creating",
aParent ));
}
}
break;
default:
aChild = new StringNode( "ERROR", aParent );
break;
aChild = aVNode;
}
catch( IndexOutOfBoundsException e )
{
aChild = new StringNode( "IndexOutOfBounds",
aParent );
}
}
break;
default:
aChild = new StringNode( "ERROR", aParent );
break;
}
return aChild;
......
......@@ -82,48 +82,48 @@ public class CommandName
{
try
{
if (this.setMetaDataAttributes())
{
this.DisplayName = _DisplayName;
int iIndex;
if (oCommandMetaData.xDBMetaData.supportsCatalogsInDataManipulation())
{ // ...dann Catalog mit in TableName
iIndex = _DisplayName.indexOf(sCatalogSep);
if (iIndex >= 0)
{
if (bCatalogAtStart)
{
CatalogName = _DisplayName.substring(0, iIndex);
_DisplayName = _DisplayName.substring(iIndex + 1, _DisplayName.length());
}
else
{
CatalogName = _DisplayName.substring(iIndex + 1, _DisplayName.length());
_DisplayName = _DisplayName.substring(0, iIndex);
}
}
}
if (oCommandMetaData.xDBMetaData.supportsSchemasInDataManipulation())
if (!setMetaDataAttributes())
return;
this.DisplayName = _DisplayName;
int iIndex;
if (oCommandMetaData.xDBMetaData.supportsCatalogsInDataManipulation())
{ // ...dann Catalog mit in TableName
iIndex = _DisplayName.indexOf(sCatalogSep);
if (iIndex >= 0)
{
String[] NameList;
NameList = new String[0];
NameList = JavaTools.ArrayoutofString(_DisplayName, ".");
if (NameList.length > 1)
if (bCatalogAtStart)
{
SchemaName = NameList[0];
TableName = NameList[1];
CatalogName = _DisplayName.substring(0, iIndex);
_DisplayName = _DisplayName.substring(iIndex + 1, _DisplayName.length());
}
else
{
TableName = _DisplayName;
CatalogName = _DisplayName.substring(iIndex + 1, _DisplayName.length());
_DisplayName = _DisplayName.substring(0, iIndex);
}
}
}
if (oCommandMetaData.xDBMetaData.supportsSchemasInDataManipulation())
{
String[] NameList;
NameList = new String[0];
NameList = JavaTools.ArrayoutofString(_DisplayName, ".");
if (NameList.length > 1)
{
SchemaName = NameList[0];
TableName = NameList[1];
}
else
{
TableName = _DisplayName;
}
setComposedCommandName();
}
else
{
TableName = _DisplayName;
}
setComposedCommandName();
}
catch (Exception exception)
{
......
......@@ -151,28 +151,20 @@ public final class Record {
*/
@Override
public boolean equals(Object obj) {
boolean bool = false;
if (obj instanceof Record) {
Record rec = (Record) obj;
checkLabel: {
if (rec.getAttributes() != attributes) {
break checkLabel;
}
if (rec.getSize() == data.length) {
for (int i = 0; i < data.length; i++) {
if (data[i] != rec.data[i]) {
break checkLabel;
}
}
bool = true;
if (!(obj instanceof Record)) {
return false;
}
Record rec = (Record) obj;
if (rec.getAttributes() != attributes) {
return false;
}
if (rec.getSize() == data.length) {
for (int i = 0; i < data.length; i++) {
if (data[i] != rec.data[i]) {
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