1 package net.sf.saxon.type; 2 3 import net.sf.saxon.trans.XPathException; 4 import org.xml.sax.Locator ; 5 6 import javax.xml.transform.SourceLocator ; 7 8 12 13 public class ValidationException extends XPathException 14 implements SourceLocator , Locator { 15 16 private String systemId; 17 private String publicId; 18 private int lineNumber = -1; 19 private int columnNumber = -1; 20 21 25 public ValidationException(String message) { 26 super(message); 27 } 28 29 34 public ValidationException(Exception exception) { 35 super(exception); 36 } 37 38 44 public ValidationException(String message, Exception exception) { 45 super(message, exception); 46 } 47 48 53 public ValidationException(String message, SourceLocator locator) { 54 super(message, locator); 55 setSourceLocator(locator); 60 } 61 62 66 public String toString() { 67 StringBuffer sb = new StringBuffer ("ValidationException: "); 68 String message = getMessage(); 69 if (message != null) sb.append(message); 70 return sb.toString(); 71 } 72 73 public String getPublicId() { 74 if (publicId == null && getLocator() != this) { 75 return getLocator().getPublicId(); 76 } else{ 77 return publicId; 78 } 79 } 80 81 public String getSystemId() { 82 if (systemId == null && getLocator() != this) { 83 return getLocator().getSystemId(); 84 } else{ 85 return systemId; 86 } 87 } 88 89 public int getLineNumber() { 90 if (lineNumber == -1 && getLocator() != this) { 91 return getLocator().getLineNumber(); 92 } else{ 93 return lineNumber; 94 } 95 } 96 97 public int getColumnNumber() { 98 if (columnNumber == -1 && getLocator() != this) { 99 return getLocator().getColumnNumber(); 100 } else{ 101 return columnNumber; 102 } 103 } 104 105 public void setPublicId(String id) { 106 publicId = id; 107 } 108 109 public void setSystemId(String id) { 110 systemId = id; 111 } 112 113 public void setLineNumber(int line) { 114 lineNumber = line; 115 } 116 117 public void setColumnNumber(int column) { 118 columnNumber = column; 119 } 120 121 public void setLocator(Locator locator) { 122 setPublicId(locator.getPublicId()); 123 setSystemId(locator.getSystemId()); 124 setLineNumber(locator.getLineNumber()); 125 setColumnNumber(locator.getColumnNumber()); 126 super.setLocator(null); 127 } 128 129 public void setSourceLocator(SourceLocator locator) { 130 setPublicId(locator.getPublicId()); 131 setSystemId(locator.getSystemId()); 132 setLineNumber(locator.getLineNumber()); 133 setColumnNumber(locator.getColumnNumber()); 134 super.setLocator(null); 135 } 136 137 public SourceLocator getLocator() { 138 SourceLocator loc = super.getLocator(); 139 if (loc != null) { 140 return loc; 141 } else { 142 return this; 143 } 144 } 145 146 } 147 148 | Popular Tags |