harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r410592 - in /incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging: FileHandler.java Handler.java Level.java LogRecord.java Logger.java MemoryHandler.java XMLFormatter.java
Date Wed, 31 May 2006 16:42:03 GMT
Author: tellison
Date: Wed May 31 09:42:02 2006
New Revision: 410592

URL: http://svn.apache.org/viewvc?rev=410592&view=rev
Log:
Generics uplift for java.util.logging

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Handler.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Level.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogRecord.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/MemoryHandler.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/XMLFormatter.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java?rev=410592&r1=410591&r2=410592&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java
Wed May 31 09:42:02 2006
@@ -119,7 +119,7 @@
      * ---------------------------------------------
      */
     //maintain all file locks hold by this process
-    private static Hashtable allLocks = new Hashtable();
+    private static Hashtable<String, FileLock> allLocks = new Hashtable<String,
FileLock>();
 
     /*
      * ---------------------------------------------
@@ -539,7 +539,7 @@
         super.publish(record);
         flush();
         if (limit > 0 && output.getLength() >= limit) {
-            AccessController.doPrivileged(new PrivilegedAction() {
+            AccessController.doPrivileged(new PrivilegedAction<Object>() {
                 public Object run() {
                     findNextGeneration();
                     return null;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Handler.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Handler.java?rev=410592&r1=410591&r2=410592&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Handler.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Handler.java
Wed May 31 09:42:02 2006
@@ -103,9 +103,8 @@
     // get a instance from given class name, using context classloader
     private Object getCustomizeInstance(final String className)
             throws Exception {
-        Class c = (Class) AccessController
-                .doPrivileged(new PrivilegedExceptionAction() {
-                    public Object run() throws Exception {
+        Class c = AccessController.doPrivileged(new PrivilegedExceptionAction<Class>()
{
+                    public Class run() throws Exception {
                         ClassLoader loader = Thread.currentThread()
                                 .getContextClassLoader();
                         if (null == loader)

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Level.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Level.java?rev=410592&r1=410591&r2=410592&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Level.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Level.java
Wed May 31 09:42:02 2006
@@ -51,7 +51,7 @@
      * Class variables
      * -------------------------------------------------------------------
      */
-    private static Map levels = new HashMap();
+    private static Map<String, Level> levels = new HashMap<String, Level>();
 	
     // The following string constants define the name of all predefined levels.
     private static final String SEVERESTR = "SEVERE"; //$NON-NLS-1$
