Tabnine Logo
StreamResource$Builder.mediaType
Code IndexAdd Tabnine to your IDE (free)

How to use
mediaType
method
in
org.apache.juneau.http.StreamResource$Builder

Best Java code snippets using org.apache.juneau.http.StreamResource$Builder.mediaType (Showing top 7 results out of 315)

origin: org.apache.juneau/juneau-rest-client

return (T)StreamResource.create().headers(headers).mediaType(mediaType).contents(getInputStream()).build();
origin: apache/juneau

return (T)StreamResource.create().headers(headers).mediaType(mediaType).contents(getInputStream()).build();
origin: apache/juneau

return (T)StreamResource.create().headers(headers).mediaType(mediaType).contents(getInputStream()).build();
origin: apache/juneau

/**
 * Returns an instance of a {@link StreamResource} that represents the contents of a resource binary file from the
 * classpath.
 *
 * <h5 class='section'>See Also:</h5>
 * <ul>
 *     <li class='jf'>{@link org.apache.juneau.rest.RestContext#REST_classpathResourceFinder}
 *     <li class='jm'>{@link org.apache.juneau.rest.RestRequest#getClasspathStreamResource(String)}
 * </ul>
 *
 * @param name The name of the resource (i.e. the value normally passed to {@link Class#getResourceAsStream(String)}.
 * @param mediaType The value to set as the <js>"Content-Type"</js> header for this object.
 * @param cached If <jk>true</jk>, the resource will be read into a byte array for fast serialization.
 * @return A new stream resource, or <jk>null</jk> if resource could not be found.
 * @throws IOException
 */
@SuppressWarnings("resource")
public StreamResource getClasspathStreamResource(String name, MediaType mediaType, boolean cached) throws IOException {
  InputStream is = context.getClasspathResource(name, getLocale());
  if (is == null)
    return null;
  StreamResource.Builder b = StreamResource.create().mediaType(mediaType).contents(is);
  if (cached)
    b.cached();
  return b.build();
}
origin: org.apache.juneau/juneau-rest-server

/**
 * Returns an instance of a {@link StreamResource} that represents the contents of a resource binary file from the
 * classpath.
 *
 * <h5 class='section'>See Also:</h5>
 * <ul>
 *     <li class='jf'>{@link org.apache.juneau.rest.RestContext#REST_classpathResourceFinder}
 *     <li class='jm'>{@link org.apache.juneau.rest.RestRequest#getClasspathStreamResource(String)}
 * </ul>
 *
 * @param name The name of the resource (i.e. the value normally passed to {@link Class#getResourceAsStream(String)}.
 * @param mediaType The value to set as the <js>"Content-Type"</js> header for this object.
 * @param cached If <jk>true</jk>, the resource will be read into a byte array for fast serialization.
 * @return A new stream resource, or <jk>null</jk> if resource could not be found.
 * @throws IOException
 */
@SuppressWarnings("resource")
public StreamResource getClasspathStreamResource(String name, MediaType mediaType, boolean cached) throws IOException {
  InputStream is = context.getClasspathResource(name, getLocale());
  if (is == null)
    return null;
  StreamResource.Builder b = StreamResource.create().mediaType(mediaType).contents(is);
  if (cached)
    b.cached();
  return b.build();
}
origin: apache/juneau

/**
 * Returns an instance of a {@link StreamResource} that represents the contents of a resource binary file from the
 * classpath.
 *
 * <h5 class='section'>See Also:</h5>
 * <ul>
 *     <li class='jf'>{@link org.apache.juneau.rest.RestContext#REST_classpathResourceFinder}
 *     <li class='jm'>{@link org.apache.juneau.rest.RestRequest#getClasspathStreamResource(String)}
 * </ul>
 *
 * @param name The name of the resource (i.e. the value normally passed to {@link Class#getResourceAsStream(String)}.
 * @param mediaType The value to set as the <js>"Content-Type"</js> header for this object.
 * @param cached If <jk>true</jk>, the resource will be read into a byte array for fast serialization.
 * @return A new stream resource, or <jk>null</jk> if resource could not be found.
 * @throws IOException
 */
@SuppressWarnings("resource")
public StreamResource getClasspathStreamResource(String name, MediaType mediaType, boolean cached) throws IOException {
  InputStream is = context.getClasspathResource(name, getLocale());
  if (is == null)
    return null;
  StreamResource.Builder b = StreamResource.create().mediaType(mediaType).contents(is);
  if (cached)
    b.cached();
  return b.build();
}
origin: apache/juneau

@RestMethod
public StreamResource a03() throws Exception {
  return StreamResource.create().mediaType(MediaType.JSON).build();
}
org.apache.juneau.httpStreamResource$BuildermediaType

Javadoc

Specifies the resource media type string.

Popular methods of StreamResource$Builder

  • build
    Create a new StreamResource using values in this builder.
  • contents
    Specifies the contents for this resource. This method can be called multiple times to add more conte
  • <init>
  • cached
    Specifies that this resource is intended to be cached. This will trigger the contents to be loaded i
  • headers
    Specifies HTTP response header values.
  • header
    Specifies an HTTP response header value.

Popular in Java

  • Finding current android device location
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • requestLocationUpdates (LocationManager)
  • getExternalFilesDir (Context)
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • JComboBox (javax.swing)
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now