001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the "License"); 007 * you may not use this file except in compliance with the License. 008 * You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 /* 019 * $Id: DOMLocatorImpl.java 1225426 2011-12-29 04:13:08Z mrglavas $ 020 */ 021 022 package org.apache.xml.serializer.dom3; 023 024 import org.w3c.dom.DOMLocator; 025 import org.w3c.dom.Node; 026 027 028 /** 029 * <code>DOMLocatorImpl</code> is an implementaion that describes a location (e.g. 030 * where an error occured). 031 * <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>. 032 * This class is a copy of the Xerces-2J class org.apache.xerces.dom.DOMLocatorImpl.java v 1.10 033 * 034 * @author Gopal Sharma, SUN Microsystems Inc. 035 * @version $Id: 036 * 037 * @xsl.usage internal 038 */ 039 final class DOMLocatorImpl implements DOMLocator { 040 041 // 042 // Data 043 // 044 045 /** 046 * The column number where the error occured, 047 * or -1 if there is no column number available. 048 */ 049 private final int fColumnNumber; 050 051 /** 052 * The line number where the error occured, 053 * or -1 if there is no line number available. 054 */ 055 private final int fLineNumber; 056 057 /** related data node*/ 058 private final Node fRelatedNode; 059 060 /** 061 * The URI where the error occured, 062 * or null if there is no URI available. 063 */ 064 private final String fUri; 065 066 /** 067 * The byte offset into the input source this locator is pointing to or -1 068 * if there is no byte offset available 069 */ 070 private final int fByteOffset; 071 072 /** 073 * The UTF-16, as defined in [Unicode] and Amendment 1 of [ISO/IEC 10646], 074 * offset into the input source this locator is pointing to or -1 if there 075 * is no UTF-16 offset available. 076 */ 077 private final int fUtf16Offset; 078 079 // 080 // Constructors 081 // 082 083 DOMLocatorImpl(){ 084 fColumnNumber = -1; 085 fLineNumber = -1; 086 fRelatedNode = null; 087 fUri = null; 088 fByteOffset = -1; 089 fUtf16Offset = -1; 090 } 091 092 DOMLocatorImpl (int lineNumber, int columnNumber, String uri ){ 093 fLineNumber = lineNumber ; 094 fColumnNumber = columnNumber ; 095 fUri = uri; 096 097 fRelatedNode = null; 098 fByteOffset = -1; 099 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