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: NodeLocator.java 468653 2006-10-28 07:07:05Z minchau $ 020 */ 021 022 package org.apache.xml.dtm.ref; 023 024 import javax.xml.transform.SourceLocator; 025 026 /** 027 * <code>NodeLocator</code> maintains information on an XML source 028 * node. 029 * 030 * @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a> 031 * @since May 23, 2001 032 */ 033 public class NodeLocator implements SourceLocator 034 { 035 protected String m_publicId; 036 protected String m_systemId; 037 protected int m_lineNumber; 038 protected int m_columnNumber; 039 040 /** 041 * Creates a new <code>NodeLocator</code> instance. 042 * 043 * @param publicId a <code>String</code> value 044 * @param systemId a <code>String</code> value 045 * @param lineNumber an <code>int</code> value 046 * @param columnNumber an <code>int</code> value 047 */ 048 public NodeLocator(String publicId, String systemId, 049 int lineNumber, int columnNumber) 050 { 051 this.m_publicId = publicId; 052 this.m_systemId = systemId; 053 this.m_lineNumber = lineNumber; 054 this.m_columnNumber = columnNumber; 055 } 056 057 /** 058 * <code>getPublicId</code> returns the public ID of the node. 059 * 060 * @return a <code>String</code> value 061 */ 062 public String getPublicId() 063 { 064 return m_publicId; 065 } 066 067 /** 068 * <code>getSystemId</code> returns the system ID of the node. 069 * 070 * @return a <code>String</code> value 071 */ 072 public String getSystemId() 073 { 074 return m_systemId; 075 } 076 077 /** 078 * <code>getLineNumber</code> returns the line number of the node. 079 * 080 * @return an <code>int</code> value 081 */ 082 public int getLineNumber() 083 { 084 return m_lineNumber; 085 } 086 087 /** 088 * <code>getColumnNumber</code> returns the column number of the 089 * node. 090 * 091 * @return an <code>int</code> value 092 */ 093 public int getColumnNumber() 094 { 095 return m_columnNumber; 096 } 097 098 /** 099 * <code>toString</code> returns a string representation of this 100 * NodeLocator instance. 101 * 102 * @return a <code>String</code> value 103 */ 104 public String toString() 105 { 106 return "file '" + m_systemId 107 + "', line #" + m_lineNumber 108 + ", column #" + m_columnNumber; 109 } 110 }