refactor solrj ClientUtils to avoid autoboxing float <> Float. also, don't send float value=1.0

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@581340 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ryan McKinley 2007-10-02 18:29:29 +00:00
parent 8d410307d4
commit 0d4fec041f
1 changed files with 12 additions and 15 deletions

View File

@ -70,19 +70,6 @@ public class ClientUtils
//------------------------------------------------------------------------
//------------------------------------------------------------------------
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 @@ public class ClientUtils
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;