1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/mobile/android/thirdparty/ch/boye/httpclientandroidlib/io/SessionOutputBuffer.java Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,120 @@ 1.4 +/* 1.5 + * ==================================================================== 1.6 + * Licensed to the Apache Software Foundation (ASF) under one 1.7 + * or more contributor license agreements. See the NOTICE file 1.8 + * distributed with this work for additional information 1.9 + * regarding copyright ownership. The ASF licenses this file 1.10 + * to you under the Apache License, Version 2.0 (the 1.11 + * "License"); you may not use this file except in compliance 1.12 + * with the License. You may obtain a copy of the License at 1.13 + * 1.14 + * http://www.apache.org/licenses/LICENSE-2.0 1.15 + * 1.16 + * Unless required by applicable law or agreed to in writing, 1.17 + * software distributed under the License is distributed on an 1.18 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1.19 + * KIND, either express or implied. See the License for the 1.20 + * specific language governing permissions and limitations 1.21 + * under the License. 1.22 + * ==================================================================== 1.23 + * 1.24 + * This software consists of voluntary contributions made by many 1.25 + * individuals on behalf of the Apache Software Foundation. For more 1.26 + * information on the Apache Software Foundation, please see 1.27 + * <http://www.apache.org/>. 1.28 + * 1.29 + */ 1.30 + 1.31 +package ch.boye.httpclientandroidlib.io; 1.32 + 1.33 +import java.io.IOException; 1.34 + 1.35 +import ch.boye.httpclientandroidlib.util.CharArrayBuffer; 1.36 + 1.37 +/** 1.38 + * Session output buffer for blocking connections. This interface is similar to 1.39 + * OutputStream class, but it also provides methods for writing lines of text. 1.40 + * <p> 1.41 + * Implementing classes are also expected to manage intermediate data buffering 1.42 + * for optimal output performance. 1.43 + * 1.44 + * @since 4.0 1.45 + */ 1.46 +public interface SessionOutputBuffer { 1.47 + 1.48 + /** 1.49 + * Writes <code>len</code> bytes from the specified byte array 1.50 + * starting at offset <code>off</code> to this session buffer. 1.51 + * <p> 1.52 + * If <code>off</code> is negative, or <code>len</code> is negative, or 1.53 + * <code>off+len</code> is greater than the length of the array 1.54 + * <code>b</code>, then an <tt>IndexOutOfBoundsException</tt> is thrown. 1.55 + * 1.56 + * @param b the data. 1.57 + * @param off the start offset in the data. 1.58 + * @param len the number of bytes to write. 1.59 + * @exception IOException if an I/O error occurs. 1.60 + */ 1.61 + void write(byte[] b, int off, int len) throws IOException; 1.62 + 1.63 + /** 1.64 + * Writes <code>b.length</code> bytes from the specified byte array 1.65 + * to this session buffer. 1.66 + * 1.67 + * @param b the data. 1.68 + * @exception IOException if an I/O error occurs. 1.69 + */ 1.70 + void write(byte[] b) throws IOException; 1.71 + 1.72 + /** 1.73 + * Writes the specified byte to this session buffer. 1.74 + * 1.75 + * @param b the <code>byte</code>. 1.76 + * @exception IOException if an I/O error occurs. 1.77 + */ 1.78 + void write(int b) throws IOException; 1.79 + 1.80 + /** 1.81 + * Writes characters from the specified string followed by a line delimiter 1.82 + * to this session buffer. 1.83 + * <p> 1.84 + * The choice of a char encoding and line delimiter sequence is up to the 1.85 + * specific implementations of this interface. 1.86 + * 1.87 + * @param s the line. 1.88 + * @exception IOException if an I/O error occurs. 1.89 + */ 1.90 + void writeLine(String s) throws IOException; 1.91 + 1.92 + /** 1.93 + * Writes characters from the specified char array followed by a line 1.94 + * delimiter to this session buffer. 1.95 + * <p> 1.96 + * The choice of a char encoding and line delimiter sequence is up to the 1.97 + * specific implementations of this interface. 1.98 + * 1.99 + * @param buffer the buffer containing chars of the line. 1.100 + * @exception IOException if an I/O error occurs. 1.101 + */ 1.102 + void writeLine(CharArrayBuffer buffer) throws IOException; 1.103 + 1.104 + /** 1.105 + * Flushes this session buffer and forces any buffered output bytes 1.106 + * to be written out. The general contract of <code>flush</code> is 1.107 + * that calling it is an indication that, if any bytes previously 1.108 + * written have been buffered by the implementation of the output 1.109 + * stream, such bytes should immediately be written to their 1.110 + * intended destination. 1.111 + * 1.112 + * @exception IOException if an I/O error occurs. 1.113 + */ 1.114 + void flush() throws IOException; 1.115 + 1.116 + /** 1.117 + * Returns {@link HttpTransportMetrics} for this session buffer. 1.118 + * 1.119 + * @return transport metrics. 1.120 + */ 1.121 + HttpTransportMetrics getMetrics(); 1.122 + 1.123 +}