1 package org.ejen.ext; 22 23 import org.ejen.util.XSLUtil; 24 import org.ejen.EjenChildNode; 25 import java.sql.SQLException ; 26 import org.apache.xalan.extensions.XSLProcessorContext; 27 import org.apache.xalan.templates.ElemExtensionCall; 28 import org.apache.xml.utils.WrappedRuntimeException; 29 30 60 public class Messenger { 61 62 65 protected Messenger() {} 66 67 84 public static void send(XSLProcessorContext context, ElemExtensionCall elem) { 85 EjenChildNode.sendXSLMessageEvent(XSLUtil.getAttribute(context, elem, 86 "message", true)); 87 } 88 89 109 public static void throwSQLException(XSLProcessorContext context, ElemExtensionCall elem) 110 throws SQLException { 111 String message = XSLUtil.getAttribute(context, elem, "message", true); 112 String code = XSLUtil.getAttribute(context, elem, "code", true); 113 int iCode; 114 115 try { 116 iCode = Integer.parseInt(code); 117 } catch (NumberFormatException e) { 118 throw new WrappedRuntimeException("Invalid 'code' attribute in 'throwSQLException' node: " 119 + code + " (message: " + message + ")", 120 e); 121 } 122 throw new SQLException (message, null, iCode); 123 } 124 125 143 public static void throwRuntimeException(XSLProcessorContext context, ElemExtensionCall elem) { 144 context.getTransformer().stopTransformation(); 145 throw new RuntimeException (XSLUtil.getAttribute(context, elem, "message", 146 true)); 147 } 148 } 149
| Popular Tags
|