1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the  "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 *     http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18/*
19 * $Id:  $
20 */
21
22package org.apache.xml.serializer.dom3;
23
24import org.w3c.dom.DOMLocator;
25import org.w3c.dom.Node;
26
27
28/**
29 * <code>DOMLocatorImpl</code> is an implementaion that describes a location (e.g.
30 * where an error occured).
31 * <p>See also the <a href='http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407'>Document Object Model (DOM) Level 3 Core Specification</a>.
32 * This class is a copy of the Xerces-2J class org.apache.xerces.dom.DOMLocatorImpl.java v 1.10
33 *
34 * @author Gopal Sharma, SUN Microsystems Inc.
35 * @version $Id:
36 *
37 * @xsl.usage internal
38 */
39final class DOMLocatorImpl implements DOMLocator {
40
41    //
42    // Data
43    //
44
45    /**
46     * The column number where the error occured,
47     * or -1 if there is no column number available.
48     */
49    private final int fColumnNumber;
50
51    /**
52     * The line number where the error occured,
53     * or -1 if there is no line number available.
54     */
55    private final int fLineNumber;
56
57    /** related data node*/
58    private final Node fRelatedNode;
59
60    /**
61     * The URI where the error occured,
62     * or null if there is no URI available.
63     */
64    private final String fUri;
65
66    /**
67     * The byte offset into the input source this locator is pointing to or -1
68     * if there is no byte offset available
69     */
70    private final int fByteOffset;
71
72    /**
73     * The UTF-16, as defined in [Unicode] and Amendment 1 of [ISO/IEC 10646],
74     * offset into the input source this locator is pointing to or -1 if there
75     * is no UTF-16 offset available.
76     */
77    private final int fUtf16Offset;
78
79    //
80    // Constructors
81    //
82
83    DOMLocatorImpl(){
84        fColumnNumber = -1;
85        fLineNumber = -1;
86        fRelatedNode = null;
87        fUri = null;
88        fByteOffset = -1;
89        fUtf16Offset = -1;
90    }
91
92    DOMLocatorImpl (int lineNumber, int columnNumber, String uri ){
93        fLineNumber = lineNumber ;
94        fColumnNumber = columnNumber ;
95        fUri = uri;
96
97        fRelatedNode = null;
98        fByteOffset = -1;
99        fUtf16Offset = -1;
100    } // DOMLocatorImpl (int lineNumber, int columnNumber, String uri )
101
102    DOMLocatorImpl (int lineNumber, int columnNumber, int utf16Offset, String uri ){
103        fLineNumber = lineNumber ;
104        fColumnNumber = columnNumber ;
105        fUri = uri;
106        fUtf16Offset = utf16Offset;
107
108
109        fRelatedNode = null;
110        fByteOffset = -1;
111    } // DOMLocatorImpl (int lineNumber, int columnNumber, int utf16Offset, String uri )
112
113    DOMLocatorImpl (int lineNumber, int columnNumber, int byteoffset, Node relatedData, String uri ){
114        fLineNumber = lineNumber ;
115        fColumnNumber = columnNumber ;
116        fByteOffset = byteoffset ;
117        fRelatedNode = relatedData ;
118        fUri = uri;
119
120        fUtf16Offset = -1;
121    } // DOMLocatorImpl (int lineNumber, int columnNumber, int offset, Node errorNode, String uri )
122
123    DOMLocatorImpl (int lineNumber, int columnNumber, int byteoffset, Node relatedData, String uri, int utf16Offset ){
124        fLineNumber = lineNumber ;
125        fColumnNumber = columnNumber ;
126        fByteOffset = byteoffset ;
127        fRelatedNode = relatedData ;
128        fUri = uri;
129        fUtf16Offset = utf16Offset;
130    } // DOMLocatorImpl (int lineNumber, int columnNumber, int offset, Node errorNode, String uri )
131
132
133    /**
134     * The line number where the error occured, or -1 if there is no line
135     * number available.
136     */
137    public int getLineNumber(){
138        return fLineNumber;
139    }
140
141    /**
142     * The column number where the error occured, or -1 if there is no column
143     * number available.
144     */
145    public int getColumnNumber(){
146        return fColumnNumber;
147    }
148
149
150    /**
151     * The URI where the error occured, or null if there is no URI available.
152     */
153    public String getUri(){
154        return fUri;
155    }
156
157
158    public Node getRelatedNode(){
159        return fRelatedNode;
160    }
161
162
163    /**
164     * The byte offset into the input source this locator is pointing to or -1
165     * if there is no byte offset available
166     */
167    public int getByteOffset(){
168        return fByteOffset;
169    }
170
171    /**
172     * The UTF-16, as defined in [Unicode] and Amendment 1 of [ISO/IEC 10646],
173     * offset into the input source this locator is pointing to or -1 if there
174     * is no UTF-16 offset available.
175     */
176    public int getUtf16Offset(){
177        return fUtf16Offset;
178    }
179
180}// class DOMLocatorImpl
181