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

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

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

origin: apache/juneau

return (T)StreamResource.create().headers(headers).mediaType(mediaType).contents(getInputStream()).build();
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

/**
 * 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 a06() throws Exception {
  return StreamResource.create().contents(new StringReader("foo")).build();
}
origin: apache/juneau

@RestMethod
public StreamResource a03() throws Exception {
  return StreamResource.create().mediaType(MediaType.JSON).build();
}
origin: apache/juneau

@RestMethod
public StreamResource a04() throws Exception {
  return StreamResource.create().contents("foo".getBytes()).build();
}
origin: apache/juneau

@RestMethod
public StreamResource a02() throws Exception {
  return StreamResource.create().header("Foo", "Bar").build();
}
origin: apache/juneau

@RestMethod
public StreamResource a05() throws Exception {
  return StreamResource.create().contents(new ByteArrayInputStream("foo".getBytes())).build();
}
origin: apache/juneau

@RestMethod
public StreamResource a01() throws Exception {
  return StreamResource.create().contents("foo").build();
}
origin: apache/juneau

/**
 * Creates a new instance of a {@link Builder} for this class.
 *
 * @return A new instance of a {@link Builder}.
 */
public static Builder create() {
  return new Builder();
}
origin: apache/juneau

/**
 * Creates a new instance of a {@link Builder} for this class.
 *
 * @return A new instance of a {@link Builder}.
 */
public static Builder create() {
  return new Builder();
}
origin: apache/juneau

  @RestMethod
  public StreamResource a07() throws Exception {
    return StreamResource.create().contents(new StringBuilder("foo")).build();
  }
}
origin: org.apache.juneau/juneau-marshall

/**
 * Creates a new instance of a {@link Builder} for this class.
 *
 * @return A new instance of a {@link Builder}.
 */
public static Builder create() {
  return new Builder();
}
org.apache.juneau.httpStreamResource$Builder

Javadoc

Builder class for constructing StreamResource objects.
See Also:
  • juneau-rest-server.RestMethod.StreamResource

Most used methods

  • 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
  • mediaType
    Specifies the resource media type string.
  • <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

  • Reading from database using SQL prepared statement
  • requestLocationUpdates (LocationManager)
  • compareTo (BigDecimal)
  • getExternalFilesDir (Context)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • JPanel (javax.swing)
  • Top plugins for Android Studio
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