org.springframework.integration.adapter.file
Class SimpleFileMessageMapper

java.lang.Object
  extended by org.springframework.integration.adapter.file.SimpleFileMessageMapper
All Implemented Interfaces:
MessageMapper<java.lang.Object,java.io.File>

public class SimpleFileMessageMapper
extends java.lang.Object
implements MessageMapper<java.lang.Object,java.io.File>

A default MessageMapper for FileTarget, converting payloads of the File, byte[] and String types to files. The name of the newly created file is defined by the FileNameGenerator instance configured with it. By default, it uses a DefaultFileNameGenerator.

Author:
Marius Bogoevici

Field Summary
private  FileNameGenerator fileNameGenerator
           
private  java.io.File parentDirectory
           
 
Constructor Summary
SimpleFileMessageMapper(java.io.File parentDirectory)
           
SimpleFileMessageMapper(java.lang.String parentDirectoryPath)
           
 
Method Summary
 java.io.File mapMessage(Message<java.lang.Object> message)
          Map from the given Message to an Object.
 void setFileNameGenerator(FileNameGenerator fileNameGenerator)
           
 void writeToFile(java.io.File file, java.lang.Object payload)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fileNameGenerator

private volatile FileNameGenerator fileNameGenerator

parentDirectory

private final java.io.File parentDirectory
Constructor Detail

SimpleFileMessageMapper

public SimpleFileMessageMapper(java.lang.String parentDirectoryPath)

SimpleFileMessageMapper

public SimpleFileMessageMapper(java.io.File parentDirectory)
Method Detail

setFileNameGenerator

public void setFileNameGenerator(FileNameGenerator fileNameGenerator)

mapMessage

public java.io.File mapMessage(Message<java.lang.Object> message)
Description copied from interface: MessageMapper
Map from the given Message to an Object.

Specified by:
mapMessage in interface MessageMapper<java.lang.Object,java.io.File>

writeToFile

public void writeToFile(java.io.File file,
                        java.lang.Object payload)
                 throws java.io.IOException
Throws:
java.io.IOException