View Javadoc
1   /* 
2    * Licensed under the Apache License, Version 2.0 (the "License");
3    * you may not use this file except in compliance with the License.
4    * You may obtain a copy of the License at
5    *
6    * http://www.apache.org/licenses/LICENSE-2.0
7    *
8    * Unless required by applicable law or agreed to in writing, software
9    * distributed under the License is distributed on an "AS IS" BASIS,
10   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11   * See the License for the specific language governing permissions and
12   * limitations under the License.
13   *
14   */
15  
16  package org.esigate.parser.future;
17  
18  import org.apache.http.HttpResponse;
19  import org.esigate.impl.DriverRequest;
20  
21  import java.io.IOException;
22  import java.util.concurrent.Future;
23  
24  /**
25   * The current context used during parsing.
26   * <p>
27   * This class is based on ParserContext
28   * 
29   * @see org.esigate.parser.ParserContext
30   * @author Nicolas Richeton
31   * 
32   */
33  public interface FutureParserContext {
34  
35      /** @return {@linkplain org.apache.http.HttpRequest} associated with current processing. */
36      DriverRequest getHttpRequest();
37  
38      /** @return {@linkplain org.apache.http.HttpResponse} associated with current processing. */
39      HttpResponse getHttpResponse();
40  
41      /**
42       * @param element
43       * @param e
44       * @return <code>true</code> if error has been handled by this element and it should not be propagated further.
45       */
46      boolean reportError(FutureElement element, Exception e);
47  
48      FutureElement getCurrent();
49  
50      <T> T findAncestor(Class<T> type);
51  
52      /**
53       * Allow to get custom context data.
54       * 
55       * @param key
56       *            key
57       * @return custom context data
58       */
59      Object getData(String key);
60  
61      /**
62       * Writes characters into current writer.
63       * 
64       * @param csq
65       *            sequence
66       * @throws IOException
67       *             exception
68       */
69      void characters(Future<CharSequence> csq) throws IOException;
70  
71  }