harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r441983 - /incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/
Date Sun, 10 Sep 2006 18:46:39 GMT
Author: ndbeyer
Date: Sun Sep 10 11:46:38 2006
New Revision: 441983

URL: http://svn.apache.org/viewvc?view=rev&rev=441983
Log:
Code cleanup for 'java.awt.datatransfer'; add braces, remove compiler warnings, add documentation,
etc

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/Clipboard.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/ClipboardOwner.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/DataFlavor.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/DuplicatedPropertiesResourceBundle.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/FlavorEvent.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/FlavorListener.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/FlavorMap.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/FlavorTable.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/MimeTypeParseException.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/MimeTypeProcessor.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/StringSelection.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/SystemFlavorMap.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/Transferable.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/UnsupportedFlavorException.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/Clipboard.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/Clipboard.java?view=diff&rev=441983&r1=441982&r2=441983
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/Clipboard.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/Clipboard.java
Sun Sep 10 11:46:38 2006
@@ -13,10 +13,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Michael Danilov
- * @version $Revision$
- */
+
 package java.awt.datatransfer;
 
 import java.awt.*;
@@ -36,14 +33,14 @@
     private final String name;
     private final FlavorEventProcessor processor;
     private final ListenerList listeners;
-    private HashSet flavors;
+    private HashSet<DataFlavor> flavors;
     private Synchronizer awtSynchronizer;
 
     public Clipboard(String name) {
         this.name = name;
         listeners = new ListenerList();
         processor = new FlavorEventProcessor();
-        flavors = new HashSet();
+        flavors = new HashSet<DataFlavor>();
         awtSynchronizer = ContextStorage.getSynchronizer();
     }
 
