Merge from mainline (gomp-merge-2005-02-26).
[official-gcc.git] / libjava / external / sax / org / xml / sax / helpers / LocatorImpl.java
blobeafdbb96ce0483f359f12404d517a91364835c28
1 // SAX default implementation for Locator.
2 // http://www.saxproject.org
3 // No warranty; no copyright -- use this as you will.
4 // $Id: LocatorImpl.java,v 1.1 2005/02/02 00:41:54 tromey Exp $
6 package org.xml.sax.helpers;
8 import org.xml.sax.Locator;
11 /**
12 * Provide an optional convenience implementation of Locator.
14 * <blockquote>
15 * <em>This module, both source code and documentation, is in the
16 * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
17 * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
18 * for further information.
19 * </blockquote>
21 * <p>This class is available mainly for application writers, who
22 * can use it to make a persistent snapshot of a locator at any
23 * point during a document parse:</p>
25 * <pre>
26 * Locator locator;
27 * Locator startloc;
29 * public void setLocator (Locator locator)
30 * {
31 * // note the locator
32 * this.locator = locator;
33 * }
35 * public void startDocument ()
36 * {
37 * // save the location of the start of the document
38 * // for future use.
39 * Locator startloc = new LocatorImpl(locator);
40 * }
41 *</pre>
43 * <p>Normally, parser writers will not use this class, since it
44 * is more efficient to provide location information only when
45 * requested, rather than constantly updating a Locator object.</p>
47 * @since SAX 1.0
48 * @author David Megginson
49 * @version 2.0.1 (sax2r2)
50 * @see org.xml.sax.Locator Locator
52 public class LocatorImpl implements Locator
56 /**
57 * Zero-argument constructor.
59 * <p>This will not normally be useful, since the main purpose
60 * of this class is to make a snapshot of an existing Locator.</p>
62 public LocatorImpl ()
67 /**
68 * Copy constructor.
70 * <p>Create a persistent copy of the current state of a locator.
71 * When the original locator changes, this copy will still keep
72 * the original values (and it can be used outside the scope of
73 * DocumentHandler methods).</p>
75 * @param locator The locator to copy.
77 public LocatorImpl (Locator locator)
79 setPublicId(locator.getPublicId());
80 setSystemId(locator.getSystemId());
81 setLineNumber(locator.getLineNumber());
82 setColumnNumber(locator.getColumnNumber());
87 ////////////////////////////////////////////////////////////////////
88 // Implementation of org.xml.sax.Locator
89 ////////////////////////////////////////////////////////////////////
92 /**
93 * Return the saved public identifier.
95 * @return The public identifier as a string, or null if none
96 * is available.
97 * @see org.xml.sax.Locator#getPublicId
98 * @see #setPublicId
100 public String getPublicId ()
102 return publicId;
107 * Return the saved system identifier.
109 * @return The system identifier as a string, or null if none
110 * is available.
111 * @see org.xml.sax.Locator#getSystemId
112 * @see #setSystemId
114 public String getSystemId ()
116 return systemId;
121 * Return the saved line number (1-based).
123 * @return The line number as an integer, or -1 if none is available.
124 * @see org.xml.sax.Locator#getLineNumber
125 * @see #setLineNumber
127 public int getLineNumber ()
129 return lineNumber;
134 * Return the saved column number (1-based).
136 * @return The column number as an integer, or -1 if none is available.
137 * @see org.xml.sax.Locator#getColumnNumber
138 * @see #setColumnNumber
140 public int getColumnNumber ()
142 return columnNumber;
147 ////////////////////////////////////////////////////////////////////
148 // Setters for the properties (not in org.xml.sax.Locator)
149 ////////////////////////////////////////////////////////////////////
153 * Set the public identifier for this locator.
155 * @param publicId The new public identifier, or null
156 * if none is available.
157 * @see #getPublicId
159 public void setPublicId (String publicId)
161 this.publicId = publicId;
166 * Set the system identifier for this locator.
168 * @param systemId The new system identifier, or null
169 * if none is available.
170 * @see #getSystemId
172 public void setSystemId (String systemId)
174 this.systemId = systemId;
179 * Set the line number for this locator (1-based).
181 * @param lineNumber The line number, or -1 if none is available.
182 * @see #getLineNumber
184 public void setLineNumber (int lineNumber)
186 this.lineNumber = lineNumber;
191 * Set the column number for this locator (1-based).
193 * @param columnNumber The column number, or -1 if none is available.
194 * @see #getColumnNumber
196 public void setColumnNumber (int columnNumber)
198 this.columnNumber = columnNumber;
203 ////////////////////////////////////////////////////////////////////
204 // Internal state.
205 ////////////////////////////////////////////////////////////////////
207 private String publicId;
208 private String systemId;
209 private int lineNumber;
210 private int columnNumber;
214 // end of LocatorImpl.java