1 16 17 package com.sun.org.apache.xerces.internal.util; 18 19 import org.xml.sax.Locator ; 20 import org.xml.sax.ext.Locator2 ; 21 22 import com.sun.org.apache.xerces.internal.xni.XMLLocator; 23 24 32 public final class SAXLocatorWrapper implements XMLLocator { 33 34 private Locator fLocator = null; 35 private Locator2 fLocator2 = null; 36 37 public SAXLocatorWrapper() {} 38 39 public void setLocator(Locator locator) { 40 fLocator = locator; 41 if (locator instanceof Locator2 || locator == null) { 42 fLocator2 = (Locator2 ) locator; 43 } 44 } 45 46 public Locator getLocator() { 47 return fLocator; 48 } 49 50 53 54 public String getPublicId() { 55 if (fLocator != null) { 56 return fLocator.getPublicId(); 57 } 58 return null; 59 } 60 61 public String getLiteralSystemId() { 62 if (fLocator != null) { 63 return fLocator.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 (fLocator != null) { 78 return fLocator.getLineNumber(); 79 } 80 return -1; 81 } 82 83 public int getColumnNumber() { 84 if (fLocator != null) { 85 return fLocator.getColumnNumber(); 86 } 87 return -1; 88 } 89 90 public int getCharacterOffset() { 91 return -1; 92 } 93 94 public String getEncoding() { 95 if (fLocator2 != null) { 96 return fLocator2.getEncoding(); 97 } 98 return null; 99 } 100 101 public String getXMLVersion() { 102 if (fLocator2 != null) { 103 return fLocator2.getXMLVersion(); 104 } 105 return null; 106 } 107 108 } | Popular Tags |