1 16 19 package org.apache.xalan.transformer; 20 21 import javax.xml.transform.ErrorListener ; 22 import javax.xml.transform.SourceLocator ; 23 import javax.xml.transform.TransformerException ; 24 25 import org.apache.xalan.res.XSLMessages; 26 27 import org.w3c.dom.Node ; 28 29 33 public class MsgMgr 34 { 35 36 41 public MsgMgr(TransformerImpl transformer) 42 { 43 m_transformer = transformer; 44 } 45 46 47 private TransformerImpl m_transformer; 48 49 60 public void message(SourceLocator srcLctr, String msg, boolean terminate) throws TransformerException 61 { 62 63 ErrorListener errHandler = m_transformer.getErrorListener(); 64 65 if (null != errHandler) 66 { 67 errHandler.warning(new TransformerException (msg, srcLctr)); 68 } 69 else 70 { 71 if (terminate) 72 throw new TransformerException (msg, srcLctr); 73 else 74 System.out.println(msg); 75 } 76 } 77 78 88 public void warn(SourceLocator srcLctr, String msg) throws TransformerException 89 { 90 warn(srcLctr, null, null, msg, null); 91 } 92 93 104 public void warn(SourceLocator srcLctr, String msg, Object [] args) throws TransformerException 105 { 106 warn(srcLctr, null, null, msg, args); 107 } 108 109 122 public void warn(SourceLocator srcLctr, Node styleNode, Node sourceNode, String msg) 123 throws TransformerException 124 { 125 warn(srcLctr, styleNode, sourceNode, msg, null); 126 } 127 128 141 public void warn(SourceLocator srcLctr, Node styleNode, Node sourceNode, String msg, Object args[]) 142 throws TransformerException 143 { 144 145 String formattedMsg = XSLMessages.createWarning(msg, args); 146 ErrorListener errHandler = m_transformer.getErrorListener(); 147 148 if (null != errHandler) 149 errHandler.warning(new TransformerException (formattedMsg, srcLctr)); 150 else 151 System.out.println(formattedMsg); 152 } 153 154 181 182 193 public void error(SourceLocator srcLctr, String msg) throws TransformerException 194 { 195 error(srcLctr, null, null, msg, null); 196 } 197 198 210 public void error(SourceLocator srcLctr, String msg, Object [] args) throws TransformerException 211 { 212 error(srcLctr, null, null, msg, args); 213 } 214 215 227 public void error(SourceLocator srcLctr, String msg, Exception e) throws TransformerException 228 { 229 error(srcLctr, msg, null, e); 230 } 231 232 245 public void error(SourceLocator srcLctr, String msg, Object args[], Exception e) throws TransformerException 246 { 247 248 String formattedMsg = XSLMessages.createMessage(msg, args); 250 251 ErrorListener errHandler = m_transformer.getErrorListener(); 256 257 if (null != errHandler) 258 errHandler.fatalError(new TransformerException (formattedMsg, srcLctr)); 259 else 260 throw new TransformerException (formattedMsg, srcLctr); 261 } 262 263 276 public void error(SourceLocator srcLctr, Node styleNode, Node sourceNode, String msg) 277 throws TransformerException 278 { 279 error(srcLctr, styleNode, sourceNode, msg, null); 280 } 281 282 296 public void error(SourceLocator srcLctr, Node styleNode, Node sourceNode, String msg, Object args[]) 297 throws TransformerException 298 { 299 300 String formattedMsg = XSLMessages.createMessage(msg, args); 301 302 ErrorListener errHandler = m_transformer.getErrorListener(); 307 308 if (null != errHandler) 309 errHandler.fatalError(new TransformerException (formattedMsg, srcLctr)); 310 else 311 throw new TransformerException (formattedMsg, srcLctr); 312 } 313 } 314 | Popular Tags |