1 23 24 29 30 package com.sun.jdo.spi.persistence.support.sqlstore.query.jqlc; 31 32 import java.util.ResourceBundle ; 33 34 import com.sun.jdo.api.persistence.support.JDOQueryException; 35 import com.sun.jdo.api.persistence.support.JDOFatalInternalException; 36 import com.sun.jdo.api.persistence.support.JDOUnsupportedOptionException; 37 import com.sun.jdo.spi.persistence.utility.I18NHelper; 38 import com.sun.jdo.spi.persistence.utility.logging.Logger; 39 40 45 public class ErrorMsg 46 { 47 50 protected String context = null; 51 52 55 protected final static ResourceBundle messages = 56 I18NHelper.loadBundle(ErrorMsg.class); 57 58 59 private static Logger logger = LogHelperQueryCompilerJDO.getLogger(); 60 61 64 public String getContext() 65 { 66 return context; 67 } 68 69 72 public void setContext(String name) 73 { 74 context = name; 75 } 76 77 83 public void error(int line, int col, String msg) 84 throws JDOQueryException 85 { 86 JDOQueryException ex; 87 if (line > 1) 88 { 89 Object args[] = {context, new Integer (line), new Integer (col), msg}; 91 ex = new JDOQueryException(I18NHelper.getMessage( 92 messages, "jqlc.errormsg.generic.msglinecolumn", args)); } 94 else if (col > 0) 95 { 96 Object args[] = {context, new Integer (col), msg}; 98 ex = new JDOQueryException(I18NHelper.getMessage( 99 messages, "jqlc.errormsg.generic.msgcolumn", args)); } 101 else 102 { 103 Object args[] = {context, msg}; 104 ex = new JDOQueryException(I18NHelper.getMessage( 105 messages, "jqlc.errormsg.generic.msg", args)); } 107 logger.throwing("jqlc.ErrorMsg", "error", ex); 108 throw ex; 109 } 110 111 117 public void unsupported(int line, int col, String msg) 118 throws JDOUnsupportedOptionException 119 { 120 JDOUnsupportedOptionException ex; 121 if (line > 1) 122 { 123 Object args[] = {context, new Integer (line), new Integer (col), msg}; 125 ex = new JDOUnsupportedOptionException(I18NHelper.getMessage( 126 messages, "jqlc.errormsg.generic.msglinecolumn", args)); } 128 else if (col > 0) 129 { 130 Object args[] = {context, new Integer (col), msg}; 132 ex = new JDOUnsupportedOptionException(I18NHelper.getMessage( 133 messages, "jqlc.errormsg.generic.msgcolumn", args)); 135 } 136 else 137 { 138 Object args[] = {context, msg}; 139 ex = new JDOUnsupportedOptionException(I18NHelper.getMessage( 140 messages, "jqlc.errormsg.generic.msg", args)); } 142 logger.throwing("jqlc.ErrorMsg", "unsupported", ex); 143 throw ex; 144 } 145 146 150 public void fatal(String msg) 151 throws JDOFatalInternalException 152 { 153 JDOFatalInternalException ex = new JDOFatalInternalException(msg); 154 logger.throwing("jqlc.ErrorMsg", "fatal", ex); 155 throw ex; 156 } 157 158 162 public void fatal(String msg, Exception nested) 163 throws JDOFatalInternalException 164 { 165 JDOFatalInternalException ex = new JDOFatalInternalException(msg, nested); 166 logger.throwing("jqlc.ErrorMsg", "fatal", ex); 167 throw ex; 168 } 169 } 170 171 172 | Popular Tags |