001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.http.resource;
014
015import java.io.*;
016import java.util.function.*;
017
018import org.apache.juneau.http.entity.*;
019import org.apache.juneau.http.header.*;
020import org.apache.juneau.internal.*;
021
022/**
023 * A streamed, non-repeatable resource that obtains its content from an {@link InputStream}.
024 *
025 * <h5 class='section'>See Also:</h5><ul>
026 *    <li class='link'><a class="doclink" href="../../../../../index.html#juneau-rest-common">juneau-rest-common</a>
027 * </ul>
028 */
029@FluentSetters
030public class StreamResource extends BasicResource {
031
032   //-----------------------------------------------------------------------------------------------------------------
033   // Instance
034   //-----------------------------------------------------------------------------------------------------------------
035
036   /**
037    * Constructor.
038    */
039   public StreamResource() {
040      super(new StreamEntity());
041   }
042
043   /**
044    * Constructor.
045    *
046    * @param contentType The entity content type.
047    * @param contents The entity contents.
048    */
049   public StreamResource(ContentType contentType, InputStream contents) {
050      super(new StreamEntity(contentType, contents));
051   }
052
053   /**
054    * Copy constructor.
055    *
056    * @param copyFrom The bean being copied.
057    */
058   protected StreamResource(StreamResource copyFrom) {
059      super(copyFrom);
060   }
061
062   @Override
063   public StreamResource copy() {
064      return new StreamResource(this);
065   }
066
067   // <FluentSetters>
068
069   @Override /* GENERATED - org.apache.juneau.http.resource.BasicResource */
070   public StreamResource setCached() throws IOException{
071      super.setCached();
072      return this;
073   }
074
075   @Override /* GENERATED - org.apache.juneau.http.resource.BasicResource */
076   public StreamResource setChunked() {
077      super.setChunked();
078      return this;
079   }
080
081   @Override /* GENERATED - org.apache.juneau.http.resource.BasicResource */
082   public StreamResource setChunked(boolean value) {
083      super.setChunked(value);
084      return this;
085   }
086
087   @Override /* GENERATED - org.apache.juneau.http.resource.BasicResource */
088   public StreamResource setContent(Object value) {
089      super.setContent(value);
090      return this;
091   }
092
093   @Override /* GENERATED - org.apache.juneau.http.resource.BasicResource */
094   public StreamResource setContent(Supplier<?> value) {
095      super.setContent(value);
096      return this;
097   }
098
099   @Override /* GENERATED - org.apache.juneau.http.resource.BasicResource */
100   public StreamResource setContentEncoding(String value) {
101      super.setContentEncoding(value);
102      return this;
103   }
104
105   @Override /* GENERATED - org.apache.juneau.http.resource.BasicResource */
106   public StreamResource setContentEncoding(ContentEncoding value) {
107      super.setContentEncoding(value);
108      return this;
109   }
110
111   @Override /* GENERATED - org.apache.juneau.http.resource.BasicResource */
112   public StreamResource setContentLength(long value) {
113      super.setContentLength(value);
114      return this;
115   }
116
117   @Override /* GENERATED - org.apache.juneau.http.resource.BasicResource */
118   public StreamResource setContentType(String value) {
119      super.setContentType(value);
120      return this;
121   }
122
123   @Override /* GENERATED - org.apache.juneau.http.resource.BasicResource */
124   public StreamResource setContentType(ContentType value) {
125      super.setContentType(value);
126      return this;
127   }
128
129   @Override /* GENERATED - org.apache.juneau.http.resource.BasicResource */
130   public StreamResource setHeaders(HeaderList value) {
131      super.setHeaders(value);
132      return this;
133   }
134
135   @Override /* GENERATED - org.apache.juneau.http.resource.BasicResource */
136   public StreamResource setUnmodifiable() {
137      super.setUnmodifiable();
138      return this;
139   }
140
141   // </FluentSetters>
142}