1 /* 2 * reserved comment block 3 * DO NOT REMOVE OR ALTER! 4 */ 5 /* 6 * Licensed to the Apache Software Foundation (ASF) under one or more 7 * contributor license agreements. See the NOTICE file distributed with 8 * this work for additional information regarding copyright ownership. 9 * The ASF licenses this file to You under the Apache License, Version 2.0 10 * (the "License"); you may not use this file except in compliance with 11 * the License. You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 */ 21 22 package com.sun.org.apache.xerces.internal.util; 23 24 25 import javax.xml.stream.Location; 26 27 import com.sun.org.apache.xerces.internal.xni.XMLLocator; 28 29 /** 30 * <p>A light wrapper around a StAX location. This is useful 31 * when bridging between StAX and XNI components.</p> 32 * 33 * @author Michael Glavassevich, IBM 34 * 35 */ 36 public final class StAXLocationWrapper implements XMLLocator { 37 38 private Location fLocation = null; 39 40 public StAXLocationWrapper() {} 41 42 public void setLocation(Location location) { 43 fLocation = location; 44 } 45 46 public Location getLocation() { 47 return fLocation; 48 } 49 50 /* 51 * XMLLocator methods 52 */ 53 54 public String getPublicId() { 55 if (fLocation != null) { 56 return fLocation.getPublicId(); 57 } 58 return null; 59 } 60 61 public String getLiteralSystemId() { 62 if (fLocation != null) { 63 return fLocation.getSystemId(); 64 } 65 return null; 66 } 67 68 public String getBaseSystemId() { 69 return null; 70 } 71 72 public String getExpandedSystemId() { 73 return getLiteralSystemId(); 74 } 75 76 public int getLineNumber() { 77 if (fLocation != null) { 78 return fLocation.getLineNumber(); 79 } 80 return -1; 81 } 82 83 public int getColumnNumber() { 84 if (fLocation != null) { 85 return fLocation.getColumnNumber(); 86 } 87 return -1; 88 } 89 90 public int getCharacterOffset() { 91 if (fLocation != null) { 92 return fLocation.getCharacterOffset(); 93 } 94 return -1; 95 } 96 97 public String getEncoding() { 98 return null; 99 } 100 101 public String getXMLVersion() { 102 return null; 103 } 104 105 } // StAXLocationWrapper