jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jalka...@apache.org
Subject svn commit: r666852 - in /incubator/jspwiki/trunk/src/com/ecyrd/jspwiki: dav/ dav/items/ event/
Date Wed, 11 Jun 2008 21:36:11 GMT
Author: jalkanen
Date: Wed Jun 11 14:36:10 2008
New Revision: 666852

URL: http://svn.apache.org/viewvc?rev=666852&view=rev
Log:
Switched to use generics.

Modified:
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/DavPath.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/HTMLPagesDavProvider.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/RawPagesDavProvider.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/WikiRootProvider.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/AttachmentItem.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/DavItem.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/DirectoryItem.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/HTMLPageDavItem.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/PageDavItem.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/event/WikiEventManager.java

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/DavPath.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/DavPath.java?rev=666852&r1=666851&r2=666852&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/DavPath.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/DavPath.java Wed Jun 11 14:36:10 2008
@@ -37,7 +37,7 @@
  */
 public class DavPath
 {
-    private ArrayList m_parts = new ArrayList();
+    private ArrayList<String> m_parts = new ArrayList<String>();
     
     private boolean   m_isAbsolute  = false;
     private boolean   m_isDirectory = false;
@@ -153,7 +153,7 @@
    
         for( int i = 0; i < m_parts.size()-(m_isDirectory ? 0 : 1); i++ )
         {
-            result.append( (String)m_parts.get(i) );
+            result.append( m_parts.get(i) );
             result.append( "/" );
         }
         
@@ -170,7 +170,7 @@
     public String filePart()
     {
         if( m_parts.size() > 0 && !m_isDirectory )
-            return (String) m_parts.get( m_parts.size()-1 );
+            return m_parts.get( m_parts.size()-1 );
        
         return "";
     }
@@ -186,7 +186,7 @@
         if( isRoot() ) return "/";
         if( !isDirectory() ) return filePart();
         
-        return (String) m_parts.get( m_parts.size()-1 );
+        return m_parts.get( m_parts.size()-1 );
     }
     
     /**
@@ -235,7 +235,7 @@
         if( idx > size() )
             return null;
         
-        return (String)m_parts.get(idx);
+        return m_parts.get(idx);
     }
     
     /**

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/HTMLPagesDavProvider.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/HTMLPagesDavProvider.java?rev=666852&r1=666851&r2=666852&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/HTMLPagesDavProvider.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/HTMLPagesDavProvider.java Wed Jun 11
14:36:10 2008
@@ -44,7 +44,7 @@
         String st = path.getName();
         
         log.info("Listing contents for dir "+st);
-        ArrayList davItems = new ArrayList();
+        ArrayList<DavItem> davItems = new ArrayList<DavItem>();
         
         try
         {

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/RawPagesDavProvider.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/RawPagesDavProvider.java?rev=666852&r1=666851&r2=666852&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/RawPagesDavProvider.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/RawPagesDavProvider.java Wed Jun 11
14:36:10 2008
@@ -59,7 +59,7 @@
 
     protected Collection listAlphabeticals( DavPath path )
     {
-        ArrayList charList = new ArrayList();
+        ArrayList<Character> charList = new ArrayList<Character>();
         
         try
         {
@@ -84,7 +84,7 @@
         
         Collections.sort( charList );
         
-        ArrayList result = new ArrayList();
+        ArrayList<DavItem> result = new ArrayList<DavItem>();
         
         for( Iterator i = charList.iterator(); i.hasNext(); )
         {
@@ -104,7 +104,7 @@
         String st = path.getName();
         
         log.info("Listing contents for dir "+st);
-        ArrayList davItems = new ArrayList();
+        ArrayList<DavItem> davItems = new ArrayList<DavItem>();
         
         try
         {

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/WikiRootProvider.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/WikiRootProvider.java?rev=666852&r1=666851&r2=666852&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/WikiRootProvider.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/WikiRootProvider.java Wed Jun 11 14:36:10
2008
@@ -37,7 +37,7 @@
 
     public Collection listItems( DavPath path )
     {
-        ArrayList list = new ArrayList();
+        ArrayList<DavItem> list = new ArrayList<DavItem>();
         
         list.add( new TopLevelDavItem(this) );
         

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/AttachmentItem.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/AttachmentItem.java?rev=666852&r1=666851&r2=666852&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/AttachmentItem.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/AttachmentItem.java Wed Jun 11
14:36:10 2008
@@ -57,7 +57,7 @@
      */
     public Collection getPropertySet()
     {
-        Collection set = getCommonProperties();
+        Collection<Element> set = getCommonProperties();
 
         set.add( new Element("getcontentlength",m_davns).setText( Long.toString(getLength()))
);
         set.add( new Element("getcontenttype",m_davns).setText( getContentType() ));

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/DavItem.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/DavItem.java?rev=666852&r1=666851&r2=666852&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/DavItem.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/DavItem.java Wed Jun 11 14:36:10
2008
@@ -35,7 +35,7 @@
 public abstract class DavItem
 {
     protected DavProvider m_provider;
-    protected ArrayList  m_items = new ArrayList();
+    protected ArrayList<DavItem> m_items = new ArrayList<DavItem>();
     protected DavPath     m_path;
     
     protected DavItem( DavProvider provider, DavPath path )
@@ -61,7 +61,7 @@
     
     public Iterator iterator( int depth )
     {
-        ArrayList list = new ArrayList();
+        ArrayList<DavItem> list = new ArrayList<DavItem>();
         
         if( depth == 0 )
         {
@@ -82,7 +82,7 @@
                                 
                 for( Iterator j = di.iterator(-1); i.hasNext(); )
                 {
-                    list.add( j.next() );
+                    list.add( (DavItem)j.next() );
                 }
             }
         }

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/DirectoryItem.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/DirectoryItem.java?rev=666852&r1=666851&r2=666852&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/DirectoryItem.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/DirectoryItem.java Wed Jun 11
14:36:10 2008
@@ -55,7 +55,7 @@
 
     public Collection getPropertySet()
     {
-        ArrayList ts = new ArrayList();
+        ArrayList<Element> ts = new ArrayList<Element>();
         Namespace davns = Namespace.getNamespace( "DAV:" );
         
         ts.add( new Element("resourcetype",davns).addContent(new Element("collection",davns))
);

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/HTMLPageDavItem.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/HTMLPageDavItem.java?rev=666852&r1=666851&r2=666852&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/HTMLPageDavItem.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/HTMLPageDavItem.java Wed Jun 11
14:36:10 2008
@@ -117,7 +117,7 @@
 
     public Collection getPropertySet()
     {
-        Collection set = getCommonProperties();
+        Collection<Element> set = getCommonProperties();
 
         //
         //  Rendering the page for every single time is not really a very good idea.

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/PageDavItem.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/PageDavItem.java?rev=666852&r1=666851&r2=666852&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/PageDavItem.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/dav/items/PageDavItem.java Wed Jun 11 14:36:10
2008
@@ -59,9 +59,9 @@
         return m_page;
     }
     
-    protected Collection getCommonProperties()
+    protected Collection<Element> getCommonProperties()
     {
-        ArrayList set = new ArrayList();
+        ArrayList<Element> set = new ArrayList<Element>();
         
         set.add( new Element("resourcetype",m_davns) );
         set.add( new Element("creator",m_dcns).setText(m_page.getAuthor()) );
@@ -76,7 +76,7 @@
      */
     public Collection getPropertySet()
     {
-        Collection set = getCommonProperties();
+        Collection<Element> set = getCommonProperties();
         
         set.add( new Element("getcontentlength",m_davns).setText( Long.toString(getLength()))
);
         set.add( new Element("getcontenttype",m_davns).setText( getContentType() ));

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/event/WikiEventManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/event/WikiEventManager.java?rev=666852&r1=666851&r2=666852&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/event/WikiEventManager.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/event/WikiEventManager.java Wed Jun 11 14:36:10
2008
@@ -154,10 +154,10 @@
     private static WikiEventListener c_monitor = null;
 
     /* The Map of client object to WikiEventDelegate. */
-    private final Map m_delegates = new HashMap();
+    private final Map<Object, WikiEventDelegate> m_delegates = new HashMap<Object,
WikiEventDelegate>();
 
     /* The Vector containing any preloaded WikiEventDelegates. */
-    private final Vector m_preloadCache = new Vector();
+    private final Vector<WikiEventDelegate> m_preloadCache = new Vector<WikiEventDelegate>();
 
     /* Singleton instance of the WikiEventManager. */
     private static WikiEventManager c_instance = null;
@@ -391,7 +391,7 @@
                 // then see if any of the cached delegates match the class of the incoming
client
                 for( int i = m_preloadCache.size()-1 ; i >= 0 ; i-- ) // start with most-recently
added
                 {
-                    WikiEventDelegate delegate = (WikiEventDelegate)m_preloadCache.elementAt(i);
+                    WikiEventDelegate delegate = m_preloadCache.elementAt(i);
                     if( delegate.getClientClass() == null
                         || delegate.getClientClass().equals(client.getClass()) )
                     {
@@ -406,7 +406,7 @@
                 }
             }
             // otherwise treat normally...
-            WikiEventDelegate delegate = (WikiEventDelegate)m_delegates.get( client );
+            WikiEventDelegate delegate = m_delegates.get( client );
             if( delegate == null )
             {
                 delegate = new WikiEventDelegate( client );
@@ -434,7 +434,7 @@
     {
         /* A list of event listeners for this instance. */
 
-        private ArrayList m_listenerList = new ArrayList();
+        private ArrayList<WeakReference<WikiEventListener>> m_listenerList =
new ArrayList<WeakReference<WikiEventListener>>();
 
         private Class  m_class  = null;
 
@@ -474,7 +474,7 @@
         {
             synchronized( m_listenerList )
             {
-                TreeSet set = new TreeSet( new WikiEventListenerComparator() );
+                TreeSet<WikiEventListener> set = new TreeSet<WikiEventListener>(
new WikiEventListenerComparator() );
 
                 for( Iterator i = m_listenerList.iterator(); i.hasNext(); )
                 {
@@ -501,7 +501,7 @@
         {
             synchronized( m_listenerList )
             {
-                return m_listenerList.add( new WeakReference(listener) );
+                return m_listenerList.add( new WeakReference<WikiEventListener>(listener)
);
             }
         }
 
@@ -578,7 +578,7 @@
                     {
                         for( int i = 0; i < m_listenerList.size(); i++ )
                         {
-                            WeakReference w = (WeakReference)m_listenerList.get(i);
+                            WeakReference w = m_listenerList.get(i);
 
                             if( w.get() == null ) m_listenerList.remove(i--);
                         }
@@ -598,22 +598,14 @@
 
     } // end inner class WikiEventDelegate
 
-    private static class WikiEventListenerComparator implements Comparator
+    private static class WikiEventListenerComparator implements Comparator<WikiEventListener>
     {
         // TODO: This method is a critical performance bottleneck
-        public int compare(Object arg0, Object arg1)
+        public int compare(WikiEventListener w0, WikiEventListener w1)
         {
-            if( arg0 instanceof WikiEventListener && arg1 instanceof WikiEventListener
)
-            {
-                WikiEventListener w0 = (WikiEventListener) arg0;
-                WikiEventListener w1 = (WikiEventListener) arg1;
-
-                if( w1 == w0 || w0.equals(w1) ) return 0;
-
-                return w1.hashCode() - w0.hashCode();
-            }
+            if( w1 == w0 || w0.equals(w1) ) return 0;
 
-            throw new ClassCastException( arg1.getClass().getName() + " != " + arg0.getClass().getName()
);
+            return w1.hashCode() - w0.hashCode();
         }
     }
 } // end com.ecyrd.jspwiki.event.WikiEventManager



Mime
View raw message