Back to index

wims  3.65+svn20090927
SimpleStringBuffer.java
Go to the documentation of this file.
00001 package rene.util;
00002 public class SimpleStringBuffer
00003 {      private int Size,N;
00004        private char Buf[];
00005        public SimpleStringBuffer (int size)
00006        {      Size=size;
00007               Buf=new char[size];
00008               N=0;
00009        }
00010        public SimpleStringBuffer (char b[])
00011        {      Size=b.length;
00012               Buf=b;
00013               N=0;
00014        }
00015        public void append (char c)
00016        {      if (N<Size) Buf[N++]=c;
00017               else
00018               {      Size=2*Size;
00019                      char NewBuf[]=new char[Size];
00020                      for (int i=0; i<N; i++) NewBuf[i]=Buf[i];
00021                      Buf=NewBuf;
00022                      Buf[N++]=c;
00023               }
00024        }
00025        public void append (String s)
00026        {      int n=s.length();
00027               for (int i=0; i<n; i++) append(s.charAt(i));
00028        }
00029        public void clear ()
00030        {      N=0;
00031        }
00032        public String toString ()
00033        {      if (N==0) return "";
00034               return new String(Buf,0,N);
00035        }
00036 }
00037