001 /*
002 * Copyright (c) 1999 World Wide Web Consortium
003 * (Massachusetts Institute of Technology, Institut National de Recherche
004 * en Informatique et en Automatique, Keio University).
005 * All Rights Reserved. http://www.w3.org/Consortium/Legal/
006 *
007 * $Id: LocatorImpl.java,v 1.1.1.1 2006/04/23 14:51:25 taqua Exp $
008 */
009 package org.w3c.flute.parser;
010
011 import org.w3c.css.sac.Locator;
012
013 /**
014 * @version $Revision: 1.1.1.1 $
015 * @author Philippe Le Hegaret
016 */
017 public class LocatorImpl implements Locator {
018
019 // W3C DEBUG mode
020 private static boolean W3CDebug;
021 static {
022 try {
023 W3CDebug = (Boolean.getBoolean("debug")
024 || Boolean.getBoolean("org.w3c.flute.parser.LocatorImpl.debug")
025 || Boolean.getBoolean("org.w3c.flute.parser.debug")
026 || Boolean.getBoolean("org.w3c.flute.debug")
027 || Boolean.getBoolean("org.w3c.debug")
028 || Boolean.getBoolean("org.debug"));
029 } catch (Exception e) {
030 // nothing
031 }
032 }
033
034 String uri;
035 int line;
036 int column;
037
038 public String getURI() {
039 return uri;
040 }
041
042 public int getLineNumber() {
043 return line;
044 }
045
046 public int getColumnNumber() {
047 return column;
048 }
049
050 /**
051 * Creates a new LocatorImpl
052 */
053 public LocatorImpl(Parser p) {
054 if (W3CDebug) {
055 System.err.println( "LocatorImpl::newLocator(" + p + ");");
056 }
057 uri = p.source.getURI();
058 line = p.token.beginLine;
059 column = p.token.beginColumn;
060 }
061
062 /**
063 * Reinitializes a LocatorImpl
064 */
065 public LocatorImpl(Parser p, Token tok) {
066 if (W3CDebug) {
067 System.err.println( "LocatorImpl::newLocator(" + p
068 + ", " + tok + ");");
069 }
070 uri = p.source.getURI();
071 line = tok.beginLine;
072 column = tok.beginColumn;
073 }
074
075 /**
076 * Reinitializes a LocatorImpl
077 */
078 public LocatorImpl(Parser p, int line, int column) {
079 if (W3CDebug) {
080 System.err.println( "LocatorImpl::newLocator(" + p
081 + ", " + line
082 + ", " + column + ");");
083 }
084 uri = p.source.getURI();
085 this.line = line;
086 this.column = column;
087 }
088
089 /**
090 * Reinitializes a LocatorImpl
091 */
092 public LocatorImpl reInit(Parser p) {
093 if (W3CDebug) {
094 System.err.println( "LocatorImpl::reInit(" + p + ");" );
095 }
096 uri = p.source.getURI();
097 line = p.token.beginLine;
098 column = p.token.beginColumn;
099 return this;
100 }
101
102 /**
103 * Reinitializes a LocatorImpl
104 */
105 public LocatorImpl reInit(Parser p, Token tok) {
106 if (W3CDebug) {
107 System.err.println( "LocatorImpl::reInit(" + p
108 + ", " + tok + ");");
109 }
110 uri = p.source.getURI();
111 line = tok.beginLine;
112 column = tok.beginColumn;
113 return this;
114 }
115
116 /**
117 * Reinitializes a LocatorImpl
118 */
119 public LocatorImpl reInit(Parser p, int line, int column) {
120 if (W3CDebug) {
121 System.err.println("LocatorImpl::reInit(" + p
122 + ", " + line
123 + ", " + column + ");");
124 }
125 uri = p.source.getURI();
126 this.line = line;
127 this.column = column;
128 return this;
129 }
130 }