void prepareFields(){
  adders=new CSVLoaderBase.FieldAdder[fieldnames.length];
  String skipStr=params.get(SKIP);
  List<String> skipFields=skipStr == null ? null : StrUtils.splitSmart(skipStr,',');
  CSVLoaderBase.FieldAdder adder=new CSVLoaderBase.FieldAdder();
  CSVLoaderBase.FieldAdder adderKeepEmpty=new CSVLoaderBase.FieldAdderEmpty();
  for (int i=0; i < fieldnames.length; i++) {
    String fname=fieldnames[i];
    if (fname.length() == 0 || (skipFields != null && skipFields.contains(fname)))     continue;
    boolean keepEmpty=params.getFieldBool(fname,EMPTY,false);
    adders[i]=keepEmpty ? adderKeepEmpty : adder;
    String[] fmap=params.getFieldParams(fname,MAP);
    if (fmap != null) {
      for (      String mapRule : fmap) {
        String[] mapArgs=colonSplit.split(mapRule,-1);
        if (mapArgs.length != 2)         throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,"Map rules must be of the form 'from:to' ,got '" + mapRule + "'");
        adders[i]=new CSVLoaderBase.FieldMapperSingle(mapArgs[0],mapArgs[1],adders[i]);
      }
    }
    if (params.getFieldBool(fname,TRIM,false)) {
      adders[i]=new CSVLoaderBase.FieldTrimmer(adders[i]);
    }
    if (params.getFieldBool(fname,SPLIT,false)) {
      String sepStr=params.getFieldParam(fname,SEPARATOR);
      char fsep=sepStr == null || sepStr.length() == 0 ? ',' : sepStr.charAt(0);
      String encStr=params.getFieldParam(fname,ENCAPSULATOR);
      char fenc=encStr == null || encStr.length() == 0 ? (char)-2 : encStr.charAt(0);
      String escStr=params.getFieldParam(fname,ESCAPE);
      char fesc=escStr == null || escStr.length() == 0 ? CSVStrategy.ESCAPE_DISABLED : escStr.charAt(0);
      CSVStrategy fstrat=new CSVStrategy(fsep,fenc,CSVStrategy.COMMENTS_DISABLED,fesc,false,false,false,false);
      adders[i]=new CSVLoaderBase.FieldSplitter(fstrat,adders[i]);
    }
  }
  Iterator<String> paramNames=params.getParameterNamesIterator();
  while (paramNames.hasNext()) {
    String pname=paramNames.next();
    if (!pname.startsWith(LITERALS_PREFIX))     continue;
    String name=pname.substring(LITERALS_PREFIX.length());
    literals.put(name,params.get(pname));
  }
}

void prepareFields ( ) { adders = new CSVLoaderBase . FieldAdder [ fieldnames . length ] ; String skipStr = params . get ( SKIP ) ; List < String > skipFields = skipStr == null ? null : StrUtils . splitSmart ( skipStr , ',' ) ; CSVLoaderBase . FieldAdder adder = new CSVLoaderBase . FieldAdder ( ) ; CSVLoaderBase . FieldAdder adderKeepEmpty = new CSVLoaderBase . FieldAdderEmpty ( ) ; for ( int i = 0 ; i < fieldnames . length ; i ++ ) { String fname = fieldnames [ i ] ; if ( fname . length ( ) == 0 || ( skipFields != null && skipFields . contains ( fname ) ) ) continue ; boolean keepEmpty = params . getFieldBool ( fname , EMPTY , false ) ; adders [ i ] = keepEmpty ? adderKeepEmpty : adder ; String [ ] fmap = params . getFieldParams ( fname , MAP ) ; if ( fmap != null ) { for ( String mapRule : fmap ) { String [ ] mapArgs = colonSplit . split ( mapRule , - 1 ) ; if ( mapArgs . length != 2 ) throw new SolrException ( SolrException . ErrorCode . BAD_REQUEST , "Map rules must be of the form 'from:to' ,got '" + mapRule + "'" ) ; adders [ i ] = new CSVLoaderBase . FieldMapperSingle ( mapArgs [ 0 ] , mapArgs [ 1 ] , adders [ i ] ) ; } } if ( params . getFieldBool ( fname , TRIM , false ) ) { adders [ i ] = new CSVLoaderBase . FieldTrimmer ( adders [ i ] ) ; } if ( params . getFieldBool ( fname , SPLIT , false ) ) { String sepStr = params . getFieldParam ( fname , SEPARATOR ) ; char fsep = sepStr == null || sepStr . length ( ) == 0 ? ',' : sepStr . charAt ( 0 ) ; String encStr = params . getFieldParam ( fname , ENCAPSULATOR ) ; char fenc = encStr == null || encStr . length ( ) == 0 ? ( char ) - 2 : encStr . charAt ( 0 ) ; String escStr = params . getFieldParam ( fname , ESCAPE ) ; char fesc = escStr == null || escStr . length ( ) == 0 ? CSVStrategy . ESCAPE_DISABLED : escStr . charAt ( 0 ) ; CSVStrategy fstrat = new CSVStrategy ( fsep , fenc , CSVStrategy . COMMENTS_DISABLED , fesc , false , false , false , false ) ; adders [ i ] = new CSVLoaderBase . FieldSplitter ( fstrat , adders [ i ] ) ; } } Iterator < String > paramNames = params . getParameterNamesIterator ( ) ; while ( paramNames . hasNext ( ) ) { String pname = paramNames . next ( ) ; if ( ! pname . startsWith ( LITERALS_PREFIX ) ) continue ; String name = pname . substring ( LITERALS_PREFIX . length ( ) ) ; literals . put ( name , params . get ( pname ) ) ; } }
create the fieldadders that control how each field is indexed
