/** * Sets the output properties for the current {@link java.lang.Thread} and * returns any existing input properties that have been set (so they can be * restored later). */ public static OutputProperties setThreadOutputProperties( OutputProperties outputProperties) { Preconditions.checkNotNull(outputProperties, "outputProperties"); OutputProperties currentProperties = getThreadOutputProperties(); threadOutputProperties.set(outputProperties); return currentProperties; }
/** * Sets the output properties for the current {@link java.lang.Thread} and * returns any existing input properties that have been set (so they can be * restored later). */ public static OutputProperties setThreadOutputProperties( OutputProperties outputProperties) { Preconditions.checkNotNull(outputProperties, "outputProperties"); OutputProperties currentProperties = getThreadOutputProperties(); threadOutputProperties.set(outputProperties); return currentProperties; }
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); } }