+ /**
+ * Reads a data container including the content data.
+ * @throws IOException
+ */
+ public static DataContainer readFile(DataInput input, Binding expectedBinding) throws IOException, DataFormatException {
+ DataContainer result = readHeader(input);
+ Datatype contentType = (Datatype) DATATYPE_SERIALIZER.deserialize(input);
+ if (!expectedBinding.type().equals(contentType))
+ throw new DataFormatException(
+ "Content type didn't match the type expected for the binding " + expectedBinding
+ + ":\nexpected type: " + expectedBinding.type()
+ + "\nactual type: " + contentType);
+ Object value = Bindings.getSerializerUnchecked(expectedBinding).deserialize(input);
+ result.content = new Variant(expectedBinding, value);
+ return result;
+ }
+