View Javadoc
1   /*
2    * reserved comment block
3    * DO NOT REMOVE OR ALTER!
4    */
5   /*
6    * Copyright 2002, 2003,2004 The Apache Software Foundation.
7    *
8    * Licensed under the Apache License, Version 2.0 (the "License");
9    * you may not use this file except in compliance with the License.
10   * You may obtain a copy of the License at
11   *
12   *      http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  
21  package com.sun.org.apache.xerces.internal.impl.xs.util;
22  
23  import com.sun.org.apache.xerces.internal.xni.XMLLocator;
24  
25  /**
26   * An XMLLocator implementation used for schema error reporting.
27   *
28   * @xerces.internal
29   *
30   * @author Sandy Gao, IBM
31   */
32  public class SimpleLocator implements XMLLocator {
33  
34      String lsid, esid;
35      int line, column;
36      int charOffset;
37  
38      public SimpleLocator() {
39      }
40  
41      public SimpleLocator(String lsid, String esid, int line, int column) {
42          this(lsid, esid, line, column, -1);
43      }
44  
45      public void setValues(String lsid, String esid, int line, int column) {
46          setValues(lsid, esid, line, column, -1);
47      }
48  
49      public SimpleLocator(String lsid, String esid, int line, int column, int offset) {
50          this.line = line;
51          this.column = column;
52          this.lsid = lsid;
53          this.esid = esid;
54          charOffset = offset;
55      }
56  
57      public void setValues(String lsid, String esid, int line, int column, int offset) {
58          this.line = line;
59          this.column = column;
60          this.lsid = lsid;
61          this.esid = esid;
62          charOffset = offset;
63      }
64  
65      public int getLineNumber() {
66          return line;
67      }
68  
69      public int getColumnNumber() {
70          return column;
71      }
72  
73      public int getCharacterOffset() {
74          return charOffset;
75      }
76  
77      public String getPublicId() {
78          return null;
79      }
80  
81      public String getExpandedSystemId() {
82          return esid;
83      }
84  
85      public String getLiteralSystemId() {
86          return lsid;
87      }
88  
89      public String getBaseSystemId() {
90          return null;
91      }
92      /**
93       * @see com.sun.org.apache.xerces.internal.xni.XMLLocator#setColumnNumber(int)
94       */
95      public void setColumnNumber(int col) {
96          this.column = col;
97      }
98  
99      /**
100      * @see com.sun.org.apache.xerces.internal.xni.XMLLocator#setLineNumber(int)
101      */
102     public void setLineNumber(int line) {
103         this.line = line;
104     }
105 
106     public void setCharacterOffset(int offset) {
107         charOffset = offset;
108     }
109 
110     /**
111      * @see com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier#setBaseSystemId(String)
112      */
113     public void setBaseSystemId(String systemId) {}
114 
115     /**
116      * @see com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier#setExpandedSystemId(String)
117      */
118     public void setExpandedSystemId(String systemId) {
119         esid = systemId;
120     }
121 
122     /**
123      * @see com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier#setLiteralSystemId(String)
124      */
125     public void setLiteralSystemId(String systemId) {
126         lsid = systemId;
127     }
128 
129     /**
130      * @see com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier#setPublicId(String)
131      */
132     public void setPublicId(String publicId) {}
133 
134     /** Returns the encoding of the current entity.
135      * Since these locators are used in the construction of
136      * XMLParseExceptions, which know nothing about encodings, there is
137      * no point in having this object deal intelligently
138      * with encoding information.
139      */
140     public String getEncoding() {
141         return null;
142     }
143 
144     public String getXMLVersion() {
145         return null;
146     }
147 }