View Javadoc
1   /*
2    * ====================================================================
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   * ====================================================================
20   *
21   * This software consists of voluntary contributions made by many
22   * individuals on behalf of the Apache Software Foundation.  For more
23   * information on the Apache Software Foundation, please see
24   * <http://www.apache.org/>.
25   *
26   */
27  
28  package org.apache.hc.core5.http.message;
29  
30  import java.util.BitSet;
31  
32  import org.apache.hc.core5.annotation.Contract;
33  import org.apache.hc.core5.annotation.ThreadingBehavior;
34  import org.apache.hc.core5.util.Tokenizer;
35  
36  /**
37   * Low level parser for header field elements. The parsing routines of this class are designed
38   * to produce near zero intermediate garbage and make no intermediate copies of input data.
39   * <p>
40   * This class is immutable and thread safe.
41   *
42   * @since 4.4
43   *
44   * @deprecated Use {@link Tokenizer}
45   */
46  @Deprecated
47  @Contract(threading = ThreadingBehavior.IMMUTABLE)
48  public class TokenParser extends Tokenizer {
49  
50      public static final TokenParserage/TokenParser.html#TokenParser">TokenParser INSTANCE = new TokenParser();
51  
52      /** Double quote */
53      public static final char DQUOTE = '\"';
54  
55      /** Backward slash / escape character */
56      public static final char ESCAPE = '\\';
57  
58      public String parseToken(final CharSequence buf, final ParserCursor cursor, final BitSet delimiters) {
59          return super.parseToken(buf, cursor, delimiters);
60      }
61  
62      public String parseValue(final CharSequence buf, final ParserCursor cursor, final BitSet delimiters) {
63          return super.parseValue(buf, cursor, delimiters);
64      }
65  
66      public void skipWhiteSpace(final CharSequence buf, final ParserCursor cursor) {
67          super.skipWhiteSpace(buf, cursor);
68      }
69  
70      public void copyContent(final CharSequence buf, final ParserCursor cursor, final BitSet delimiters,
71                              final StringBuilder dst) {
72          super.copyContent(buf, cursor, delimiters, dst);
73      }
74  
75      @Override
76      public void copyContent(final CharSequence buf, final Tokenizer.Cursor cursor, final BitSet delimiters,
77                              final StringBuilder dst) {
78          final ParserCursorarserCursor.html#ParserCursor">ParserCursor parserCursor = new ParserCursor(cursor.getLowerBound(), cursor.getUpperBound());
79          parserCursor.updatePos(cursor.getPos());
80          copyContent(buf, parserCursor, delimiters, dst);
81          cursor.updatePos(parserCursor.getPos());
82      }
83  
84      public void copyUnquotedContent(final CharSequence buf, final ParserCursor cursor, final BitSet delimiters,
85                                      final StringBuilder dst) {
86          super.copyUnquotedContent(buf, cursor, delimiters, dst);
87      }
88  
89      @Override
90      public void copyUnquotedContent(final CharSequence buf, final Tokenizer.Cursor cursor, final BitSet delimiters,
91                                      final StringBuilder dst) {
92          final ParserCursorarserCursor.html#ParserCursor">ParserCursor parserCursor = new ParserCursor(cursor.getLowerBound(), cursor.getUpperBound());
93          parserCursor.updatePos(cursor.getPos());
94          copyUnquotedContent(buf, parserCursor, delimiters, dst);
95          cursor.updatePos(parserCursor.getPos());
96      }
97  
98      public void copyQuotedContent(final CharSequence buf, final ParserCursor cursor, final StringBuilder dst) {
99          super.copyQuotedContent(buf, cursor, dst);
100     }
101 
102     @Override
103     public void copyQuotedContent(final CharSequence buf, final Tokenizer.Cursor cursor, final StringBuilder dst) {
104         final ParserCursorarserCursor.html#ParserCursor">ParserCursor parserCursor = new ParserCursor(cursor.getLowerBound(), cursor.getUpperBound());
105         parserCursor.updatePos(cursor.getPos());
106         copyQuotedContent(buf, parserCursor, dst);
107         cursor.updatePos(parserCursor.getPos());
108     }
109 
110 }