com.ddtek.xmlconverter
Interface SampleGenerator


public interface SampleGenerator

An SampleGenerator is used to create a sample EDI XML file from a message definition.

The SampleGenerator is created from a ConverterFactory using ConverterFactory.newSampleGenerator.

Sometimes, an SampleGenerator will need an instance of the native data file to create the sample EDI XML file, so all the methods in SampleGenerator come in pairs. One of the methods has a Source parameter to provide the native data file while the other method of the pair has no Source parameter and is used when no native data file is required. The caller can determine whether a Source parameter is needed with the requiresSource() method.


Method Summary
 Configuration getConfiguration()
          Get the Configuration object for this SampleGenerator.
 void getSample(Result result)
          Create a sample EDI XML file and write it to the specified result object.
 void getSample(Source source, Result result)
          Create a sample EDI XML file and write it to the specified result object.
 boolean requiresSource()
          Determine whether this SampleGenerator will require an instance of the native data file to generate the sample EDI XML file.
 

Method Detail

getSample

void getSample(Result result)
               throws ConverterException
Create a sample EDI XML file and write it to the specified result object. This method should be used if the native data file is not needed to generate the sample EDI XML output.

Parameters:
result - Specifies where the created sample EDI XML should be written.
Throws:
ConverterException

getSample

void getSample(Source source,
               Result result)
               throws ConverterException
Create a sample EDI XML file and write it to the specified result object. This method should be used if an instance of the native data file is needed to generate the sample EDI XML output.

Parameters:
source - A Source object which specifies an instance of the native data file.
result - Specifies where the created sample EDI XML should be written.
Throws:
ConverterException

requiresSource

boolean requiresSource()
                       throws ConverterException
Determine whether this SampleGenerator will require an instance of the native data file to generate the sample EDI XML file.

If this method returns true, then the caller should use the getSample(Source, Result) method which uses a source object.

If this method returns false, then the caller can use either one of the above methods, or can instead use the getSample(Result) method which does not use a source object. Some converters, such as EDI, will take settings from the source object to set their values, and allow them to be augmented by URI parameters. In those cases, it can be useful to specify a source object. There is never harm in specifying a source object; at the very worst, if it is not necessary it will be silently ignored.

Returns:
A boolean indicating whether a Source object is required to generate the sample EDI XML.
Throws:
ConverterException

getConfiguration

Configuration getConfiguration()
Get the Configuration object for this SampleGenerator. The caller can modify the returned Configuration object. Any changes affect subsequent operations done with this SampleGenerator object.

Returns:
The SampleGenerator's Configuration object.