⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 standardexception.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	public static StandardException newException(String messageID, Throwable t, Object a1, Object a2, Object a3) {		Object[] oa = new Object[] {a1, a2, a3};		return new StandardException(messageID, t, oa);	}	/* 4 arguments */	public static StandardException newException(String messageID, Object a1, Object a2, Object a3, Object a4) {		Object[] oa = new Object[] {a1, a2, a3, a4};		return new StandardException(messageID, oa);	}	public static StandardException newException(String messageID, Throwable t, Object a1, Object a2, Object a3, Object a4) {		Object[] oa = new Object[] {a1, a2, a3, a4};		return new StandardException(messageID, t, oa);	} 	/* 5 arguments */	public static StandardException newException(String messageID, Object a1, Object a2, Object a3, Object a4, Object a5) {		Object[] oa = new Object[] {a1, a2, a3, a4, a5};		return new StandardException(messageID, oa);	}	public static StandardException newException(String messageID, Throwable t, Object a1, Object a2, Object a3, Object a4, Object a5) {		Object[] oa = new Object[] {a1, a2, a3, a4, a5};		return new StandardException(messageID, t, oa);	}	/* 6 arguments */	public static StandardException newException(String messageID, Object a1, Object a2, Object a3, Object a4, Object a5, Object a6) {		Object[] oa = new Object[] {a1, a2, a3, a4, a5, a6};		return new StandardException(messageID, oa);	}	public static StandardException newException(String messageID, Throwable t, Object a1, Object a2, Object a3, Object a4, Object a5, Object a6) {		Object[] oa = new Object[] {a1, a2, a3, a4, a5, a6};		return new StandardException(messageID, t, oa);	}	/* 7 arguments */	public static StandardException newException(String messageID, Object a1, Object a2, Object a3, Object a4, Object a5, Object a6, Object a7) {		Object[] oa = new Object[] {a1, a2, a3, a4, a5, a6, a7};		return new StandardException(messageID, oa);	}	public static StandardException newException(String messageID, Throwable t, Object a1, Object a2, Object a3, Object a4, Object a5, Object a6, Object a7) {		Object[] oa = new Object[] {a1, a2, a3, a4, a5, a6, a7};		return new StandardException(messageID, t, oa);	}	/* 8 arguments */	public static StandardException newException(String messageID, Object a1, Object a2, Object a3, Object a4, Object a5, Object a6, Object a7, Object a8) {		Object[] oa = new Object[] {a1, a2, a3, a4, a5, a6, a7, a8};		return new StandardException(messageID, oa);	}	public static StandardException newException(String messageID, Throwable t, Object a1, Object a2, Object a3, Object a4, Object a5, Object a6, Object a7, Object a8) {		Object[] oa = new Object[] {a1, a2, a3, a4, a5, a6, a7, a8};		return new StandardException(messageID, t, oa);	}    /**     * Creates a new StandardException using message text that has already been localized.     *     * @param MessageID The SQLState and severity are derived from the ID. However the text message is not.     * @param t The Throwable that caused this exception, null if this exception was not caused by another Throwable.     * @param localizedMessage The message associated with this exception.     *        <b>It is the caller's responsibility to ensure that this message is properly localized.</b>     *     * @see org.apache.derby.iapi.tools.i18n.LocalizedResource     */    public static StandardException newPreLocalizedException( String MessageID,                                                              Throwable t,                                                              String localizedMessage)    {        StandardException se = new StandardException( MessageID, localizedMessage);        if( t != null)            se.nestedException = t;        return se;    }	public static StandardException unexpectedUserException(Throwable t)	{		/*		** If we have a SQLException that isn't a Util		** (i.e. it didn't come from cloudscape), then we check		** to see if it is a valid user defined exception range 		** (38001-38XXX).  If so, then we convert it into a 		** StandardException without further ado.		*/ 		if ((t instanceof SQLException) &&		    !(t instanceof EmbedSQLException)) 		{			SQLException sqlex  = (SQLException)t;			String state = sqlex.getSQLState();			if ((state != null) && 				(state.length() == 5) &&				state.startsWith("38") &&				!state.equals("38000"))			{				StandardException se = new StandardException(state, sqlex.getMessage());				if (sqlex.getNextException() != null)						{						se.setNestedException(sqlex.getNextException());				}				return se;			}		}		// Look for simple wrappers for 3.0.1 - will be cleaned up in main		if (t instanceof EmbedSQLException) {			EmbedSQLException csqle = (EmbedSQLException) t;			if (csqle.isSimpleWrapper()) {				Throwable wrapped = csqle.getJavaException();				if (wrapped instanceof StandardException)					return (StandardException) wrapped;			}		}		// no need to wrap a StandardException		if (t instanceof StandardException) 		{			return (StandardException) t;		}		else		{			/*			** 			** The exception at this point could be a:			**			**    standard java exception, e.g. NullPointerException			**    SQL Exception - from some server-side JDBC			**    3rd party exception - from some application			**    some cloudscape exception that is not a standard exception.			**    			**    			** We don't want to call t.toString() here, because the JVM is			** inconsistent about whether it includes a detail message			** with some exceptions (esp. NullPointerException).  In those			** cases where there is a detail message, t.toString() puts in			** a colon character, even when the detail message is blank.			** So, we do our own string formatting here, including the colon			** only when there is a non-blank message.			**			** The above is because our test canons contain the text of			** error messages.			**			** In addition we don't want to place the class name in an			** exception when the class is from cloudscape because			** the class name changes in obfuscated builds. Thus for			** exceptions that are in a package below com.ibm.db2j			** we use toString(). If this returns an empty or null			** then we use the class name to make tracking the problem			** down easier, though the lack of a message should be seen			** as a bug.			*/			String	detailMessage;			boolean cloudscapeException = false;			if (t instanceof EmbedSQLException) {				detailMessage = ((EmbedSQLException) t).toString();				cloudscapeException = true;			}			else {				detailMessage = t.getMessage();			}			if (detailMessage == null)			{				detailMessage = "";			} else {				detailMessage = detailMessage.trim();			}			// if no message, use the class name			if (detailMessage.length() == 0) {				detailMessage = t.getClass().getName();			}			else {				if (!cloudscapeException) {					detailMessage = t.getClass().getName() + ": " + detailMessage;				}			}			StandardException se =				newException(SQLState.LANG_UNEXPECTED_USER_EXCEPTION, t, detailMessage);			return se;		}	}	/**		Similar to unexpectedUserException but makes no assumtion about		when the execption is being called. The error is wrapped as simply		as possible.	*/	public static StandardException plainWrapException(Throwable t) {		if (t instanceof StandardException)			return (StandardException) t;		if (t instanceof SQLException) {			SQLException sqle = (SQLException) t;			String sqlState = sqle.getSQLState();			if (sqlState != null) {				StandardException se = new StandardException(sqlState, "(" + sqle.getErrorCode()  + ") " + sqle.getMessage());				sqle = sqle.getNextException();				if (sqle != null)					se.setNestedException(plainWrapException(sqle));				return se;			}		}		String	detailMessage = t.getMessage();		if (detailMessage == null)		{			detailMessage = "";		} else {			detailMessage = detailMessage.trim();		}				StandardException se =				newException(SQLState.JAVA_EXCEPTION, t, detailMessage, t.getClass().getName());		return se;	}	/**	** A special exception to close a session.	*/	public static StandardException closeException() {		StandardException se = newException(SQLState.CLOSE_REQUEST);		se.setReport(REPORT_NEVER);		return se;	}	/*	** Message handling	*/	/**		The message stored in the super class Throwable must be set		up object creation. At this time we cannot get any information		about the object itself (ie. this) in order to determine the		natural language message. Ie. we need to class of the objec in		order to look up its message, but we can't get the class of the		exception before calling the super class message.		<P>		Thus the message stored by Throwable and obtained by the		getMessage() of Throwable (ie. super.getMessage() in this		class) is the message identifier. The actual text message		is stored in this class at the first request.	*/	public String getMessage() {		if (textMessage == null)			textMessage = MessageService.getCompleteMessage(getMessageId(), getArguments());		return textMessage;	}	/**		Return the message identifier that is used to look up the		error message text in the messages.properties file.	*/	public final String getMessageId() {		return super.getMessage();	}	/**		Get the error code for an error given a type. The value of		the property messageId.type will be returned, e.g.		deadlock.sqlstate.	*/	public String getErrorProperty(String type) {		return getErrorProperty(getMessageId(), type);	}	/**		Don't print the class name in the toString() method.	*/	public String toString() {		String msg = getMessage();		return "ERROR " + getSQLState() + ": " + msg;	}	/*	** Static methods	*/	private static String getErrorProperty(String messageId, String type) {		return MessageService.getProperty(messageId, type);	}	public static StandardException interrupt(InterruptedException ie) {		StandardException se = StandardException.newException(SQLState.CONN_INTERRUPT, ie);		return se;	}	/*	** SQL warnings	*/	public static SQLWarning newWarning(String messageId) {		return newWarningCommon( messageId, (Object[]) null );	}	public static SQLWarning newWarning(String messageId, Object a1) {		Object[] oa = new Object[] {a1};		return newWarningCommon( messageId, oa );	}	public static SQLWarning newWarning(String messageId, Object a1, Object a2) {		Object[] oa = new Object[] {a1, a2};		return newWarningCommon( messageId, oa );	}	private	static	SQLWarning	newWarningCommon( String messageId, Object[] oa )	{		String		message = MessageService.getCompleteMessage(messageId, oa);		String		state = StandardException.getSQLStateFromIdentifier(messageId);		SQLWarning	sqlw = new SQLWarning(message, state, ExceptionSeverity.WARNING_SEVERITY);		return sqlw;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -