001 /* 002 * Copyright (c) 2007 Henri Sivonen 003 * Copyright (c) 2007 Mozilla Foundation 004 * 005 * Permission is hereby granted, free of charge, to any person obtaining a 006 * copy of this software and associated documentation files (the "Software"), 007 * to deal in the Software without restriction, including without limitation 008 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 009 * and/or sell copies of the Software, and to permit persons to whom the 010 * Software is furnished to do so, subject to the following conditions: 011 * 012 * The above copyright notice and this permission notice shall be included in 013 * all copies or substantial portions of the Software. 014 * 015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 018 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 019 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 020 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 021 * DEALINGS IN THE SOFTWARE. 022 */ 023 024 package nu.validator.saxtree; 025 026 import org.xml.sax.Locator; 027 028 public final class LocatorImpl implements Locator { 029 030 private final String systemId; 031 private final String publicId; 032 private final int column; 033 private final int line; 034 035 public LocatorImpl(Locator locator) { 036 if (locator == null) { 037 this.systemId = null; 038 this.publicId = null; 039 this.column = -1; 040 this.line = -1; 041 } else { 042 this.systemId = locator.getSystemId(); 043 this.publicId = locator.getPublicId(); 044 this.column = locator.getColumnNumber(); 045 this.line = locator.getLineNumber(); 046 } 047 } 048 049 public int getColumnNumber() { 050 return column; 051 } 052 053 public int getLineNumber() { 054 return line; 055 } 056 057 public String getPublicId() { 058 return publicId; 059 } 060 061 public String getSystemId() { 062 return systemId; 063 } 064 }