1/*
2 * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/LineParser.java $
3 * $Revision: 589374 $
4 * $Date: 2007-10-28 09:25:07 -0700 (Sun, 28 Oct 2007) $
5 *
6 * ====================================================================
7 * Licensed to the Apache Software Foundation (ASF) under one
8 * or more contributor license agreements.  See the NOTICE file
9 * distributed with this work for additional information
10 * regarding copyright ownership.  The ASF licenses this file
11 * to you under the Apache License, Version 2.0 (the
12 * "License"); you may not use this file except in compliance
13 * with the License.  You may obtain a copy of the License at
14 *
15 *   http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * Unless required by applicable law or agreed to in writing,
18 * software distributed under the License is distributed on an
19 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20 * KIND, either express or implied.  See the License for the
21 * specific language governing permissions and limitations
22 * under the License.
23 * ====================================================================
24 *
25 * This software consists of voluntary contributions made by many
26 * individuals on behalf of the Apache Software Foundation.  For more
27 * information on the Apache Software Foundation, please see
28 * <http://www.apache.org/>.
29 *
30 */
31
32package org.apache.http.message;
33
34
35import org.apache.http.ProtocolVersion;
36import org.apache.http.ParseException;
37import org.apache.http.RequestLine;
38import org.apache.http.StatusLine;
39import org.apache.http.Header;
40import org.apache.http.util.CharArrayBuffer;
41
42
43/**
44 * Interface for parsing lines in the HEAD section of an HTTP message.
45 * There are individual methods for parsing a request line, a
46 * status line, or a header line.
47 * The lines to parse are passed in memory, the parser does not depend
48 * on any specific IO mechanism.
49 * Instances of this interface are expected to be stateless and thread-safe.
50 *
51 * @author <a href="mailto:rolandw AT apache.org">Roland Weber</a>
52 *
53 *
54 * <!-- empty lines above to avoid 'svn diff' context problems -->
55 * @version $Revision: 589374 $ $Date: 2007-10-28 09:25:07 -0700 (Sun, 28 Oct 2007) $
56 *
57 * @since 4.0
58 *
59 * @deprecated Please use {@link java.net.URL#openConnection} instead.
60 *     Please visit <a href="http://android-developers.blogspot.com/2011/09/androids-http-clients.html">this webpage</a>
61 *     for further details.
62 */
63@Deprecated
64public interface LineParser {
65
66
67    /**
68     * Parses the textual representation of a protocol version.
69     * This is needed for parsing request lines (last element)
70     * as well as status lines (first element).
71     *
72     * @param buffer    a buffer holding the protocol version to parse
73     * @param cursor    the parser cursor containing the current position and
74     *                  the bounds within the buffer for the parsing operation
75     *
76     * @return  the parsed protocol version
77     *
78     * @throws ParseException        in case of a parse error
79     */
80    ProtocolVersion parseProtocolVersion(
81            CharArrayBuffer buffer,
82            ParserCursor cursor) throws ParseException;
83
84
85    /**
86     * Checks whether there likely is a protocol version in a line.
87     * This method implements a <i>heuristic</i> to check for a
88     * likely protocol version specification. It does <i>not</i>
89     * guarantee that {@link #parseProtocolVersion} would not
90     * detect a parse error.
91     * This can be used to detect garbage lines before a request
92     * or status line.
93     *
94     * @param buffer    a buffer holding the line to inspect
95     * @param cursor    the cursor at which to check for a protocol version, or
96     *                  negative for "end of line". Whether the check tolerates
97     *                  whitespace before or after the protocol version is
98     *                  implementation dependent.
99     *
100     * @return  <code>true</code> if there is a protocol version at the
101     *          argument index (possibly ignoring whitespace),
102     *          <code>false</code> otherwise
103     */
104    boolean hasProtocolVersion(
105            CharArrayBuffer buffer,
106            ParserCursor cursor);
107
108
109    /**
110     * Parses a request line.
111     *
112     * @param buffer    a buffer holding the line to parse
113     * @param cursor    the parser cursor containing the current position and
114     *                  the bounds within the buffer for the parsing operation
115     *
116     * @return  the parsed request line
117     *
118     * @throws ParseException        in case of a parse error
119     */
120    RequestLine parseRequestLine(
121            CharArrayBuffer buffer,
122            ParserCursor cursor) throws ParseException;
123
124
125    /**
126     * Parses a status line.
127     *
128     * @param buffer    a buffer holding the line to parse
129     * @param cursor    the parser cursor containing the current position and
130     *                  the bounds within the buffer for the parsing operation
131     *
132     * @return  the parsed status line
133     *
134     * @throws ParseException        in case of a parse error
135     */
136    StatusLine parseStatusLine(
137            CharArrayBuffer buffer,
138            ParserCursor cursor) throws ParseException;
139
140
141    /**
142     * Creates a header from a line.
143     * The full header line is expected here. Header continuation lines
144     * must be joined by the caller before invoking this method.
145     *
146     * @param buffer    a buffer holding the full header line.
147     *                  This buffer MUST NOT be re-used afterwards, since
148     *                  the returned object may reference the contents later.
149     *
150     * @return  the header in the argument buffer.
151     *          The returned object MAY be a wrapper for the argument buffer.
152     *          The argument buffer MUST NOT be re-used or changed afterwards.
153     *
154     * @throws ParseException        in case of a parse error
155     */
156    Header parseHeader(CharArrayBuffer buffer)
157        throws ParseException
158        ;
159
160
161}
162