httpcore-4.3.1

16:36:43.145 INFO  jd.cli.Main - Decompiling httpcore-4.3.1.jar
package org.apache.http.annotation;

import java.lang.annotation.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Documented
@Target({java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.METHOD})
@Retention(RetentionPolicy.CLASS)
public @interface GuardedBy
{
  String value();
}

/* Location:
 * Qualified Name:     org.apache.http.annotation.GuardedBy
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.annotation;

import java.lang.annotation.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Documented
@Target({java.lang.annotation.ElementType.TYPE})
@Retention(RetentionPolicy.CLASS)
public @interface Immutable {}

/* Location:
 * Qualified Name:     org.apache.http.annotation.Immutable
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.annotation;

import java.lang.annotation.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Documented
@Target({java.lang.annotation.ElementType.TYPE})
@Retention(RetentionPolicy.CLASS)
public @interface NotThreadSafe {}

/* Location:
 * Qualified Name:     org.apache.http.annotation.NotThreadSafe
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.annotation;

import java.lang.annotation.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Documented
@Target({java.lang.annotation.ElementType.TYPE})
@Retention(RetentionPolicy.CLASS)
public @interface ThreadSafe {}

/* Location:
 * Qualified Name:     org.apache.http.annotation.ThreadSafe
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.concurrent;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.apache.http.util.Args;

public class BasicFuture<T>
  implements Future<T>, Cancellable
{
  private final FutureCallback<T> callback;
  private volatile boolean completed;
  private volatile boolean cancelled;
  private volatile T result;
  private volatile Exception ex;
  
  public BasicFuture(FutureCallback<T> callback)
  {
    this.callback = callback;
  }
  
  public boolean isCancelled()
  {
    return cancelled;
  }
  
  public boolean isDone()
  {
    return completed;
  }
  
  private T getResult()
    throws ExecutionException
  {
    if (ex != null) {
      throw new ExecutionException(ex);
    }
    return (T)result;
  }
  
  public synchronized T get()
    throws InterruptedException, ExecutionException
  {
    while (!completed) {
      wait();
    }
    return (T)getResult();
  }
  
  public synchronized T get(long timeout, TimeUnit unit)
    throws InterruptedException, ExecutionException, TimeoutException
  {
    Args.notNull(unit, "Time unit");
    long msecs = unit.toMillis(timeout);
    long startTime = msecs <= 0L ? 0L : System.currentTimeMillis();
    long waitTime = msecs;
    if (completed) {
      return (T)getResult();
    }
    if (waitTime <= 0L) {
      throw new TimeoutException();
    }
    do
    {
      wait(waitTime);
      if (completed) {
        return (T)getResult();
      }
      waitTime = msecs - (System.currentTimeMillis() - startTime);
    } while (waitTime > 0L);
    throw new TimeoutException();
  }
  
  public boolean completed(T result)
  {
    synchronized (this)
    {
      if (completed) {
        return false;
      }
      completed = true;
      this.result = result;
      notifyAll();
    }
    if (callback != null) {
      callback.completed(result);
    }
    return true;
  }
  
  public boolean failed(Exception exception)
  {
    synchronized (this)
    {
      if (completed) {
        return false;
      }
      completed = true;
      ex = exception;
      notifyAll();
    }
    if (callback != null) {
      callback.failed(exception);
    }
    return true;
  }
  
  public boolean cancel(boolean mayInterruptIfRunning)
  {
    synchronized (this)
    {
      if (completed) {
        return false;
      }
      completed = true;
      cancelled = true;
      notifyAll();
    }
    if (callback != null) {
      callback.cancelled();
    }
    return true;
  }
  
  public boolean cancel()
  {
    return cancel(true);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.concurrent.BasicFuture
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.concurrent;

public abstract interface Cancellable
{
  public abstract boolean cancel();
}

/* Location:
 * Qualified Name:     org.apache.http.concurrent.Cancellable
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.concurrent;

public abstract interface FutureCallback<T>
{
  public abstract void completed(T paramT);
  
  public abstract void failed(Exception paramException);
  
  public abstract void cancelled();
}

/* Location:
 * Qualified Name:     org.apache.http.concurrent.FutureCallback
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.config;

import java.nio.charset.Charset;
import java.nio.charset.CodingErrorAction;
import org.apache.http.Consts;

public class ConnectionConfig$Builder
{
  private int bufferSize;
  private int fragmentSizeHint;
  private Charset charset;
  private CodingErrorAction malformedInputAction;
  private CodingErrorAction unmappableInputAction;
  private MessageConstraints messageConstraints;
  
  ConnectionConfig$Builder()
  {
    fragmentSizeHint = -1;
  }
  
  public Builder setBufferSize(int bufferSize)
  {
    this.bufferSize = bufferSize;
    return this;
  }
  
  public Builder setFragmentSizeHint(int fragmentSizeHint)
  {
    this.fragmentSizeHint = fragmentSizeHint;
    return this;
  }
  
  public Builder setCharset(Charset charset)
  {
    this.charset = charset;
    return this;
  }
  
  public Builder setMalformedInputAction(CodingErrorAction malformedInputAction)
  {
    this.malformedInputAction = malformedInputAction;
    if ((malformedInputAction != null) && (charset == null)) {
      charset = Consts.ASCII;
    }
    return this;
  }
  
  public Builder setUnmappableInputAction(CodingErrorAction unmappableInputAction)
  {
    this.unmappableInputAction = unmappableInputAction;
    if ((unmappableInputAction != null) && (charset == null)) {
      charset = Consts.ASCII;
    }
    return this;
  }
  
  public Builder setMessageConstraints(MessageConstraints messageConstraints)
  {
    this.messageConstraints = messageConstraints;
    return this;
  }
  
  public ConnectionConfig build()
  {
    Charset cs = charset;
    if ((cs == null) && ((malformedInputAction != null) || (unmappableInputAction != null))) {
      cs = Consts.ASCII;
    }
    int bufSize = bufferSize > 0 ? bufferSize : 8192;
    int fragmentHintSize = fragmentSizeHint >= 0 ? fragmentSizeHint : bufSize;
    return new ConnectionConfig(bufSize, fragmentHintSize, cs, malformedInputAction, unmappableInputAction, messageConstraints);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.config.ConnectionConfig.Builder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.config;

import java.nio.charset.Charset;
import java.nio.charset.CodingErrorAction;
import org.apache.http.Consts;
import org.apache.http.annotation.Immutable;
import org.apache.http.util.Args;

@Immutable
public class ConnectionConfig
  implements Cloneable
{
  public static final ConnectionConfig DEFAULT = new Builder().build();
  private final int bufferSize;
  private final int fragmentSizeHint;
  private final Charset charset;
  private final CodingErrorAction malformedInputAction;
  private final CodingErrorAction unmappableInputAction;
  private final MessageConstraints messageConstraints;
  
  ConnectionConfig(int bufferSize, int fragmentSizeHint, Charset charset, CodingErrorAction malformedInputAction, CodingErrorAction unmappableInputAction, MessageConstraints messageConstraints)
  {
    this.bufferSize = bufferSize;
    this.fragmentSizeHint = fragmentSizeHint;
    this.charset = charset;
    this.malformedInputAction = malformedInputAction;
    this.unmappableInputAction = unmappableInputAction;
    this.messageConstraints = messageConstraints;
  }
  
  public int getBufferSize()
  {
    return bufferSize;
  }
  
  public int getFragmentSizeHint()
  {
    return fragmentSizeHint;
  }
  
  public Charset getCharset()
  {
    return charset;
  }
  
  public CodingErrorAction getMalformedInputAction()
  {
    return malformedInputAction;
  }
  
  public CodingErrorAction getUnmappableInputAction()
  {
    return unmappableInputAction;
  }
  
  public MessageConstraints getMessageConstraints()
  {
    return messageConstraints;
  }
  
  protected ConnectionConfig clone()
    throws CloneNotSupportedException
  {
    return (ConnectionConfig)super.clone();
  }
  
  public String toString()
  {
    StringBuilder builder = new StringBuilder();
    builder.append("[bufferSize=").append(bufferSize).append(", fragmentSizeHint=").append(fragmentSizeHint).append(", charset=").append(charset).append(", malformedInputAction=").append(malformedInputAction).append(", unmappableInputAction=").append(unmappableInputAction).append(", messageConstraints=").append(messageConstraints).append("]");
    
    return builder.toString();
  }
  
  public static Builder custom()
  {
    return new Builder();
  }
  
  public static Builder copy(ConnectionConfig config)
  {
    Args.notNull(config, "Connection config");
    return new Builder().setCharset(config.getCharset()).setMalformedInputAction(config.getMalformedInputAction()).setUnmappableInputAction(config.getUnmappableInputAction()).setMessageConstraints(config.getMessageConstraints());
  }
  
  public static class Builder
  {
    private int bufferSize;
    private int fragmentSizeHint;
    private Charset charset;
    private CodingErrorAction malformedInputAction;
    private CodingErrorAction unmappableInputAction;
    private MessageConstraints messageConstraints;
    
    Builder()
    {
      fragmentSizeHint = -1;
    }
    
    public Builder setBufferSize(int bufferSize)
    {
      this.bufferSize = bufferSize;
      return this;
    }
    
    public Builder setFragmentSizeHint(int fragmentSizeHint)
    {
      this.fragmentSizeHint = fragmentSizeHint;
      return this;
    }
    
    public Builder setCharset(Charset charset)
    {
      this.charset = charset;
      return this;
    }
    
    public Builder setMalformedInputAction(CodingErrorAction malformedInputAction)
    {
      this.malformedInputAction = malformedInputAction;
      if ((malformedInputAction != null) && (charset == null)) {
        charset = Consts.ASCII;
      }
      return this;
    }
    
    public Builder setUnmappableInputAction(CodingErrorAction unmappableInputAction)
    {
      this.unmappableInputAction = unmappableInputAction;
      if ((unmappableInputAction != null) && (charset == null)) {
        charset = Consts.ASCII;
      }
      return this;
    }
    
    public Builder setMessageConstraints(MessageConstraints messageConstraints)
    {
      this.messageConstraints = messageConstraints;
      return this;
    }
    
    public ConnectionConfig build()
    {
      Charset cs = charset;
      if ((cs == null) && ((malformedInputAction != null) || (unmappableInputAction != null))) {
        cs = Consts.ASCII;
      }
      int bufSize = bufferSize > 0 ? bufferSize : 8192;
      int fragmentHintSize = fragmentSizeHint >= 0 ? fragmentSizeHint : bufSize;
      return new ConnectionConfig(bufSize, fragmentHintSize, cs, malformedInputAction, unmappableInputAction, messageConstraints);
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.http.config.ConnectionConfig
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.config;

public abstract interface Lookup<I>
{
  public abstract I lookup(String paramString);
}

/* Location:
 * Qualified Name:     org.apache.http.config.Lookup
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.config;

public class MessageConstraints$Builder
{
  private int maxLineLength;
  private int maxHeaderCount;
  
  MessageConstraints$Builder()
  {
    maxLineLength = -1;
    maxHeaderCount = -1;
  }
  
  public Builder setMaxLineLength(int maxLineLength)
  {
    this.maxLineLength = maxLineLength;
    return this;
  }
  
  public Builder setMaxHeaderCount(int maxHeaderCount)
  {
    this.maxHeaderCount = maxHeaderCount;
    return this;
  }
  
  public MessageConstraints build()
  {
    return new MessageConstraints(maxLineLength, maxHeaderCount);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.config.MessageConstraints.Builder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.config;

import org.apache.http.util.Args;

public class MessageConstraints
  implements Cloneable
{
  public static final MessageConstraints DEFAULT = new Builder().build();
  private final int maxLineLength;
  private final int maxHeaderCount;
  
  MessageConstraints(int maxLineLength, int maxHeaderCount)
  {
    this.maxLineLength = maxLineLength;
    this.maxHeaderCount = maxHeaderCount;
  }
  
  public int getMaxLineLength()
  {
    return maxLineLength;
  }
  
  public int getMaxHeaderCount()
  {
    return maxHeaderCount;
  }
  
  protected MessageConstraints clone()
    throws CloneNotSupportedException
  {
    return (MessageConstraints)super.clone();
  }
  
  public String toString()
  {
    StringBuilder builder = new StringBuilder();
    builder.append("[maxLineLength=").append(maxLineLength).append(", maxHeaderCount=").append(maxHeaderCount).append("]");
    
    return builder.toString();
  }
  
  public static MessageConstraints lineLen(int max)
  {
    return new MessageConstraints(Args.notNegative(max, "Max line length"), -1);
  }
  
  public static Builder custom()
  {
    return new Builder();
  }
  
  public static Builder copy(MessageConstraints config)
  {
    Args.notNull(config, "Message constraints");
    return new Builder().setMaxHeaderCount(config.getMaxHeaderCount()).setMaxLineLength(config.getMaxLineLength());
  }
  
  public static class Builder
  {
    private int maxLineLength;
    private int maxHeaderCount;
    
    Builder()
    {
      maxLineLength = -1;
      maxHeaderCount = -1;
    }
    
    public Builder setMaxLineLength(int maxLineLength)
    {
      this.maxLineLength = maxLineLength;
      return this;
    }
    
    public Builder setMaxHeaderCount(int maxHeaderCount)
    {
      this.maxHeaderCount = maxHeaderCount;
      return this;
    }
    
    public MessageConstraints build()
    {
      return new MessageConstraints(maxLineLength, maxHeaderCount);
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.http.config.MessageConstraints
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.config;

import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.http.annotation.ThreadSafe;

@ThreadSafe
public final class Registry<I>
  implements Lookup<I>
{
  private final Map<String, I> map;
  
  Registry(Map<String, I> map)
  {
    this.map = new ConcurrentHashMap(map);
  }
  
  public I lookup(String key)
  {
    if (key == null) {
      return null;
    }
    return (I)map.get(key.toLowerCase(Locale.US));
  }
  
  public String toString()
  {
    return map.toString();
  }
}

/* Location:
 * Qualified Name:     org.apache.http.config.Registry
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.config;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.util.Args;

@NotThreadSafe
public final class RegistryBuilder<I>
{
  private final Map<String, I> items;
  
  public static <I> RegistryBuilder<I> create()
  {
    return new RegistryBuilder();
  }
  
  RegistryBuilder()
  {
    items = new HashMap();
  }
  
  public RegistryBuilder<I> register(String id, I item)
  {
    Args.notEmpty(id, "ID");
    Args.notNull(item, "Item");
    items.put(id.toLowerCase(Locale.US), item);
    return this;
  }
  
  public Registry<I> build()
  {
    return new Registry(items);
  }
  
  public String toString()
  {
    return items.toString();
  }
}

/* Location:
 * Qualified Name:     org.apache.http.config.RegistryBuilder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.config;

public class SocketConfig$Builder
{
  private int soTimeout;
  private boolean soReuseAddress;
  private int soLinger;
  private boolean soKeepAlive;
  private boolean tcpNoDelay;
  
  SocketConfig$Builder()
  {
    soLinger = -1;
    tcpNoDelay = true;
  }
  
  public Builder setSoTimeout(int soTimeout)
  {
    this.soTimeout = soTimeout;
    return this;
  }
  
  public Builder setSoReuseAddress(boolean soReuseAddress)
  {
    this.soReuseAddress = soReuseAddress;
    return this;
  }
  
  public Builder setSoLinger(int soLinger)
  {
    this.soLinger = soLinger;
    return this;
  }
  
  public Builder setSoKeepAlive(boolean soKeepAlive)
  {
    this.soKeepAlive = soKeepAlive;
    return this;
  }
  
  public Builder setTcpNoDelay(boolean tcpNoDelay)
  {
    this.tcpNoDelay = tcpNoDelay;
    return this;
  }
  
  public SocketConfig build()
  {
    return new SocketConfig(soTimeout, soReuseAddress, soLinger, soKeepAlive, tcpNoDelay);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.config.SocketConfig.Builder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.config;

import org.apache.http.annotation.Immutable;
import org.apache.http.util.Args;

@Immutable
public class SocketConfig
  implements Cloneable
{
  public static final SocketConfig DEFAULT = new Builder().build();
  private final int soTimeout;
  private final boolean soReuseAddress;
  private final int soLinger;
  private final boolean soKeepAlive;
  private final boolean tcpNoDelay;
  
  SocketConfig(int soTimeout, boolean soReuseAddress, int soLinger, boolean soKeepAlive, boolean tcpNoDelay)
  {
    this.soTimeout = soTimeout;
    this.soReuseAddress = soReuseAddress;
    this.soLinger = soLinger;
    this.soKeepAlive = soKeepAlive;
    this.tcpNoDelay = tcpNoDelay;
  }
  
  public int getSoTimeout()
  {
    return soTimeout;
  }
  
  public boolean isSoReuseAddress()
  {
    return soReuseAddress;
  }
  
  public int getSoLinger()
  {
    return soLinger;
  }
  
  public boolean isSoKeepAlive()
  {
    return soKeepAlive;
  }
  
  public boolean isTcpNoDelay()
  {
    return tcpNoDelay;
  }
  
  protected SocketConfig clone()
    throws CloneNotSupportedException
  {
    return (SocketConfig)super.clone();
  }
  
  public String toString()
  {
    StringBuilder builder = new StringBuilder();
    builder.append("[soTimeout=").append(soTimeout).append(", soReuseAddress=").append(soReuseAddress).append(", soLinger=").append(soLinger).append(", soKeepAlive=").append(soKeepAlive).append(", tcpNoDelay=").append(tcpNoDelay).append("]");
    
    return builder.toString();
  }
  
  public static Builder custom()
  {
    return new Builder();
  }
  
  public static Builder copy(SocketConfig config)
  {
    Args.notNull(config, "Socket config");
    return new Builder().setSoTimeout(config.getSoTimeout()).setSoReuseAddress(config.isSoReuseAddress()).setSoLinger(config.getSoLinger()).setSoKeepAlive(config.isSoKeepAlive()).setTcpNoDelay(config.isTcpNoDelay());
  }
  
  public static class Builder
  {
    private int soTimeout;
    private boolean soReuseAddress;
    private int soLinger;
    private boolean soKeepAlive;
    private boolean tcpNoDelay;
    
    Builder()
    {
      soLinger = -1;
      tcpNoDelay = true;
    }
    
    public Builder setSoTimeout(int soTimeout)
    {
      this.soTimeout = soTimeout;
      return this;
    }
    
    public Builder setSoReuseAddress(boolean soReuseAddress)
    {
      this.soReuseAddress = soReuseAddress;
      return this;
    }
    
    public Builder setSoLinger(int soLinger)
    {
      this.soLinger = soLinger;
      return this;
    }
    
    public Builder setSoKeepAlive(boolean soKeepAlive)
    {
      this.soKeepAlive = soKeepAlive;
      return this;
    }
    
    public Builder setTcpNoDelay(boolean tcpNoDelay)
    {
      this.tcpNoDelay = tcpNoDelay;
      return this;
    }
    
    public SocketConfig build()
    {
      return new SocketConfig(soTimeout, soReuseAddress, soLinger, soKeepAlive, tcpNoDelay);
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.http.config.SocketConfig
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http;

import java.io.IOException;

public class ConnectionClosedException
  extends IOException
{
  private static final long serialVersionUID = 617550366255636674L;
  
  public ConnectionClosedException(String message)
  {
    super(message);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.ConnectionClosedException
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http;

import org.apache.http.protocol.HttpContext;

public abstract interface ConnectionReuseStrategy
{
  public abstract boolean keepAlive(HttpResponse paramHttpResponse, HttpContext paramHttpContext);
}

/* Location:
 * Qualified Name:     org.apache.http.ConnectionReuseStrategy
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http;

import java.nio.charset.Charset;

public final class Consts
{
  public static final int CR = 13;
  public static final int LF = 10;
  public static final int SP = 32;
  public static final int HT = 9;
  public static final Charset UTF_8 = Charset.forName("UTF-8");
  public static final Charset ASCII = Charset.forName("US-ASCII");
  public static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1");
}

/* Location:
 * Qualified Name:     org.apache.http.Consts
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http;

import java.io.IOException;

public class ContentTooLongException
  extends IOException
{
  private static final long serialVersionUID = -924287689552495383L;
  
  public ContentTooLongException(String message)
  {
    super(message);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.ContentTooLongException
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.entity;

import java.io.IOException;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.message.BasicHeader;

@NotThreadSafe
public abstract class AbstractHttpEntity
  implements HttpEntity
{
  protected static final int OUTPUT_BUFFER_SIZE = 4096;
  protected Header contentType;
  protected Header contentEncoding;
  protected boolean chunked;
  
  public Header getContentType()
  {
    return contentType;
  }
  
  public Header getContentEncoding()
  {
    return contentEncoding;
  }
  
  public boolean isChunked()
  {
    return chunked;
  }
  
  public void setContentType(Header contentType)
  {
    this.contentType = contentType;
  }
  
  public void setContentType(String ctString)
  {
    Header h = null;
    if (ctString != null) {
      h = new BasicHeader("Content-Type", ctString);
    }
    setContentType(h);
  }
  
  public void setContentEncoding(Header contentEncoding)
  {
    this.contentEncoding = contentEncoding;
  }
  
  public void setContentEncoding(String ceString)
  {
    Header h = null;
    if (ceString != null) {
      h = new BasicHeader("Content-Encoding", ceString);
    }
    setContentEncoding(h);
  }
  
  public void setChunked(boolean b)
  {
    chunked = b;
  }
  
  @Deprecated
  public void consumeContent()
    throws IOException
  {}
}

/* Location:
 * Qualified Name:     org.apache.http.entity.AbstractHttpEntity
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.entity;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.util.Args;
import org.apache.http.util.Asserts;

@NotThreadSafe
public class BasicHttpEntity
  extends AbstractHttpEntity
{
  private InputStream content;
  private long length;
  
  public BasicHttpEntity()
  {
    length = -1L;
  }
  
  public long getContentLength()
  {
    return length;
  }
  
  public InputStream getContent()
    throws IllegalStateException
  {
    Asserts.check(content != null, "Content has not been provided");
    return content;
  }
  
  public boolean isRepeatable()
  {
    return false;
  }
  
  public void setContentLength(long len)
  {
    length = len;
  }
  
  public void setContent(InputStream instream)
  {
    content = instream;
  }
  
  public void writeTo(OutputStream outstream)
    throws IOException
  {
    Args.notNull(outstream, "Output stream");
    InputStream instream = getContent();
    try
    {
      byte[] tmp = new byte['?'];
      int l;
      while ((l = instream.read(tmp)) != -1) {
        outstream.write(tmp, 0, l);
      }
    }
    finally
    {
      instream.close();
    }
  }
  
  public boolean isStreaming()
  {
    return content != null;
  }
}

/* Location:
 * Qualified Name:     org.apache.http.entity.BasicHttpEntity
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.entity;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.http.HttpEntity;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.util.Args;
import org.apache.http.util.EntityUtils;

@NotThreadSafe
public class BufferedHttpEntity
  extends HttpEntityWrapper
{
  private final byte[] buffer;
  
  public BufferedHttpEntity(HttpEntity entity)
    throws IOException
  {
    super(entity);
    if ((!entity.isRepeatable()) || (entity.getContentLength() < 0L)) {
      buffer = EntityUtils.toByteArray(entity);
    } else {
      buffer = null;
    }
  }
  
  public long getContentLength()
  {
    if (buffer != null) {
      return buffer.length;
    }
    return super.getContentLength();
  }
  
  public InputStream getContent()
    throws IOException
  {
    if (buffer != null) {
      return new ByteArrayInputStream(buffer);
    }
    return super.getContent();
  }
  
  public boolean isChunked()
  {
    return (buffer == null) && (super.isChunked());
  }
  
  public boolean isRepeatable()
  {
    return true;
  }
  
  public void writeTo(OutputStream outstream)
    throws IOException
  {
    Args.notNull(outstream, "Output stream");
    if (buffer != null) {
      outstream.write(buffer);
    } else {
      super.writeTo(outstream);
    }
  }
  
  public boolean isStreaming()
  {
    return (buffer == null) && (super.isStreaming());
  }
}

/* Location:
 * Qualified Name:     org.apache.http.entity.BufferedHttpEntity
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.entity;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.util.Args;

@NotThreadSafe
public class ByteArrayEntity
  extends AbstractHttpEntity
  implements Cloneable
{
  @Deprecated
  protected final byte[] content;
  private final byte[] b;
  private final int off;
  private final int len;
  
  public ByteArrayEntity(byte[] b, ContentType contentType)
  {
    Args.notNull(b, "Source byte array");
    content = b;
    this.b = b;
    off = 0;
    len = this.b.length;
    if (contentType != null) {
      setContentType(contentType.toString());
    }
  }
  
  public ByteArrayEntity(byte[] b, int off, int len, ContentType contentType)
  {
    Args.notNull(b, "Source byte array");
    if ((off < 0) || (off > b.length) || (len < 0) || (off + len < 0) || (off + len > b.length)) {
      throw new IndexOutOfBoundsException("off: " + off + " len: " + len + " b.length: " + b.length);
    }
    content = b;
    this.b = b;
    this.off = off;
    this.len = len;
    if (contentType != null) {
      setContentType(contentType.toString());
    }
  }
  
  public ByteArrayEntity(byte[] b)
  {
    this(b, null);
  }
  
  public ByteArrayEntity(byte[] b, int off, int len)
  {
    this(b, off, len, null);
  }
  
  public boolean isRepeatable()
  {
    return true;
  }
  
  public long getContentLength()
  {
    return len;
  }
  
  public InputStream getContent()
  {
    return new ByteArrayInputStream(b, off, len);
  }
  
  public void writeTo(OutputStream outstream)
    throws IOException
  {
    Args.notNull(outstream, "Output stream");
    outstream.write(b, off, len);
    outstream.flush();
  }
  
  public boolean isStreaming()
  {
    return false;
  }
  
  public Object clone()
    throws CloneNotSupportedException
  {
    return super.clone();
  }
}

/* Location:
 * Qualified Name:     org.apache.http.entity.ByteArrayEntity
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.entity;

import org.apache.http.HttpException;
import org.apache.http.HttpMessage;

public abstract interface ContentLengthStrategy
{
  public static final int IDENTITY = -1;
  public static final int CHUNKED = -2;
  
  public abstract long determineLength(HttpMessage paramHttpMessage)
    throws HttpException;
}

/* Location:
 * Qualified Name:     org.apache.http.entity.ContentLengthStrategy
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.entity;

import java.io.IOException;
import java.io.OutputStream;

public abstract interface ContentProducer
{
  public abstract void writeTo(OutputStream paramOutputStream)
    throws IOException;
}

/* Location:
 * Qualified Name:     org.apache.http.entity.ContentProducer
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.entity;

import java.io.Serializable;
import java.nio.charset.Charset;
import java.nio.charset.UnsupportedCharsetException;
import java.util.Locale;
import org.apache.http.Consts;
import org.apache.http.Header;
import org.apache.http.HeaderElement;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.ParseException;
import org.apache.http.annotation.Immutable;
import org.apache.http.message.BasicHeaderValueFormatter;
import org.apache.http.message.BasicHeaderValueParser;
import org.apache.http.message.ParserCursor;
import org.apache.http.util.Args;
import org.apache.http.util.CharArrayBuffer;
import org.apache.http.util.TextUtils;

@Immutable
public final class ContentType
  implements Serializable
{
  private static final long serialVersionUID = -7768694718232371896L;
  public static final ContentType APPLICATION_ATOM_XML = create("application/atom+xml", Consts.ISO_8859_1);
  public static final ContentType APPLICATION_FORM_URLENCODED = create("application/x-www-form-urlencoded", Consts.ISO_8859_1);
  public static final ContentType APPLICATION_JSON = create("application/json", Consts.UTF_8);
  public static final ContentType APPLICATION_OCTET_STREAM = create("application/octet-stream", (Charset)null);
  public static final ContentType APPLICATION_SVG_XML = create("application/svg+xml", Consts.ISO_8859_1);
  public static final ContentType APPLICATION_XHTML_XML = create("application/xhtml+xml", Consts.ISO_8859_1);
  public static final ContentType APPLICATION_XML = create("application/xml", Consts.ISO_8859_1);
  public static final ContentType MULTIPART_FORM_DATA = create("multipart/form-data", Consts.ISO_8859_1);
  public static final ContentType TEXT_HTML = create("text/html", Consts.ISO_8859_1);
  public static final ContentType TEXT_PLAIN = create("text/plain", Consts.ISO_8859_1);
  public static final ContentType TEXT_XML = create("text/xml", Consts.ISO_8859_1);
  public static final ContentType WILDCARD = create("*/*", (Charset)null);
  public static final ContentType DEFAULT_TEXT = TEXT_PLAIN;
  public static final ContentType DEFAULT_BINARY = APPLICATION_OCTET_STREAM;
  private final String mimeType;
  private final Charset charset;
  private final NameValuePair[] params;
  
  ContentType(String mimeType, Charset charset)
  {
    this.mimeType = mimeType;
    this.charset = charset;
    params = null;
  }
  
  ContentType(String mimeType, NameValuePair[] params)
    throws UnsupportedCharsetException
  {
    this.mimeType = mimeType;
    this.params = params;
    String s = getParameter("charset");
    charset = (!TextUtils.isBlank(s) ? Charset.forName(s) : null);
  }
  
  public String getMimeType()
  {
    return mimeType;
  }
  
  public Charset getCharset()
  {
    return charset;
  }
  
  public String getParameter(String name)
  {
    Args.notEmpty(name, "Parameter name");
    if (params == null) {
      return null;
    }
    for (NameValuePair param : params) {
      if (param.getName().equalsIgnoreCase(name)) {
        return param.getValue();
      }
    }
    return null;
  }
  
  public String toString()
  {
    CharArrayBuffer buf = new CharArrayBuffer(64);
    buf.append(mimeType);
    if (params != null)
    {
      buf.append("; ");
      BasicHeaderValueFormatter.INSTANCE.formatParameters(buf, params, false);
    }
    else if (charset != null)
    {
      buf.append("; charset=");
      buf.append(charset.name());
    }
    return buf.toString();
  }
  
  private static boolean valid(String s)
  {
    for (int i = 0; i < s.length(); i++)
    {
      char ch = s.charAt(i);
      if ((ch == '"') || (ch == ',') || (ch == ';')) {
        return false;
      }
    }
    return true;
  }
  
  public static ContentType create(String mimeType, Charset charset)
  {
    String type = ((String)Args.notBlank(mimeType, "MIME type")).toLowerCase(Locale.US);
    Args.check(valid(type), "MIME type may not contain reserved characters");
    return new ContentType(type, charset);
  }
  
  public static ContentType create(String mimeType)
  {
    return new ContentType(mimeType, (Charset)null);
  }
  
  public static ContentType create(String mimeType, String charset)
    throws UnsupportedCharsetException
  {
    return create(mimeType, !TextUtils.isBlank(charset) ? Charset.forName(charset) : null);
  }
  
  private static ContentType create(HeaderElement helem)
  {
    String mimeType = helem.getName();
    NameValuePair[] params = helem.getParameters();
    return new ContentType(mimeType, (params != null) && (params.length > 0) ? params : null);
  }
  
  public static ContentType parse(String s)
    throws ParseException, UnsupportedCharsetException
  {
    Args.notNull(s, "Content type");
    CharArrayBuffer buf = new CharArrayBuffer(s.length());
    buf.append(s);
    ParserCursor cursor = new ParserCursor(0, s.length());
    HeaderElement[] elements = BasicHeaderValueParser.INSTANCE.parseElements(buf, cursor);
    if (elements.length > 0) {
      return create(elements[0]);
    }
    throw new ParseException("Invalid content type: " + s);
  }
  
  public static ContentType get(HttpEntity entity)
    throws ParseException, UnsupportedCharsetException
  {
    if (entity == null) {
      return null;
    }
    Header header = entity.getContentType();
    if (header != null)
    {
      HeaderElement[] elements = header.getElements();
      if (elements.length > 0) {
        return create(elements[0]);
      }
    }
    return null;
  }
  
  public static ContentType getOrDefault(HttpEntity entity)
    throws ParseException, UnsupportedCharsetException
  {
    ContentType contentType = get(entity);
    return contentType != null ? contentType : DEFAULT_TEXT;
  }
  
  public ContentType withCharset(Charset charset)
  {
    return create(getMimeType(), charset);
  }
  
  public ContentType withCharset(String charset)
  {
    return create(getMimeType(), charset);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.entity.ContentType
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.entity;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.http.util.Args;

public class EntityTemplate
  extends AbstractHttpEntity
{
  private final ContentProducer contentproducer;
  
  public EntityTemplate(ContentProducer contentproducer)
  {
    this.contentproducer = ((ContentProducer)Args.notNull(contentproducer, "Content producer"));
  }
  
  public long getContentLength()
  {
    return -1L;
  }
  
  public InputStream getContent()
    throws IOException
  {
    ByteArrayOutputStream buf = new ByteArrayOutputStream();
    writeTo(buf);
    return new ByteArrayInputStream(buf.toByteArray());
  }
  
  public boolean isRepeatable()
  {
    return true;
  }
  
  public void writeTo(OutputStream outstream)
    throws IOException
  {
    Args.notNull(outstream, "Output stream");
    contentproducer.writeTo(outstream);
  }
  
  public boolean isStreaming()
  {
    return false;
  }
}

/* Location:
 * Qualified Name:     org.apache.http.entity.EntityTemplate
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.entity;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.util.Args;

@NotThreadSafe
public class FileEntity
  extends AbstractHttpEntity
  implements Cloneable
{
  protected final File file;
  
  @Deprecated
  public FileEntity(File file, String contentType)
  {
    this.file = ((File)Args.notNull(file, "File"));
    setContentType(contentType);
  }
  
  public FileEntity(File file, ContentType contentType)
  {
    this.file = ((File)Args.notNull(file, "File"));
    if (contentType != null) {
      setContentType(contentType.toString());
    }
  }
  
  public FileEntity(File file)
  {
    this.file = ((File)Args.notNull(file, "File"));
  }
  
  public boolean isRepeatable()
  {
    return true;
  }
  
  public long getContentLength()
  {
    return file.length();
  }
  
  public InputStream getContent()
    throws IOException
  {
    return new FileInputStream(file);
  }
  
  public void writeTo(OutputStream outstream)
    throws IOException
  {
    Args.notNull(outstream, "Output stream");
    InputStream instream = new FileInputStream(file);
    try
    {
      byte[] tmp = new byte['?'];
      int l;
      while ((l = instream.read(tmp)) != -1) {
        outstream.write(tmp, 0, l);
      }
      outstream.flush();
    }
    finally
    {
      instream.close();
    }
  }
  
  public boolean isStreaming()
  {
    return false;
  }
  
  public Object clone()
    throws CloneNotSupportedException
  {
    return super.clone();
  }
}

/* Location:
 * Qualified Name:     org.apache.http.entity.FileEntity
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.entity;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.util.Args;

@NotThreadSafe
publ
1 2 3 4 5 6 7 8 9 10 11 12

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd