[Swift-commit] r4804 - in trunk/src/org/globus/swift/catalog: . transformation types util

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Thu Jul 7 18:36:33 CDT 2011


Author: hategan
Date: 2011-07-07 18:36:33 -0500 (Thu, 07 Jul 2011)
New Revision: 4804

Modified:
   trunk/src/org/globus/swift/catalog/TCEntry.java
   trunk/src/org/globus/swift/catalog/TransformationCatalog.java
   trunk/src/org/globus/swift/catalog/TransformationCatalogEntry.java
   trunk/src/org/globus/swift/catalog/transformation/File.java
   trunk/src/org/globus/swift/catalog/types/Arch.java
   trunk/src/org/globus/swift/catalog/types/Os.java
   trunk/src/org/globus/swift/catalog/types/TCType.java
   trunk/src/org/globus/swift/catalog/util/Data.java
Log:
code cleanup

Modified: trunk/src/org/globus/swift/catalog/TCEntry.java
===================================================================
--- trunk/src/org/globus/swift/catalog/TCEntry.java	2011-07-07 23:35:39 UTC (rev 4803)
+++ trunk/src/org/globus/swift/catalog/TCEntry.java	2011-07-07 23:36:33 UTC (rev 4804)
@@ -391,7 +391,6 @@
      * @param namespace String The namespace of the profile
      * @return List   List of Profile objects. returns null if none are found.
      */
-    @SuppressWarnings("hiding")
     public List<Profile> getProfiles( String namespace ) {
         List<Profile> results = null;
         if ( profiles != null ) {

Modified: trunk/src/org/globus/swift/catalog/TransformationCatalog.java
===================================================================
--- trunk/src/org/globus/swift/catalog/TransformationCatalog.java	2011-07-07 23:35:39 UTC (rev 4803)
+++ trunk/src/org/globus/swift/catalog/TransformationCatalog.java	2011-07-07 23:36:33 UTC (rev 4804)
@@ -119,7 +119,7 @@
      *                   Returns <B>NULL</B> if no results found.
      * @throws Exception  NotImplementedException if not implemented.
      */
-    List getTCLogicalNames( String resourceid, TCType type ) throws
+    List<Object> getTCLogicalNames( String resourceid, TCType type ) throws
         Exception;
 
     /**
@@ -132,7 +132,7 @@
      * @throws Exception NotImplementedException if not implemented.
      * @see org.globus.swift.catalog.util.Profile
      */
-    List getTCLfnProfiles( String namespace, String name, String version ) throws
+    List<Profile> getTCLfnProfiles( String namespace, String name, String version ) throws
         Exception;
 
     /**
@@ -146,7 +146,7 @@
      *                   Returns <B>NULL</B> if no profiless found.
      * @see org.globus.swift.catalog.util.Profile
      */
-    List getTCPfnProfiles( String pfn, String resourceid, TCType type ) throws
+    List<Profile> getTCPfnProfiles( String pfn, String resourceid, TCType type ) throws
         Exception;
 
     /**
@@ -155,7 +155,7 @@
      * @return List Returns a List of TransformationCatalogEntry objects.
      * @throws Exception
      */
-    List getTC() throws Exception;
+    List<TCEntry> getTC() throws Exception;
 
     /**
      *  ADDITIONS
@@ -168,7 +168,7 @@
      * @return boolean Return true if succesful, false if error. Exception is thrown when error occurs.
      * @see org.globus.swift.catalog.TCEntry
      */
-    boolean addTCEntry( List tcentry ) throws Exception;
+    boolean addTCEntry( List<TCEntry> tcentry ) throws Exception;
 
     /**
      * Add an single entry into the transformation catalog.
@@ -207,7 +207,7 @@
      */
     boolean addTCLfnProfile( String namespace, String name,
         String version,
-        List profiles ) throws Exception;
+        List<Profile> profiles ) throws Exception;
 
     /**
      * Add additional profile to a physical transformation.
@@ -220,7 +220,7 @@
      * @see org.globus.swift.catalog.util.Profile
      */
     boolean addTCPfnProfile( String pfn, TCType type, String resourcename,
-        List profiles ) throws Exception;
+        List<Profile> profiles ) throws Exception;
 
     /**
      * DELETIONS
@@ -308,7 +308,7 @@
      * @throws Exception
      */
     boolean deleteTCPfnProfile( String physicalname, TCType type,
-        String resourceid, List profiles ) throws
+        String resourceid, List<Profile> profiles ) throws
         Exception;
 
     /**
@@ -322,7 +322,7 @@
      * @throws Exception
      */
     boolean deleteTCLfnProfile( String namespace, String name,
-        String version, List profiles ) throws
+        String version, List<Profile> profiles ) throws
         Exception;
 
     /**

Modified: trunk/src/org/globus/swift/catalog/TransformationCatalogEntry.java
===================================================================
--- trunk/src/org/globus/swift/catalog/TransformationCatalogEntry.java	2011-07-07 23:35:39 UTC (rev 4803)
+++ trunk/src/org/globus/swift/catalog/TransformationCatalogEntry.java	2011-07-07 23:36:33 UTC (rev 4804)
@@ -25,16 +25,15 @@
  * @see org.griphyn.common.classes.TCType
  */
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.globus.swift.catalog.types.SysInfo;
 import org.globus.swift.catalog.types.TCType;
 import org.globus.swift.catalog.util.Profile;
 import org.globus.swift.catalog.util.ProfileParser;
 import org.globus.swift.catalog.util.Separator;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
 public class TransformationCatalogEntry
     implements CatalogEntry {
 

Modified: trunk/src/org/globus/swift/catalog/transformation/File.java
===================================================================
--- trunk/src/org/globus/swift/catalog/transformation/File.java	2011-07-07 23:35:39 UTC (rev 4803)
+++ trunk/src/org/globus/swift/catalog/transformation/File.java	2011-07-07 23:36:33 UTC (rev 4804)
@@ -38,7 +38,6 @@
 import java.io.PrintWriter;
 import java.io.Reader;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -67,11 +66,6 @@
      * It's values are set in the CPlanner (the main toolkit) class.
      */
 
-    /**
-     * The List containing the user specified list of pools on which he wants
-     * the dag to run.
-     */
-    protected List mvExecPools;
 
     /**
      * The Tree Map which stores the contents of the file.
@@ -207,7 +201,7 @@
      * @see org.globus.swift.catalog.TCEntry
      */
     public List<TCEntry> getTCEntries( String namespace, String name, String version,
-        List resourceids, TCType type ) throws Exception {
+        List<String> resourceids, TCType type ) throws Exception {
         logMessage( "getTCEntries(String namespace,String name,String version," +
             "List resourceids, TCType type" );
         logMessage( "\tgetTCEntries(" + namespace + ", " + name + ", " +
@@ -215,9 +209,9 @@
             resourceids + ", " + type );
         List<TCEntry> results = null;
         if ( resourceids != null ) {
-            for ( Iterator i = resourceids.iterator(); i.hasNext(); ) {
+            for ( Iterator<String> i = resourceids.iterator(); i.hasNext(); ) {
                 List<TCEntry> tempresults = getTCEntries( namespace, name, version,
-                    ( String ) i.next(), type );
+                    i.next(), type );
                 if ( tempresults != null ) {
                     if ( results == null ) {
                         results = new ArrayList<TCEntry>();
@@ -276,9 +270,9 @@
         }
         if ( resourceid != null ) {
             if ( mTreeMap.containsKey( resourceid ) ) {
-                Map lfnMap = mTreeMap.get( resourceid );
+                Map<String, List<TCEntry>> lfnMap = mTreeMap.get( resourceid );
                 if ( lfnMap.containsKey( lfn ) ) {
-                    List<TCEntry> l = ( List<TCEntry> ) lfnMap.get( lfn );
+                    List<TCEntry> l = lfnMap.get( lfn );
                     if ( type != null && l != null ) {
                         for ( Iterator<TCEntry> i = l.iterator(); i.hasNext(); ) {
                             TCEntry tc = i.next();
@@ -302,11 +296,10 @@
                     //check all maps for the executable.
                     Map<String, List<TCEntry>> lfnMap = j.next();
                     if ( lfnMap.containsKey( lfn ) ) {
-                        List l = lfnMap.get( lfn );
+                        List<TCEntry> l = lfnMap.get( lfn );
                         if ( type != null && l != null ) {
-                            for ( Iterator i = l.iterator(); i.hasNext(); ) {
-                                TCEntry tc = (
-                                    TCEntry ) i.next();
+                            for ( Iterator<TCEntry> i = l.iterator(); i.hasNext(); ) {
+                                TCEntry tc = i.next();
                                 if ( tc.getType().equals( type ) ) {
                                     if ( results == null ) {
                                         results = new ArrayList<TCEntry>();
@@ -357,7 +350,7 @@
             version +
             ", " + type );
         List<String> results = null;
-        List<Map> lfnList = new ArrayList<Map>();
+        List<Map<String, List<TCEntry>>> lfnList = new ArrayList<Map<String, List<TCEntry>>>();
         if ( name == null ) {
             if ( type == null ) {
                 //return all the resources only
@@ -368,20 +361,20 @@
         //return all the entries to search for type
         lfnList.addAll( mTreeMap.values() );
 
-        List entries = null;
-        for ( Iterator<Map> i = lfnList.iterator(); i.hasNext(); ) {
-            Map lfnMap = i.next();
+        List<TCEntry> entries = null;
+        for ( Iterator<Map<String, List<TCEntry>>> i = lfnList.iterator(); i.hasNext(); ) {
+            Map<String, List<TCEntry>> lfnMap = i.next();
             if ( entries == null ) {
-                entries = new ArrayList();
+                entries = new ArrayList<TCEntry>();
             }
             if ( name == null ) {
-                for ( Iterator j = lfnMap.values().iterator(); j.hasNext(); ) {
-                    entries.addAll( ( List ) j.next() );
+                for ( Iterator<List<TCEntry>> j = lfnMap.values().iterator(); j.hasNext(); ) {
+                    entries.addAll( j.next() );
                 }
             } else {
                 if ( lfnMap.containsKey( Separator.combine( namespace, name,
                     version ) ) ) {
-                    entries.addAll( ( List ) lfnMap.get( Separator.combine(
+                    entries.addAll( lfnMap.get( Separator.combine(
                         namespace,
                         name,
                         version ) ) );
@@ -389,12 +382,11 @@
             }
         }
         TreeSet<String> rset = null;
-        for ( Iterator i = entries.iterator(); i.hasNext(); ) {
+        for ( Iterator<TCEntry> i = entries.iterator(); i.hasNext(); ) {
             if ( rset == null ) {
                 rset = new TreeSet<String>();
             }
-            TCEntry entry = ( TCEntry ) i.
-                next();
+            TCEntry entry = i.next();
             if ( type == null ) {
                 rset.add( entry.getResourceId() );
             } else {
@@ -464,11 +456,10 @@
         //     Map lMap = i.next();
         for (Map<String,List<TCEntry>> lMap : lfnList) {
             if ( lMap.containsKey( Separator.combine( namespace, name, version ) ) ) {
-                for ( Iterator j = lMap.get( Separator.combine(
+                for ( Iterator<TCEntry> j = lMap.get( Separator.combine(
                     namespace,
                     name, version ) ).iterator(); j.hasNext(); ) {
-                    TCEntry entry = (
-                        TCEntry ) j.next();
+                    TCEntry entry = j.next();
                     if ( type != null ) {
                         if ( !entry.getType().equals( type ) ) {
                             break;
@@ -515,7 +506,8 @@
         logMessage( "\t getTCLogicalNames(" + resourceid + "," + type + ")" );
         List<Object> result = null;
         int[] length = {0, 0};
-        List<Map> lfnMap = new ArrayList<Map>();
+        List<Map<String, List<TCEntry>>> lfnMap = 
+            new ArrayList<Map<String, List<TCEntry>>>();
         String lfn = null, resource = null, tctype = null;
         if ( resourceid == null ) {
             lfnMap.addAll( mTreeMap.values() );
@@ -527,13 +519,12 @@
             }
         }
         if ( lfnMap != null ) {
-            for ( Iterator<Map> i = lfnMap.iterator(); i.hasNext(); ) {
-                for ( Iterator j = i.next().values().iterator();
+            for ( Iterator<Map<String, List<TCEntry>>> i = lfnMap.iterator(); i.hasNext(); ) {
+                for ( Iterator<List<TCEntry>> j = i.next().values().iterator();
                     j.hasNext(); ) {
-                    for ( Iterator k = ( ( List ) j.next() ).iterator();
+                    for ( Iterator<TCEntry> k = j.next().iterator();
                         k.hasNext(); ) {
-                        TCEntry tc = (
-                            TCEntry ) k.next();
+                        TCEntry tc = k.next();
                         String l = null, r = null, t = null;
                         if ( type == null ) {
                             l = tc.getLogicalTransformation();
@@ -588,7 +579,7 @@
      *
      * @see org.globus.swift.catalog.util.Profile
      */
-    public List getTCLfnProfiles( String namespace, String name,
+    public List<Profile> getTCLfnProfiles( String namespace, String name,
         String version ) throws
         Exception {
         throw new UnsupportedOperationException( "Not Implemented" );
@@ -609,32 +600,31 @@
      *
      * @see org.globus.swift.catalog.util.Profile
      */
-    public List getTCPfnProfiles( String pfn, String resourceid, TCType type ) throws
+    public List<Profile> getTCPfnProfiles( String pfn, String resourceid, TCType type ) throws
         Exception {
         logMessage(
             "getTCPfnProfiles(String pfn, String resourceid, TCType type)" );
         logMessage( "\t getTCPfnProfiles(" + pfn + "," + resourceid + "," +
             type + ")" );
 
-        List result = null;
-        List<Map> lfnMap = new ArrayList<Map>();
+        List<Profile> result = null;
+        List<Map<String, List<TCEntry>>> lfnMap = new ArrayList<Map<String, List<TCEntry>>>();
         if ( mTreeMap.containsKey( resourceid ) ) {
             lfnMap.add( mTreeMap.get( resourceid ) );
         }
-        for ( Iterator<Map> i = lfnMap.iterator(); i.hasNext(); ) {
-            for ( Iterator j = i.next().values().iterator();
+        for ( Iterator<Map<String, List<TCEntry>>> i = lfnMap.iterator(); i.hasNext(); ) {
+            for ( Iterator<List<TCEntry>> j = i.next().values().iterator();
                 j.hasNext(); ) {
-                for ( Iterator k = ( ( List ) j.next() ).iterator(); k.hasNext(); ) {
-                    TCEntry tc = (
-                        TCEntry ) k.next();
-                    List profiles = null;
+                for ( Iterator<TCEntry> k = j.next().iterator(); k.hasNext(); ) {
+                    TCEntry tc = k.next();
+                    List<Profile> profiles = null;
                     if ( tc.getPhysicalTransformation().equals( pfn ) ) {
                         if ( type == null || tc.getType().equals( type ) ) {
                             profiles = tc.getProfiles();
                         }
                         if ( profiles != null ) {
                             if ( result == null ) {
-                                result = new ArrayList( 10 );
+                                result = new ArrayList<Profile>( 10 );
                             }
                             result.addAll( profiles );
                         }
@@ -660,11 +650,10 @@
         List<TCEntry> result=new ArrayList<TCEntry>();
         for ( Iterator<Map<String, List<TCEntry>>> i = 
             mTreeMap.values().iterator(); i.hasNext(); ) {
-            for ( Iterator j = i.next().values().iterator();
+            for ( Iterator<List<TCEntry>> j = i.next().values().iterator();
                 j.hasNext(); ) {
-                for ( Iterator k = ( ( List ) j.next() ).iterator(); k.hasNext(); ) {
-                    TCEntry tc = (
-                        TCEntry ) k.next();
+                for ( Iterator<TCEntry> k = j.next().iterator(); k.hasNext(); ) {
+                    TCEntry tc = k.next();
                     result.add(tc);
                 }
 
@@ -715,11 +704,10 @@
      * @throws Exception
      * @see org.globus.swift.catalog.TCEntry
      */
-    public boolean addTCEntry( List entries ) throws
+    public boolean addTCEntry( List<TCEntry> entries ) throws
         Exception {
         for ( int i = 0; i < entries.size(); i++ ) {
-            TCEntry entry = ( ( TCEntry )
-                entries.get( i ) );
+            TCEntry entry = entries.get( i );
             this.addTCEntry( entry.getLogicalNamespace(),
                 entry.getLogicalName(), entry.getLogicalVersion(),
                 entry.getPhysicalTransformation(),
@@ -820,7 +808,7 @@
      */
     public boolean addTCLfnProfile( String namespace, String name,
         String version,
-        List profiles ) throws Exception {
+        List<Profile> profiles ) throws Exception {
         throw new UnsupportedOperationException( "Not Implemented" );
     }
 
@@ -840,7 +828,7 @@
      */
     public boolean addTCPfnProfile( String pfn, TCType type,
         String resourcename,
-        List profiles ) throws Exception {
+        List<Profile> profiles ) throws Exception {
         throw new UnsupportedOperationException( "Not Implemented" );
     }
 
@@ -935,13 +923,13 @@
     }
 
     public boolean deleteTCPfnProfile( String physicalname, TCType type,
-        String resourceid, List profiles ) throws
+        String resourceid, List<Profile> profiles ) throws
         Exception {
         throw new UnsupportedOperationException( "Not Implemented" );
     }
 
     public boolean deleteTCLfnProfile( String namespace, String name,
-        String version, List profiles ) throws
+        String version, List<Profile> profiles ) throws
         Exception {
         throw new UnsupportedOperationException( "Not Implemented" );
     }

Modified: trunk/src/org/globus/swift/catalog/types/Arch.java
===================================================================
--- trunk/src/org/globus/swift/catalog/types/Arch.java	2011-07-07 23:35:39 UTC (rev 4803)
+++ trunk/src/org/globus/swift/catalog/types/Arch.java	2011-07-07 23:36:33 UTC (rev 4804)
@@ -31,7 +31,7 @@
 public class Arch
     implements Serializable {
     private String _value_;
-    private static HashMap _table_ = new HashMap(5);
+    private static HashMap<String, Arch> _table_ = new HashMap<String, Arch>(5);
 
     protected Arch(String value) {
         _value_ = value;
@@ -67,7 +67,7 @@
      * @return Arch
      */
     public static Arch fromValue(String value) throws IllegalStateException {
-        Arch m_enum = (Arch) _table_.get(value.toUpperCase());
+        Arch m_enum = _table_.get(value.toUpperCase());
         if (m_enum == null) {
             throw new IllegalStateException(err);
         }

Modified: trunk/src/org/globus/swift/catalog/types/Os.java
===================================================================
--- trunk/src/org/globus/swift/catalog/types/Os.java	2011-07-07 23:35:39 UTC (rev 4803)
+++ trunk/src/org/globus/swift/catalog/types/Os.java	2011-07-07 23:36:33 UTC (rev 4804)
@@ -31,7 +31,7 @@
 public class Os
     implements Serializable {
     private String _value_;
-    private static HashMap _table_ = new HashMap(5);
+    private static HashMap<String, Os> _table_ = new HashMap<String, Os>(5);
 
     protected Os(String value) {
         _value_ = value;
@@ -65,7 +65,7 @@
      * @return Os
      */
     public static Os fromValue(String value) throws IllegalStateException {
-        Os m_enum = (Os) _table_.get(value.toUpperCase());
+        Os m_enum = _table_.get(value.toUpperCase());
         if (m_enum == null) {
             throw new IllegalStateException(err);
         }

Modified: trunk/src/org/globus/swift/catalog/types/TCType.java
===================================================================
--- trunk/src/org/globus/swift/catalog/types/TCType.java	2011-07-07 23:35:39 UTC (rev 4803)
+++ trunk/src/org/globus/swift/catalog/types/TCType.java	2011-07-07 23:36:33 UTC (rev 4804)
@@ -30,7 +30,7 @@
 public class TCType
     implements Serializable {
     private String _value_;
-    private static HashMap _table_ = new HashMap(6);
+    private static HashMap<String, TCType> _table_ = new HashMap<String, TCType>(6);
 
     protected TCType(String value) {
         _value_ = value;
@@ -68,7 +68,7 @@
      * @return TCType
      */
     public static TCType fromValue(String value) throws IllegalStateException {
-        TCType m_enum = (TCType) _table_.get(value.toUpperCase());
+        TCType m_enum = _table_.get(value.toUpperCase());
         if (m_enum == null) {
             throw new IllegalStateException(err);
         }

Modified: trunk/src/org/globus/swift/catalog/util/Data.java
===================================================================
--- trunk/src/org/globus/swift/catalog/util/Data.java	2011-07-07 23:35:39 UTC (rev 4803)
+++ trunk/src/org/globus/swift/catalog/util/Data.java	2011-07-07 23:36:33 UTC (rev 4804)
@@ -14,13 +14,7 @@
  */
 package org.globus.swift.catalog.util;
 
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.Vector;
 
-import org.apache.log4j.Logger;
-
 /**
  * This is the container for all the Data classes.
  *
@@ -50,46 +44,4 @@
      */
     public abstract String toString();
 
-
-    /**
-     * It converts the contents of the Vector to a String and returns it.
-     * For this to work , all the objects making up the vector should be having
-     * a valid toString() method.
-     *
-     * @param heading   The heading you want to give
-     *                  to the text which is printed
-     *
-     * @param vector    The <code>Vector</code> whose
-     *                  elements you want to print
-     */
-    public String vectorToString(String heading,Vector vector){
-        Enumeration e = vector.elements();
-
-        String st = "\n" + heading;
-        while(e.hasMoreElements()){
-            st += " " + e.nextElement().toString();
-        }
-
-        return st;
-    }
-
-    /**
-     * A small helper method that displays the contents of a Set in a String.
-     *
-     * @param delim  The delimited between the members of the set.
-     * @return  String
-     */
-    public String setToString(Set s, String delim){
-        Iterator it = s.iterator();
-        String st = new String();
-        while(it.hasNext()){
-            st += (String)it.next() + delim;
-        }
-        st = (st.length() > 0)?
-             st.substring(0,st.lastIndexOf(delim)):
-             st;
-        return st;
-    }
-
-
 }
\ No newline at end of file




More information about the Swift-commit mailing list