jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From juanpa...@apache.org
Subject svn commit: r1547620 - in /jspwiki/trunk/jspwiki-war/src: main/java/org/apache/wiki/ main/java/org/apache/wiki/plugin/ main/java/org/apache/wiki/providers/ main/java/org/apache/wiki/search/ main/java/org/apache/wiki/tags/ test/java/org/apache/wiki/search/
Date Tue, 03 Dec 2013 22:39:57 GMT
Author: juanpablo
Date: Tue Dec  3 22:39:56 2013
New Revision: 1547620

URL: http://svn.apache.org/r1547620
Log:
org.apache.wiki.SearchResult, org.apache.wiki.SearchResultComparator and org.apache.wiki.SearchMatcher
moved to org.apache.wiki.search package

Added:
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/SearchMatcher.java
      - copied, changed from r1546194, jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/SearchMatcher.java
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/SearchResult.java
      - copied, changed from r1546194, jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/SearchResult.java
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/SearchResultComparator.java
      - copied, changed from r1546194, jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/SearchResultComparator.java
Removed:
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/SearchMatcher.java
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/SearchResult.java
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/SearchResultComparator.java
Modified:
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/Search.java
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/providers/AbstractFileProvider.java
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/BasicSearchProvider.java
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/tags/SearchResultIteratorTag.java
    jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/search/SearchManagerTest.java

Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/Search.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/Search.java?rev=1547620&r1=1547619&r2=1547620&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/Search.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/plugin/Search.java Tue Dec  3
22:39:56 2013
@@ -23,14 +23,18 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.Map;
 
-import org.apache.ecs.xhtml.*;
+import org.apache.ecs.xhtml.b;
+import org.apache.ecs.xhtml.table;
+import org.apache.ecs.xhtml.td;
+import org.apache.ecs.xhtml.th;
+import org.apache.ecs.xhtml.tr;
 import org.apache.log4j.Logger;
-import org.apache.wiki.SearchResult;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.api.exceptions.PluginException;
 import org.apache.wiki.api.plugin.WikiPlugin;
 import org.apache.wiki.providers.ProviderException;
+import org.apache.wiki.search.SearchResult;
 
 /**
  *  The "Search" plugin allows you to access the JSPWiki search routines and show the displays
in an array on your page. 

Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/providers/AbstractFileProvider.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/providers/AbstractFileProvider.java?rev=1547620&r1=1547619&r2=1547620&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/providers/AbstractFileProvider.java
(original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/providers/AbstractFileProvider.java
Tue Dec  3 22:39:56 2013
@@ -18,12 +18,33 @@
  */
 package org.apache.wiki.providers;
 
-import java.io.*;
-import java.util.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
+import java.util.TreeSet;
 
 import org.apache.log4j.Logger;
-import org.apache.wiki.*;
+import org.apache.wiki.InternalWikiException;
+import org.apache.wiki.QueryItem;
+import org.apache.wiki.WikiEngine;
+import org.apache.wiki.WikiPage;
+import org.apache.wiki.WikiProvider;
 import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
