File: NokogiriErrorHandler.java

package info (click to toggle)
ruby-nokogiri 1.13.10%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,416 kB
  • sloc: ansic: 38,198; xml: 28,086; ruby: 22,271; java: 15,517; cpp: 7,037; yacc: 244; sh: 148; makefile: 136
file content (65 lines) | stat: -rw-r--r-- 1,435 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package nokogiri.internals;

import nokogiri.XmlSyntaxError;
import org.apache.xerces.xni.parser.XMLErrorHandler;
import org.jruby.Ruby;
import org.jruby.RubyException;
import org.jruby.exceptions.RaiseException;
import org.xml.sax.ErrorHandler;

import java.util.ArrayList;
import java.util.List;

/**
 * Super class of error handlers.
 *
 * XMLErrorHandler is used by nokogiri.internals.HtmlDomParserContext since NekoHtml
 * uses this type of the error handler.
 *
 * @author sergio
 * @author Yoko Harada <yokolet@gmail.com>
 */
public abstract class NokogiriErrorHandler implements ErrorHandler, XMLErrorHandler
{
  private final Ruby runtime;
  protected final List<RubyException> errors;
  protected boolean noerror;
  protected boolean nowarning;

  public
  NokogiriErrorHandler(Ruby runtime, boolean noerror, boolean nowarning)
  {
    this.runtime = runtime;
    this.errors = new ArrayList<RubyException>(4);
    this.noerror = noerror;
    this.nowarning = nowarning;
  }

  public List<RubyException>
  getErrors() { return errors; }

  public void
  addError(Exception ex)
  {
    addError(XmlSyntaxError.createXMLSyntaxError(runtime, ex));
  }

  public void
  addError(RubyException ex)
  {
    errors.add(ex);
  }

  public void
  addError(RaiseException ex)
  {
    addError(ex.getException());
  }

  protected boolean
  usesNekoHtml(String domain)
  {
    return "http://cyberneko.org/html".equals(domain);
  }

}