Return-Path: Delivered-To: apmail-jakarta-httpclient-commits-archive@www.apache.org Received: (qmail 89403 invoked from network); 20 May 2006 16:56:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 May 2006 16:56:05 -0000 Received: (qmail 63883 invoked by uid 500); 20 May 2006 16:56:05 -0000 Mailing-List: contact httpclient-commits-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: httpclient-dev@jakarta.apache.org Delivered-To: mailing list httpclient-commits@jakarta.apache.org Received: (qmail 63868 invoked by uid 99); 20 May 2006 16:56:05 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 20 May 2006 09:56:05 -0700 X-ASF-Spam-Status: No, hits=0.6 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 20 May 2006 09:56:04 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 511461A983A; Sat, 20 May 2006 09:55:44 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r408032 - in /jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/entity: ContentProducer.java EntityTemplate.java Date: Sat, 20 May 2006 16:55:43 -0000 To: httpclient-commits@jakarta.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060520165544.511461A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: olegk Date: Sat May 20 09:55:43 2006 New Revision: 408032 URL: http://svn.apache.org/viewvc?rev=408032&view=rev Log: Added ContentProducer interface and EntityTemplate class Added: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/entity/ContentProducer.java (with props) jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/entity/EntityTemplate.java (with props) Added: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/entity/ContentProducer.java URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/entity/ContentProducer.java?rev=408032&view=auto ============================================================================== --- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/entity/ContentProducer.java (added) +++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/entity/ContentProducer.java Sat May 20 09:55:43 2006 @@ -0,0 +1,51 @@ +/* + * $HeadURL$ + * $Revision$ + * $Date$ + * + * ==================================================================== + * + * Copyright 1999-2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.http.entity; + +import java.io.IOException; +import java.io.OutputStream; + +/** + * An abstract entity content producer. + * + *

Content producers are expected to be able to produce their + * content multiple times

+ * + * @author Oleg Kalnichevski + * + * @version $Revision$ + * + * @since 4.0 + */ +public interface ContentProducer { + + void writeTo(OutputStream outstream) throws IOException; + +} Propchange: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/entity/ContentProducer.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/entity/ContentProducer.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/entity/ContentProducer.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/entity/EntityTemplate.java URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/entity/EntityTemplate.java?rev=408032&view=auto ============================================================================== --- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/entity/EntityTemplate.java (added) +++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/entity/EntityTemplate.java Sat May 20 09:55:43 2006 @@ -0,0 +1,84 @@ +/* + * $HeadURL$ + * $Revision$ + * $Date$ + * + * ==================================================================== + * + * Copyright 1999-2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.http.entity; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +/** + * Entity that delegates the process of content generation to an abstract + * content producer. + * + * @author Oleg Kalnichevski + * + * @version $Revision$ + * + * @since 4.0 + */ +public class EntityTemplate extends AbstractHttpEntity { + + private final ContentProducer contentproducer; + + public EntityTemplate(final ContentProducer contentproducer) { + super(); + if (this.contentproducer == null) { + throw new IllegalArgumentException("Content producer may not be null"); + } + this.contentproducer = contentproducer; + } + + public long getContentLength() { + return -1; + } + + public InputStream getContent() { + throw new UnsupportedOperationException("Entity template does not implement getContent()"); + } + + public boolean isRepeatable() { + return true; + } + + public void writeTo(final OutputStream outstream) throws IOException { + if (outstream == null) { + throw new IllegalArgumentException("Output stream may not be null"); + } + this.contentproducer.writeTo(outstream); + } + + public boolean isStreaming() { + return true; + } + + public void consumeContent() throws IOException { + } + +} Propchange: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/entity/EntityTemplate.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/entity/EntityTemplate.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/entity/EntityTemplate.java ------------------------------------------------------------------------------ svn:mime-type = text/plain