lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hoss...@apache.org
Subject svn commit: r1056594 - in /lucene/dev/trunk/solr/src/solrj/org/apache/solr/client/solrj/response: AnalysisResponseBase.java DocumentAnalysisResponse.java FieldAnalysisResponse.java
Date Sat, 08 Jan 2011 01:58:15 GMT
Author: hossman
Date: Sat Jan  8 01:58:15 2011
New Revision: 1056594

URL: http://svn.apache.org/viewvc?rev=1056594&view=rev
Log:
SOLR-2288: more small tweaks to eliminate compiler warnings .. inlcudes a small code de-dup
refactoring in FieldAnalysisResponse

Modified:
    lucene/dev/trunk/solr/src/solrj/org/apache/solr/client/solrj/response/AnalysisResponseBase.java
    lucene/dev/trunk/solr/src/solrj/org/apache/solr/client/solrj/response/DocumentAnalysisResponse.java
    lucene/dev/trunk/solr/src/solrj/org/apache/solr/client/solrj/response/FieldAnalysisResponse.java

Modified: lucene/dev/trunk/solr/src/solrj/org/apache/solr/client/solrj/response/AnalysisResponseBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/solrj/org/apache/solr/client/solrj/response/AnalysisResponseBase.java?rev=1056594&r1=1056593&r2=1056594&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/solrj/org/apache/solr/client/solrj/response/AnalysisResponseBase.java
(original)
+++ lucene/dev/trunk/solr/src/solrj/org/apache/solr/client/solrj/response/AnalysisResponseBase.java
Sat Jan  8 01:58:15 2011
@@ -62,12 +62,12 @@ public class AnalysisResponseBase extend
    *
    * @return The built analysis phases list.
    */
-  protected List<AnalysisPhase> buildPhases(NamedList<Object> phaseNL) {
+  protected List<AnalysisPhase> buildPhases(NamedList<List<NamedList<Object>>>
phaseNL) {
     List<AnalysisPhase> phases = new ArrayList<AnalysisPhase>(phaseNL.size());
-    for (Map.Entry<String, Object> phaseEntry : phaseNL) {
+    for (Map.Entry<String, List<NamedList<Object>>> phaseEntry : phaseNL)
{
       AnalysisPhase phase = new AnalysisPhase(phaseEntry.getKey());
-      List<NamedList> tokens = (List<NamedList>) phaseEntry.getValue();
-      for (NamedList token : tokens) {
+      List<NamedList<Object>> tokens = phaseEntry.getValue();
+      for (NamedList<Object> token : tokens) {
         TokenInfo tokenInfo = buildTokenInfo(token);
         phase.addTokenInfo(tokenInfo);
       }
@@ -95,7 +95,7 @@ public class AnalysisResponseBase extend
    *
    * @return The built token info.
    */
-  protected TokenInfo buildTokenInfo(NamedList tokenNL) {
+  protected TokenInfo buildTokenInfo(NamedList<Object> tokenNL) {
     String text = (String) tokenNL.get("text");
     String rawText = (String) tokenNL.get("rawText");
     String type = (String) tokenNL.get("type");

Modified: lucene/dev/trunk/solr/src/solrj/org/apache/solr/client/solrj/response/DocumentAnalysisResponse.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/solrj/org/apache/solr/client/solrj/response/DocumentAnalysisResponse.java?rev=1056594&r1=1056593&r2=1056594&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/solrj/org/apache/solr/client/solrj/response/DocumentAnalysisResponse.java
(original)
+++ lucene/dev/trunk/solr/src/solrj/org/apache/solr/client/solrj/response/DocumentAnalysisResponse.java
Sat Jan  8 01:58:15 2011
@@ -42,24 +42,30 @@ public class DocumentAnalysisResponse ex
   public void setResponse(NamedList<Object> response) {
     super.setResponse(response);
 
-    NamedList<Object> analysis = (NamedList<Object>) response.get("analysis");
-    for (Map.Entry<String, Object> documentEntry : analysis) {
-      DocumentAnalysis documentAnalysis = new DocumentAnalysis(documentEntry.getKey());
-      NamedList<Object> document = (NamedList<Object>) documentEntry.getValue();
-      for (Map.Entry<String, Object> fieldEntry : document) {
+    @SuppressWarnings("unchecked")
+    NamedList<NamedList<NamedList<Object>>> analysis 
+      = (NamedList<NamedList<NamedList<Object>>>) response.get("analysis");
+    for (Map.Entry<String, NamedList<NamedList<Object>>> document : analysis)
{
+      DocumentAnalysis documentAnalysis = new DocumentAnalysis(document.getKey());
+      for (Map.Entry<String, NamedList<Object>> fieldEntry : document.getValue())
{
         FieldAnalysis fieldAnalysis = new FieldAnalysis(fieldEntry.getKey());
-        NamedList field = (NamedList) fieldEntry.getValue();
 
-        NamedList<Object> query = (NamedList<Object>) field.get("query");
+        NamedList<Object> field = fieldEntry.getValue();
+
+        @SuppressWarnings("unchecked")
+        NamedList<List<NamedList<Object>>> query 
+          = (NamedList<List<NamedList<Object>>>) field.get("query");
         if (query != null) {
           List<AnalysisPhase> phases = buildPhases(query);
           fieldAnalysis.setQueryPhases(phases);
         }
-
-        NamedList<Object> index = (NamedList<Object>) field.get("index");
-        for (Map.Entry<String, Object> valueEntry : index) {
+        
+        @SuppressWarnings("unchecked")
+        NamedList<NamedList<List<NamedList<Object>>>> index 
+          = (NamedList<NamedList<List<NamedList<Object>>>>) field.get("index");
+        for (Map.Entry<String, NamedList<List<NamedList<Object>>>>
valueEntry : index) {
           String fieldValue = valueEntry.getKey();
-          NamedList<Object> valueNL = (NamedList<Object>) valueEntry.getValue();
+          NamedList<List<NamedList<Object>>> valueNL = valueEntry.getValue();
           List<AnalysisPhase> phases = buildPhases(valueNL);
           fieldAnalysis.setIndexPhases(fieldValue, phases);
         }

Modified: lucene/dev/trunk/solr/src/solrj/org/apache/solr/client/solrj/response/FieldAnalysisResponse.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/solrj/org/apache/solr/client/solrj/response/FieldAnalysisResponse.java?rev=1056594&r1=1056593&r2=1056594&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/solrj/org/apache/solr/client/solrj/response/FieldAnalysisResponse.java
(original)
+++ lucene/dev/trunk/solr/src/solrj/org/apache/solr/client/solrj/response/FieldAnalysisResponse.java
Sat Jan  8 01:58:15 2011
@@ -42,35 +42,35 @@ public class FieldAnalysisResponse exten
   public void setResponse(NamedList<Object> response) {
     super.setResponse(response);
 
-    NamedList analysisNL = (NamedList) response.get("analysis");
+    @SuppressWarnings("unchecked")
+    NamedList<NamedList<NamedList<NamedList<List<NamedList<Object>>>>>>
analysisNL 
+      = (NamedList<NamedList<NamedList<NamedList<List<NamedList<Object>>>>>>)
response.get("analysis");
 
-    NamedList<Object> fieldTypesNL = (NamedList<Object>) analysisNL.get("field_types");
-    for (Map.Entry<String, Object> entry : fieldTypesNL) {
-      Analysis analysis = new Analysis();
-      NamedList fieldTypeNL = (NamedList) entry.getValue();
-      NamedList<Object> queryNL = (NamedList<Object>) fieldTypeNL.get("query");
-      List<AnalysisPhase> phases = (queryNL == null) ? null : buildPhases(queryNL);
-      analysis.setQueryPhases(phases);
-      NamedList<Object> indexNL = (NamedList<Object>) fieldTypeNL.get("index");
-      phases = buildPhases(indexNL);
-      analysis.setIndexPhases(phases);
-      String fieldTypeName = entry.getKey();
-      analysisByFieldTypeName.put(fieldTypeName, analysis);
+    for (Map.Entry<String, NamedList<NamedList<List<NamedList<Object>>>>>
entry 
+           : analysisNL.get("field_types")) {
+
+      analysisByFieldTypeName.put(entry.getKey(), buildAnalysis(entry.getValue()));
     }
 
-    NamedList<Object> fieldNamesNL = (NamedList<Object>) analysisNL.get("field_names");
-    for (Map.Entry<String, Object> entry : fieldNamesNL) {
+    for (Map.Entry<String, NamedList<NamedList<List<NamedList<Object>>>>>
entry 
+           : analysisNL.get("field_names")) {
+
+      analysisByFieldName.put(entry.getKey(), buildAnalysis(entry.getValue()));
+    }
+  }
+
+  private Analysis buildAnalysis(NamedList<NamedList<List<NamedList<Object>>>>
value) {
       Analysis analysis = new Analysis();
-      NamedList fieldNameNL = (NamedList) entry.getValue();
-      NamedList<Object> queryNL = (NamedList<Object>) fieldNameNL.get("query");
+      
+      NamedList<List<NamedList<Object>>> queryNL = value.get("query");
       List<AnalysisPhase> phases = (queryNL == null) ? null : buildPhases(queryNL);
       analysis.setQueryPhases(phases);
-      NamedList<Object> indexNL = (NamedList<Object>) fieldNameNL.get("index");
+
+      NamedList<List<NamedList<Object>>> indexNL = value.get("index");
       phases = buildPhases(indexNL);
       analysis.setIndexPhases(phases);
-      String fieldName = entry.getKey();
-      analysisByFieldName.put(fieldName, analysis);
-    }
+      
+      return analysis;
   }
 
   /**



Mime
View raw message