001    package railo.commons.net.http.httpclient4.entity;
002    
003    import java.io.ByteArrayInputStream;
004    import java.io.IOException;
005    import java.io.InputStream;
006    import java.io.OutputStream;
007    
008    import org.apache.http.entity.AbstractHttpEntity;
009    
010    public class EmptyHttpEntity extends AbstractHttpEntity implements Entity4 {
011    
012            
013            
014            private String strContentType;
015    
016            /**
017             * Constructor of the class
018             * @param contentType
019             */
020            public EmptyHttpEntity(String contentType) {
021                    super();
022                    setContentType(contentType);
023                    strContentType=contentType;
024            }
025            
026            @Override
027            public long getContentLength() {
028                    return 0;
029            }
030    
031            @Override
032            public boolean isRepeatable() {
033                    return true;
034            }
035    
036            @Override
037            public void writeTo(OutputStream os) {
038                    // do nothing
039            }
040    
041            @Override
042            public InputStream getContent() throws IOException, IllegalStateException {
043                    return new ByteArrayInputStream(new byte[0]);
044            }
045    
046            @Override
047            public boolean isStreaming() {
048                    return false;
049            }
050    
051            @Override
052            public long contentLength() {
053                    return getContentLength();
054            }
055    
056            @Override
057            public String contentType() {
058                    return strContentType;
059            }
060    
061    }