public class DataInputOutputUtilities extends Object
DataInputStream and DataOutputStream| Constructor and Description |
|---|
DataInputOutputUtilities() |
| Modifier and Type | Method and Description |
|---|---|
static List<String> |
getFileDataAttributeValues(org.jdom.Element element)
Returns any
PluginDocument.FILE_DATA_ATTRIBUTE_NAME attributeValues anywhere within the given Element's tree |
static void |
readBooleans(DataInputStream in,
boolean[] values,
int numberOfValues)
Reads some boolean values to a stream, using 1 bit per value (rather than 1 byte per value if you use
DataOutputStream.writeBoolean(boolean) |
static SequenceDocument |
readSequence(DataInput input)
Reads a sequence from this input stream that was previously written using
writeSequence(java.io.DataOutput, com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument ,jebl.util.ProgressListener) |
static String |
readUTF(DataInput input)
Reads UTF (previously written by
writeUTF(java.io.DataOutput, String)) from a DataInput without running into the 65K limit normally encountered with DataInput.readUTF() |
static XMLSerializable |
readXmlSerializable(DataInput input)
Reads an XMLSerializable from this input stream that was previously written using
writeXmlSerializable(java.io.DataOutput, com.biomatters.geneious.publicapi.documents.XMLSerializable, jebl.util.ProgressListener) |
static int |
writeBooleans(DataOutputStream out,
boolean[] values,
int numberOfValues)
Writes some boolean values to a stream, using 1 bit per value (rather than 1 byte per value if you use
DataOutputStream.writeBoolean(boolean) |
static void |
writeSequence(DataOutput out,
SequenceDocument sequence,
ProgressListener progressListener)
Writes a sequence to a DataOutput which can be read back using
readSequence(java.io.DataInput) |
static void |
writeSequence(Geneious.MajorVersion version,
DataOutput out,
SequenceDocument sequence,
ProgressListener progressListener)
Writes a sequence to a DataOutput which can be read back using
readSequence(java.io.DataInput) |
static void |
writeUTF(DataOutput output,
String string)
Writes UTF to a DataOutput without running into the 65K limit normally encountered with
DataOutput.writeUTF(String).When using this to serialize PluginDocument subclasses or other classes that make use of PluginDocument.FILE_DATA_ATTRIBUTE_NAME, care must be taken. |
static void |
writeXmlSerializable(DataOutput out,
XMLSerializable xmlSerializable,
ProgressListener progressListener)
Writes an XmlSerializable object to a DataOutput which can be read back using
readXmlSerializable(java.io.DataInput)This method lacks many of the optimizations that writeSequence(java.io.DataOutput, com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument, jebl.util.ProgressListener) contains. |
public static void writeUTF(DataOutput output, String string) throws IOException
DataOutput.writeUTF(String).PluginDocument.FILE_DATA_ATTRIBUTE_NAME, care must be taken. See the
note in the docs for writeXmlSerializable(DataOutput, XMLSerializable, ProgressListener).output - the DataOutput to write tostring - the string to writeIOException - if an IOException was encountered when writing to outputpublic static String readUTF(DataInput input) throws IOException
writeUTF(java.io.DataOutput, String)) from a DataInput without running into the 65K limit normally encountered with DataInput.readUTF()input - the DataInput to read fromIOException - if an IOException was encountered when reading from inputpublic static SequenceDocument readSequence(DataInput input) throws IOException
writeSequence(java.io.DataOutput, com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument ,jebl.util.ProgressListener)input - the DataInput to read fromIOException - if we can't read a sequencewriteSequence(java.io.DataOutput, com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument ,jebl.util.ProgressListener)public static XMLSerializable readXmlSerializable(DataInput input) throws IOException
writeXmlSerializable(java.io.DataOutput, com.biomatters.geneious.publicapi.documents.XMLSerializable, jebl.util.ProgressListener)input - the DataInput to read fromIOException - if we can't read an XMLSerializablewriteXmlSerializable(java.io.DataOutput, com.biomatters.geneious.publicapi.documents.XMLSerializable, jebl.util.ProgressListener)public static void writeSequence(DataOutput out, SequenceDocument sequence, ProgressListener progressListener) throws IOException
readSequence(java.io.DataInput)out - the DataOutput to write to.sequence - the sequence to writeprogressListener - for reporting progressIOException - if we can't write it.GeneiousObjectInputStream.readSequence()public static void writeSequence(Geneious.MajorVersion version, DataOutput out, SequenceDocument sequence, ProgressListener progressListener) throws IOException
readSequence(java.io.DataInput)version - the major version of Geneious to ensure that this sequence can be read back in by.out - the DataOutput to write to.sequence - the sequence to writeprogressListener - for reporting progressIOException - if we can't write it.GeneiousObjectInputStream.readSequence()public static void writeXmlSerializable(DataOutput out, XMLSerializable xmlSerializable, ProgressListener progressListener) throws IOException
readXmlSerializable(java.io.DataInput)writeSequence(java.io.DataOutput, com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument, jebl.util.ProgressListener) contains.
If applicable, you should use that method instead.PluginDocument.FILE_DATA_ATTRIBUTE_NAME (such as many PluginDocument classes,
in particular SequenceDocument),
In particular, that method has support for .
PluginDocuments and their associated file data are generally stored using this
mechanism. When creating a data file for a plugin document, code will often do so using a temporary file created via FileUtilities.createTempFile(String, boolean).
Once this code has finished executing, and its resulting PluginDocument has been serialized and returned, there is no longer a java variable reference to that
temporary file. This is fine for usages that immediately commit this file to a WritableDatabaseService and return
the version of the file that is now in the database. However, some usages may simply pass the serialized PluginDocument straight back to calling code, which leaves the
temporary file at risk of being deleted by Geneious, which now detects the file is no longer referenced.getFileDataAttributeValues(Element, List) and manually manage the results from that List.out - the DataOutput to write to.xmlSerializable - the XmlSerializable to writeprogressListener - for reporting progressIOException - if we can't write it.readXmlSerializable(java.io.DataInput)public static List<String> getFileDataAttributeValues(org.jdom.Element element)
PluginDocument.FILE_DATA_ATTRIBUTE_NAME attributeValues anywhere within the given Element's treeelement - The elementpublic static int writeBooleans(DataOutputStream out, boolean[] values, int numberOfValues) throws IOException
DataOutputStream.writeBoolean(boolean)out - the stream to write to.values - the values to writenumberOfValues - the number of values from the array to writeIOException - if we can't writereadBooleans(java.io.DataInputStream, boolean[], int)public static void readBooleans(DataInputStream in, boolean[] values, int numberOfValues) throws IOException
DataOutputStream.writeBoolean(boolean)in - the stream to read fromvalues - an array to read the values intonumberOfValues - the number of values to read into the arrayIOException - if we can't writewriteBooleans(java.io.DataOutputStream, boolean[], int)