+import org.apache.wiki.search.SearchMatcher;
+import org.apache.wiki.search.SearchResult;
+import org.apache.wiki.search.SearchResultComparator;
 import org.apache.wiki.util.FileUtil;
 import org.apache.wiki.util.TextUtil;
 

Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/BasicSearchProvider.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/BasicSearchProvider.java?rev=1547620&r1=1547619&r2=1547620&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/BasicSearchProvider.java
(original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/BasicSearchProvider.java
Tue Dec  3 22:39:56 2013
@@ -27,9 +27,6 @@ import java.util.TreeSet;
 
 import org.apache.log4j.Logger;
 import org.apache.wiki.QueryItem;
-import org.apache.wiki.SearchMatcher;
-import org.apache.wiki.SearchResult;
-import org.apache.wiki.SearchResultComparator;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.exceptions.NoRequiredPropertyException;

Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java?rev=1547620&r1=1547619&r2=1547620&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java
(original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java
Tue Dec  3 22:39:56 2013
@@ -64,7 +64,6 @@ import org.apache.lucene.store.LockObtai
 import org.apache.lucene.store.SimpleFSDirectory;
 import org.apache.lucene.util.Version;
 import org.apache.wiki.InternalWikiException;
-import org.apache.wiki.SearchResult;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.WikiProvider;

Copied: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/SearchMatcher.java
(from r1546194, jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/SearchMatcher.java)
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/SearchMatcher.java?p2=jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/SearchMatcher.java&p1=jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/SearchMatcher.java&r1=1546194&r2=1547620&rev=1547620&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/SearchMatcher.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/SearchMatcher.java Tue
Dec  3 22:39:56 2013
@@ -16,13 +16,17 @@
     specific language governing permissions and limitations
     under the License.   
  */
-package org.apache.wiki;
+package org.apache.wiki.search;
 
 
 import java.io.IOException;
 import java.io.BufferedReader;
 import java.io.StringReader;
 
+import org.apache.wiki.QueryItem;
+import org.apache.wiki.WikiEngine;
+import org.apache.wiki.WikiPage;
+
 /**
  * SearchMatcher performs the task of matching a search query to a page's
  * contents. This utility class is isolated to simplify WikiPageProvider
@@ -31,9 +35,8 @@ import java.io.StringReader;
  *
  * @since 2.1.5
  */
-// FIXME: Move to the "search" -package in 3.0
-public class SearchMatcher
-{
+public class SearchMatcher {
+	
     private QueryItem[] m_queries;
     private WikiEngine m_engine;
 
@@ -43,8 +46,7 @@ public class SearchMatcher
      *  @param engine The WikiEngine
      *  @param queries A list of queries
      */
-    public SearchMatcher( WikiEngine engine, QueryItem[] queries )
-    {
+    public SearchMatcher( WikiEngine engine, QueryItem[] queries ) {
         m_engine = engine;
         m_queries = queries;
     }
@@ -61,11 +63,8 @@ public class SearchMatcher
      * @return A SearchResult item, or null, there are no queries
      * @throws IOException If reading page content fails
      */
-    public SearchResult matchPageContent( String wikiname, String pageText )
-        throws IOException
-    {
-        if( m_queries == null )
-        {
+    public SearchResult matchPageContent( String wikiname, String pageText ) throws IOException
{
+        if( m_queries == null ) {
             return null;
         }
 
@@ -73,22 +72,16 @@ public class SearchMatcher
         BufferedReader in = new BufferedReader( new StringReader( pageText ) );
         String line = null;
 
-        while( (line = in.readLine()) != null )
-        {
+        while( (line = in.readLine() ) != null ) {
             line = line.toLowerCase();
 
-            for( int j = 0; j < m_queries.length; j++ )
-            {
+            for( int j = 0; j < m_queries.length; j++ ) {
                 int index = -1;
 
-                while( (index = line.indexOf( m_queries[j].word, index+1 )) != -1 )
-                {
-                    if( m_queries[j].type != QueryItem.FORBIDDEN )
-                    {
+                while( (index = line.indexOf( m_queries[j].word, index + 1 ) ) != -1 ) {
+                    if( m_queries[j].type != QueryItem.FORBIDDEN ) {
                         scores[j]++; // Mark, found this word n times
-                    }
-                    else
-                    {
+                    } else {
                         // Found something that was forbidden.
                         return null;
                     }
@@ -99,23 +92,20 @@ public class SearchMatcher
         //
         //  Check that we have all required words.
         //
-
         int totalscore = 0;
 
-        for( int j = 0; j < scores.length; j++ )
-        {
+        for( int j = 0; j < scores.length; j++ ) {
             // Give five points for each occurrence
             // of the word in the wiki name.
 
-            if( wikiname.toLowerCase().indexOf( m_queries[j].word ) != -1 &&
-                m_queries[j].type != QueryItem.FORBIDDEN )
+            if( wikiname.toLowerCase().indexOf( m_queries[j].word ) != -1 && m_queries[j].type
!= QueryItem.FORBIDDEN ) {
                 scores[j] += 5;
+            }
 
             //  Filter out pages if the search word is marked 'required'
             //  but they have no score.
 
-            if( m_queries[j].type == QueryItem.REQUIRED && scores[j] == 0 )
-            {
+            if( m_queries[j].type == QueryItem.REQUIRED && scores[j] == 0 ) {
                 return null;
             }
 
@@ -125,8 +115,7 @@ public class SearchMatcher
             totalscore += scores[j];
         }
 
-        if( totalscore > 0 )
-        {
+        if( totalscore > 0 ) {
             return new SearchResultImpl( wikiname, totalscore );
         }
 
@@ -135,11 +124,9 @@ public class SearchMatcher
 
     /**
      *  A local search result.
-     *  
      */
-    public class SearchResultImpl
-        implements SearchResult
-    {
+    public class SearchResultImpl implements SearchResult {
+    	
         int      m_score;
         WikiPage m_page;
 
@@ -149,8 +136,7 @@ public class SearchMatcher
          *  @param name Page Name
          *  @param score A score from 0+
          */
-        public SearchResultImpl( String name, int score )
-        {
+        public SearchResultImpl( String name, int score ) {
             m_page  = new WikiPage( m_engine, name );
             m_score = score;
         }
@@ -159,8 +145,7 @@ public class SearchMatcher
          *  Returns Wikipage for this result.
          *  @return WikiPage
          */
-        public WikiPage getPage()
-        {
+        public WikiPage getPage() {
             return m_page;
         }
 
@@ -169,8 +154,7 @@ public class SearchMatcher
          *  
          *  @return Score from 0+
          */
-        public int getScore()
-        {
+        public int getScore() {
             return m_score;
         }
 
@@ -180,8 +164,7 @@ public class SearchMatcher
          *  
          *  @return an empty array
          */
-        public String[] getContexts()
-        {
+        public String[] getContexts() {
             // Unimplemented
             return new String[0];
         }

Copied: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/SearchResult.java (from
r1546194, jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/SearchResult.java)
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/SearchResult.java?p2=jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/SearchResult.java&p1=jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/SearchResult.java&r1=1546194&r2=1547620&rev=1547620&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/SearchResult.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/SearchResult.java Tue Dec
 3 22:39:56 2013
@@ -16,15 +16,17 @@
     specific language governing permissions and limitations
     under the License.     
  */
-package org.apache.wiki;
+package org.apache.wiki.search;
+
+import org.apache.wiki.WikiPage;
+
 
 /**
  *  Defines a search result.
  */
-// FIXME3.0: Move to the search-package
-public interface SearchResult
-{
-    /**
+public interface SearchResult {
+    
+	/**
      *  Return the page.
      *  
      *  @return the WikiPage object containing this result
@@ -36,16 +38,15 @@ public interface SearchResult
      *  
      *  @return A positive score value.  Note that there is no upper limit for the score.
      */
-
     int getScore();
     
     
     /**
-     * Collection of XHTML fragments representing some contexts in which
-     * the match was made (a.k.a., "snippets").
+     * Collection of XHTML fragments representing some contexts in which the match was made
(a.k.a., "snippets").
      *
      * @return the search results
      * @since 2.4
      */
     String[] getContexts();
+
 }

Copied: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/SearchResultComparator.java
(from r1546194, jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/SearchResultComparator.java)
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/SearchResultComparator.java?p2=jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/SearchResultComparator.java&p1=jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/SearchResultComparator.java&r1=1546194&r2=1547620&rev=1547620&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/SearchResultComparator.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/SearchResultComparator.java
Tue Dec  3 22:39:56 2013
@@ -16,19 +16,17 @@
     specific language governing permissions and limitations
     under the License.     
  */
-package org.apache.wiki;
+package org.apache.wiki.search;
 
 import java.io.Serializable;
-import java.util.*;
+import java.util.Comparator;
+
 
 /**
- *  Simple class that decides which search results are more
- *  important than others.
+ *  Simple class that decides which search results are more important than others.
  */
-// FIXME3.0: move to the search package
-public class SearchResultComparator
-    implements Comparator<SearchResult>, Serializable
-{
+public class SearchResultComparator implements Comparator< SearchResult >, Serializable
{
+	
     private static final long serialVersionUID = 1L;
 
     /**
@@ -37,15 +35,16 @@ public class SearchResultComparator
      *  
      *  {@inheritDoc}
      */
-    public int compare( SearchResult s1, SearchResult s2 )
-    {
+    public int compare( SearchResult s1, SearchResult s2 ) {
         // Bigger scores are first.
 
         int res = s2.getScore() - s1.getScore();
 
-        if( res == 0 )
-            res = s1.getPage().getName().compareTo(s2.getPage().getName());
+        if( res == 0 ) {
+            res = s1.getPage().getName().compareTo( s2.getPage().getName() );
+        }
 
         return res;
     }
+
 }

Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/tags/SearchResultIteratorTag.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/tags/SearchResultIteratorTag.java?rev=1547620&r1=1547619&r2=1547620&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/tags/SearchResultIteratorTag.java
(original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/tags/SearchResultIteratorTag.java
Tue Dec  3 22:39:56 2013
@@ -26,10 +26,9 @@ import javax.servlet.jsp.JspWriter;
 import javax.servlet.jsp.PageContext;
 
 import org.apache.log4j.Logger;
-
-import org.apache.wiki.SearchResult;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
+import org.apache.wiki.search.SearchResult;
 import org.apache.wiki.ui.Command;
 import org.apache.wiki.ui.PageCommand;
 

Modified: jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/search/SearchManagerTest.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/search/SearchManagerTest.java?rev=1547620&r1=1547619&r2=1547620&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/search/SearchManagerTest.java
(original)
+++ jspwiki/trunk/jspwiki-war/src/test/java/org/apache/wiki/search/SearchManagerTest.java
Tue Dec  3 22:39:56 2013
@@ -28,7 +28,6 @@ import junit.framework.TestSuite;
 import net.sf.ehcache.CacheManager;
 import net.sourceforge.stripes.mock.MockHttpServletRequest;
 
-import org.apache.wiki.SearchResult;
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
 



Mime
View raw message