lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r581340 - /lucene/solr/trunk/client/java/solrj/src/org/apache/solr/client/solrj/util/ClientUtils.java
Date Tue, 02 Oct 2007 18:29:29 GMT
Author: ryan
Date: Tue Oct  2 11:29:29 2007
New Revision: 581340

URL: http://svn.apache.org/viewvc?rev=581340&view=rev
Log:
refactor solrj ClientUtils to avoid autoboxing float <> Float.  also, don't send float
value=1.0

Modified:
    lucene/solr/trunk/client/java/solrj/src/org/apache/solr/client/solrj/util/ClientUtils.java

Modified: lucene/solr/trunk/client/java/solrj/src/org/apache/solr/client/solrj/util/ClientUtils.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/client/java/solrj/src/org/apache/solr/client/solrj/util/ClientUtils.java?rev=581340&r1=581339&r2=581340&view=diff
==============================================================================
--- lucene/solr/trunk/client/java/solrj/src/org/apache/solr/client/solrj/util/ClientUtils.java
(original)
+++ lucene/solr/trunk/client/java/solrj/src/org/apache/solr/client/solrj/util/ClientUtils.java
Tue Oct  2 11:29:29 2007
@@ -70,19 +70,6 @@
   
   //------------------------------------------------------------------------
   //------------------------------------------------------------------------
-
-  private static void writeFieldValue(Writer writer, String fieldName, Float boost, Object
fieldValue) throws IOException 
-  {
-    if (fieldValue instanceof Date) {
-      fieldValue = fmtThreadLocal.get().format( (Date)fieldValue );
-    }
-    if( boost != null ) {
-      XML.writeXML(writer, "field", fieldValue.toString(), "name", fieldName, "boost", boost
);          
-    }
-    else if( fieldValue != null ){
-      XML.writeXML(writer, "field", fieldValue.toString(), "name", fieldName);
-    }
-  }
   
   public static void writeXML( SolrInputDocument doc, Writer writer ) throws IOException
   {
@@ -90,8 +77,18 @@
    
     for( SolrInputField field : doc ) {
       float boost = field.getBoost();
-      for( Object o : field ) {
-        writeFieldValue(writer, field.getName(), boost, o );
+      String name = field.getName();
+      for( Object v : field ) {
+        if (v instanceof Date) {
+          v = fmtThreadLocal.get().format( (Date)v );
+        }
+        if( boost != 1.0f ) {
+          XML.writeXML(writer, "field", v.toString(), "name", name, "boost", boost ); 
+        }
+        else {
+          XML.writeXML(writer, "field", v.toString(), "name", name ); 
+        }
+        
         // only write the boost for the first multi-valued field
         // otherwise, the used boost is the product of all the boost values
         boost = 1.0f; 



Mime
View raw message