1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # This file is free software, which comes along with NIT. This software is
4 # distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
5 # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
6 # PARTICULAR PURPOSE. You can modify it is you want, provided this header
7 # is kept unaltered, and a notification of the changes is added.
8 # You are allowed to redistribute it and sell it, alone or is a part of
11 # Provides an optional convenience implementation of `Locator`.
12 module sax
::helpers
::sax_locator_impl
14 import sax
::sax_locator
16 # Provides an optional convenience implementation of `Locator`.
18 # This class is available mainly for application writers, who
19 # can use it to make a persistent snapshot of a locator at any
20 # point during a document parse:
23 # import sax::helpers::sax_locator_impl
24 # import sax::content_handler
26 # class Example super ContentHandler
27 # private var locator: SAXLocator
28 # private var start_loc: nullable SAXLocator = null
30 # redef fun start_document do
31 # # save the location of the start of the document
33 # start_loc = new SAXLocatorImpl.from(locator)
38 # Normally, parser writers will not use this class, since it
39 # is more efficient to provide location information only when
40 # requested, rather than constantly updating a `Locator` object.
42 # Note: The original source code and documentation of this class comes, in part,
43 # from [SAX 2.0](http://www.saxproject.org).
44 class SAXLocatorImpl super SAXLocator
45 redef var public_id
= null is writable
46 redef var system_id
= null is writable
47 redef var line_number
= -1 is writable
48 redef var column_number
= -1 is writable
50 # Zero-argument constructor.
52 # This will not normally be useful, since the main purpose
53 # of this class is to make a snapshot of an existing Locator.
59 # Create a persistent copy of the current state of a locator.
60 # When the original locator changes, this copy will still keep
61 # the original values (and it can be used outside the scope of
62 # `ContentHandler` methods).
66 # * `locator`: locator to copy.
67 init from
(locator
: SAXLocator) do
68 public_id
= locator
.public_id
69 system_id
= locator
.system_id
70 line_number
= locator
.line_number
71 column_number
= locator
.column_number