public static boolean addField(Document doc,String field,Object fieldValue){
  Class<?> clazz=fieldValue.getClass();
  if (clazz == String.class) {
    doc.add(new TextField(field,(String)fieldValue,Store.NO));
  }
 else   if (clazz == Long.class) {
    doc.add(new LongPoint(field,(Long)fieldValue));
  }
 else   if (clazz == Integer.class) {
    doc.add(new IntPoint(field,(Integer)fieldValue));
  }
 else   if (clazz == Float.class) {
    doc.add(new FloatPoint(field,(Float)fieldValue));
  }
 else   if (clazz == Double.class) {
    doc.add(new DoublePoint(field,(Double)fieldValue));
  }
 else {
    return false;
  }
  return true;
}

public static boolean addField ( Document doc , String field , Object fieldValue ) { Class < ? > clazz = fieldValue . getClass ( ) ; if ( clazz == String . class ) { doc . add ( new TextField ( field , ( String ) fieldValue , Store . NO ) ) ; } else if ( clazz == Long . class ) { doc . add ( new LongPoint ( field , ( Long ) fieldValue ) ) ; } else if ( clazz == Integer . class ) { doc . add ( new IntPoint ( field , ( Integer ) fieldValue ) ) ; } else if ( clazz == Float . class ) { doc . add ( new FloatPoint ( field , ( Float ) fieldValue ) ) ; } else if ( clazz == Double . class ) { doc . add ( new DoublePoint ( field , ( Double ) fieldValue ) ) ; } else { return false ; } return true ; }
add a field to the document .
