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 * @version $Id: StAXLocationWrapper.java,v 1.2 2010-10-26 23:01:13 joehw Exp $ 36 */ 37 public final class StAXLocationWrapper implements XMLLocator { 38 39 private Location fLocation = null; 40 StAXLocationWrapper()41 public StAXLocationWrapper() {} 42 setLocation(Location location)43 public void setLocation(Location location) { 44 fLocation = location; 45 } 46 getLocation()47 public Location getLocation() { 48 return fLocation; 49 } 50 51 /* 52 * XMLLocator methods 53 */ 54 getPublicId()55 public String getPublicId() { 56 if (fLocation != null) { 57 return fLocation.getPublicId(); 58 } 59 return null; 60 } 61 getLiteralSystemId()62 public String getLiteralSystemId() { 63 if (fLocation != null) { 64 return fLocation.getSystemId(); 65 } 66 return null; 67 } 68 getBaseSystemId()69 public String getBaseSystemId() { 70 return null; 71 } 72 getExpandedSystemId()73 public String getExpandedSystemId() { 74 return getLiteralSystemId(); 75 } 76 getLineNumber()77 public int getLineNumber() { 78 if (fLocation != null) { 79 return fLocation.getLineNumber(); 80 } 81 return -1; 82 } 83 getColumnNumber()84 public int getColumnNumber() { 85 if (fLocation != null) { 86 return fLocation.getColumnNumber(); 87 } 88 return -1; 89 } 90 getCharacterOffset()91 public int getCharacterOffset() { 92 if (fLocation != null) { 93 return fLocation.getCharacterOffset(); 94 } 95 return -1; 96 } 97 getEncoding()98 public String getEncoding() { 99 return null; 100 } 101 getXMLVersion()102 public String getXMLVersion() { 103 return null; 104 } 105 106 } // StAXLocationWrapper 107