}
public void decode(InputStream in, String contentType, Packet packet, AttachmentSet att ) throws IOException {
List<String> expectedContentTypes = getExpectedContentTypes();
if (contentType != null && !isContentTypeSupported(contentType,expectedContentTypes)) {
throw new UnsupportedMediaException(contentType, expectedContentTypes);
}
String charset = new ContentTypeImpl(contentType).getCharSet();
if (charset != null && !Charset.isSupported(charset)) {
throw new UnsupportedMediaException(charset);
}
XMLStreamReader reader = XMLStreamReaderFactory.create(null, in, charset, true);
reader = new TidyXMLStreamReader(reader, in);
packet.setMessage(decode(reader, att));
}