changes.
[IRC.git] / Robust / src / ClassLibrary / SSJava / StringBuffer.java
index fb1222b48843f0f2cf08c8daecb7aa1323c6ae0b..bebe02f0322d9f334ad6abf32333baddf4b4c3ac 100644 (file)
@@ -1,23 +1,28 @@
+@LATTICE("V<C, V<O")
+@METHODDEFAULT("O<V,V<C,C<IN,C*,THISLOC=O,RETURNLOC=O")
 public class StringBuffer {
+  @LOC("V")
   char value[];
+  @LOC("C")
   int count;
-  //    private static final int DEFAULTSIZE=16;
+
+  // private static final int DEFAULTSIZE=16;
 
   public StringBuffer(String str) {
-    value=new char[str.count+16];    //16 is DEFAULTSIZE
-    count=str.count;
-    for(int i=0; i<count; i++)
-      value[i]=str.value[i+str.offset];
+    value = new char[str.count + 16]; // 16 is DEFAULTSIZE
+    count = str.count;
+    for (int i = 0; i < count; i++)
+      value[i] = str.value[i + str.offset];
   }
 
   public StringBuffer() {
-    value=new char[16];    //16 is DEFAULTSIZE
-    count=0;
+    value = new char[16]; // 16 is DEFAULTSIZE
+    count = 0;
   }
 
   public StringBuffer(int i) {
-    value=new char[i];
-    count=0;
+    value = new char[i];
+    count = 0;
   }
 
   public int length() {
@@ -32,56 +37,57 @@ public class StringBuffer {
     return value[x];
   }
 
-  public StringBuffer append(char c) {
+  public StringBuffer append(@LOC("IN") char c) {
     return append(String.valueOf(c));
   }
 
-  public StringBuffer append(String s) {
-    if ((s.count+count)>value.length) {
+  public StringBuffer append(@LOC("IN") String s) {
+    if ((s.count + count) > value.length) {
       // Need to allocate
-      char newvalue[]=new char[s.count+count+16];       //16 is DEFAULTSIZE
-      for(int i=0; i<count; i++)
-        newvalue[i]=value[i];
-      for(int i=0; i<s.count; i++)
-        newvalue[i+count]=s.value[i+s.offset];
-      value=newvalue;
-      count+=s.count;
+      @LOC("C") char newvalue[] = new char[s.count + count + 16]; // 16 is
+                                                                  // DEFAULTSIZE
+      for (@LOC("C") int i = 0; i < count; i++)
+        newvalue[i] = value[i];
+      for (@LOC("C") int i = 0; i < s.count; i++)
+        newvalue[i + count] = s.value[i + s.offset];
+      value = newvalue;
+      count += s.count;
     } else {
-      for(int i=0; i<s.count; i++) {
-        value[i+count]=s.value[i+s.offset];
+      for (@LOC("C") int i = 0; i < s.count; i++) {
+        value[i + count] = s.value[i + s.offset];
       }
-      count+=s.count;
+      count += s.count;
     }
     return this;
   }
 
   public void ensureCapacity(int i) {
-    int size=2*count;
-    if (i>size)
-      size=i;
-    if (i>value.length) {
-      char newvalue[]=new char[i];
-      for(int ii=0; ii<count; ii++)
-        newvalue[ii]=value[ii];
-      value=newvalue;
+    int size = 2 * count;
+    if (i > size)
+      size = i;
+    if (i > value.length) {
+      char newvalue[] = new char[i];
+      for (int ii = 0; ii < count; ii++)
+        newvalue[ii] = value[ii];
+      value = newvalue;
     }
   }
 
   public StringBuffer append(StringBuffer s) {
-    if ((s.count+count)>value.length) {
+    if ((s.count + count) > value.length) {
       // Need to allocate
-      char newvalue[]=new char[s.count+count+16];       //16 is DEFAULTSIZE
-      for(int i=0; i<count; i++)
-        newvalue[i]=value[i];
-      for(int i=0; i<s.count; i++)
-        newvalue[i+count]=s.value[i];
-      value=newvalue;
-      count+=s.count;
+      char newvalue[] = new char[s.count + count + 16]; // 16 is DEFAULTSIZE
+      for (int i = 0; i < count; i++)
+        newvalue[i] = value[i];
+      for (int i = 0; i < s.count; i++)
+        newvalue[i + count] = s.value[i];
+      value = newvalue;
+      count += s.count;
     } else {
-      for(int i=0; i<s.count; i++) {
-        value[i+count]=s.value[i];
+      for (int i = 0; i < s.count; i++) {
+        value[i + count] = s.value[i];
       }
-      count+=s.count;
+      count += s.count;
     }
     return this;
   }
@@ -102,7 +108,7 @@ public class StringBuffer {
   public synchronized StringBuffer replace(int start, int end, String str) {
     if (start < 0) {
       // FIXME
-      System.printString("StringIndexOutOfBoundsException: "+start+"\n");
+      System.printString("StringIndexOutOfBoundsException: " + start + "\n");
     }
     if (start > count) {
       // FIXME
@@ -131,7 +137,7 @@ public class StringBuffer {
   void expandCapacity(int minimumCapacity) {
     int newCapacity = (value.length + 1) * 2;
     if (newCapacity < 0) {
-      newCapacity = 0x7fffffff /*Integer.MAX_VALUE*/;
+      newCapacity = 0x7fffffff /* Integer.MAX_VALUE */;
     } else if (minimumCapacity > newCapacity) {
       newCapacity = minimumCapacity;
     }