db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1493714 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/ engine/org/apache/derby/iapi/error/ engine/org/apache/derby/iapi/services/i18n/ engine/org/apache/derby/iapi/services/monitor/ engine/org/apache/derby/impl/jdbc/ en...
Date Mon, 17 Jun 2013 11:14:45 GMT
Author: kahatlen
Date: Mon Jun 17 11:14:45 2013
New Revision: 1493714

URL: http://svn.apache.org/r1493714
Log:
DERBY-6262: Simplify message-generating methods using varargs

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlException.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlWarning.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/SQLWarningFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/StandardException.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/i18n/MessageService.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/monitor/Monitor.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/IndexChanger.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/i18n/MessageUtil.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlException.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlException.java?rev=1493714&r1=1493713&r2=1493714&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlException.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlException.java Mon Jun 17
11:14:45 2013
@@ -158,9 +158,7 @@ public class SqlException extends Except
      *      Can be null.  Indicates the cause of this exception.  If this is
      *      an instance of SqlException or java.sql.SQLException then the exception
      *      is chained into the nextException chain.  Otherwise it is chained
-     *      using initCause().  On JDK 1.3, since initCause() does not exist,
-     *      a non-SQL exception can not be chained.  Instead, the exception class
-     *      and message text is appended to the message for this exception.
+     *      using initCause().
      */
     SqlException(LogWriter logwriter,
         ClientMessageId msgid, Object[] args, Throwable cause)
@@ -211,23 +209,13 @@ public class SqlException extends Except
         this (logwriter, msgid, (Object[])null, cause);
     }
     
-    private SqlException(LogWriter logwriter,
-                         ClientMessageId msgid,
-                         Object[] args)
+    public SqlException(LogWriter logwriter,
+                        ClientMessageId msgid,
+                        Object... args)
     {
         this(logwriter, msgid, args, (Throwable)null);
     }
-    
-    public SqlException (LogWriter logwriter, ClientMessageId msgid)
-    {
-        this(logwriter, msgid, (Object[])null);
-    }
-    
-    public SqlException(LogWriter logwriter, ClientMessageId msgid, Object arg1)
-    {
-        this(logwriter, msgid, new Object[] { arg1 });
-    }
-    
+
     public SqlException(LogWriter logwriter, ClientMessageId msgid, 
             Object arg1, Throwable cause)
     {
@@ -240,18 +228,6 @@ public class SqlException extends Except
         this(logwriter, msgid, new Object[] { arg1, arg2 }, cause);
     }
     
