Public interface ITPDSDataSender
The ITPDSDataSender interface provides for sending binary data to the ITP/Server server. This is typically something like the XML stream used as data input for an ITP process.
This interface is used to send data when this is requested by the ReceiveFile Src(...) Dest(...) command.
import com.aia_itp.itpdsapi.*;
import java.io.*;
class MyClass implements ITPDSDataSender
{
....
public ITPDSInputStream ITPDSSendData(String DataItem)
{
try
{
// We're going to 'read' the file corresponding to 'DataItem'...
java.io.File f = new java.io.File(DataItem + ".xml");
InputStream stream = new BufferedInputStream(new FileInputStream(f));
return new ITPDSInputStream(stream, (int)f.length());
}
catch(Exception e)
{
return null;
}
}
public void ITPDSSendDataFinished(String DataItem, ITPDSInputStream out)
{
try
{
out.getInputStream().close();
}
catch(Exception e)
{
}
}
....
}
public ITPDSInputStream ITPDSSendData(java.lang.String DataItem)
Method called when the ITP/Server server executes a ReceiveFile command.
This method should return either null to indicate that it does not want to send the data or an ITPDSInputStream object from which the data will be read.
The InputStream object that is returned must be wrapped in an ITPDSInputStream object, because ITP/Server requires the size of the data to be available before actually sending the data.
DataItem: The Client parameter as passed in the ReceiveFile Src(...) Dest(...) command.
public void ITPDSSendDataFinished(java.lang.String DataItem,ITPDSInputStream in)
Method call when sending the data has been finished.
When this method is called all data has been sent to the ITP/Server server. It is typically used to close the InputStream object.
in - The ITPDSInputStream object as returned by ITPDSSendData.