source: contrib/MailArchiver/sources/vendor/mime4j/custom/core/src/main/java/org/apache/james/mime4j/io/LineReaderInputStream.java @ 6785

Revision 6785, 2.5 KB checked in by rafaelraymundo, 12 years ago (diff)

Ticket #2946 - Liberado codigo do MailArchiver?. Documentação na subpasta DOCS.

Line 
1/****************************************************************
2 * Licensed to the Apache Software Foundation (ASF) under one   *
3 * or more contributor license agreements.  See the NOTICE file *
4 * distributed with this work for additional information        *
5 * regarding copyright ownership.  The ASF licenses this file   *
6 * to you under the Apache License, Version 2.0 (the            *
7 * "License"); you may not use this file except in compliance   *
8 * with the License.  You may obtain a copy of the License at   *
9 *                                                              *
10 *   http://www.apache.org/licenses/LICENSE-2.0                 *
11 *                                                              *
12 * Unless required by applicable law or agreed to in writing,   *
13 * software distributed under the License is distributed on an  *
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
15 * KIND, either express or implied.  See the License for the    *
16 * specific language governing permissions and limitations      *
17 * under the License.                                           *
18 ****************************************************************/
19
20package org.apache.james.mime4j.io;
21
22import org.apache.james.mime4j.util.ByteArrayBuffer;
23
24import java.io.FilterInputStream;
25import java.io.IOException;
26import java.io.InputStream;
27
28/**
29 * Input stream capable of reading lines of text.
30 */
31public abstract class LineReaderInputStream extends FilterInputStream {
32
33    protected LineReaderInputStream(InputStream in) {
34        super(in);
35    }
36
37    /**
38     * Reads one line of text into the given {@link ByteArrayBuffer}.
39     * 
40     * @param dst Destination
41     * @return number of bytes copied or <code>-1</code> if the end of
42     * the stream has been reached.
43     *
44     * @throws MaxLineLimitException if the line exceeds a limit on
45     *   the line length imposed by a subclass.
46     * @throws IOException in case of an I/O error.
47     */
48    public abstract int readLine(final ByteArrayBuffer dst)
49            throws MaxLineLimitException, IOException;
50   
51    /**
52     * Tries to unread the last read line.
53     *
54     * Implementation may refuse to unread a new buffer until the previous
55     * unread one has been competely consumed.
56     *
57     * Implementations will directly use the byte array backed by buf, so
58     * make sure to not alter it anymore once this method has been called.
59     *
60     * @return true if the unread has been succesfull.
61     */
62    public abstract boolean unread(ByteArrayBuffer buf);
63
64}
Note: See TracBrowser for help on using the repository browser.