jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From juanpa...@apache.org
Subject svn commit: r1547609 - in /jspwiki/trunk/jspwiki-war/src: main/java/org/apache/wiki/ main/java/org/apache/wiki/xmlrpc/ test/java/org/apache/wiki/parser/
Date Tue, 03 Dec 2013 22:20:11 GMT
Author: juanpablo
Date: Tue Dec  3 22:20:11 2013
New Revision: 1547609

URL: http://svn.apache.org/r1547609
Log:
 * typed return of WikiEngine.getAllInterWikiLinks() to Collection< String >; internally
now uses an ArrayList< String > instead of a Vector< String >
 * typed return of WikiEngine.scanWikiLinks() to Collection< String >
 * typed return of LinkCollector.getLinks() to Collection< String >

Modified:
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/LinkCollector.java
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/ReferenceManager.java
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/VariableManager.java
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/WikiEngine.java
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/xmlrpc/RPCHandler.java
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/xmlrpc/RPCHandlerUTF8.java
    jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java

Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/LinkCollector.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/LinkCollector.java?rev=1547609&r1=1547608&r2=1547609&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/LinkCollector.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/LinkCollector.java Tue Dec  3
22:20:11 2013
@@ -21,32 +21,29 @@ package org.apache.wiki;
 import java.util.ArrayList;
 import java.util.Collection;
 
+
 /**
- *  Just a simple class collecting all of the links
- *  that come in.
+ *  Just a simple class collecting all of the links that come in.
  */
