You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2013/06/10 10:07:04 UTC
svn commit: r1491366 -
/db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/StandardException.java
Author: kahatlen
Date: Mon Jun 10 08:07:04 2013
New Revision: 1491366
URL: http://svn.apache.org/r1491366
Log:
DERBY-6254: Reduce number of factory methods in StandardException
Generalize the factory methods by using varargs.
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/StandardException.java
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/StandardException.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/StandardException.java?rev=1491366&r1=1491365&r2=1491366&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/StandardException.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/StandardException.java Mon Jun 10 08:07:04 2013
@@ -71,11 +71,6 @@ public class StandardException extends E
}
- protected StandardException(String messageID, Object[] args)
- {
- this(messageID, (Throwable) null, args);
- }
-
protected StandardException(String messageID, Throwable t, Object[] args)
{
super(messageID);
@@ -260,39 +255,18 @@ public class StandardException extends E
return se;
}
- /* 0 arguments */
-
- public static StandardException newException(String messageID) {
- return new StandardException(messageID);
- }
- public static StandardException newException(String messageID, Throwable t) {
- return new StandardException(messageID, t, (Object[]) null);
- }
-
- /* 1 argument */
-
- public static StandardException newException(String messageID, Object a1) {
- Object[] oa = new Object[] {a1};
- return new StandardException(messageID, oa);
- }
-
- public static StandardException newException(String messageID,
- Object[] a1) {
- return new StandardException(messageID, a1);
- }
+ public static StandardException
+ newException(String messageId, Object... args) {
+ return newException(messageId, (Throwable) null, args);
+ }
- public static StandardException newException(String messageID, Throwable t, Object a1) {
- Object[] oa = new Object[] {a1};
- return new StandardException(messageID, t, oa);
- }
+ public static StandardException
+ newException(String messageId, Throwable t, Object... args) {
+ return new StandardException(messageId, t, args);
+ }
/* 2 arguments */
- public static StandardException newException(String messageID, Object a1, Object a2) {
- Object[] oa = new Object[] {a1, a2};
- return new StandardException(messageID, oa);
- }
-
/**
* Dummy exception to catch incorrect use of
* StandardException.newException(), at compile-time. If you get a
@@ -321,18 +295,8 @@ public class StandardException extends E
throw new BadMessageArgumentException();
}
- public static StandardException newException(String messageID, Throwable t, Object a1, Object a2) {
- Object[] oa = new Object[] {a1, a2};
- return new StandardException(messageID, t, oa);
- }
-
/* 3 arguments */
- public static StandardException newException(String messageID, Object a1, Object a2, Object a3) {
- Object[] oa = new Object[] {a1, a2, a3};
- return new StandardException(messageID, oa);
- }
-
/**
* Dummy overload which should never be called. Only used to
* detect incorrect usage, at compile time.
@@ -351,62 +315,6 @@ public class StandardException extends E
throw new BadMessageArgumentException();
}
- 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.
*
@@ -693,27 +601,7 @@ public class StandardException extends E
** 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 )
+ public static SQLWarning newWarning(String messageId, Object... oa)
{
String message = MessageService.getCompleteMessage(messageId, oa);
String state = StandardException.getSQLStateFromIdentifier(messageId);