/[classpath]/classpath/java/lang/StringBuffer.java
ViewVC logotype

Diff of /classpath/java/lang/StringBuffer.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.24 by bryce, Wed Sep 24 06:23:19 2003 UTC revision 1.25 by mkoch, Sat Oct 18 08:45:37 2003 UTC
# Line 244  public final class StringBuffer implemen Line 244  public final class StringBuffer implemen
244    public synchronized void getChars(int srcOffset, int srcEnd,    public synchronized void getChars(int srcOffset, int srcEnd,
245                                      char[] dst, int dstOffset)                                      char[] dst, int dstOffset)
246    {    {
247      int todo = srcEnd - srcOffset;      if (srcOffset < 0 || srcEnd > count || srcEnd < srcOffset)
     if (srcOffset < 0 || srcEnd > count || todo < 0)  
248        throw new StringIndexOutOfBoundsException();        throw new StringIndexOutOfBoundsException();
249      System.arraycopy(value, srcOffset, dst, dstOffset, todo);      System.arraycopy(value, srcOffset, dst, dstOffset, srcEnd - srcOffset);
250    }    }
251    
252    /**    /**
# Line 355  public final class StringBuffer implemen Line 354  public final class StringBuffer implemen
354     */     */
355    public synchronized StringBuffer append(char[] data, int offset, int count)    public synchronized StringBuffer append(char[] data, int offset, int count)
356    {    {
357        if (offset < 0 || count < 0 || offset > data.length - count)
358          throw new StringIndexOutOfBoundsException();
359      ensureCapacity_unsynchronized(this.count + count);      ensureCapacity_unsynchronized(this.count + count);
360      System.arraycopy(data, offset, value, this.count, count);      System.arraycopy(data, offset, value, this.count, count);
361      this.count += count;      this.count += count;
# Line 563  public final class StringBuffer implemen Line 564  public final class StringBuffer implemen
564    public synchronized String substring(int beginIndex, int endIndex)    public synchronized String substring(int beginIndex, int endIndex)
565    {    {
566      int len = endIndex - beginIndex;      int len = endIndex - beginIndex;
567      if (beginIndex < 0 || endIndex > count || len < 0)      if (beginIndex < 0 || endIndex > count || endIndex < beginIndex)
568        throw new StringIndexOutOfBoundsException();        throw new StringIndexOutOfBoundsException();
569      if (len == 0)      if (len == 0)
570        return "";        return "";
# Line 592  public final class StringBuffer implemen Line 593  public final class StringBuffer implemen
593                                            char[] str, int str_offset, int len)                                            char[] str, int str_offset, int len)
594    {    {
595      if (offset < 0 || offset > count || len < 0      if (offset < 0 || offset > count || len < 0
596          || str_offset < 0 || str_offset + len > str.length)          || str_offset < 0 || str_offset > str.length - len)
597        throw new StringIndexOutOfBoundsException();        throw new StringIndexOutOfBoundsException();
598      ensureCapacity_unsynchronized(count + len);      ensureCapacity_unsynchronized(count + len);
599      System.arraycopy(value, offset, value, offset + len, count - offset);      System.arraycopy(value, offset, value, offset + len, count - offset);

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26