-    public SqlException(LogWriter logwriter,
-        ClientMessageId msgid, Object arg1, Object arg2)
-    {
-        this(logwriter, msgid, new Object[] { arg1, arg2 });
-    }
-    
-    public SqlException(LogWriter logwriter,
-        ClientMessageId msgid, Object arg1, Object arg2, Object arg3)
-    {
-        this(logwriter, msgid, new Object[] { arg1, arg2, arg3 });
-    }
-
     /**
      * Create an exception for an engine generated error.
      *

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlWarning.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlWarning.java?rev=1493714&r1=1493713&r2=1493714&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlWarning.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlWarning.java Mon Jun 17
11:14:45 2013
@@ -34,20 +34,9 @@ public class SqlWarning extends SqlExcep
 
     private SqlWarning nextWarning_;
     
-    SqlWarning (LogWriter logwriter, ClientMessageId msgid)
+    SqlWarning(LogWriter logwriter, ClientMessageId msgid, Object... args)
     {
-        super(logwriter, msgid);
-    }
-    
-    SqlWarning(LogWriter logwriter, ClientMessageId msgid, Object arg1)
-    {
-        super(logwriter, msgid, arg1);
-    }
-    
-    SqlWarning(LogWriter logwriter,
-        ClientMessageId msgid, Object arg1, Object arg2)
-    {
-        super(logwriter, msgid, arg1, arg2);
+        super(logwriter, msgid, args);
     }
     
     public SqlWarning(LogWriter logWriter, Sqlca sqlca)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/SQLWarningFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/SQLWarningFactory.java?rev=1493714&r1=1493713&r2=1493714&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/SQLWarningFactory.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/error/SQLWarningFactory.java Mon
Jun 17 11:14:45 2013
@@ -37,52 +37,6 @@ import org.apache.derby.shared.common.re
 public class SQLWarningFactory {
 
 	/**
-	 * Generates a SQLWarning instance based on the supplied messageId. It looks
-	 * up the messageId to generate a localised warning message. Also, SQLState
-	 * is set correctly based on the messageId.
-	 * 
-	 * @param messageId A Derby messageId as defined in{@link SQLState org.apache.derby.shared.common.reference.SQLState}.
-	 * @return Properly initialized SQLWarning instance.
-	 * @see org.apache.derby.shared.common.reference.SQLState
-	 */
-	public static SQLWarning newSQLWarning( String messageId )
-    {
-		return newSQLWarning(messageId, new Object[] {} );
-	}
-
-	/**
-	 * Generates a SQLWarning instance based on the supplied messageId and
-	 * argument. It looks up the messageId to generate a localised warning
-	 * message. Also, SQLState is set correctly based on the messageId.
-	 * 
-	 * @param messageId A Derby messageId as defined in {@link SQLState org.apache.derby.shared.common.reference.SQLState}.
-	 * @param arg1 An argument for the warning message
-	 * @return Properly initialized SQLWarning instance.
-	 * @see org.apache.derby.shared.common.reference.SQLState
-	 */
-	public static SQLWarning newSQLWarning( String messageId, Object arg1 )
-    {
-        return newSQLWarning( messageId, new Object[] { arg1 } );
-	}
-
-	/**
-	 * Generates a SQLWarning instance based on the supplied messageId and
-	 * arguments. It looks up the messageId to generate a localised warning
-	 * message. Also, SQLState is set correctly based on the messageId.
-	 * 
-	 * @param messageId
-	 *            A Derby messageId as defined in {@link SQLState org.apache.derby.shared.common.reference.SQLState}.
-	 * @param arg1 First argument for the warning message
-	 * @param arg2 Second argument for the warning message
-	 * @return Properly initialized SQLWarning instance.
-	 * @see org.apache.derby.shared.common.reference.SQLState
-	 */
-	public static SQLWarning newSQLWarning( String messageId, Object arg1, Object arg2 )
-    {
-        return newSQLWarning( messageId, new Object[] { arg1, arg2 } );
-	}
-
-	/**
 	 * Generates a SQLWarning instance based on the supplied messageId and
 	 * arguments. It looks up the messageId to generate a localised warning
 	 * message. Also, SQLState is set correctly based on the messageId.
@@ -92,11 +46,11 @@ public class SQLWarningFactory {
 	 * @return Properly initialized SQLWarning instance.
 	 * @see org.apache.derby.shared.common.reference.SQLState
 	 */
