/**
* Construct an appropriate external representation of the object
* and write it to a file.
* Errors are returned by throwing an IOException containing the
* cause of the problem as its message.
* <P>
* DataType is responsible for validating that the given text
* text from a Popup JTextArea can be converted to an object.
* This text-to-object conversion is the same as validateAndConvertInPopup,
* which may be used internally by the object to do the validation.
* <P>
* The DataType object must flush and close the output stream before returning.
* Typically it will create another object (e.g. an OutputWriter), and
* that is the object that must be flushed and closed.
*
* <P>
* File is assumed to be and ASCII string of digits
* representing a value of this data type.
*/
/**
* Construct an appropriate external representation of the object and write it to a file. Errors are
* returned by throwing an IOException containing the cause of the problem as its message.
* <P>
* DataType is responsible for validating that the given text text from a Popup JTextArea can be converted
* to an object. This text-to-object conversion is the same as validateAndConvertInPopup, which may be used
* internally by the object to do the validation.
* <P>
* The DataType object must flush and close the output stream before returning. Typically it will create
* another object (e.g. an OutputWriter), and that is the object that must be flushed and closed.
* <P>
* File is assumed to be and ASCII string of digits representing a value of this data type.
*/
/**
* Construct an appropriate external representation of the object
* and write it to a file.
* Errors are returned by throwing an IOException containing the
* cause of the problem as its message.
* <P>
* DataType is responsible for validating that the given text
* text from a Popup JTextArea can be converted to an object.
* This text-to-object conversion is the same as validateAndConvertInPopup,
* which may be used internally by the object to do the validation.
* <P>
* The DataType object must flush and close the output stream before returning.
* Typically it will create another object (e.g. an OutputWriter), and
* that is the object that must be flushed and closed.
*
* <P>
* File is assumed to be and ASCII string of digits
* representing a value of this data type.
*/
/**
* Construct an appropriate external representation of the object
* and write it to a file.
* Errors are returned by throwing an IOException containing the
* cause of the problem as its message.
* <P>
* DataType is responsible for validating that the given text
* text from a Popup JTextArea can be converted to an object.
* This text-to-object conversion is the same as validateAndConvertInPopup,
* which may be used internally by the object to do the validation.
* <P>
* The DataType object must flush and close the output stream before returning.
* Typically it will create another object (e.g. an OutputWriter), and
* that is the object that must be flushed and closed.
*
* <P>
* File is assumed to be and ASCII string of digits
* representing a value of this data type.
*/
public void exportObject(FileOutputStream outStream, String text) throws IOException {
OutputStreamWriter outWriter = new OutputStreamWriter(outStream);
// check that the text is a valid representation
StringBuffer messageBuffer = new StringBuffer();
validateAndConvertInPopup(text, null, messageBuffer);
if (messageBuffer.length() > 0) {
// there was an error in the conversion
throw new IOException(new String(messageBuffer));
}
// just send the text to the output file
outWriter.write(text);
outWriter.flush();
outWriter.close();
}
|