/[classpath]/inetlib/source/gnu/inet/http/ByteArrayRequestBodyWriter.java
ViewVC logotype

Diff of /inetlib/source/gnu/inet/http/ByteArrayRequestBodyWriter.java

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

revision 1.2 by dog, Thu Oct 21 15:21:55 2004 UTC revision 1.3 by dog, Thu Nov 25 22:15:05 2004 UTC
# Line 1  Line 1 
1  /*  /*
2   * $Id$   * ByteArrayRequestBodyWriter.java
3   * Copyright (C) 2004 The Free Software Foundation   * Copyright (C) 2004 The Free Software Foundation
4   *   *
5   * This file is part of GNU inetlib, a library.   * This file is part of GNU inetlib, a library.
# Line 44  package gnu.inet.http; Line 44  package gnu.inet.http;
44   * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>   * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
45   */   */
46  public class ByteArrayRequestBodyWriter  public class ByteArrayRequestBodyWriter
47  implements RequestBodyWriter    implements RequestBodyWriter
48  {  {
49    
50    /**    /**
# Line 62  implements RequestBodyWriter Line 62  implements RequestBodyWriter
62     * content.     * content.
63     * @param content the content buffer     * @param content the content buffer
64     */     */
65    public ByteArrayRequestBodyWriter (byte[] content)    public ByteArrayRequestBodyWriter(byte[] content)
66    {    {
67      this.content = content;      this.content = content;
68      pos = 0;      pos = 0;
# Line 72  implements RequestBodyWriter Line 72  implements RequestBodyWriter
72     * Returns the total number of bytes that will be written in a single pass     * Returns the total number of bytes that will be written in a single pass
73     * by this writer.     * by this writer.
74     */     */
75    public int getContentLength ()    public int getContentLength()
76    {    {
77      return content.length;      return content.length;
78    }    }
# Line 81  implements RequestBodyWriter Line 81  implements RequestBodyWriter
81     * Initialises the writer.     * Initialises the writer.
82     * This will be called before each pass.     * This will be called before each pass.
83     */     */
84    public void reset ()    public void reset()
85    {    {
86      pos = 0;      pos = 0;
87    }    }
# Line 91  implements RequestBodyWriter Line 91  implements RequestBodyWriter
91     * @param buffer the content buffer     * @param buffer the content buffer
92     * @return the number of bytes written     * @return the number of bytes written
93     */     */
94    public int write (byte[] buffer)    public int write(byte[] buffer)
95    {    {
96      int len = content.length - pos;      int len = content.length - pos;
97      len = (buffer.length < len) ? buffer.length : len;      len = (buffer.length < len) ? buffer.length : len;
98      if (len > -1)      if (len > -1)
99        {        {
100          System.arraycopy (content, pos, buffer, 0, len);          System.arraycopy(content, pos, buffer, 0, len);
101          pos += len;          pos += len;
102        }        }
103      return len;      return len;
104    }    }
105        
106  }  }
107    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

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