-	public static SQLWarning newSQLWarning( String messageId, Object[] args )
+    public static SQLWarning newSQLWarning(String messageId, Object... args)
     {
 		return new SQLWarning
             (
-             MessageService.getCompleteMessage( messageId, args ),
+             MessageService.getTextMessage( messageId, args ),
              StandardException.getSQLStateFromIdentifier(messageId),
              ExceptionSeverity.WARNING_SEVERITY
              );

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=1493714&r1=1493713&r2=1493714&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 17 11:14:45 2013
@@ -551,8 +551,10 @@ public class StandardException extends E
 	*/
 
 	public String getMessage() {
-		if (textMessage == null)
-			textMessage = MessageService.getCompleteMessage(getMessageId(), getArguments());
+        if (textMessage == null) {
+            textMessage = MessageService.getTextMessage(
+                                getMessageId(), getArguments());
+        }
 
 		return textMessage;
 	}
@@ -602,7 +604,7 @@ public class StandardException extends E
 
     public static SQLWarning newWarning(String messageId, Object... oa)
 	{
-		String		message = MessageService.getCompleteMessage(messageId, oa);
+        String      message = MessageService.getTextMessage(messageId, oa);
 		String		state = StandardException.getSQLStateFromIdentifier(messageId);
 		SQLWarning	sqlw = new SQLWarning(message, state, ExceptionSeverity.WARNING_SEVERITY);
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/i18n/MessageService.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/i18n/MessageService.java?rev=1493714&r1=1493713&r2=1493714&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/i18n/MessageService.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/i18n/MessageService.java
Mon Jun 17 11:14:45 2013
@@ -61,26 +61,6 @@ public final class MessageService {
 		finder = theFinder;
 	}
 
-	public static String getTextMessage(String messageID) {
-		return getCompleteMessage(messageID, (Object[]) null);
-	}
-	public static String getTextMessage(String messageID, Object a1) {
-
-		return getCompleteMessage(messageID, new Object[]{a1});
-	}
-	public static String getTextMessage(String messageID, Object a1, Object a2) {
-		return getCompleteMessage(messageID, new Object[]{a1, a2});
-	}
-	public static String getTextMessage(String messageID, Object a1, Object a2, Object a3) {
-		return getCompleteMessage(messageID, new Object[]{a1, a2, a3});
-	}
-	public static String getTextMessage(String messageID, Object a1, Object a2, Object a3, Object
a4) {
-		return getCompleteMessage(messageID, new Object[]{a1, a2, a3, a4});
-	}
-    public static String getTextMessage(String messageID, Object a1, Object a2, Object a3,
Object a4, Object a5) {
-        return getCompleteMessage(messageID, new Object[]{a1, a2, a3, a4, a5});
-    }
-
 	/**
 	  Transform the message from messageID to the actual error, warning, or
 	  info message using the correct locale.
@@ -91,8 +71,7 @@ public final class MessageService {
 	  object back from this array.
 
 	 */
-	public static String getCompleteMessage(String messageId, Object[] arguments) {
-
+    public static String getTextMessage(String messageId, Object... arguments) {
 		try {
 			return formatMessage(getBundle(messageId), messageId, arguments, true);
 		} catch (MissingResourceException mre) {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/monitor/Monitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/monitor/Monitor.java?rev=1493714&r1=1493713&r2=1493714&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/monitor/Monitor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/monitor/Monitor.java Mon
Jun 17 11:14:45 2013
@@ -685,20 +685,8 @@ public class Monitor {
 		getStream().println(messageText);
 	}
 
-	public static void logTextMessage(String messageID) {
-		getStream().println(MessageService.getTextMessage(messageID));
-	}
-	public static void logTextMessage(String messageID, Object a1) {
-		getStream().println(MessageService.getTextMessage(messageID, a1));
-	}
-	public static void logTextMessage(String messageID, Object a1, Object a2) {
-		getStream().println(MessageService.getTextMessage(messageID, a1, a2));
-	}
-	public static void logTextMessage(String messageID, Object a1, Object a2, Object a3) {
-		getStream().println(MessageService.getTextMessage(messageID, a1, a2, a3));
-	}
-	public static void logTextMessage(String messageID, Object a1, Object a2, Object a3, Object
a4) {
-		getStream().println(MessageService.getTextMessage(messageID, a1, a2, a3, a4));
+    public static void logTextMessage(String messageID, Object... args) {
+        getStream().println(MessageService.getTextMessage(messageID, args));
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java?rev=1493714&r1=1493713&r2=1493714&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java Mon Jun 17 11:14:45
2013
@@ -215,7 +215,7 @@ final class EmbedClob extends Connection
                 reader = this.clob.getInternalReader(pos);
             } catch (EOFException eofe) {
                 throw Util.generateCsSQLException(
-                        SQLState.BLOB_POSITION_TOO_LARGE, new Long(pos), eofe);
+                        SQLState.BLOB_POSITION_TOO_LARGE, eofe, pos);
             }
             char[] chars = new char[length];
             int charsRead = 0;
@@ -401,7 +401,7 @@ final class EmbedClob extends Connection
         } catch (EOFException eofe) {
             restoreIntrFlagIfSeen(pushStack, ec);
             throw Util.generateCsSQLException(
-                                        SQLState.BLOB_POSITION_TOO_LARGE, eofe);
+                    SQLState.BLOB_POSITION_TOO_LARGE, eofe, start);
         } catch (IOException ioe) {
             restoreIntrFlagIfSeen(pushStack, ec);
             throw Util.setStreamFailure(ioe);
@@ -677,7 +677,7 @@ restartScan:
         catch (EOFException eofe) {
             throw Util.generateCsSQLException(
                         SQLState.BLOB_LENGTH_TOO_LONG,
-                        new Long(len), eofe);
+                        eofe, len);
         } catch (IOException e) {
             throw Util.setStreamFailure(e);
         }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory.java?rev=1493714&r1=1493713&r2=1493714&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory.java Mon
Jun 17 11:14:45 2013
@@ -116,7 +116,7 @@ public class SQLExceptionFactory extends
     @Override
     public final SQLException getSQLException(String messageId,
             SQLException next, Throwable cause, Object... args) {
-        String message = MessageService.getCompleteMessage(messageId, args);
+        String message = MessageService.getTextMessage(messageId, args);
         int severity = StandardException.getSeverityFromIdentifier(messageId);
         return getSQLException(message, messageId, next, severity, cause, args);
     }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java?rev=1493714&r1=1493713&r2=1493714&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/Util.java Mon Jun 17 11:14:45
2013
@@ -137,8 +137,7 @@ public abstract class Util  {
 
 	private static SQLException newEmbedSQLException(String messageId,
 			Object[] args, SQLException next, int severity, Throwable t) {
-        String message = MessageService.getCompleteMessage
-                                        (messageId, args);
+        String message = MessageService.getTextMessage(messageId, args);
         return ExceptionFactory.getInstance().getSQLException(
 			    message, messageId, next, severity, t, args);
 	}
@@ -282,10 +281,10 @@ public abstract class Util  {
         		StandardException.getSeverityFromIdentifier(error));
 	}
 
-	static SQLException generateCsSQLException(
-                    String error, Object arg1, Throwable t) {
+    static SQLException generateCsSQLException(
+                    String error, Throwable t, Object... args) {
 		return newEmbedSQLException(error,
-			new Object[] {arg1},
+                args,
                 StandardException.getSeverityFromIdentifier(error), t);
 	}
 
@@ -362,7 +361,7 @@ public abstract class Util  {
 		msg = e.getMessage();
 		if (msg == null) 
 			msg = e.getClass().getName();
-        return generateCsSQLException(SQLState.SET_STREAM_FAILURE, msg, e);
+        return generateCsSQLException(SQLState.SET_STREAM_FAILURE, e, msg);
 	}
 
 	static SQLException typeMisMatch(int targetSQLType) {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/IndexChanger.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/IndexChanger.java?rev=1493714&r1=1493713&r2=1493714&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/IndexChanger.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/IndexChanger.java Mon
Jun 17 11:14:45 2013
@@ -357,7 +357,7 @@ class IndexChanger
                 args[0] = ourIndexRow.getRowArray()[ourIndexRow.getRowArray().length - 1];
                 args[1] = new Long(indexCID);
 
-                Monitor.getStream().println(MessageService.getCompleteMessage(
+                Monitor.getStream().println(MessageService.getTextMessage(
                     SQLState.LANG_IGNORE_MISSING_INDEX_ROW_DURING_DELETE, 
                     args));
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java?rev=1493714&r1=1493713&r2=1493714&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java
Mon Jun 17 11:14:45 2013
@@ -1943,7 +1943,7 @@ public class BaseDataFileFactory
                 {
 
                     String warningMsg = 
-                      MessageService.getCompleteMessage(
+                      MessageService.getTextMessage(
                           SQLState.DATA_MULTIPLE_JBMS_WARNING, args);
 
                     logMsg(warningMsg);

Modified: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/i18n/MessageUtil.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/i18n/MessageUtil.java?rev=1493714&r1=1493713&r2=1493714&view=diff
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/i18n/MessageUtil.java (original)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/i18n/MessageUtil.java Mon
Jun 17 11:14:45 2013
@@ -54,36 +54,11 @@ public class MessageUtil
         this.resourceBundleName = resourceBundleName;
     }
     
-    /** Get a message with default locale - no arguments */
-       public String getTextMessage(String messageID) 
-    {
-        return getCompleteMessage(messageID, (Object[]) null);
-    }
-    
-    /** Get a message with default locale - one argument */
-    public String getTextMessage(String messageID, Object a1) 
-    {
-        return getCompleteMessage(messageID, new Object[]{a1});
-    }
-    
-    /** Get a message with default locale - two arguments */
-    public String getTextMessage(String messageID, Object a1, Object a2) 
-    {
-        return getCompleteMessage(messageID, new Object[]{a1, a2});
-    }
-    
-    /** Get a message with default locale - three arguments */
-    public String getTextMessage(String messageID, Object a1, Object a2, 
-        Object a3) 
-    {
-        return getCompleteMessage(messageID, new Object[]{a1, a2, a3});
-    }
-    
-    /** Get a message with default locale - four arguments */
-    public String getTextMessage(String messageID, Object a1, Object a2, 
-        Object a3, Object a4) 
-    {
-        return getCompleteMessage(messageID, new Object[]{a1, a2, a3, a4});
+    /**
+     * Get a message with default locale.
+     */
+    public String getTextMessage(String messageID, Object... args) {
+        return getCompleteMessage(messageID, args);
     }
     
     /** 



Mime
View raw message