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;
17  
18  import org.apache.http.HttpResponse;
19  import org.esigate.impl.DriverRequest;
20  
21  import java.io.IOException;
22  
23  /**
24   * The current context used during parsing.
25   * 
26   * @author Francois-Xavier Bonnet
27   */
28  public interface ParserContext {
29  
30      /** @return {@linkplain org.apache.http.HttpRequest} associated with current processing. */
31      DriverRequest getHttpRequest();
32  
33      /** @return {@linkplain HttpResponse} associated with current processing. */
34      HttpResponse getHttpResponse();
35  
36      /**
37       * @param e
38       *            exception
39       * @return <code>true</code> if error has been handled by this element and it should not be propagated further.
40       */
41      boolean reportError(Exception e);
42  
43      Element getCurrent();
44  
45      <T> T findAncestor(Class<T> type);
46  
47      /**
48       * Writes characters into current writer.
49       * 
50       * @param cs
51       *            sequence
52       * @throws IOException
53       *             exception
54       */
55      void characters(CharSequence cs) throws IOException;
56  
57  }