lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romseyg...@apache.org
Subject [2/3] lucene-solr:master: LUCENE-7360: Explanation.toHtml() is deprecated
Date Wed, 29 Jun 2016 08:32:06 GMT
LUCENE-7360: Explanation.toHtml() is deprecated


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/23119db3
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/23119db3
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/23119db3

Branch: refs/heads/master
Commit: 23119db3606732986d31c6e44ec26fbbde79ef75
Parents: 4070bdd
Author: Alan Woodward <romseygeek@apache.org>
Authored: Wed Jun 29 09:08:16 2016 +0100
Committer: Alan Woodward <romseygeek@apache.org>
Committed: Wed Jun 29 09:13:29 2016 +0100

----------------------------------------------------------------------
 lucene/CHANGES.txt                              |  2 ++
 .../org/apache/lucene/search/Explanation.java   |  1 +
 .../transform/ExplainAugmenterFactory.java      | 22 +++++++++++++++++++-
 3 files changed, 24 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/23119db3/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index e0f11c3..14455ba 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -81,6 +81,8 @@ Other
 
 * LUCENE-7346: Update forbiddenapis to version 2.2.
   (Uwe Schindler)
+
+* LUCENE-7360: Explanation.toHtml() is deprecated. (Alan Woodward)
   
 ======================= Lucene 6.1.0 =======================
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/23119db3/lucene/core/src/java/org/apache/lucene/search/Explanation.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/Explanation.java b/lucene/core/src/java/org/apache/lucene/search/Explanation.java
index 70bf8bc..3e5951a 100644
--- a/lucene/core/src/java/org/apache/lucene/search/Explanation.java
+++ b/lucene/core/src/java/org/apache/lucene/search/Explanation.java
@@ -123,6 +123,7 @@ public final class Explanation {
 
 
   /** Render an explanation as HTML. */
+  @Deprecated
   public String toHtml() {
     StringBuilder buffer = new StringBuilder();
     buffer.append("<ul>\n");

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/23119db3/solr/core/src/java/org/apache/solr/response/transform/ExplainAugmenterFactory.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/response/transform/ExplainAugmenterFactory.java
b/solr/core/src/java/org/apache/solr/response/transform/ExplainAugmenterFactory.java
index 71e4094..f9e1ec6 100644
--- a/solr/core/src/java/org/apache/solr/response/transform/ExplainAugmenterFactory.java
+++ b/solr/core/src/java/org/apache/solr/response/transform/ExplainAugmenterFactory.java
@@ -70,6 +70,26 @@ public class ExplainAugmenterFactory extends TransformerFactory
     return new ExplainAugmenter( field, style );
   }
 
+  /** Render an explanation as HTML. */
+  public static String toHtml(Explanation explanation) {
+    StringBuilder buffer = new StringBuilder();
+    buffer.append("<ul>\n");
+
+    buffer.append("<li>");
+    buffer.append(explanation.getValue()).append(" = ").append(explanation.getDescription());
+    buffer.append("<br />\n");
+
+    Explanation[] details = explanation.getDetails();
+    for (int i = 0 ; i < details.length; i++) {
+      buffer.append(toHtml(details[i]));
+    }
+
+    buffer.append("</li>\n");
+    buffer.append("</ul>\n");
+
+    return buffer.toString();
+  }
+
   static class ExplainAugmenter extends DocTransformer {
     final String name;
     final Style style;
@@ -95,7 +115,7 @@ public class ExplainAugmenterFactory extends TransformerFactory
             doc.setField( name, SolrPluginUtils.explanationToNamedList(exp) );
           }
           else if( style == Style.html ) {
-            doc.setField( name, exp.toHtml() );
+            doc.setField( name, toHtml(exp));
           }
           else {
             doc.setField( name, exp.toString() );


Mime
View raw message