001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.xerces.util;
019:
020: import org.apache.xerces.xni.XMLLocator;
021:
022: /**
023: * <p>A light wrapper around an <code>XMLLocator</code>.</p>
024: *
025: * @author Michael Glavassevich, IBM
026: *
027: * @version $Id: XMLLocatorWrapper.java 533423 2007-04-28 20:47:15Z mrglavas $
028: */
029: public final class XMLLocatorWrapper implements XMLLocator {
030:
031: private XMLLocator fLocator = null;
032:
033: public XMLLocatorWrapper() {
034: }
035:
036: public void setLocator(XMLLocator locator) {
037: fLocator = locator;
038: }
039:
040: public XMLLocator getLocator() {
041: return fLocator;
042: }
043:
044: /*
045: * XMLLocator methods
046: */
047:
048: public String getPublicId() {
049: if (fLocator != null) {
050: return fLocator.getPublicId();
051: }
052: return null;
053: }
054:
055: public String getLiteralSystemId() {
056: if (fLocator != null) {
057: return fLocator.getLiteralSystemId();
058: }
059: return null;
060: }
061:
062: public String getBaseSystemId() {
063: if (fLocator != null) {
064: return fLocator.getBaseSystemId();
065: }
066: return null;
067: }
068:
069: public String getExpandedSystemId() {
070: if (fLocator != null) {
071: return fLocator.getExpandedSystemId();
072: }
073: return null;
074: }
075:
076: public int getLineNumber() {
077: if (fLocator != null) {
078: return fLocator.getLineNumber();
079: }
080: return -1;
081: }
082:
083: public int getColumnNumber() {
084: if (fLocator != null) {
085: return fLocator.getColumnNumber();
086: }
087: return -1;
088: }
089:
090: public int getCharacterOffset() {
091: if (fLocator != null) {
092: return fLocator.getCharacterOffset();
093: }
094: return -1;
095: }
096:
097: public String getEncoding() {
098: if (fLocator != null) {
099: return fLocator.getEncoding();
100: }
101: return null;
102: }
103:
104: public String getXMLVersion() {
105: if (fLocator != null) {
106: return fLocator.getXMLVersion();
107: }
108: return null;
109: }
110: }
|