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

java: always use braces for while loops

Change-Id: Iff896b0cace8b8305528b3b0140004ea856169ce
üst 94ae3e82
...@@ -87,8 +87,9 @@ public final class XOutputStreamToByteArrayAdapter ...@@ -87,8 +87,9 @@ public final class XOutputStreamToByteArrayAdapter
{ {
if ( externalBuffer ) if ( externalBuffer )
throw new BufferSizeExceededException("out of buffer space, cannot grow external buffer"); throw new BufferSizeExceededException("out of buffer space, cannot grow external buffer");
while ( values.length > size-position ) while ( values.length > size-position ) {
size *= 2; size *= 2;
}
byte[] newBuffer = new byte[size]; byte[] newBuffer = new byte[size];
System.arraycopy(buffer, 0, newBuffer, 0, position); System.arraycopy(buffer, 0, newBuffer, 0, position);
buffer = newBuffer; buffer = newBuffer;
......
...@@ -138,14 +138,16 @@ public class MultiTypeInterfaceContainer ...@@ -138,14 +138,16 @@ public class MultiTypeInterfaceContainer
{ {
it= map.values().iterator(); it= map.values().iterator();
} }
while (it.hasNext() ) while (it.hasNext() ) {
it.next().disposeAndClear(evt); it.next().disposeAndClear(evt);
}
} }
synchronized public void clear() synchronized public void clear()
{ {
Iterator<InterfaceContainer> it= map.values().iterator(); Iterator<InterfaceContainer> it= map.values().iterator();
while (it.hasNext()) while (it.hasNext()) {
it.next().clear(); it.next().clear();
}
} }
} }
...@@ -571,11 +571,13 @@ public class InterfaceContainer_Test ...@@ -571,11 +571,13 @@ public class InterfaceContainer_Test
cont.addAll(list1); cont.addAll(list1);
// go to the end of our list and list1 // go to the end of our list and list1
ListIterator it= cont.listIterator(); ListIterator it= cont.listIterator();
while (it.hasNext()) while (it.hasNext()) {
it.next(); it.next();
}
ListIterator it_list1= list1.listIterator(); ListIterator it_list1= list1.listIterator();
while (it_list1.hasNext()) while (it_list1.hasNext()) {
it_list1.next(); it_list1.next();
}
while (it.hasPrevious()) while (it.hasPrevious())
{ {
...@@ -612,8 +614,9 @@ public class InterfaceContainer_Test ...@@ -612,8 +614,9 @@ public class InterfaceContainer_Test
ListIterator it; ListIterator it;
cont.addAll(list1); cont.addAll(list1);
it= cont.listIterator(); it= cont.listIterator();
while (it.hasNext()) while (it.hasNext()) {
it.next(); it.next();
}
assertEquals(it.previousIndex(), 2); assertEquals(it.previousIndex(), 2);
it.previous(); it.previous();
......
...@@ -73,8 +73,9 @@ public class ThreadPool_Test { ...@@ -73,8 +73,9 @@ public class ThreadPool_Test {
synchronized(workAt) { synchronized(workAt) {
putJob(workAt, false, threadId, "notifyme"); putJob(workAt, false, threadId, "notifyme");
while(!workAt._notified) while(!workAt._notified) {
workAt.wait(); workAt.wait();
}
} }
assertEquals(TestWorkAt.MESSAGES, workAt._counter); assertEquals(TestWorkAt.MESSAGES, workAt._counter);
...@@ -94,8 +95,9 @@ public class ThreadPool_Test { ...@@ -94,8 +95,9 @@ public class ThreadPool_Test {
synchronized(workAt) { synchronized(workAt) {
putJob(workAt, true, threadId, "notifyme"); putJob(workAt, true, threadId, "notifyme");
while(!workAt._notified) while(!workAt._notified) {
workAt.wait(); workAt.wait();
}
} }
assertEquals(TestWorkAt.MESSAGES, workAt._counter); assertEquals(TestWorkAt.MESSAGES, workAt._counter);
...@@ -161,8 +163,9 @@ public class ThreadPool_Test { ...@@ -161,8 +163,9 @@ public class ThreadPool_Test {
synchronized(workAt) { synchronized(workAt) {
putJob(workAt, true, threadId, "notifyme"); putJob(workAt, true, threadId, "notifyme");
while(!workAt._notified) while(!workAt._notified) {
workAt.wait(); workAt.wait();
}
} }
assertTrue(workAt.passedAsyncTest()); assertTrue(workAt.passedAsyncTest());
...@@ -322,8 +325,9 @@ public class ThreadPool_Test { ...@@ -322,8 +325,9 @@ public class ThreadPool_Test {
synchronized(workAt) { synchronized(workAt) {
putJob(workAt, false, threadId, "notifyme"); putJob(workAt, false, threadId, "notifyme");
while(!workAt._notified) while(!workAt._notified) {
workAt.wait(); workAt.wait();
}
} }
assertEquals(TestWorkAt.MESSAGES, workAt._async_counter); assertEquals(TestWorkAt.MESSAGES, workAt._async_counter);
......
...@@ -39,8 +39,9 @@ public class GlobalString { ...@@ -39,8 +39,9 @@ public class GlobalString {
public static String[] tokenize(String input , String tokenKey) { public static String[] tokenize(String input , String tokenKey) {
ArrayList<String> v = new ArrayList<String>(); ArrayList<String> v = new ArrayList<String>();
StringTokenizer t = new StringTokenizer(input, tokenKey); StringTokenizer t = new StringTokenizer(input, tokenKey);
while (t.hasMoreTokens()) while (t.hasMoreTokens()) {
v.add(t.nextToken()); v.add(t.nextToken());
}
return v.toArray(new String[v.size()]); return v.toArray(new String[v.size()]);
} }
......
...@@ -277,8 +277,9 @@ public class FileHelper ...@@ -277,8 +277,9 @@ public class FileHelper
out = new java.io.FileWriter(outputFile); out = new java.io.FileWriter(outputFile);
int c; int c;
while ((c = in.read()) != -1) while ((c = in.read()) != -1) {
out.write(c); out.write(c);
}
} }
finally finally
......
...@@ -139,8 +139,9 @@ public class URLHelper ...@@ -139,8 +139,9 @@ public class URLHelper
if (lSubFiles != null) if (lSubFiles != null)
{ {
Iterator<File> aSnapshot = lSubFiles.iterator(); Iterator<File> aSnapshot = lSubFiles.iterator();
while (aSnapshot.hasNext()) while (aSnapshot.hasNext()) {
lFilteredFiles.add(aSnapshot.next()); lFilteredFiles.add(aSnapshot.next());
}
} }
} }
} }
......
...@@ -152,8 +152,8 @@ public class _XArrayFormulaRange extends MultiMethodTest { ...@@ -152,8 +152,8 @@ public class _XArrayFormulaRange extends MultiMethodTest {
s1 = s1.trim() ; s1 = s1.trim() ;
s2 = s2.trim() ; s2 = s2.trim() ;
while (p1 < s1.length() && p2 < s2.length()) { while (p1 < s1.length() && p2 < s2.length()) {
while (s1.charAt(p1) == ' ') p1 ++ ; while (s1.charAt(p1) == ' ') { p1 ++; }
while (s2.charAt(p2) == ' ') p2 ++ ; while (s2.charAt(p2) == ' ') { p2 ++; }
if (s1.charAt(p1) != s2.charAt(p2)) return false ; if (s1.charAt(p1) != s2.charAt(p2)) return false ;
p1 ++ ; p1 ++ ;
p2 ++ ; p2 ++ ;
......
...@@ -499,8 +499,9 @@ public class _CharacterProperties extends MultiPropertyTest { ...@@ -499,8 +499,9 @@ public class _CharacterProperties extends MultiPropertyTest {
int count = members.size(); int count = members.size();
String[] res = new String[count]; String[] res = new String[count];
int i=0; int i=0;
while(oEnum.hasNext()) while(oEnum.hasNext()) {
res[i++] = oEnum.next(); res[i++] = oEnum.next();
}
return res; return res;
} }
......
...@@ -97,8 +97,9 @@ public class NestedRegistry extends TestCase { ...@@ -97,8 +97,9 @@ public class NestedRegistry extends TestCase {
byte[] buf = new byte[1024] ; byte[] buf = new byte[1024] ;
int bytesRead = 0 ; int bytesRead = 0 ;
while ((bytesRead = fIn.read(buf)) > 0) while ((bytesRead = fIn.read(buf)) > 0) {
fOut.write(buf, 0, bytesRead) ; fOut.write(buf, 0, bytesRead) ;
}
fIn.close() ; fIn.close() ;
fOut.close() ; fOut.close() ;
......
...@@ -94,8 +94,9 @@ public class NestedRegistry extends TestCase { ...@@ -94,8 +94,9 @@ public class NestedRegistry extends TestCase {
byte[] buf = new byte[1024] ; byte[] buf = new byte[1024] ;
int bytesRead = 0 ; int bytesRead = 0 ;
while ((bytesRead = fIn.read(buf)) > 0) while ((bytesRead = fIn.read(buf)) > 0) {
fOut.write(buf, 0, bytesRead) ; fOut.write(buf, 0, bytesRead) ;
}
fIn.close() ; fIn.close() ;
fOut.close() ; fOut.close() ;
......
...@@ -76,8 +76,9 @@ public class SimpleRegistry extends TestCase { ...@@ -76,8 +76,9 @@ public class SimpleRegistry extends TestCase {
byte[] buf = new byte[1024] ; byte[] buf = new byte[1024] ;
int bytesRead = 0 ; int bytesRead = 0 ;
while ((bytesRead = fIn.read(buf)) > 0) while ((bytesRead = fIn.read(buf)) > 0) {
fOut.write(buf, 0, bytesRead) ; fOut.write(buf, 0, bytesRead) ;
}
fIn.close() ; fIn.close() ;
fOut.close() ; fOut.close() ;
......
...@@ -79,8 +79,9 @@ public class SimpleRegistry extends TestCase { ...@@ -79,8 +79,9 @@ public class SimpleRegistry extends TestCase {
byte[] buf = new byte[1024] ; byte[] buf = new byte[1024] ;
int bytesRead = 0 ; int bytesRead = 0 ;
while ((bytesRead = fIn.read(buf)) > 0) while ((bytesRead = fIn.read(buf)) > 0) {
fOut.write(buf, 0, bytesRead) ; fOut.write(buf, 0, bytesRead) ;
}
fIn.close() ; fIn.close() ;
fOut.close() ; fOut.close() ;
......
...@@ -233,8 +233,9 @@ public class ParcelDescriptor { ...@@ -233,8 +233,9 @@ public class ParcelDescriptor {
public void setScriptEntries(Iterator<ScriptEntry> scripts) { public void setScriptEntries(Iterator<ScriptEntry> scripts) {
clearEntries(); clearEntries();
while (scripts.hasNext()) while (scripts.hasNext()) {
addScriptEntry(scripts.next()); addScriptEntry(scripts.next());
}
} }
private String getLanguageProperty(String name) { private String getLanguageProperty(String name) {
......
...@@ -160,9 +160,10 @@ public class AccessibilityTreeModel ...@@ -160,9 +160,10 @@ public class AccessibilityTreeModel
else else
{ {
// depth-first removal of children // depth-first removal of children
while (aNode.getChildCount() > 0) while (aNode.getChildCount() > 0) {
if ( ! removeChild (aNode.getChildNoCreate (0))) if ( ! removeChild (aNode.getChildNoCreate (0)))
break; break;
}
// Remove node from its parent. // Remove node from its parent.
AccessibleTreeNode aParent = aNode.getParent(); AccessibleTreeNode aParent = aNode.getParent();
......
...@@ -650,13 +650,15 @@ class TextEditDialog extends TextActionDialog ...@@ -650,13 +650,15 @@ class TextEditDialog extends TextActionDialog
// count equal characters from front and end // count equal characters from front and end
int nFront = 0; int nFront = 0;
while( (nFront < nMinLength) && while( (nFront < nMinLength) &&
(sNew.charAt(nFront) == sOld.charAt(nFront)) ) (sNew.charAt(nFront) == sOld.charAt(nFront)) ) {
nFront++; nFront++;
}
int nBack = 0; int nBack = 0;
while( (nBack < nMinLength) && while( (nBack < nMinLength) &&
( sNew.charAt(sNew.length()-nBack-1) == ( sNew.charAt(sNew.length()-nBack-1) ==
sOld.charAt(sOld.length()-nBack-1) ) ) sOld.charAt(sOld.length()-nBack-1) ) ) {
nBack++; nBack++;
}
if( nFront + nBack > nMinLength ) if( nFront + nBack > nMinLength )
nBack = nMinLength - nFront; nBack = nMinLength - nFront;
......
...@@ -79,8 +79,9 @@ public class AccessibleTreeCellRenderer ...@@ -79,8 +79,9 @@ public class AccessibleTreeCellRenderer
*/ */
public void addChangedLine (int nRow) public void addChangedLine (int nRow)
{ {
while (maChangedLines.size() <= nRow) while (maChangedLines.size() <= nRow) {
maChangedLines.add(null); maChangedLines.add(null);
}
nRow -= 1; // row index is one to large for some reason. nRow -= 1; // row index is one to large for some reason.
maChangedLines.set (nRow, true); maChangedLines.set (nRow, true);
} }
......
...@@ -144,9 +144,9 @@ class Canvas ...@@ -144,9 +144,9 @@ class Canvas
public void clear () public void clear ()
{ {
while (maNodes.size() > 0) while (maNodes.size() > 0) {
removeNode (maNodes.get(0)); removeNode (maNodes.get(0));
}
maNodes.clear(); maNodes.clear();
maObjects.clear(); maObjects.clear();
maObjectList.clear(); maObjectList.clear();
......
...@@ -222,8 +222,9 @@ public class InformationWriter ...@@ -222,8 +222,9 @@ public class InformationWriter
{ {
// Create indentation string. // Create indentation string.
String sIndent = ""; String sIndent = "";
while (depth-- > 0) while (depth-- > 0) {
sIndent += " "; sIndent += " ";
}
// Get XAccessibleContext object if given object does not // Get XAccessibleContext object if given object does not
// already support this interface. // already support this interface.
......
...@@ -76,8 +76,9 @@ public class MessageArea ...@@ -76,8 +76,9 @@ public class MessageArea
*/ */
public static synchronized void print (int nIndentation, String aMessage) public static synchronized void print (int nIndentation, String aMessage)
{ {
while (nIndentation-- > 0) while (nIndentation-- > 0) {
aMessage = " " + aMessage; aMessage = " " + aMessage;
}
Instance().printMessage(aMessage); Instance().printMessage(aMessage);
} }
......
...@@ -89,13 +89,15 @@ class TextUpdateListener implements TreeModelListener ...@@ -89,13 +89,15 @@ class TextUpdateListener implements TreeModelListener
// count equal characters from front and end // count equal characters from front and end
int nFront = 0; int nFront = 0;
while( (nFront < nMinLength) && while( (nFront < nMinLength) &&
(sNew.charAt(nFront) == sOld.charAt(nFront)) ) (sNew.charAt(nFront) == sOld.charAt(nFront)) ) {
nFront++; nFront++;
}
int nBack = 0; int nBack = 0;
while( (nBack < nMinLength) && while( (nBack < nMinLength) &&
( sNew.charAt(sNew.length()-nBack-1) == ( sNew.charAt(sNew.length()-nBack-1) ==
sOld.charAt(sOld.length()-nBack-1) ) ) sOld.charAt(sOld.length()-nBack-1) ) ) {
nBack++; nBack++;
}
if( nFront + nBack > nMinLength ) if( nFront + nBack > nMinLength )
nBack = nMinLength - nFront; nBack = nMinLength - nFront;
......
...@@ -1062,8 +1062,9 @@ public abstract class OfficeDocument ...@@ -1062,8 +1062,9 @@ public abstract class OfficeDocument
char[] charArray = new char[4096]; char[] charArray = new char[4096];
StringBuffer sBuf = new StringBuffer(); StringBuffer sBuf = new StringBuffer();
int n; int n;
while ((n=br.read(charArray, 0, charArray.length)) > 0) while ((n=br.read(charArray, 0, charArray.length)) > 0) {
sBuf.append(charArray, 0, n); sBuf.append(charArray, 0, n);
}
// ensure there is no trailing garbage after the end of the stream. // ensure there is no trailing garbage after the end of the stream.
int sIndex = sBuf.lastIndexOf("</office:document>"); int sIndex = sBuf.lastIndexOf("</office:document>");
......
...@@ -95,8 +95,9 @@ public class OfficeUtil implements OfficeConstants { ...@@ -95,8 +95,9 @@ public class OfficeUtil implements OfficeConstants {
// Compute length of space sequence. // Compute length of space sequence.
int nrSpaces = 2; int nrSpaces = 2;
while ((nrSpaces < text.length()) while ((nrSpaces < text.length())
&& text.substring(nrSpaces, nrSpaces + 1).equals(" ")) && text.substring(nrSpaces, nrSpaces + 1).equals(" ")) {
nrSpaces++; nrSpaces++;
}
Element spaceNode = parentDoc.createElement(TAG_SPACE); Element spaceNode = parentDoc.createElement(TAG_SPACE);
spaceNode.setAttribute(ATTRIBUTE_SPACE_COUNT, spaceNode.setAttribute(ATTRIBUTE_SPACE_COUNT,
......
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