1 package net.sf.saxon.expr; 2 3 import net.sf.saxon.event.LocationProvider; 4 import net.sf.saxon.event.SaxonLocator; 5 import net.sf.saxon.instruct.LocationMap; 6 import net.sf.saxon.instruct.InstructionDetails; 7 8 import javax.xml.transform.SourceLocator ; 9 import java.io.Serializable ; 10 11 14 15 public class ExpressionLocation implements SaxonLocator, Serializable { 16 17 public ExpressionLocation() {} 18 19 public ExpressionLocation(SourceLocator loc) { 20 systemId = loc.getSystemId(); 21 lineNumber = loc.getLineNumber(); 22 } 23 24 public ExpressionLocation(LocationProvider provider, int locationId) { 25 systemId = provider.getSystemId(locationId); 26 lineNumber = provider.getLineNumber(locationId); 27 } 28 29 private String systemId; 30 private int lineNumber; 32 private int columnNumber = -1; 33 34 public String getSystemId() { 35 return systemId; 36 } 37 38 public String getPublicId() { 39 return null; 40 } 41 42 public int getLineNumber() { 43 return lineNumber; 44 } 45 46 public int getColumnNumber() { 47 return columnNumber; 48 } 49 50 public void setSystemId(String systemId) { 51 this.systemId = systemId; 52 } 53 54 public void setPublicId(String publicId) { 55 } 57 58 public void setLineNumber(int lineNumber) { 59 this.lineNumber = lineNumber; 60 } 61 62 public void setColumnNumber(int columnNumber) { 63 this.columnNumber = columnNumber; 64 } 65 66 public String getSystemId(int locationId) { 67 return getSystemId(); 68 } 69 70 public int getLineNumber(int locationId) { 71 return getLineNumber(); 72 } 73 74 80 public static SaxonLocator getSourceLocator(int locationId, LocationProvider locationProvider) { 81 SaxonLocator locator; 82 if (locationProvider instanceof LocationMap && locationId != 0) { 83 ExpressionLocation loc = new ExpressionLocation(); 85 loc.setLineNumber(locationProvider.getLineNumber(locationId)); 86 loc.setSystemId(locationProvider.getSystemId(locationId)); 87 locator = loc; 88 } else if (locationProvider instanceof SaxonLocator) { 89 locator = (SaxonLocator)locationProvider; 91 } else { 92 return new InstructionDetails(); 95 } 96 return locator; 97 } 98 } 99 | Popular Tags |