-public class LinkCollector
-    implements StringTransmutator
-{
-    private ArrayList<String> m_items = new ArrayList<String>();
+public class LinkCollector implements StringTransmutator {
+	
+    private ArrayList< String > m_items = new ArrayList< String >();
 
     /**
      * Returns a List of Strings representing links.
      * @return the link collection
      */
-    public Collection getLinks()
-    {
+    public Collection< String > getLinks() {
         return m_items;
     }
 
     /**
      * {@inheritDoc}
      */
-    public String mutate( WikiContext context, String in )
-    {
+    public String mutate( WikiContext context, String in ) {
         m_items.add( in );
-
         return in;
     }
+
 }
 

Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/ReferenceManager.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/ReferenceManager.java?rev=1547609&r1=1547608&r2=1547609&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/ReferenceManager.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/ReferenceManager.java Tue Dec
 3 22:20:11 2013
@@ -166,9 +166,7 @@ public class ReferenceManager
     /**
      *  Does a full reference update.  Does not sync; assumes that you do it afterwards.
      */
-    @SuppressWarnings("unchecked")
-    private void updatePageReferences( WikiPage page )
-        throws ProviderException
+    private void updatePageReferences( WikiPage page ) throws ProviderException
     {
         String content = m_engine.getPageManager().getPageText( page.getName(),
                                                                 WikiPageProvider.LATEST_VERSION
);
@@ -661,7 +659,7 @@ public class ReferenceManager
      *  @param page Name of the page to update.
      *  @param references A Collection of Strings, each one pointing to a page this page
references.
      */
-    public synchronized void updateReferences( String page, Collection references )
+    public synchronized void updateReferences( String page, Collection< String > references
)
     {
         internalUpdateReferences(page, references);
 
@@ -679,7 +677,7 @@ public class ReferenceManager
      *  @param references A Collection of Strings, each one pointing to a page this page
references.
      */
 
-    private void internalUpdateReferences(String page, Collection references)
+    private void internalUpdateReferences(String page, Collection< String > references)
     {
         page = getFinalPageName( page );
 
@@ -690,9 +688,9 @@ public class ReferenceManager
         m_refersTo.remove( page );
 
         TreeSet<String> cleanedRefs = new TreeSet<String>();
-        for( Iterator i = references.iterator(); i.hasNext(); )
+        for( Iterator< String > i = references.iterator(); i.hasNext(); )
         {
-            String ref = (String)i.next();
+            String ref = i.next();
 
             ref = getFinalPageName( ref );
 

Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/VariableManager.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/VariableManager.java?rev=1547609&r1=1547608&r2=1547609&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/VariableManager.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/VariableManager.java Tue Dec 
3 22:20:11 2013
@@ -26,7 +26,6 @@ import javax.servlet.http.HttpServletReq
 import javax.servlet.http.HttpSession;
 
 import org.apache.log4j.Logger;
-
 import org.apache.wiki.api.engine.FilterManager;
 import org.apache.wiki.api.filters.PageFilter;
 import org.apache.wiki.i18n.InternationalizationManager;
@@ -424,10 +423,10 @@ public class VariableManager
         {
             StringBuffer res = new StringBuffer();
 
-            for( Iterator i = m_context.getEngine().getAllInterWikiLinks().iterator(); i.hasNext();
)
+            for( Iterator< String > i = m_context.getEngine().getAllInterWikiLinks().iterator();
i.hasNext(); )
             {
                 if( res.length() > 0 ) res.append(", ");
-                String link = (String) i.next();
+                String link = i.next();
                 res.append( link );
                 res.append( " --> " );
                 res.append( m_context.getEngine().getInterWikiURL(link) );    
@@ -439,7 +438,7 @@ public class VariableManager
         {
             StringBuffer res = new StringBuffer();
 
-            for( Iterator<String> i = m_context.getEngine().getAllInlinedImagePatterns().iterator();
i.hasNext(); )
+            for( Iterator< String > i = m_context.getEngine().getAllInlinedImagePatterns().iterator();
i.hasNext(); )
             {
                 if( res.length() > 0 ) res.append(", ");
 

Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/WikiEngine.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/WikiEngine.java?rev=1547609&r1=1547608&r2=1547609&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/WikiEngine.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/WikiEngine.java Tue Dec  3 22:20:11
2013
@@ -531,7 +531,7 @@ public class WikiEngine
         //        of a better way to do the startup-sequence.
         try
         {
-            Class urlclass = ClassUtil.findClass( "org.apache.wiki.url",
+            Class< ? > urlclass = ClassUtil.findClass( "org.apache.wiki.url",
                     TextUtil.getStringProperty( props, PROP_URLCONSTRUCTOR, "DefaultURLConstructor"
) );
             m_urlConstructor = (URLConstructor) urlclass.newInstance();
             m_urlConstructor.initialize( this, props );
@@ -1024,21 +1024,21 @@ public class WikiEngine
      *
      *  @return A Collection of Strings.
      */
-    public Collection getAllInterWikiLinks()
+    public Collection< String > getAllInterWikiLinks()
     {
-        Vector<String> v = new Vector<String>();
+    	ArrayList< String > list = new ArrayList< String >();
 
-        for( Enumeration i = m_properties.propertyNames(); i.hasMoreElements(); )
+        for( Enumeration< ? > i = m_properties.propertyNames(); i.hasMoreElements();
)
         {
-            String prop = (String) i.nextElement();
+            String prop = ( String )i.nextElement();
 
             if( prop.startsWith( PROP_INTERWIKIREF ) )
             {
-                v.add( prop.substring( prop.lastIndexOf(".")+1 ) );
+                list.add( prop.substring( prop.lastIndexOf( "." ) + 1 ) );
             }
         }
 
-        return v;
+        return list;
     }
 
     /**
@@ -1051,9 +1051,9 @@ public class WikiEngine
         Properties props    = getWikiProperties();
         ArrayList<String>  ptrnlist = new ArrayList<String>();
 
-        for( Enumeration e = props.propertyNames(); e.hasMoreElements(); )
+        for( Enumeration< ? > e = props.propertyNames(); e.hasMoreElements(); )
         {
-            String name = (String) e.nextElement();
+            String name = ( String )e.nextElement();
 
             if( name.startsWith( PROP_INLINEIMAGEPTRN ) )
             {
@@ -1565,11 +1565,10 @@ public class WikiEngine
      *  @param pagedata The page contents
      *  @return a Collection of Strings
      */
-    public Collection scanWikiLinks( WikiPage page, String pagedata )
-    {
+    public Collection< String > scanWikiLinks( WikiPage page, String pagedata ) {
         LinkCollector localCollector = new LinkCollector();
 
-        textToHTML( new WikiContext(this,page),
+        textToHTML( new WikiContext( this, page ),
                     pagedata,
                     localCollector,
                     null,
@@ -1685,10 +1684,11 @@ public class WikiEngine
         }
         catch( IOException e )
         {
-            log.error("Failed to scan page data: ", e);
+            log.error( "Failed to scan page data: ", e );
         }
         catch( FilterException e )
         {
+        	log.error( "page filter threw exception: ", e );
             // FIXME: Don't yet know what to do
         }
 
@@ -1943,7 +1943,7 @@ public class WikiEngine
         }
         catch( ProviderException e )
         {
-            log.error("FIXME");
+            log.error( "FIXME", e );
         }
 
         return c;

Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/xmlrpc/RPCHandler.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/xmlrpc/RPCHandler.java?rev=1547609&r1=1547608&r2=1547609&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/xmlrpc/RPCHandler.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/xmlrpc/RPCHandler.java Tue Dec
 3 22:20:11 2013
@@ -278,10 +278,10 @@ public class RPCHandler
         //
         //  Add local links.
         //
-        for( Iterator i = localCollector.getLinks().iterator(); i.hasNext(); )
+        for( Iterator< String > i = localCollector.getLinks().iterator(); i.hasNext();
)
         {
-            String link = (String) i.next();
-            Hashtable<String, String> ht = new Hashtable<String, String>();
+            String link = i.next();
+            Hashtable< String, String > ht = new Hashtable<String, String>();
             ht.put( "page", toRPCString( link ) );
             ht.put( "type", LINK_LOCAL );
 
@@ -311,15 +311,15 @@ public class RPCHandler
         //
         // Add links to inline attachments
         //
-        for( Iterator i = attCollector.getLinks().iterator(); i.hasNext(); )
+        for( Iterator< String > i = attCollector.getLinks().iterator(); i.hasNext();
)
         {
-            String link = (String) i.next();
+            String link = i.next();
 
-            Hashtable<String, String> ht = new Hashtable<String, String>();
+            Hashtable< String, String > ht = new Hashtable< String, String >();
 
             ht.put( "page", toRPCString( link ) );
             ht.put( "type", LINK_LOCAL );
-            ht.put( "href", context.getURL(WikiContext.ATTACH,link) );
+            ht.put( "href", context.getURL( WikiContext.ATTACH, link ) );
 
             result.add( ht );
         }
@@ -329,11 +329,11 @@ public class RPCHandler
         // simply because URLs are by definition ASCII.
         //
 
-        for( Iterator i = extCollector.getLinks().iterator(); i.hasNext(); )
+        for( Iterator< String > i = extCollector.getLinks().iterator(); i.hasNext();
)
         {
-            String link = (String) i.next();
+            String link = i.next();
 
-            Hashtable<String, String> ht = new Hashtable<String, String>();
+            Hashtable< String, String > ht = new Hashtable< String, String >();
 
             ht.put( "page", link );
             ht.put( "type", LINK_EXTERNAL );

Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/xmlrpc/RPCHandlerUTF8.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/xmlrpc/RPCHandlerUTF8.java?rev=1547609&r1=1547608&r2=1547609&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/xmlrpc/RPCHandlerUTF8.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/xmlrpc/RPCHandlerUTF8.java Tue
Dec  3 22:20:11 2013
@@ -233,10 +233,10 @@ public class RPCHandlerUTF8
         //
         //  Add local links.
         //
-        for( Iterator i = localCollector.getLinks().iterator(); i.hasNext(); )
+        for( Iterator< String > i = localCollector.getLinks().iterator(); i.hasNext();
)
         {
-            String link = (String) i.next();
-            Hashtable<String, String> ht = new Hashtable<String, String>();
+            String link = i.next();
+            Hashtable< String, String > ht = new Hashtable< String, String >();
             ht.put( "page", link );
             ht.put( "type", LINK_LOCAL );
 

Modified: jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java?rev=1547609&r1=1547608&r2=1547609&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java
(original)
+++ jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java
Tue Dec  3 22:20:11 2013
@@ -32,9 +32,14 @@ import javax.servlet.ServletException;
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-
 import net.sf.ehcache.CacheManager;
-import org.apache.wiki.*;
+
+import org.apache.wiki.LinkCollector;
+import org.apache.wiki.NoRequiredPropertyException;
+import org.apache.wiki.TestEngine;
+import org.apache.wiki.WikiContext;
+import org.apache.wiki.WikiEngine;
+import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.providers.BasicAttachmentProvider;
@@ -2331,7 +2336,7 @@ public class JSPWikiMarkupParserTest ext
 
         p.parse();
 
-        Collection links = coll.getLinks();
+        Collection< String > links = coll.getLinks();
 
         assertEquals( "no links found", 1, links.size() );
         assertEquals( "wrong link", "Test", links.iterator().next() );
@@ -2354,7 +2359,7 @@ public class JSPWikiMarkupParserTest ext
 
         p.parse();
 
-        Collection links = coll.getLinks();
+        Collection< String > links = coll.getLinks();
 
         assertEquals( "no links found", 1, links.size() );
         assertEquals( "wrong link", PAGE_NAME+"/Test.txt",
@@ -2388,7 +2393,7 @@ public class JSPWikiMarkupParserTest ext
 
             p.parse();
 
-            Collection links = coll.getLinks();
+            Collection< String > links = coll.getLinks();
 
             assertEquals( "no links found", 1, links.size() );
             assertEquals( "wrong link", PAGE_NAME+"/TestAtt.txt",



Mime
View raw message