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