1 4 5 9 10 package org.openlaszlo.compiler; 11 import org.jdom.Namespace; 12 13 17 public class SourceLocator { 18 String pathname; 19 20 String messagePathname; 21 int startLineNumber; 22 int startColumnNumber; 23 int endLineNumber; 24 int endColumnNumber; 25 26 27 private static String serializationSeparator = "[]"; 28 29 static SourceLocator fromString(String string) { 30 SourceLocator locator = new SourceLocator(); 31 java.util.StringTokenizer st = new java.util.StringTokenizer (string, serializationSeparator); 32 locator.pathname = st.nextToken(); 33 locator.messagePathname = st.nextToken(); 34 locator.startLineNumber = Integer.parseInt(st.nextToken()); 35 locator.startColumnNumber = Integer.parseInt(st.nextToken()); 36 locator.endLineNumber = Integer.parseInt(st.nextToken()); 37 locator.endColumnNumber = Integer.parseInt(st.nextToken()); 38 return locator; 39 } 40 41 public String toString() { 42 StringBuffer buffer = new StringBuffer (); 43 buffer.append(pathname); 44 buffer.append(serializationSeparator); 45 buffer.append(messagePathname); 46 buffer.append(serializationSeparator); 47 buffer.append(startLineNumber); 48 buffer.append(serializationSeparator); 49 buffer.append(startColumnNumber); 50 buffer.append(serializationSeparator); 51 buffer.append(endLineNumber); 52 buffer.append(serializationSeparator); 53 buffer.append(endColumnNumber); 54 return buffer.toString(); 55 } 56 57 public void setPathname(String pathname, String messagePathname) { 58 if (this.pathname != null && !this.pathname.equals(pathname)) { 59 throw new RuntimeException ("element start and end don't match"); 60 } 61 if (this.messagePathname != null && !this.messagePathname.equals(messagePathname)) { 62 throw new RuntimeException ("element start and end don't match"); 63 } 64 this.pathname = pathname; 65 this.messagePathname = messagePathname; 66 } 67 } 68 69 | Popular Tags |