1 18 package org.apache.batik.bridge; 19 20 import org.apache.batik.gvt.GraphicsNode; 21 import org.w3c.dom.Element ; 22 import org.w3c.dom.svg.SVGDocument; 23 24 30 public class BridgeException extends RuntimeException { 31 32 33 protected Element e; 34 35 36 protected String code; 37 38 39 protected Object [] params; 40 41 42 protected int line; 43 44 45 protected GraphicsNode node; 46 47 54 public BridgeException(Element e, String code, Object [] params) { 55 this.e = e; 56 this.code = code; 57 this.params = params; 58 } 59 60 63 public Element getElement() { 64 return e; 65 } 66 67 70 public void setLineNumber(int line) { 71 this.line = line; 72 } 73 74 79 public void setGraphicsNode(GraphicsNode node) { 80 this.node = node; 81 } 82 83 86 public GraphicsNode getGraphicsNode() { 87 return node; 88 } 89 90 93 public String getMessage() { 94 String uri; 95 String lname = "<Unknown Element>"; 96 SVGDocument doc = null; 97 if (e != null) { 98 doc = (SVGDocument)e.getOwnerDocument(); 99 lname = e.getLocalName(); 100 } 101 if (doc == null) uri = "<Unknown Document>"; 102 else uri = doc.getURL(); 103 Object [] fullparams = new Object [params.length+3]; 104 fullparams[0] = uri; 105 fullparams[1] = new Integer (line); 106 fullparams[2] = lname; 107 for (int i=0; i < params.length; ++i) { 108 fullparams[i+3] = params[i]; 109 } 110 return Messages.formatMessage(code, fullparams); 111 } 112 113 116 public String getCode() { 117 return code; 118 } 119 } 120 | Popular Tags |