private void visitFromCached(Document document,StoredFieldVisitor visitor) throws IOException {
  for (  IndexableField f : document) {
    FieldInfo info=fieldInfos.fieldInfo(f.name());
switch (visitor.needsField(info)) {
case YES:
      if (f.binaryValue() != null) {
        BytesRef binaryValue=f.binaryValue();
        byte copy[]=new byte[binaryValue.length];
        System.arraycopy(binaryValue.bytes,binaryValue.offset,copy,0,copy.length);
        visitor.binaryField(info,copy);
      }
 else       if (f.numericValue() != null) {
        Number numericValue=f.numericValue();
        if (numericValue instanceof Double) {
          visitor.doubleField(info,numericValue.doubleValue());
        }
 else         if (numericValue instanceof Integer) {
          visitor.intField(info,numericValue.intValue());
        }
 else         if (numericValue instanceof Float) {
          visitor.floatField(info,numericValue.floatValue());
        }
 else         if (numericValue instanceof Long) {
          visitor.longField(info,numericValue.longValue());
        }
 else {
          throw new AssertionError();
        }
      }
 else {
        visitor.stringField(info,f.stringValue());
      }
    break;
case NO:
  break;
case STOP:
return;
}
}
}

private void visitFromCached ( Document document , StoredFieldVisitor visitor ) throws IOException { for ( IndexableField f : document ) { FieldInfo info = fieldInfos . fieldInfo ( f . name ( ) ) ; switch ( visitor . needsField ( info ) ) { case YES : if ( f . binaryValue ( ) != null ) { BytesRef binaryValue = f . binaryValue ( ) ; byte copy [ ] = new byte [ binaryValue . length ] ; System . arraycopy ( binaryValue . bytes , binaryValue . offset , copy , 0 , copy . length ) ; visitor . binaryField ( info , copy ) ; } else if ( f . numericValue ( ) != null ) { Number numericValue = f . numericValue ( ) ; if ( numericValue instanceof Double ) { visitor . doubleField ( info , numericValue . doubleValue ( ) ) ; } else if ( numericValue instanceof Integer ) { visitor . intField ( info , numericValue . intValue ( ) ) ; } else if ( numericValue instanceof Float ) { visitor . floatField ( info , numericValue . floatValue ( ) ) ; } else if ( numericValue instanceof Long ) { visitor . longField ( info , numericValue . longValue ( ) ) ; } else { throw new AssertionError ( ) ; } } else { visitor . stringField ( info , f . stringValue ( ) ) ; } break ; case NO : break ; case STOP : return ; } } }
executes a stored field visitor against a hit from the document cache
