1 61 62 package org.jaxen.saxpath; 63 64 65 70 public class XPathSyntaxException extends SAXPathException 71 { 72 private String xpath; 73 private int position; 74 private final static String lineSeparator = System.getProperty("line.separator"); 75 76 83 public XPathSyntaxException(String xpath, 84 int position, 85 String message) 86 { 87 super( message ); 88 this.position = position; 89 this.xpath = xpath; 90 } 91 92 101 public int getPosition() 102 { 103 return this.position; 104 } 105 106 113 public String getXPath() 114 { 115 return this.xpath; 116 } 117 118 public String toString() 119 { 120 return getClass() + ": " + getXPath() + ": " + getPosition() + ": " + getMessage(); 121 } 122 123 132 public String getPositionMarker() 133 { 134 int pos = getPosition(); 135 StringBuffer buf = new StringBuffer (pos+1); 136 for ( int i = 0 ; i < pos ; ++i ) 137 { 138 buf.append(" "); 139 } 140 141 buf.append("^"); 142 143 return buf.toString(); 144 145 } 146 147 155 public String getMultilineMessage() 156 { 157 StringBuffer buf = new StringBuffer (); 158 159 buf.append( getMessage() ); 160 buf.append( lineSeparator ); 161 buf.append( getXPath() ); 162 buf.append( lineSeparator ); 163 164 buf.append( getPositionMarker() ); 165 166 return buf.toString(); 167 } 168 169 } 170 | Popular Tags |