public void writeTo(Object obj, String mimeType, OutputStream os) throws IOException { Preconditions.checkNotNull(obj, "obj"); // Get the output properties to use when generating content OutputProperties outputProperties = getThreadOutputProperties(); AltRegistry altRegistry = outputProperties.getAltRegistry(); ContentType contentType = new ContentType(mimeType); final AltFormat altFormat = altRegistry.lookupType(contentType); OutputGenerator<?> generator = altRegistry.getGenerator(altFormat); if (generator == null) { throw new IllegalStateException("Unable to generate media: " + contentType); } generateAtom(generator, os, new ForwardingOutputProperties(outputProperties) { @Override public ContentType getContentType() { return altFormat.getContentType(); } }, obj); } }
public void writeTo(Object obj, String mimeType, OutputStream os) throws IOException { Preconditions.checkNotNull(obj, "obj"); // Get the output properties to use when generating content OutputProperties outputProperties = getThreadOutputProperties(); AltRegistry altRegistry = outputProperties.getAltRegistry(); ContentType contentType = new ContentType(mimeType); final AltFormat altFormat = altRegistry.lookupType(contentType); OutputGenerator<?> generator = altRegistry.getGenerator(altFormat); if (generator == null) { throw new IllegalStateException("Unable to generate media: " + contentType); } generateAtom(generator, os, new ForwardingOutputProperties(outputProperties) { @Override public ContentType getContentType() { return altFormat.getContentType(); } }, obj); } }