@@ -65,11 +62,11 @@
         try {
             boolean ownershipLost = (this.owner != owner);
             boolean flavorsChanged;
-            HashSet newFlavorsSet = new HashSet();
+            HashSet<DataFlavor> newFlavorsSet = new HashSet<DataFlavor>();
             DataFlavor[] newFlavorsArray = contents.getTransferDataFlavors();
 
-            for (int i = 0; i < newFlavorsArray.length; i ++) {
-                newFlavorsSet.add(newFlavorsArray[i]);
+            for (DataFlavor element : newFlavorsArray) {
+                newFlavorsSet.add(element);
             }
             flavorsChanged = !flavors.equals(newFlavorsSet);
 
@@ -114,9 +111,8 @@
         try {
             if (contents == null) {
                 throw new UnsupportedFlavorException(flavor);
-            } else {
-                return contents.getTransferData(flavor);
             }
+            return contents.getTransferData(flavor);
         } finally {
             awtSynchronizer.unlock();
         }
@@ -135,7 +131,7 @@
     }
 
     private void processFlavorEvent(FlavorEvent e) {
-        for (Iterator i = listeners.getUserIterator(); i.hasNext();) {
+        for (Iterator<?> i = listeners.getUserIterator(); i.hasNext();) {
             ((FlavorListener) i.next()).flavorsChanged(e);
         }
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/ClipboardOwner.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/ClipboardOwner.java?view=diff&rev=441983&r1=441982&r2=441983
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/ClipboardOwner.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/ClipboardOwner.java
Sun Sep 10 11:46:38 2006
@@ -13,14 +13,9 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Michael Danilov
- * @version $Revision$
- */
+
 package java.awt.datatransfer;
 
 public interface ClipboardOwner {
-
-    public void lostOwnership(Clipboard clipboard, Transferable contents);
-
+    void lostOwnership(Clipboard clipboard, Transferable contents);
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/DataFlavor.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/DataFlavor.java?view=diff&rev=441983&r1=441982&r2=441983
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/DataFlavor.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/DataFlavor.java
Sun Sep 10 11:46:38 2006
@@ -34,6 +34,7 @@
     /**
      * @deprecated
      */
+    @Deprecated
     public static final DataFlavor plainTextFlavor =
             new DataFlavor("text/plain; charset=unicode; class=java.io.InputStream",
                     "Plain Text");
@@ -81,7 +82,7 @@
     private static DataFlavor plainUnicodeFlavor = null;
 
     private String humanPresentableName;
-    private Class representationClass;
+    private Class<?> representationClass;
     private MimeTypeProcessor.MimeType mimeInfo;
 
     public static final DataFlavor getTextPlainUnicodeFlavor() {
@@ -95,7 +96,7 @@
         return plainUnicodeFlavor;
     }
 
-    protected static final Class tryToLoadClass(String className, ClassLoader fallback)
+    protected static final Class<?> tryToLoadClass(String className, ClassLoader fallback)
             throws ClassNotFoundException
     {
         try {
@@ -132,7 +133,7 @@
         representationClass = null;
     }
 
-    public DataFlavor(Class representationClass, String humanPresentableName) {
+    public DataFlavor(Class<?> representationClass, String humanPresentableName) {
         mimeInfo = new MimeTypeProcessor.MimeType("application", "x-java-serialized-object");
 
         if (humanPresentableName != null) {
@@ -193,19 +194,17 @@
     private String getCharset() {
         if (isCharsetRedundant()) {
             return "";
-        } else {
-            String charset = mimeInfo.getParameter("charset");
-
-            if (isCharsetRequired() && ((charset == null) || (charset.length() ==
0))) {
-                return DTK.getDTK().getDefaultCharset();
-            } else {
-                if (charset == null) {
-                    return "";
-                }
+        }
+        String charset = mimeInfo.getParameter("charset");
 
-                return charset;
-            }
+        if (isCharsetRequired() && ((charset == null) || (charset.length() == 0)))
{
+            return DTK.getDTK().getDefaultCharset();
+        }
+        if (charset == null) {
+            return "";
         }
+
+        return charset;
     }
 
     private boolean isCharsetRequired() {
@@ -255,9 +254,8 @@
 
         if (lowerName.equals("humanpresentablename")) {
             return humanPresentableName;
-        } else {
-            return mimeInfo.getParameter(lowerName);
         }
+        return mimeInfo.getParameter(lowerName);
     }
 
     public String getHumanPresentableName() {
@@ -268,11 +266,11 @@
         this.humanPresentableName = humanPresentableName;
     }
 
-    public Class getRepresentationClass() {
+    public Class<?> getRepresentationClass() {
         return representationClass;
     }
 
-    public final Class getDefaultRepresentationClass() {
+    public final Class<?> getDefaultRepresentationClass() {
         return InputStream.class;
     }
 
@@ -309,6 +307,7 @@
     /**
      * @deprecated
      */
+    @Deprecated
     protected String normalizeMimeTypeParameter(String parameterName, String parameterValue)
{
         return parameterValue;
     }
@@ -316,6 +315,7 @@
     /**
      * @deprecated
      */
+    @Deprecated
     protected String normalizeMimeType(String mimeType) {
         return mimeType;
     }
@@ -347,6 +347,7 @@
                 Class.forName(mimeInfo.getParameter("class")) : null;
     }
 
+    @Override
     public Object clone() throws CloneNotSupportedException {
         DataFlavor clone = new DataFlavor();
 
@@ -357,6 +358,7 @@
         return clone;
     }
 
+    @Override
     public String toString() {
         /* The format is based on 1.5 release behavior 
          * which can be revealed by the following code:
@@ -373,12 +375,12 @@
         return isMimeTypeEqual(javaSerializedObjectMimeType);
     }
 
+    @Override
     public boolean equals(Object o) {
         if ((o == null) || !(o instanceof DataFlavor)) {
             return false;
-        } else {
-            return equals((DataFlavor) o);
         }
+        return equals((DataFlavor) o);
     }
 
     public boolean equals(DataFlavor that) {
@@ -405,9 +407,8 @@
 
         if (!isCharsetSupported(charset1) || !isCharsetSupported(charset2)) {
             return charset1.equalsIgnoreCase(charset2);
-        } else {
-            return (Charset.forName(charset1).equals(Charset.forName(charset2)));
         }
+        return (Charset.forName(charset1).equals(Charset.forName(charset2)));
 
     }
 
@@ -423,6 +424,7 @@
         return equals(that);
     }
 
+    @Override
     public int hashCode() {
         return getKeyInfo().hashCode();
     }
@@ -510,9 +512,8 @@
 
             if (charset.length() == 0) {
                 return new InputStreamReader(stream);
-            } else {
-                return new InputStreamReader(stream, charset);
             }
+            return new InputStreamReader(stream, charset);
         }
     }
 
@@ -521,50 +522,49 @@
             return null;
         }
 
-        List sorted = sortTextFlavorsByType(new LinkedList(Arrays.asList(availableFlavors)));
+        List<List<DataFlavor>> sorted = sortTextFlavorsByType(new LinkedList<DataFlavor>(Arrays.asList(availableFlavors)));
 
         if (sorted.isEmpty()) {
             return null;
         }
 
-        List bestSorted = (List) sorted.get(0);
+        List<DataFlavor> bestSorted = sorted.get(0);
 
         if (bestSorted.size() == 1) {
-            return (DataFlavor) bestSorted.get(0);
+            return bestSorted.get(0);
         }
 
-        if (((DataFlavor) bestSorted.get(0)).getCharset().length() == 0) {
+        if (bestSorted.get(0).getCharset().length() == 0) {
             return selectBestFlavorWOCharset(bestSorted);
-        } else {
-            return selectBestFlavorWCharset(bestSorted);
         }
+        return selectBestFlavorWCharset(bestSorted);
     }
 
-    private static DataFlavor selectBestFlavorWCharset(List list) {
-        List best;
+    private static DataFlavor selectBestFlavorWCharset(List<DataFlavor> list) {
+        List<DataFlavor> best;
 
         best = getFlavors(list, Reader.class);
         if (best != null) {
-            return (DataFlavor) best.get(0);
+            return best.get(0);
         }
         best = getFlavors(list, String.class);
         if (best != null) {
-            return (DataFlavor) best.get(0);
+            return best.get(0);
         }
         best = getFlavors(list, CharBuffer.class);
         if (best != null) {
-            return (DataFlavor) best.get(0);
+            return best.get(0);
         }
         best = getFlavors(list, char[].class);
         if (best != null) {
-            return (DataFlavor) best.get(0);
+            return best.get(0);
         }
 
         return selectBestByCharset(list);
     }
 
-    private static DataFlavor selectBestByCharset(List list) {
-        List best;
+    private static DataFlavor selectBestByCharset(List<DataFlavor> list) {
+        List<DataFlavor> best;
 
         best = getFlavors(list, new String[] {"UTF-16", "UTF-8", "UTF-16BE", "UTF-16LE"});
         if (best == null) {
@@ -579,26 +579,25 @@
 
         if (best != null) {
             if (best.size() == 1) {
-                return (DataFlavor) best.get(0);
-            } else {
-                return selectBestFlavorWOCharset(best);
+                return best.get(0);
             }
+            return selectBestFlavorWOCharset(best);
         }
 
         return null;
     }
 
-    private static List selectBestByAlphabet(List list) {
+    private static List<DataFlavor> selectBestByAlphabet(List<DataFlavor> list)
{
         String charsets[] = new String[list.size()];
-        LinkedList best = new LinkedList();
+        LinkedList<DataFlavor> best = new LinkedList<DataFlavor>();
 
         for (int i = 0; i < charsets.length; i++) {
-            charsets[i] = ((DataFlavor) list.get(i)).getCharset();
+            charsets[i] = list.get(i).getCharset();
         }
         Arrays.sort(charsets, String.CASE_INSENSITIVE_ORDER);
 
-        for (Iterator i = list.iterator(); i.hasNext();) {
-            DataFlavor flavor = (DataFlavor) i.next();
+        for (Iterator<DataFlavor> i = list.iterator(); i.hasNext();) {
+            DataFlavor flavor = i.next();
 
             if (charsets[0].equalsIgnoreCase(flavor.getCharset())) {
                 best.add(flavor);
@@ -608,15 +607,15 @@
         return best.isEmpty() ? null : best;
     }
 
-    private static List getFlavors(List list, String[] charset) {
-        LinkedList sublist = new LinkedList();
+    private static List<DataFlavor> getFlavors(List<DataFlavor> list, String[]
charset) {
+        LinkedList<DataFlavor> sublist = new LinkedList<DataFlavor>();
 
-        for (Iterator i = list.iterator(); i.hasNext();) {
-            DataFlavor flavor = (DataFlavor) i.next();
+        for (Iterator<DataFlavor> i = list.iterator(); i.hasNext();) {
+            DataFlavor flavor = i.next();
 
             if (isCharsetSupported(flavor.getCharset())) {
-                for (int j = 0; j < charset.length; j++) {
-                    if (Charset.forName(charset[j]).equals(Charset.forName(flavor.getCharset())))
{
+                for (String element : charset) {
+                    if (Charset.forName(element).equals(Charset.forName(flavor.getCharset())))
{
                         sublist.add(flavor);
                     }
                 }
@@ -628,30 +627,30 @@
         return sublist.isEmpty() ? null : list;
     }
 
-    private static DataFlavor selectBestFlavorWOCharset(List list) {
-        List best;
+    private static DataFlavor selectBestFlavorWOCharset(List<DataFlavor> list) {
+        List<DataFlavor> best;
 
         best = getFlavors(list, InputStream.class);
         if (best != null) {
-            return (DataFlavor) best.get(0);
+            return best.get(0);
         }
         best = getFlavors(list, ByteBuffer.class);
         if (best != null) {
-            return (DataFlavor) best.get(0);
+            return best.get(0);
         }
         best = getFlavors(list, byte[].class);
         if (best != null) {
-            return (DataFlavor) best.get(0);
+            return best.get(0);
         }
 
-        return (DataFlavor) list.get(0);
+        return list.get(0);
     }
 
-    private static List getFlavors(List list, Class klass) {
-        LinkedList sublist = new LinkedList();
+    private static List<DataFlavor> getFlavors(List<DataFlavor> list, Class<?>
klass) {
+        LinkedList<DataFlavor> sublist = new LinkedList<DataFlavor>();
 
-        for (Iterator i = list.iterator(); i.hasNext();) {
-            DataFlavor flavor = (DataFlavor) i.next();
+        for (Iterator<DataFlavor> i = list.iterator(); i.hasNext();) {
+            DataFlavor flavor = i.next();
 
             if (flavor.representationClass.equals(klass)) {
                 sublist.add(flavor);
@@ -661,11 +660,11 @@
         return sublist.isEmpty() ? null : list;
     }
 
-    private static List sortTextFlavorsByType(List availableFlavors) {
-        LinkedList list = new LinkedList();
+    private static List<List<DataFlavor>> sortTextFlavorsByType(List<DataFlavor>
availableFlavors) {
+        LinkedList<List<DataFlavor>> list = new LinkedList<List<DataFlavor>>();
 
-        for (int i = 0; i < sortedTextFlavors.length; i++) {
-            List subList = fetchTextFlavors(availableFlavors, sortedTextFlavors[i]);
+        for (String element : sortedTextFlavors) {
+            List<DataFlavor> subList = fetchTextFlavors(availableFlavors, element);
 
             if (subList != null) {
                 list.addLast(subList);
@@ -678,11 +677,11 @@
         return list;
     }
 
-    private static List fetchTextFlavors(List availableFlavors, String mimeType) {
-        LinkedList list = new LinkedList();
+    private static List<DataFlavor> fetchTextFlavors(List<DataFlavor> availableFlavors,
String mimeType) {
+        LinkedList<DataFlavor> list = new LinkedList<DataFlavor>();
 
-        for (Iterator i = availableFlavors.iterator(); i.hasNext();) {
-            DataFlavor flavor = (DataFlavor) i.next();
+        for (Iterator<DataFlavor> i = availableFlavors.iterator(); i.hasNext();) {
+            DataFlavor flavor = i.next();
 
             if (flavor.isFlavorTextType()) {
                 if (flavor.mimeInfo.getFullType().equals(mimeType)) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/DuplicatedPropertiesResourceBundle.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/DuplicatedPropertiesResourceBundle.java?view=diff&rev=441983&r1=441982&r2=441983
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/DuplicatedPropertiesResourceBundle.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/DuplicatedPropertiesResourceBundle.java
Sun Sep 10 11:46:38 2006
@@ -30,45 +30,49 @@
         properties = new Properties() {
             private static final long serialVersionUID = -4869518800983843099L;
 
+            @SuppressWarnings("unchecked")
+            @Override
             public Object put(Object key, Object value) {
                 Object oldValue = get(key);
 
                 if (oldValue == null) {
                     return super.put(key, value);
-                } else {
-                    List list;
-
-                    if (oldValue instanceof String) {
-                        list = new LinkedList();
-                        list.add(oldValue);
-                    } else {
-                        list = (List) oldValue;
-                    }
-                    list.add(value);
+                }
+                List<Object> list;
 
-                    return super.put(key, list);
+                if (oldValue instanceof String) {
+                    list = new LinkedList<Object>();
+                    list.add(oldValue);
+                } else {
+                    list = (List<Object>) oldValue;
                 }
+                list.add(value);
+
+                return super.put(key, list);
             }
         };
         properties.load(stream);
     }
 
+    @Override
     public Object handleGetObject(String key) {
         return properties.get(key);
     }
 
-    public Enumeration getKeys() {
-        Enumeration result = properties.propertyNames();
+    @SuppressWarnings("unchecked")
+    @Override
+    public Enumeration<String> getKeys() {
+        Enumeration<String> result = (Enumeration<String>)properties.propertyNames();
 
         if (parent == null) {
             return result;
         }
 
-        ArrayList keys = Collections.list(result);
-        Enumeration e = parent.getKeys();
+        ArrayList<String> keys = Collections.list(result);
+        Enumeration<String> e = parent.getKeys();
 
         while (e.hasMoreElements()) {
-            Object key = e.nextElement();
+            String key = e.nextElement();
 
             if (!keys.contains(key)) {
                 keys.add(key);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/FlavorEvent.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/FlavorEvent.java?view=diff&rev=441983&r1=441982&r2=441983
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/FlavorEvent.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/FlavorEvent.java
Sun Sep 10 11:46:38 2006
@@ -13,10 +13,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Michael Danilov
- * @version $Revision$
- */
+
 package java.awt.datatransfer;
 
 import java.util.EventObject;
@@ -28,5 +25,4 @@
     public FlavorEvent(Clipboard source) {
         super(source);
     }
-
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/FlavorListener.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/FlavorListener.java?view=diff&rev=441983&r1=441982&r2=441983
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/FlavorListener.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/FlavorListener.java
Sun Sep 10 11:46:38 2006
@@ -13,16 +13,11 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Michael Danilov
- * @version $Revision$
- */
+
 package java.awt.datatransfer;
 
 import java.util.EventListener;
 
 public interface FlavorListener extends EventListener {
-
-    public void flavorsChanged(FlavorEvent e);
-
+    void flavorsChanged(FlavorEvent e);
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/FlavorMap.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/FlavorMap.java?view=diff&rev=441983&r1=441982&r2=441983
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/FlavorMap.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/FlavorMap.java
Sun Sep 10 11:46:38 2006
@@ -13,18 +13,13 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Michael Danilov
- * @version $Revision$
- */
+
 package java.awt.datatransfer;
 
 import java.util.Map;
 
 public interface FlavorMap {
+    Map<String, DataFlavor> getFlavorsForNatives(String[] natives);
 
-    public Map getFlavorsForNatives(String[] natives);
-
-    public Map getNativesForFlavors(DataFlavor[] flavors);
-
+    Map<DataFlavor, String> getNativesForFlavors(DataFlavor[] flavors);
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/FlavorTable.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/FlavorTable.java?view=diff&rev=441983&r1=441982&r2=441983
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/FlavorTable.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/FlavorTable.java
Sun Sep 10 11:46:38 2006
@@ -13,18 +13,13 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Michael Danilov
- * @version $Revision$
- */
+
 package java.awt.datatransfer;
 
 import java.util.List;
 
 public interface FlavorTable extends FlavorMap {
+    List<DataFlavor> getFlavorsForNative(String nat);
 
-    public List getFlavorsForNative(String nat);
-
-    public List getNativesForFlavor(DataFlavor flav);
-
+    List<String> getNativesForFlavor(DataFlavor flav);
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/MimeTypeParseException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/MimeTypeParseException.java?view=diff&rev=441983&r1=441982&r2=441983
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/MimeTypeParseException.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/MimeTypeParseException.java
Sun Sep 10 11:46:38 2006
@@ -13,14 +13,10 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Michael Danilov
- * @version $Revision$
- */
+
 package java.awt.datatransfer;
 
 public class MimeTypeParseException extends Exception {
-
     private static final long serialVersionUID = -5604407764691570741L;
 
     public MimeTypeParseException(String s) {
@@ -30,5 +26,4 @@
     public MimeTypeParseException() {
         super();
     }
-
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/MimeTypeProcessor.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/MimeTypeProcessor.java?view=diff&rev=441983&r1=441982&r2=441983
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/MimeTypeProcessor.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/MimeTypeProcessor.java
Sun Sep 10 11:46:38 2006
@@ -13,10 +13,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Michael Danilov
- * @version $Revision$
- */
+
 package java.awt.datatransfer;
 
 import java.io.Serializable;
@@ -25,9 +22,10 @@
 
 final class MimeTypeProcessor {
 
-    private static MimeTypeProcessor instance = null;
+    private static MimeTypeProcessor instance;
 
     private MimeTypeProcessor() {
+        super();
     }
 
     static MimeType parse(String str) {
@@ -49,14 +47,18 @@
     }
 
     static String assemble(MimeType type) {
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
 
         buf.append(type.getFullType());
-        for (Enumeration keys = type.parameters.keys(); keys.hasMoreElements();) {
-            String name = (String) keys.nextElement();
-            String value = (String) type.parameters.get(name);
-
-            buf.append("; " + name + "=\"" + value + '"');
+        for (Enumeration<String> keys = type.parameters.keys(); keys.hasMoreElements();)
{
+            String name = keys.nextElement();
+            String value = type.parameters.get(name);
+
+            buf.append("; ");
+            buf.append(name);
+            buf.append("=\"");
+            buf.append(value);
+            buf.append('"');
         }
 
         return buf.toString();
@@ -73,20 +75,18 @@
     }
 
     private static void retrieveParams(String str, MimeType res, StringPosition pos) {
-        res.parameters = new Hashtable();
-        res.systemParameters = new Hashtable();
+        res.parameters = new Hashtable<String, String>();
+        res.systemParameters = new Hashtable<String, Object>();
         do {
             pos.i = getNextMeaningfulIndex(str, pos.i);
             if (pos.i >= str.length()) {
                 return;
-            } else {
-                if (str.charAt(pos.i) != ';') {
-                    throw new IllegalArgumentException();
-                } else {
-                    pos.i++;
-                    retrieveParam(str, res, pos);
-                }
             }
+            if (str.charAt(pos.i) != ';') {
+                throw new IllegalArgumentException();
+            }
+            pos.i++;
+            retrieveParam(str, res, pos);
         } while (true);
     }
 
@@ -101,20 +101,19 @@
         pos.i = getNextMeaningfulIndex(str, pos.i);
         if ((pos.i >= str.length())) {
             throw new IllegalArgumentException();
-        } else {
-            String value;
+        }
+        String value;
 
-            if (str.charAt(pos.i) == '"') {
-                value = retrieveQuoted(str, pos);
-            } else {
-                value = retrieveToken(str, pos);
-            }
-            res.parameters.put(name, value);
+        if (str.charAt(pos.i) == '"') {
+            value = retrieveQuoted(str, pos);
+        } else {
+            value = retrieveToken(str, pos);
         }
+        res.parameters.put(name, value);
     }
 
     private static String retrieveQuoted(String str, StringPosition pos) {
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         boolean check = true;
 
         pos.i++;
@@ -139,18 +138,17 @@
     }
 
     private static String retrieveToken(String str, StringPosition pos) {
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
 
         pos.i = getNextMeaningfulIndex(str, pos.i);
         if ((pos.i >= str.length()) || isTSpecialChar(str.charAt(pos.i))) {
             throw new IllegalArgumentException();
-        } else {
-            do {
-                buf.append(str.charAt(pos.i++));
-            } while ((pos.i < str.length())
-                    && isMeaningfulChar(str.charAt(pos.i))
-                    && !isTSpecialChar(str.charAt(pos.i)));
         }
+        do {
+            buf.append(str.charAt(pos.i++));
+        } while ((pos.i < str.length())
+                && isMeaningfulChar(str.charAt(pos.i))
+                && !isTSpecialChar(str.charAt(pos.i)));
 
         return buf.toString();
     }
@@ -182,10 +180,10 @@
     static final class MimeType implements Cloneable, Serializable {
 
         private static final long serialVersionUID = -6693571907475992044L;
-        private String primaryType = null;
-        private String subType = null;
-        private Hashtable parameters = null;
-        private Hashtable systemParameters = null;
+        private String primaryType;
+        private String subType;
+        private Hashtable<String, String> parameters;
+        private Hashtable<String, Object> systemParameters;
 
         MimeType() {
             primaryType = null;
@@ -197,16 +195,15 @@
         MimeType(String primaryType, String subType) {
             this.primaryType = primaryType;
             this.subType = subType;
-            parameters = new Hashtable();
-            systemParameters = new Hashtable();
+            parameters = new Hashtable<String, String>();
+            systemParameters = new Hashtable<String, Object>();
         }
 
         boolean equals(MimeType that) {
             if (that == null) {
                 return false;
-            } else {
-                return getFullType().equals(that.getFullType());
             }
+            return getFullType().equals(that.getFullType());
         }
 
         String getPrimaryType() {
@@ -222,7 +219,7 @@
         }
 
         String getParameter(String name) {
-            return (String) parameters.get(name);
+            return parameters.get(name);
         }
 
         void addParameter(String name, String value) {
@@ -251,23 +248,14 @@
             systemParameters.put(name, value);
         }
 
+        @SuppressWarnings("unchecked")
+        @Override
         public Object clone() {
             MimeType clone = new MimeType(primaryType, subType);
-
-            copyParameters(parameters, clone.parameters);
-            copyParameters(systemParameters, clone.systemParameters);
-
+            clone.parameters = (Hashtable<String, String>)parameters.clone();
+            clone.systemParameters = (Hashtable<String, Object>)systemParameters.clone();
             return clone;
         }
-
-        private void copyParameters(Hashtable from, Hashtable to) {
-            for (Enumeration keys = from.keys(); keys.hasMoreElements();) {
-                String name = (String) keys.nextElement();
-
-                to.put(name, from.get(name));
-            }
-        }
-
     }
 
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/StringSelection.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/StringSelection.java?view=diff&rev=441983&r1=441982&r2=441983
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/StringSelection.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/StringSelection.java
Sun Sep 10 11:46:38 2006
@@ -52,7 +52,7 @@
     }
 
     public DataFlavor[] getTransferDataFlavors() {
-        return (DataFlavor[]) supportedFlavors.clone();
+        return supportedFlavors.clone();
     }
 
     public void lostOwnership(Clipboard clipboard, Transferable contents) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/SystemFlavorMap.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/SystemFlavorMap.java?view=diff&rev=441983&r1=441982&r2=441983
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/SystemFlavorMap.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/SystemFlavorMap.java
Sun Sep 10 11:46:38 2006
@@ -35,10 +35,8 @@
     private static final String SERIALIZED_PREFIX = 
         "org.apache.harmony.awt.datatransfer:";
 
-    private final HashMap flavor2Native = new HashMap();
-    private final HashMap native2Flavor = new HashMap();
-
-    private final DTK dtk;
+    private final HashMap<DataFlavor, List<String>> flavor2Native = new HashMap<DataFlavor,
List<String>>();
+    private final HashMap<String, List<DataFlavor>> native2Flavor = new HashMap<String,
List<DataFlavor>>();
 
     public static boolean isJavaMIMEType(String str) {
         return ((str != null) && str.startsWith(SERIALIZED_PREFIX));
@@ -47,34 +45,30 @@
     public static String encodeJavaMIMEType(String mimeType) {
         if (mimeType == null) {
             return null;
-        } else {
-            return (SERIALIZED_PREFIX + mimeType);
         }
+        return (SERIALIZED_PREFIX + mimeType);
     }
 
     public static String decodeJavaMIMEType(String nat) {
         if (isJavaMIMEType(nat)) {
             return nat.substring(SERIALIZED_PREFIX.length());
-        } else {
-            return null;
         }
+        return null;
     }
 
     public static String encodeDataFlavor(DataFlavor flav) {
         if (flav == null) {
             return null;
-        } else {
-            return (SERIALIZED_PREFIX + flav.getMimeType());
         }
+        return (SERIALIZED_PREFIX + flav.getMimeType());
     }
 
     public static DataFlavor decodeDataFlavor(String nat)
             throws ClassNotFoundException {
         if (isJavaMIMEType(nat)) {
             return new DataFlavor(nat.substring(SERIALIZED_PREFIX.length()));
-        } else {
-            return null;
         }
+        return null;
     }
 
     public static FlavorMap getDefaultFlavorMap() {
@@ -93,50 +87,49 @@
     }
 
     private SystemFlavorMap(DTK dtk) {
-        this.dtk = dtk;
         dtk.initSystemFlavorMap(this);
     }
 
-    public synchronized List getFlavorsForNative(String nat) {
+    public synchronized List<DataFlavor> getFlavorsForNative(String nat) {
         if (nat == null) {
-            return new ArrayList(flavor2Native.keySet());
+            return new ArrayList<DataFlavor>(flavor2Native.keySet());
         }
 
-        List list = (List) native2Flavor.get(nat);
+        List<DataFlavor> list = native2Flavor.get(nat);
         if ((list == null || list.isEmpty()) && isJavaMIMEType(nat)) {
             String decodedNat = decodeJavaMIMEType(nat);
             try {
                 DataFlavor flavor = new DataFlavor(decodedNat);
                 addMapping(nat, flavor);
-                list = (List) native2Flavor.get(nat);
+                list = native2Flavor.get(nat);
             } catch (ClassNotFoundException e) {}
         }
-        return (list != null) ? new ArrayList(list) : new ArrayList();
+        return (list != null) ? new ArrayList<DataFlavor>(list) : new ArrayList<DataFlavor>();
     }
 
-    public synchronized List getNativesForFlavor(DataFlavor flav) {
+    public synchronized List<String> getNativesForFlavor(DataFlavor flav) {
         if (flav == null) {
-            return new ArrayList(native2Flavor.keySet());
+            return new ArrayList<String>(native2Flavor.keySet());
         }
         
-        List list = (List) flavor2Native.get(flav);
+        List<String> list = flavor2Native.get(flav);
         if ((list == null || list.isEmpty()) 
                 && flav.isFlavorSerializedObjectType()) {
             String nat = encodeDataFlavor(flav);
             addMapping(nat, flav);
-            list = (List) flavor2Native.get(flav);
+            list = flavor2Native.get(flav);
         }
-        return (list != null) ? new ArrayList(list) : new ArrayList();
+        return (list != null) ? new ArrayList<String>(list) : new ArrayList<String>();
     }
 
-    public synchronized Map getFlavorsForNatives(String[] natives) {
-        HashMap map = new HashMap();
-        Iterator it = (natives != null) ? 
+    public synchronized Map<String, DataFlavor> getFlavorsForNatives(String[] natives)
{
+        HashMap<String, DataFlavor> map = new HashMap<String, DataFlavor>();
+        Iterator<String> it = (natives != null) ? 
                 Arrays.asList(natives).iterator() : 
                     native2Flavor.keySet().iterator();
         while (it.hasNext()) {
-            String nat = (String)it.next();
-            List list = getFlavorsForNative(nat);
+            String nat = it.next();
+            List<DataFlavor> list = getFlavorsForNative(nat);
             if (list.size() > 0) {
                 map.put(nat, list.get(0));
             }
@@ -144,14 +137,14 @@
         return map;
     }
 
-    public synchronized Map getNativesForFlavors(DataFlavor[] flavors) {
-        HashMap map = new HashMap();
-        Iterator it = (flavors != null) ? 
+    public synchronized Map<DataFlavor, String> getNativesForFlavors(DataFlavor[] flavors)
{
+        HashMap<DataFlavor, String> map = new HashMap<DataFlavor, String>();
+        Iterator<DataFlavor> it = (flavors != null) ? 
                 Arrays.asList(flavors).iterator() : 
                     flavor2Native.keySet().iterator();
         while (it.hasNext()) {
-            DataFlavor flavor = (DataFlavor)it.next();
-            List list = getNativesForFlavor(flavor);
+            DataFlavor flavor = it.next();
+            List<String> list = getNativesForFlavor(flavor);
             if (list.size() > 0) {
                 map.put(flavor, list.get(0));
             }
@@ -161,11 +154,9 @@
 
     public synchronized void setNativesForFlavor(
             DataFlavor flav, String[] natives) {
-        LinkedList list = new LinkedList();
-
-        for (int i = 0; i < natives.length; i++) {
-            String nat = natives[i];
+        LinkedList<String> list = new LinkedList<String>();
 
+        for (String nat : natives) {
             if (!list.contains(nat)) {
                 list.add(nat);
             }
@@ -180,11 +171,9 @@
 
     public synchronized void setFlavorsForNative(
             String nat, DataFlavor[] flavors) {
-        LinkedList list = new LinkedList();
-
-        for (int i = 0; i < flavors.length; i++) {
-            DataFlavor flav = flavors[i];
+        LinkedList<DataFlavor> list = new LinkedList<DataFlavor>();
 
+        for (DataFlavor flav : flavors) {
             if (!list.contains(flav)) {
                 list.add(flav);
             }
@@ -199,10 +188,10 @@
 
     public synchronized void addUnencodedNativeForFlavor(
             DataFlavor flav, String nat) {
-        List natives = (List) flavor2Native.get(flav);
+        List<String> natives = flavor2Native.get(flav);
 
         if (natives == null) {
-            natives = new LinkedList();
+            natives = new LinkedList<String>();
             flavor2Native.put(flav, natives);
         }
         if (!natives.contains(nat)) {
@@ -212,10 +201,10 @@
 
     public synchronized void addFlavorForUnencodedNative(
             String nat, DataFlavor flav) {
-        List flavors = (List) native2Flavor.get(nat);
+        List<DataFlavor> flavors = native2Flavor.get(nat);
 
         if (flavors == null) {
-            flavors = new LinkedList();
+            flavors = new LinkedList<DataFlavor>();
             native2Flavor.put(nat, flavors);
         }
         if (!flavors.contains(flav)) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/Transferable.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/Transferable.java?view=diff&rev=441983&r1=441982&r2=441983
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/Transferable.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/Transferable.java
Sun Sep 10 11:46:38 2006
@@ -13,21 +13,15 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Michael Danilov
- * @version $Revision$
- */
+
 package java.awt.datatransfer;
 
 import java.io.IOException;
 
 public interface Transferable {
+    Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException;
 
-    public Object getTransferData(DataFlavor flavor)
-            throws UnsupportedFlavorException, IOException;
-
-    public boolean isDataFlavorSupported(DataFlavor flavor);
-
-    public DataFlavor[] getTransferDataFlavors();
+    boolean isDataFlavorSupported(DataFlavor flavor);
 
+    DataFlavor[] getTransferDataFlavors();
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/UnsupportedFlavorException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/UnsupportedFlavorException.java?view=diff&rev=441983&r1=441982&r2=441983
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/UnsupportedFlavorException.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/UnsupportedFlavorException.java
Sun Sep 10 11:46:38 2006
@@ -13,18 +13,13 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Michael Danilov
- * @version $Revision$
- */
+
 package java.awt.datatransfer;
 
 public class UnsupportedFlavorException extends Exception {
-
     private static final long serialVersionUID = 5383814944251665601L;
 
     public UnsupportedFlavorException(DataFlavor flavor) {
         super("flavor = " + flavor.toString());
     }
-
 }



Mime
View raw message