java: simplify conditions involving logical negation

Change-Id: Ib45e58273e650ef9a31dbdb5f71e995a5976f50e
This commit is contained in:
Noel Grandin
2014-08-20 15:30:36 +02:00
parent 726fc58d0c
commit dc53e3027b
17 changed files with 26 additions and 27 deletions

View File

@@ -275,8 +275,8 @@ public class SampleHyphenator extends ComponentBase implements
// check if hyphenation pos is valid, // check if hyphenation pos is valid,
// a value of -1 indicates that hyphenation is not possible // a value of -1 indicates that hyphenation is not possible
if ( nHyphenationPos != -1 && if ( nHyphenationPos != -1 &&
!(nHyphenationPos < nHyphMinLeading) && (nHyphenationPos > nHyphMinLeading) &&
!(nHyphenationPos >= aWord.length() - nHyphMinTrailing)) (nHyphenationPos < aWord.length() - nHyphMinTrailing))
{ {
xRes = new XHyphenatedWord_impl(aWord, aLocale, xRes = new XHyphenatedWord_impl(aWord, aLocale,
nHyphenationPos, aHyphenatedWord, nHyphenPos); nHyphenationPos, aHyphenatedWord, nHyphenPos);

View File

@@ -788,7 +788,7 @@ public class MSOfficePrint
if (aLine != null) if (aLine != null)
{ {
aLine = aLine.trim(); aLine = aLine.trim();
if ( (! (aLine.length() < 2) ) && if ( (aLine.length() >= 2 ) &&
(! aLine.startsWith("#")) && (! aLine.startsWith("#")) &&
(! aLine.startsWith(";")) ) (! aLine.startsWith(";")) )
{ {

View File

@@ -161,7 +161,7 @@ public class PerformanceContainer /* extends *//* implements */ {
{ {
sLine = aRandomAccessFile.readLine(); sLine = aRandomAccessFile.readLine();
if ( (sLine != null) && if ( (sLine != null) &&
(! (sLine.length() < 2) ) && (sLine.length() >= 2 ) &&
(! sLine.startsWith("#"))) (! sLine.startsWith("#")))
{ {
if (sLine.startsWith("WordStartTime=")) if (sLine.startsWith("WordStartTime="))

View File

@@ -635,7 +635,7 @@ public class MSOfficePostscriptCreator implements IOffice
if (aLine != null) if (aLine != null)
{ {
aLine = aLine.trim(); aLine = aLine.trim();
if ( (! (aLine.length() < 2) ) && if ( (aLine.length() >= 2 ) &&
(! aLine.startsWith("#")) && (! aLine.startsWith("#")) &&
(! aLine.startsWith(";")) ) (! aLine.startsWith(";")) )
{ {

View File

@@ -177,7 +177,7 @@ public class PerformanceContainer /* extends *//* implements */ {
{ {
sLine = aRandomAccessFile.readLine(); sLine = aRandomAccessFile.readLine();
if ( (sLine != null) && if ( (sLine != null) &&
(! (sLine.length() < 2) ) && (sLine.length() >= 2 ) &&
(! sLine.startsWith("#"))) (! sLine.startsWith("#")))
{ {
if (sLine.startsWith("WordStartTime=")) if (sLine.startsWith("WordStartTime="))

View File

@@ -671,7 +671,7 @@ public class OfficeProvider implements AppProvider
if (sep.equalsIgnoreCase("\\")) if (sep.equalsIgnoreCase("\\"))
{ {
if (!(idx2 < 0)) if (idx2 >= 0)
{ {
sysDir = sysDir.substring(1); sysDir = sysDir.substring(1);
} }

View File

@@ -49,7 +49,7 @@ public class _XAreaLink extends MultiMethodTest {
log.println("testing getDestArea()"); log.println("testing getDestArea()");
boolean bResult = false; boolean bResult = false;
oORAdd = oObj.getDestArea(); oORAdd = oObj.getDestArea();
if (!(oORAdd == null)){ bResult = true; } if (oORAdd != null){ bResult = true; }
tRes.tested("getDestArea()", bResult) ; tRes.tested("getDestArea()", bResult) ;
} }
@@ -63,7 +63,7 @@ public class _XAreaLink extends MultiMethodTest {
boolean bResult = false; boolean bResult = false;
String src = null; String src = null;
src = oObj.getSourceArea() ; src = oObj.getSourceArea() ;
if (!(src == null)){ bResult = true; } if (src != null){ bResult = true; }
tRes.tested("getSourceArea()", bResult) ; tRes.tested("getSourceArea()", bResult) ;
} }

View File

@@ -40,35 +40,35 @@ public class _XScenarioEnhanced extends MultiMethodTest {
CellRangeAddress first = getting[0]; CellRangeAddress first = getting[0];
if (!(first.Sheet == 1)) { if (first.Sheet != 1) {
log.println( log.println(
"wrong RangeAddress is returned, expected Sheet=0 and got " + "wrong RangeAddress is returned, expected Sheet=0 and got " +
first.Sheet); first.Sheet);
res = false; res = false;
} }
if (!(first.StartColumn == 0)) { if (first.StartColumn != 0) {
log.println( log.println(
"wrong RangeAddress is returned, expected StartColumn=0 and got " + "wrong RangeAddress is returned, expected StartColumn=0 and got " +
first.StartColumn); first.StartColumn);
res = false; res = false;
} }
if (!(first.EndColumn == 10)) { if (first.EndColumn != 10) {
log.println( log.println(
"wrong RangeAddress is returned, expected EndColumn=10 and got " + "wrong RangeAddress is returned, expected EndColumn=10 and got " +
first.EndColumn); first.EndColumn);
res = false; res = false;
} }
if (!(first.StartRow == 0)) { if (first.StartRow != 0) {
log.println( log.println(
"wrong RangeAddress is returned, expected StartRow=0 and got " + "wrong RangeAddress is returned, expected StartRow=0 and got " +
first.StartRow); first.StartRow);
res = false; res = false;
} }
if (!(first.EndRow == 10)) { if (first.EndRow != 10) {
log.println( log.println(
"wrong RangeAddress is returned, expected EndRow=10 and got " + "wrong RangeAddress is returned, expected EndRow=10 and got " +
first.EndRow); first.EndRow);

View File

@@ -77,7 +77,7 @@ public class _XCellCursor extends MultiMethodTest {
oAddr = oRange.getRangeAddress(); oAddr = oRange.getRangeAddress();
startCol2 = oAddr.StartColumn; startCol2 = oAddr.StartColumn;
if (!(startCol == startCol2)){ if (startCol != startCol2){
bResult = true; bResult = true;
} }
tRes.tested( "gotoNext()", bResult ); tRes.tested( "gotoNext()", bResult );
@@ -105,7 +105,7 @@ public class _XCellCursor extends MultiMethodTest {
oAddr = oRange.getRangeAddress(); oAddr = oRange.getRangeAddress();
startRow2 = oAddr.StartRow; startRow2 = oAddr.StartRow;
startCol2 = oAddr.StartColumn; startCol2 = oAddr.StartColumn;
if (!(startCol == startCol2) || (startRow == startRow2)){ if ((startCol != startCol2) || (startRow == startRow2)){
bResult = true; bResult = true;
} }
tRes.tested( "gotoOffset()", bResult ); tRes.tested( "gotoOffset()", bResult );
@@ -131,7 +131,7 @@ public class _XCellCursor extends MultiMethodTest {
oAddr = oRange.getRangeAddress(); oAddr = oRange.getRangeAddress();
startCol2 = oAddr.StartColumn; startCol2 = oAddr.StartColumn;
if (!(startCol == startCol2)){ if (startCol != startCol2){
bResult = true; bResult = true;
} }
tRes.tested( "gotoPrevious()", bResult ); tRes.tested( "gotoPrevious()", bResult );

View File

@@ -49,7 +49,7 @@ public class _XSearchDescriptor extends MultiMethodTest {
log.println("test for getSearchString() "); log.println("test for getSearchString() ");
searchStr = oObj.getSearchString(); searchStr = oObj.getSearchString();
if (!(searchStr == null)){ bResult = true; } if (searchStr != null){ bResult = true; }
tRes.tested("getSearchString()", bResult); tRes.tested("getSearchString()", bResult);
} }

View File

@@ -117,8 +117,7 @@ public class UCBStreamHandler extends URLStreamHandler {
try { try {
String sUrl = url.toString(); String sUrl = url.toString();
if ( sUrl.lastIndexOf(separator) != -1 ) {
if (!(sUrl.lastIndexOf(separator) == -1)) {
String path = sUrl.substring(0, sUrl.lastIndexOf(separator)); String path = sUrl.substring(0, sUrl.lastIndexOf(separator));
if (m_xSimpleFileAccess.isReadOnly(path)) { if (m_xSimpleFileAccess.isReadOnly(path)) {

View File

@@ -125,7 +125,7 @@ public class QueryMetaData extends CommandMetaData
for (int n = 0; n < FieldColumns.length; n++) for (int n = 0; n < FieldColumns.length; n++)
{ {
String sDisplayFieldName = FieldColumns[n].getDisplayFieldName(); String sDisplayFieldName = FieldColumns[n].getDisplayFieldName();
if (!(JavaTools.FieldInList(_DisplayFieldNames, sDisplayFieldName) > -1)) if (JavaTools.FieldInList(_DisplayFieldNames, sDisplayFieldName) <= -1)
{ {
oRemainingFieldColumns.add(FieldColumns[n]); oRemainingFieldColumns.add(FieldColumns[n]);
} }

View File

@@ -373,7 +373,7 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme
CurDBColumn = getDoc().DBColumnsVector.get(ColIndex); CurDBColumn = getDoc().DBColumnsVector.get(ColIndex);
addLinkedTextSection(xTextCursor, ReportTextDocument.COPYOFGROUPSECTION + Integer.toString(ColIndex + 1), CurDBColumn, CurGroupValue); addLinkedTextSection(xTextCursor, ReportTextDocument.COPYOFGROUPSECTION + Integer.toString(ColIndex + 1), CurDBColumn, CurGroupValue);
OldGroupFieldValues[ColIndex] = CurGroupValue; OldGroupFieldValues[ColIndex] = CurGroupValue;
breset = !(ColIndex == GroupFieldCount - 1); breset = ColIndex != GroupFieldCount - 1;
} }
} }
getRecordParser().getcurrentRecordData(DataVector); getRecordParser().getcurrentRecordData(DataVector);

View File

@@ -343,7 +343,7 @@ public class CommandFieldSelection extends FieldSelection implements Comparator<
public void toggleCommandListBox(String[] _NewItems) public void toggleCommandListBox(String[] _NewItems)
{ {
boolean bdoenable = !(QueryMetaData.getIncludedCommandNames(_NewItems).length >= CurDBMetaData.getMaxTablesInSelect()); boolean bdoenable = QueryMetaData.getIncludedCommandNames(_NewItems).length < CurDBMetaData.getMaxTablesInSelect();
toggleCommandListBox(bdoenable); toggleCommandListBox(bdoenable);
} }

View File

@@ -593,7 +593,7 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL
} }
else else
{ {
enableNextButton(!(getCurrentStep() == nMaxStep)); enableNextButton(getCurrentStep() != nMaxStep);
} }
} }
} }

View File

@@ -59,7 +59,7 @@ public class MethodInvocation
{ {
mMethod = method; mMethod = method;
mObject = obj; mObject = obj;
mWithParam = !(paramClass == null); mWithParam = paramClass != null;
} }
/** /**

View File

@@ -164,7 +164,7 @@ public class Format implements Cloneable {
public boolean getAttribute(int attribute) { public boolean getAttribute(int attribute) {
if ((mask & attribute) == 0) if ((mask & attribute) == 0)
return false; return false;
return (!((attributes & attribute) == 0)); return ((attributes & attribute) != 0);
} }
/** /**