@@ -251,10 +251,11 @@
      *             When <code>name</code> cannot be parsed.
      */
     public static final Level parse(String name) {
-        if (null == name)
-            throw new NullPointerException("null"); //$NON-NLS-1$
+        if (null == name) {
+            throw new NullPointerException("null"); //$NON-NLS-1$
+        }
         // Check if the name is a predefined one
-        Level result = (Level) levels.get(name);
+        Level result = levels.get(name);
         if (null != result) {
             return result;
         }
@@ -300,7 +301,7 @@
      */
     private Object readResolve() {
         String levelName = this.getName();
-        Level result = (Level) levels.get(levelName);
+        Level result = levels.get(levelName);
 
         if (null != result) {
             boolean sameResourceBundle = (this.resourceBundleName == null ? result

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogRecord.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogRecord.java?rev=410592&r1=410591&r2=410592&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogRecord.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/LogRecord.java
Wed May 31 09:42:02 2006
@@ -42,7 +42,6 @@
  */
 public class LogRecord implements Serializable {
 
-    //for serialization compability with J2SE1.4.2
     private static final long serialVersionUID = 5372048053134512534L;
     
     /*
@@ -67,7 +66,7 @@
     private static long currentSequenceNumber = 0;
 
     // Store the id for each thread.
-    private static ThreadLocal currentThreadId = new ThreadLocal();
+    private static ThreadLocal<Integer> currentThreadId = new ThreadLocal<Integer>();
 
     // The base id as the starting point for thread ID allocation.
     private static int initThreadId = 0;
@@ -225,8 +224,9 @@
      *            the level to set
      */
     public void setLevel(Level level) {
-        if (null == level)
-            throw new NullPointerException("null"); //$NON-NLS-1$
+        if (null == level) {
+            throw new NullPointerException("null"); //$NON-NLS-1$
+        }
         this.level = level;
     }
 
@@ -485,9 +485,8 @@
             out.writeInt(-1);
         } else {
             out.writeInt(parameters.length);
-            for (int i = 0; i < parameters.length; i++) {
-                out.writeObject(null == parameters[i] ? null : parameters[i]
-                        .toString());
+            for (Object element : parameters) {
+                out.writeObject(null == element ? null : element.toString());
             }
         }
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java?rev=410592&r1=410591&r2=410592&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/Logger.java
Wed May 31 09:42:02 2006
@@ -120,7 +120,7 @@
     private ResourceBundle resBundle;
 
     // the handlers attached to this logger
-    private Vector handlers;
+    private Vector<Handler> handlers;
 
     /*
      * flag indicating whether to notify parent's handlers on receiving a log
@@ -162,7 +162,7 @@
         this.parent = null;
         this.level = null;
         this.filter = null;
-        this.handlers = new Vector();
+        this.handlers = new Vector<Handler>();
         this.notifyParentHandlers = true;
         // any logger is not anonymous by default
         this.isNamed = true;
@@ -185,9 +185,9 @@
      */
     static ResourceBundle loadResourceBundle(String resourceBundleName) {
         // try context class loader to load the resource
-        ClassLoader cl = (ClassLoader) AccessController
-                .doPrivileged(new PrivilegedAction() {
-                    public Object run() {
+        ClassLoader cl = AccessController.doPrivileged(
+                new PrivilegedAction<ClassLoader>() {
+                    public ClassLoader run() {
                         return Thread.currentThread().getContextClassLoader();
                     }
                 });
@@ -200,9 +200,9 @@
             }
         }
         // try system class loader to load the resource
-        cl = (ClassLoader) AccessController
-                .doPrivileged(new PrivilegedAction() {
-                    public Object run() {
+        cl = AccessController.doPrivileged(
+                new PrivilegedAction<ClassLoader>() {
+                    public ClassLoader run() {
                         return ClassLoader.getSystemClassLoader();
                     }
                 });
@@ -221,9 +221,9 @@
         for (int i = 1; i < classes.length; i++) {
             final int index = i;
             try {
-                cl = (ClassLoader) AccessController
-                        .doPrivileged(new PrivilegedAction() {
-                            public Object run() {
+                cl = AccessController.doPrivileged(
+                        new PrivilegedAction<ClassLoader>() {
+                            public ClassLoader run() {
                                 return classes[index].getClassLoader();
                             }
                         });
@@ -398,7 +398,7 @@
      * @return an array of all the hanlders associated with this logger
      */
     public synchronized Handler[] getHandlers() {
-        return (Handler[]) this.handlers.toArray(new Handler[0]);
+        return this.handlers.toArray(new Handler[0]);
     }
 
     /**
@@ -1030,16 +1030,16 @@
              * occurs
              */
             Handler[] ha = this.getHandlers();
-            for (int i = 0; i < ha.length; i++) {
-                ha[i].publish(record);
+            for (Handler element : ha) {
+                element.publish(record);
             }
             // call the parent's handlers if set useParentHandlers
             if (getUseParentHandlers()) {
                 Logger anyParent = this.parent;
                 while (null != anyParent) {
                     ha = anyParent.getHandlers();
-                    for (int i = 0; i < ha.length; i++) {
-                        ha[i].publish(record);
+                    for (Handler element : ha) {
+                        element.publish(record);
                     }
                     if (anyParent.getUseParentHandlers()) {
                         anyParent = anyParent.parent;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/MemoryHandler.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/MemoryHandler.java?rev=410592&r1=410591&r2=410592&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/MemoryHandler.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/MemoryHandler.java
Wed May 31 09:42:02 2006
@@ -107,9 +107,8 @@
         //init target
         final String targetName = manager.getProperty(className+".target"); //$NON-NLS-1$
         try {
-            Class targetClass = (Class)
-            AccessController.doPrivileged(new PrivilegedExceptionAction(){
-                public Object run() throws Exception{
+            Class targetClass = AccessController.doPrivileged(new PrivilegedExceptionAction<Class>(){
+                public Class run() throws Exception{
                     ClassLoader loader = Thread.currentThread().getContextClassLoader();
                     if(loader == null){
                         loader = ClassLoader.getSystemClassLoader();
@@ -208,8 +207,9 @@
      * @param record the log record.
      */
     public void publish(LogRecord record) {
-        if (!isLoggable(record))
-            return;
+        if (!isLoggable(record)) {
+            return;
+        }
         if (cursor >= size) {
             cursor = 0;
         }
@@ -254,11 +254,15 @@
      */
     public void push() {
         for (int i = cursor; i < size; i++) {
-            if(null != buffer[i])target.publish(buffer[i]);
+            if(null != buffer[i]) {
+                target.publish(buffer[i]);
+            }
             buffer[i] = null;
         }
         for (int i = 0; i < cursor; i++) {
-            if(null != buffer[i])target.publish(buffer[i]);
+            if(null != buffer[i]) {
+                target.publish(buffer[i]);
+            }
             buffer[i] = null;
         }
         cursor = 0;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/XMLFormatter.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/XMLFormatter.java?rev=410592&r1=410591&r2=410592&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/XMLFormatter.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/XMLFormatter.java
Wed May 31 09:42:02 2006
@@ -212,8 +212,9 @@
 
     //use privilege code to get system property
     private static String getSystemProperty(final String key) {
-        return (String) AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
+        return (String) AccessController.doPrivileged(
+          new PrivilegedAction<String>() {
+            public String run() {
                 return System.getProperty(key);
             }
         });



Mime
View raw message