httpcore-4.1.1

16:36:39.716 INFO  jd.cli.Main - Decompiling httpcore-4.1.1.jar
package org.apache.http;

public class UnsupportedHttpVersionException
  extends ProtocolException
{
  private static final long serialVersionUID = -1348448090193107031L;
  
  public UnsupportedHttpVersionException() {}
  
  public UnsupportedHttpVersionException(String message)
  {
    super(message);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.UnsupportedHttpVersionException
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http;

import java.io.Serializable;
import org.apache.http.util.CharArrayBuffer;

public class ProtocolVersion
  implements Serializable, Cloneable
{
  private static final long serialVersionUID = 8950662842175091068L;
  protected final String protocol;
  protected final int major;
  protected final int minor;
  
  public ProtocolVersion(String protocol, int major, int minor)
  {
    if (protocol == null) {
      throw new IllegalArgumentException("Protocol name must not be null.");
    }
    if (major < 0) {
      throw new IllegalArgumentException("Protocol major version number must not be negative.");
    }
    if (minor < 0) {
      throw new IllegalArgumentException("Protocol minor version number may not be negative");
    }
    this.protocol = protocol;
    this.major = major;
    this.minor = minor;
  }
  
  public final String getProtocol()
  {
    return protocol;
  }
  
  public final int getMajor()
  {
    return major;
  }
  
  public final int getMinor()
  {
    return minor;
  }
  
  public ProtocolVersion forVersion(int major, int minor)
  {
    if ((major == this.major) && (minor == this.minor)) {
      return this;
    }
    return new ProtocolVersion(protocol, major, minor);
  }
  
  public final int hashCode()
  {
    return protocol.hashCode() ^ major * 100000 ^ minor;
  }
  
  public final boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if (!(obj instanceof ProtocolVersion)) {
      return false;
    }
    ProtocolVersion that = (ProtocolVersion)obj;
    
    return (protocol.equals(protocol)) && (major == major) && (minor == minor);
  }
  
  public boolean isComparable(ProtocolVersion that)
  {
    return (that != null) && (protocol.equals(protocol));
  }
  
  public int compareToVersion(ProtocolVersion that)
  {
    if (that == null) {
      throw new IllegalArgumentException("Protocol version must not be null.");
    }
    if (!protocol.equals(protocol)) {
      throw new IllegalArgumentException("Versions for different protocols cannot be compared. " + this + " " + that);
    }
    int delta = getMajor() - that.getMajor();
    if (delta == 0) {
      delta = getMinor() - that.getMinor();
    }
    return delta;
  }
  
  public final boolean greaterEquals(ProtocolVersion version)
  {
    return (isComparable(version)) && (compareToVersion(version) >= 0);
  }
  
  public final boolean lessEquals(ProtocolVersion version)
  {
    return (isComparable(version)) && (compareToVersion(version) <= 0);
  }
  
  public String toString()
  {
    CharArrayBuffer buffer = new CharArrayBuffer(16);
    buffer.append(protocol);
    buffer.append('/');
    buffer.append(Integer.toString(major));
    buffer.append('.');
    buffer.append(Integer.toString(minor));
    return buffer.toString();
  }
  
  public Object clone()
    throws CloneNotSupportedException
  {
    return super.clone();
  }
}

/* Location:
 * Qualified Name:     org.apache.http.ProtocolVersion
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http;

public abstract interface HttpConnectionMetrics
{
  public abstract long getRequestCount();
  
  public abstract long getResponseCount();
  
  public abstract long getSentBytesCount();
  
  public abstract long getReceivedBytesCount();
  
  public abstract Object getMetric(String paramString);
  
  public abstract void reset();
}

/* Location:
 * Qualified Name:     org.apache.http.HttpConnectionMetrics
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.util;

import java.lang.reflect.Method;

public final class ExceptionUtils
{
  private static final Method INIT_CAUSE_METHOD = ;
  
  private static Method getInitCauseMethod()
  {
    try
    {
      Class[] paramsClasses = { Throwable.class };
      return Throwable.class.getMethod("initCause", paramsClasses);
    }
    catch (NoSuchMethodException e) {}
    return null;
  }
  
  public static void initCause(Throwable throwable, Throwable cause)
  {
    if (INIT_CAUSE_METHOD != null) {
      try
      {
        INIT_CAUSE_METHOD.invoke(throwable, new Object[] { cause });
      }
      catch (Exception e) {}
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.http.util.ExceptionUtils
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.util;

import java.io.Serializable;
import org.apache.http.protocol.HTTP;

public final class CharArrayBuffer
  implements Serializable
{
  private static final long serialVersionUID = -6208952725094867135L;
  private char[] buffer;
  private int len;
  
  public CharArrayBuffer(int capacity)
  {
    if (capacity < 0) {
      throw new IllegalArgumentException("Buffer capacity may not be negative");
    }
    buffer = new char[capacity];
  }
  
  private void expand(int newlen)
  {
    char[] newbuffer = new char[Math.max(buffer.length << 1, newlen)];
    System.arraycopy(buffer, 0, newbuffer, 0, len);
    buffer = newbuffer;
  }
  
  public void append(char[] b, int off, int len)
  {
    if (b == null) {
      return;
    }
    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);
    }
    if (len == 0) {
      return;
    }
    int newlen = this.len + len;
    if (newlen > buffer.length) {
      expand(newlen);
    }
    System.arraycopy(b, off, buffer, this.len, len);
    this.len = newlen;
  }
  
  public void append(String str)
  {
    if (str == null) {
      str = "null";
    }
    int strlen = str.length();
    int newlen = len + strlen;
    if (newlen > buffer.length) {
      expand(newlen);
    }
    str.getChars(0, strlen, buffer, len);
    len = newlen;
  }
  
  public void append(CharArrayBuffer b, int off, int len)
  {
    if (b == null) {
      return;
    }
    append(buffer, off, len);
  }
  
  public void append(CharArrayBuffer b)
  {
    if (b == null) {
      return;
    }
    append(buffer, 0, len);
  }
  
  public void append(char ch)
  {
    int newlen = len + 1;
    if (newlen > buffer.length) {
      expand(newlen);
    }
    buffer[len] = ch;
    len = newlen;
  }
  
  public void append(byte[] b, int off, int len)
  {
    if (b == null) {
      return;
    }
    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);
    }
    if (len == 0) {
      return;
    }
    int oldlen = this.len;
    int newlen = oldlen + len;
    if (newlen > buffer.length) {
      expand(newlen);
    }
    int i1 = off;
    for (int i2 = oldlen; i2 < newlen; i2++)
    {
      buffer[i2] = ((char)(b[i1] & 0xFF));i1++;
    }
    this.len = newlen;
  }
  
  public void append(ByteArrayBuffer b, int off, int len)
  {
    if (b == null) {
      return;
    }
    append(b.buffer(), off, len);
  }
  
  public void append(Object obj)
  {
    append(String.valueOf(obj));
  }
  
  public void clear()
  {
    len = 0;
  }
  
  public char[] toCharArray()
  {
    char[] b = new char[len];
    if (len > 0) {
      System.arraycopy(buffer, 0, b, 0, len);
    }
    return b;
  }
  
  public char charAt(int i)
  {
    return buffer[i];
  }
  
  public char[] buffer()
  {
    return buffer;
  }
  
  public int capacity()
  {
    return buffer.length;
  }
  
  public int length()
  {
    return len;
  }
  
  public void ensureCapacity(int required)
  {
    if (required <= 0) {
      return;
    }
    int available = buffer.length - len;
    if (required > available) {
      expand(len + required);
    }
  }
  
  public void setLength(int len)
  {
    if ((len < 0) || (len > buffer.length)) {
      throw new IndexOutOfBoundsException("len: " + len + " < 0 or > buffer len: " + buffer.length);
    }
    this.len = len;
  }
  
  public boolean isEmpty()
  {
    return len == 0;
  }
  
  public boolean isFull()
  {
    return len == buffer.length;
  }
  
  public int indexOf(int ch, int beginIndex, int endIndex)
  {
    if (beginIndex < 0) {
      beginIndex = 0;
    }
    if (endIndex > len) {
      endIndex = len;
    }
    if (beginIndex > endIndex) {
      return -1;
    }
    for (int i = beginIndex; i < endIndex; i++) {
      if (buffer[i] == ch) {
        return i;
      }
    }
    return -1;
  }
  
  public int indexOf(int ch)
  {
    return indexOf(ch, 0, len);
  }
  
  public String substring(int beginIndex, int endIndex)
  {
    return new String(buffer, beginIndex, endIndex - beginIndex);
  }
  
  public String substringTrimmed(int beginIndex, int endIndex)
  {
    if (beginIndex < 0) {
      throw new IndexOutOfBoundsException("Negative beginIndex: " + beginIndex);
    }
    if (endIndex > len) {
      throw new IndexOutOfBoundsException("endIndex: " + endIndex + " > length: " + len);
    }
    if (beginIndex > endIndex) {
      throw new IndexOutOfBoundsException("beginIndex: " + beginIndex + " > endIndex: " + endIndex);
    }
    while ((beginIndex < endIndex) && (HTTP.isWhitespace(buffer[beginIndex]))) {
      beginIndex++;
    }
    while ((endIndex > beginIndex) && (HTTP.isWhitespace(buffer[(endIndex - 1)]))) {
      endIndex--;
    }
    return new String(buffer, beginIndex, endIndex - beginIndex);
  }
  
  public String toString()
  {
    return new String(buffer, 0, len);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.util.CharArrayBuffer
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.util;

public final class LangUtils
{
  public static final int HASH_SEED = 17;
  public static final int HASH_OFFSET = 37;
  
  public static int hashCode(int seed, int hashcode)
  {
    return seed * 37 + hashcode;
  }
  
  public static int hashCode(int seed, boolean b)
  {
    return hashCode(seed, b ? 1 : 0);
  }
  
  public static int hashCode(int seed, Object obj)
  {
    return hashCode(seed, obj != null ? obj.hashCode() : 0);
  }
  
  public static boolean equals(Object obj1, Object obj2)
  {
    return obj1 == null ? false : obj2 == null ? true : obj1.equals(obj2);
  }
  
  public static boolean equals(Object[] a1, Object[] a2)
  {
    if (a1 == null)
    {
      if (a2 == null) {
        return true;
      }
      return false;
    }
    if ((a2 != null) && (a1.length == a2.length))
    {
      for (int i = 0; i < a1.length; i++) {
        if (!equals(a1[i], a2[i])) {
          return false;
        }
      }
      return true;
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.apache.http.util.LangUtils
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.util;

import java.io.UnsupportedEncodingException;

public final class EncodingUtils
{
  public static String getString(byte[] data, int offset, int length, String charset)
  {
    if (data == null) {
      throw new IllegalArgumentException("Parameter may not be null");
    }
    if ((charset == null) || (charset.length() == 0)) {
      throw new IllegalArgumentException("charset may not be null or empty");
    }
    try
    {
      return new String(data, offset, length, charset);
    }
    catch (UnsupportedEncodingException e) {}
    return new String(data, offset, length);
  }
  
  public static String getString(byte[] data, String charset)
  {
    if (data == null) {
      throw new IllegalArgumentException("Parameter may not be null");
    }
    return getString(data, 0, data.length, charset);
  }
  
  public static byte[] getBytes(String data, String charset)
  {
    if (data == null) {
      throw new IllegalArgumentException("data may not be null");
    }
    if ((charset == null) || (charset.length() == 0)) {
      throw new IllegalArgumentException("charset may not be null or empty");
    }
    try
    {
      return data.getBytes(charset);
    }
    catch (UnsupportedEncodingException e) {}
    return data.getBytes();
  }
  
  public static byte[] getAsciiBytes(String data)
  {
    if (data == null) {
      throw new IllegalArgumentException("Parameter may not be null");
    }
    try
    {
      return data.getBytes("US-ASCII");
    }
    catch (UnsupportedEncodingException e)
    {
      throw new Error("HttpClient requires ASCII support");
    }
  }
  
  public static String getAsciiString(byte[] data, int offset, int length)
  {
    if (data == null) {
      throw new IllegalArgumentException("Parameter may not be null");
    }
    try
    {
      return new String(data, offset, length, "US-ASCII");
    }
    catch (UnsupportedEncodingException e)
    {
      throw new Error("HttpClient requires ASCII support");
    }
  }
  
  public static String getAsciiString(byte[] data)
  {
    if (data == null) {
      throw new IllegalArgumentException("Parameter may not be null");
    }
    return getAsciiString(data, 0, data.length);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.util.EncodingUtils
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Map;
import java.util.Properties;

public class VersionInfo
{
  public static final String UNAVAILABLE = "UNAVAILABLE";
  public static final String VERSION_PROPERTY_FILE = "version.properties";
  public static final String PROPERTY_MODULE = "info.module";
  public static final String PROPERTY_RELEASE = "info.release";
  public static final String PROPERTY_TIMESTAMP = "info.timestamp";
  private final String infoPackage;
  private final String infoModule;
  private final String infoRelease;
  private final String infoTimestamp;
  private final String infoClassloader;
  
  protected VersionInfo(String pckg, String module, String release, String time, String clsldr)
  {
    if (pckg == null) {
      throw new IllegalArgumentException("Package identifier must not be null.");
    }
    infoPackage = pckg;
    infoModule = (module != null ? module : "UNAVAILABLE");
    infoRelease = (release != null ? release : "UNAVAILABLE");
    infoTimestamp = (time != null ? time : "UNAVAILABLE");
    infoClassloader = (clsldr != null ? clsldr : "UNAVAILABLE");
  }
  
  public final String getPackage()
  {
    return infoPackage;
  }
  
  public final String getModule()
  {
    return infoModule;
  }
  
  public final String getRelease()
  {
    return infoRelease;
  }
  
  public final String getTimestamp()
  {
    return infoTimestamp;
  }
  
  public final String getClassloader()
  {
    return infoClassloader;
  }
  
  public String toString()
  {
    StringBuffer sb = new StringBuffer(20 + infoPackage.length() + infoModule.length() + infoRelease.length() + infoTimestamp.length() + infoClassloader.length());
    
    sb.append("VersionInfo(").append(infoPackage).append(':').append(infoModule);
    if (!"UNAVAILABLE".equals(infoRelease)) {
      sb.append(':').append(infoRelease);
    }
    if (!"UNAVAILABLE".equals(infoTimestamp)) {
      sb.append(':').append(infoTimestamp);
    }
    sb.append(')');
    if (!"UNAVAILABLE".equals(infoClassloader)) {
      sb.append('@').append(infoClassloader);
    }
    return sb.toString();
  }
  
  public static final VersionInfo[] loadVersionInfo(String[] pckgs, ClassLoader clsldr)
  {
    if (pckgs == null) {
      throw new IllegalArgumentException("Package identifier list must not be null.");
    }
    ArrayList vil = new ArrayList(pckgs.length);
    for (int i = 0; i < pckgs.length; i++)
    {
      VersionInfo vi = loadVersionInfo(pckgs[i], clsldr);
      if (vi != null) {
        vil.add(vi);
      }
    }
    return (VersionInfo[])vil.toArray(new VersionInfo[vil.size()]);
  }
  
  public static final VersionInfo loadVersionInfo(String pckg, ClassLoader clsldr)
  {
    if (pckg == null) {
      throw new IllegalArgumentException("Package identifier must not be null.");
    }
    if (clsldr == null) {
      clsldr = Thread.currentThread().getContextClassLoader();
    }
    Properties vip = null;
    try
    {
      InputStream is = clsldr.getResourceAsStream(pckg.replace('.', '/') + "/" + "version.properties");
      if (is != null) {
        try
        {
          Properties props = new Properties();
          props.load(is);
          vip = props;
        }
        finally
        {
          is.close();
        }
      }
    }
    catch (IOException ex) {}
    VersionInfo result = null;
    if (vip != null) {
      result = fromMap(pckg, vip, clsldr);
    }
    return result;
  }
  
  protected static final VersionInfo fromMap(String pckg, Map info, ClassLoader clsldr)
  {
    if (pckg == null) {
      throw new IllegalArgumentException("Package identifier must not be null.");
    }
    String module = null;
    String release = null;
    String timestamp = null;
    if (info != null)
    {
      module = (String)info.get("info.module");
      if ((module != null) && (module.length() < 1)) {
        module = null;
      }
      release = (String)info.get("info.release");
      if ((release != null) && ((release.length() < 1) || (release.equals("${pom.version}")))) {
        release = null;
      }
      timestamp = (String)info.get("info.timestamp");
      if ((timestamp != null) && ((timestamp.length() < 1) || (timestamp.equals("${mvn.timestamp}")))) {
        timestamp = null;
      }
    }
    String clsldrstr = null;
    if (clsldr != null) {
      clsldrstr = clsldr.toString();
    }
    return new VersionInfo(pckg, module, release, timestamp, clsldrstr);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.util.VersionInfo
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.util;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
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;

public final class EntityUtils
{
  public static void consume(HttpEntity entity)
    throws IOException
  {
    if (entity == null) {
      return;
    }
    if (entity.isStreaming())
    {
      InputStream instream = entity.getContent();
      if (instream != null) {
        instream.close();
      }
    }
  }
  
  public static byte[] toByteArray(HttpEntity entity)
    throws IOException
  {
    if (entity == null) {
      throw new IllegalArgumentException("HTTP entity may not be null");
    }
    InputStream instream = entity.getContent();
    if (instream == null) {
      return null;
    }
    try
    {
      if (entity.getContentLength() > 2147483647L) {
        throw new IllegalArgumentException("HTTP entity too large to be buffered in memory");
      }
      int i = (int)entity.getContentLength();
      if (i < 0) {
        i = 4096;
      }
      ByteArrayBuffer buffer = new ByteArrayBuffer(i);
      byte[] tmp = new byte['?'];
      int l;
      while ((l = instream.read(tmp)) != -1) {
        buffer.append(tmp, 0, l);
      }
      return buffer.toByteArray();
    }
    finally
    {
      instream.close();
    }
  }
  
  public static String getContentCharSet(HttpEntity entity)
    throws ParseException
  {
    if (entity == null) {
      throw new IllegalArgumentException("HTTP entity may not be null");
    }
    String charset = null;
    if (entity.getContentType() != null)
    {
      HeaderElement[] values = entity.getContentType().getElements();
      if (values.length > 0)
      {
        NameValuePair param = values[0].getParameterByName("charset");
        if (param != null) {
          charset = param.getValue();
        }
      }
    }
    return charset;
  }
  
  public static String getContentMimeType(HttpEntity entity)
    throws ParseException
  {
    if (entity == null) {
      throw new IllegalArgumentException("HTTP entity may not be null");
    }
    String mimeType = null;
    if (entity.getContentType() != null)
    {
      HeaderElement[] values = entity.getContentType().getElements();
      if (values.length > 0) {
        mimeType = values[0].getName();
      }
    }
    return mimeType;
  }
  
  public static String toString(HttpEntity entity, String defaultCharset)
    throws IOException, ParseException
  {
    if (entity == null) {
      throw new IllegalArgumentException("HTTP entity may not be null");
    }
    InputStream instream = entity.getContent();
    if (instream == null) {
      return null;
    }
    try
    {
      if (entity.getContentLength() > 2147483647L) {
        throw new IllegalArgumentException("HTTP entity too large to be buffered in memory");
      }
      int i = (int)entity.getContentLength();
      if (i < 0) {
        i = 4096;
      }
      String charset = getContentCharSet(entity);
      if (charset == null) {
        charset = defaultCharset;
      }
      if (charset == null) {
        charset = "ISO-8859-1";
      }
      Reader reader = new InputStreamReader(instream, charset);
      CharArrayBuffer buffer = new CharArrayBuffer(i);
      char[] tmp = new char['?'];
      int l;
      while ((l = reader.read(tmp)) != -1) {
        buffer.append(tmp, 0, l);
      }
      return buffer.toString();
    }
    finally
    {
      instream.close();
    }
  }
  
  public static String toString(HttpEntity entity)
    throws IOException, ParseException
  {
    return toString(entity, null);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.util.EntityUtils
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.util;

import java.io.Serializable;

public final class ByteArrayBuffer
  implements Serializable
{
  private static final long serialVersionUID = 4359112959524048036L;
  private byte[] buffer;
  private int len;
  
  public ByteArrayBuffer(int capacity)
  {
    if (capacity < 0) {
      throw new IllegalArgumentException("Buffer capacity may not be negative");
    }
    buffer = new byte[capacity];
  }
  
  private void expand(int newlen)
  {
    byte[] newbuffer = new byte[Math.max(buffer.length << 1, newlen)];
    System.arraycopy(buffer, 0, newbuffer, 0, len);
    buffer = newbuffer;
  }
  
  public void append(byte[] b, int off, int len)
  {
    if (b == null) {
      return;
    }
    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);
    }
    if (len == 0) {
      return;
    }
    int newlen = this.len + len;
    if (newlen > buffer.length) {
      expand(newlen);
    }
    System.arraycopy(b, off, buffer, this.len, len);
    this.len = newlen;
  }
  
  public void append(int b)
  {
    int newlen = len + 1;
    if (newlen > buffer.length) {
      expand(newlen);
    }
    buffer[len] = ((byte)b);
    len = newlen;
  }
  
  public void append(char[] b, int off, int len)
  {
    if (b == null) {
      return;
    }
    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);
    }
    if (len == 0) {
      return;
    }
    int oldlen = this.len;
    int newlen = oldlen + len;
    if (newlen > buffer.length) {
      expand(newlen);
    }
    int i1 = off;
    for (int i2 = oldlen; i2 < newlen; i2++)
    {
      buffer[i2] = ((byte)b[i1]);i1++;
    }
    this.len = newlen;
  }
  
  public void append(CharArrayBuffer b, int off, int len)
  {
    if (b == null) {
      return;
    }
    append(b.buffer(), off, len);
  }
  
  public void clear()
  {
    len = 0;
  }
  
  public byte[] toByteArray()
  {
    byte[] b = new byte[len];
    if (len > 0) {
      System.arraycopy(buffer, 0, b, 0, len);
    }
    return b;
  }
  
  public int byteAt(int i)
  {
    return buffer[i];
  }
  
  public int capacity()
  {
    return buffer.length;
  }
  
  public int length()
  {
    return len;
  }
  
  public void ensureCapacity(int required)
  {
    if (required <= 0) {
      return;
    }
    int available = buffer.length - len;
    if (required > available) {
      expand(len + required);
    }
  }
  
  public byte[] buffer()
  {
    return buffer;
  }
  
  public void setLength(int len)
  {
    if ((len < 0) || (len > buffer.length)) {
      throw new IndexOutOfBoundsException("len: " + len + " < 0 or > buffer len: " + buffer.length);
    }
    this.len = len;
  }
  
  public boolean isEmpty()
  {
    return len == 0;
  }
  
  public boolean isFull()
  {
    return len == buffer.length;
  }
  
  public int indexOf(byte b, int beginIndex, int endIndex)
  {
    if (beginIndex < 0) {
      beginIndex = 0;
    }
    if (endIndex > len) {
      endIndex = len;
    }
    if (beginIndex > endIndex) {
      return -1;
    }
    for (int i = beginIndex; i < endIndex; i++) {
      if (buffer[i] == b) {
        return i;
      }
    }
    return -1;
  }
  
  public int indexOf(byte b)
  {
    return indexOf(b, 0, len);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.util.ByteArrayBuffer
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.io;

public abstract interface EofSensor
{
  public abstract boolean isEof();
}

/* Location:
 * Qualified Name:     org.apache.http.io.EofSensor
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.io;

import java.io.IOException;
import org.apache.http.HttpException;
import org.apache.http.HttpMessage;

public abstract interface HttpMessageParser
{
  public abstract HttpMessage parse()
    throws IOException, HttpException;
}

/* Location:
 * Qualified Name:     org.apache.http.io.HttpMessageParser
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.io;

import java.io.IOException;
import org.apache.http.util.CharArrayBuffer;

public abstract interface SessionInputBuffer
{
  public abstract int read(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    throws IOException;
  
  public abstract int read(byte[] paramArrayOfByte)
    throws IOException;
  
  public abstract int read()
    throws IOException;
  
  public abstract int readLine(CharArrayBuffer paramCharArrayBuffer)
    throws IOException;
  
  public abstract String readLine()
    throws IOException;
  
  public abstract boolean isDataAvailable(int paramInt)
    throws IOException;
  
  public abstract HttpTransportMetrics getMetrics();
}

/* Location:
 * Qualified Name:     org.apache.http.io.SessionInputBuffer
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.io;

import java.io.IOException;
import org.apache.http.util.CharArrayBuffer;

public abstract interface SessionOutputBuffer
{
  public abstract void write(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    throws IOException;
  
  public abstract void write(byte[] paramArrayOfByte)
    throws IOException;
  
  public abstract void write(int paramInt)
    throws IOException;
  
  public abstract void writeLine(String paramString)
    throws IOException;
  
  public abstract void writeLine(CharArrayBuffer paramCharArrayBuffer)
    throws IOException;
  
  public abstract void flush()
    throws IOException;
  
  public abstract HttpTransportMetrics getMetrics();
}

/* Location:
 * Qualified Name:     org.apache.http.io.SessionOutputBuffer
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.io;

import java.io.IOException;
import org.apache.http.HttpException;
import org.apache.http.HttpMessage;

public abstract interface HttpMessageWriter
{
  public abstract void write(HttpMessage paramHttpMessage)
    throws IOException, HttpException;
}

/* Location:
 * Qualified Name:     org.apache.http.io.HttpMessageWriter
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.io;

public abstract interface BufferInfo
{
  public abstract int length();
  
  public abstract int capacity();
  
  public abstract int available();
}

/* Location:
 * Qualified Name:     org.apache.http.io.BufferInfo
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.io;

public abstract interface HttpTransportMetrics
{
  public abstract long getBytesTransferred();
  
  public abstract void reset();
}

/* Location:
 * Qualified Name:     org.apache.http.io.HttpTransportMetrics
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http;

import java.util.Iterator;

public abstract interface HeaderIterator
  extends Iterator
{
  public abstract boolean hasNext();
  
  public abstract Header nextHeader();
}

/* Location:
 * Qualified Name:     org.apache.http.HeaderIterator
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http;

import org.apache.http.util.ExceptionUtils;

public class HttpException
  extends Exception
{
  private static final long serialVersionUID = -5437299376222011036L;
  
  public HttpException() {}
  
  public HttpException(String message)
  {
    super(message);
  }
  
  public HttpException(String message, Throwable cause)
  {
    super(message);
    ExceptionUtils.initCause(this, cause);
  }
}

/* Location:
 * Qualified Name:     org.apache.http.HttpException
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http;

import java.util.Iterator;

public abstract interface HeaderElementIterator
  extends Iterator
{
  public abstract boolean hasNext();
  
  public abstract HeaderElement nextElement();
}

/* Location:
 * Qualified Name:     org.apache.http.HeaderElementIterator
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http;

public abstract interface HttpStatus
{
  public static final int SC_CONTINUE = 100;
  public static final int SC_SWITCHING_PROTOCOLS = 101;
  public static final int SC_PROCESSING = 102;
  public static final int SC_OK = 200;
  public static final int SC_CREATED = 201;
  public static final int SC_ACCEPTED = 202;
  public static final int SC_NON_AUTHORITATIVE_INFORMATION = 203;
  public static final int SC_NO_CONTENT = 204;
  public static final int SC_RESET_CONTENT = 205;
  public static final int SC_PARTIAL_CONTENT = 206;
  public static final int SC_MULTI_STATUS = 207;
  public static final int SC_MULTIPLE_CHOICES = 300;
  public static final int SC_MOVED_PERMANENTLY = 301;
  public static final int SC_MOVED_TEMPORARILY = 302;
  public static final int SC_SEE_OTHER = 303;
  public static final int SC_NOT_MODIFIED = 304;
  public static final int SC_USE_PROXY = 305;
  public static final int SC_TEMPORARY_REDIRECT = 307;
  public static final int SC_BAD_REQUEST = 400;
  public static final int SC_UNAUTHORIZED = 401;
  public static final int SC_PAYMENT_REQUIRED = 402;
  public static final int SC_FORBIDDEN = 403;
  public static final int SC_NOT_FOUND = 404;
  public static final int SC_METHOD_NOT_ALLOWED = 405;
  public static final int SC_NOT_ACCEPTABLE = 406;
  public static final int SC_PROXY_AUTHENTICATION_REQUIRED = 407;
  public static final int SC_REQUEST_TIMEOUT = 408;
  public static final int SC_CONFLICT = 409;
  public static final int SC_GONE = 410;
  public static final int SC_LENGTH_REQUIRED = 411;
  public static final int SC_PRECONDITION_FAILED = 412;
  public static final int SC_REQUEST_TOO_LONG = 413;
  public static final int SC_REQUEST_URI_TOO_LONG = 414;
  public static final int SC_UNSUPPORTED_MEDIA_TYPE = 415;
  public static final int SC_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
  public static final int SC_EXPECTATION_FAILED = 417;
  public static final int SC_INSUFFICIENT_SPACE_ON_RESOURCE = 419;
  public static final int SC_METHOD_FAILURE = 420;
  public static final int SC_UNPROCESSABLE_ENTITY = 422;
  public static final int SC_LOCKED = 423;
  public static final int SC_FAILED_DEPENDENCY = 424;
  public static final int SC_INTERNAL_SERVER_ERROR = 500;
  public static final int SC_NOT_IMPLEMENTED = 501;
  public static final int SC_BAD_GATEWAY = 502;
  public static final int SC_SERVICE_UNAVAILABLE = 503;
  public static final int SC_GATEWAY_TIMEOUT = 504;
  public static final int SC_HTTP_VERSION_NOT_SUPPORTED = 505;
  public static final int SC_INSUFFICIENT_STORAGE = 507;
}

/* Location:
 * Qualified Name:     org.apache.http.HttpStatus
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.impl;

import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.SocketException;
import org.apache.http.HttpInetConnection;
import org.apache.http.impl.io.SocketInputBuffer;
import org.apache.http.impl.io.SocketOutputBuffer;
import org.apache.http.io.SessionInputBuffer;
import org.apache.http.io.SessionOutputBuffer;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;

public class SocketHttpServerConnection
  extends AbstractHttpServerConnection
  implements HttpInetConnection
{
  private volatile boolean open;
  private volatile Socket socket = null;
  
  protected void assertNotOpen()
  {
    if (open) {
      throw new IllegalStateException("Connection is already open");
    }
  }
  
  protected void assertOpen()
  {
    if (!open) {
      throw new IllegalStateException("Connection is not open");
    }
  }
  
  /**
   * @deprecated
   */
  protected SessionInputBuffer createHttpDataReceiver(Socket socket, int buffersize, HttpParams params)
    throws IOException
  {
    return createSessionInputBuffer(socket, buffersize, params);
  }
  
  /**
   * @deprecated
   */
  protected SessionOutputBuffer createHttpDataTransmitter(Socket socket, int buffersize, HttpParams params)
    throws IOException
  {
    return createSessionOutputBuffer(socket, buffersize, params);
  }
  
  protected SessionInputBuffer createSessionInputBuffer(Socket socket, int buffersize, HttpParams params)
    throws IOException
  {
    return new SocketInputBuffer(socket, buffersize, params);
  }
  
  protected SessionOutputBuffer createSessionOutputBuffer(Socket socket, int buffersize, HttpParams params)
    throws IOException
  {
    return new SocketOutputBuffer(socket, buffersize, params);
  }
  
  protected void bind(Socket socket, HttpParams params)
    throws IOException
  {
    if (socket == null) {
      throw new IllegalArgumentException("Socket may not be null");
    }
    if (params == null) {
      throw new IllegalArgumentException("HTTP parameters may not be null");
    }
    this.socket = socket;
    
    int buffersize = HttpConnectionParams.getSocketBufferSize(params);
    
    init(createHttpDataReceiver(socket, buffersize, params), createHttpDataTransmitter(socket, buffersize, params), params);
    
    open = true;
  }
  
  protected Socket getSocket()
  {
    return socket;
  }
  
  public boolean isOpen()
  {
    return open;
  }
  
  public InetAddress getLocalAddress()
  {
    if (socket != null) {
      return socket.getLocalAddress();
    }
    return null;
  }
  
  public int getLocalPort()
  {
    if (socket != null) {
      return socket.getLocalPort();
    }
    return -1;
  }
  
  public InetAddress getRemoteAddress()
  {
    if (socket != null) {
      return socket.getInetAddress();
    }
    return null;
  }
  
  public int getRemotePort()
  {
    if (socket != null) {
      return socket.getPort();
    }
    return -1;
  }
  
  public void setSocketTimeout(int timeout)
  {
    assertOpen();
    if (socket != null) {
      try
      {
        socket.setSoTimeout(timeout);
      }
      catch (SocketException ignore) {}
    }
  }
  
  public int getSocketTimeout()
  {
    if (socket != null) {
      try
      {
        return socket.getSoTimeout();
      }
      catch (SocketException ignore)
      {
        return -1;
      }
    }
    return -1;
  }
  
  public void shutdown()
    throws IOException
  {
    open = false;
    Socket tmpsocket = socket;
    if (tmpsocket != null) {
      tmpsocket.close();
    }
  }
  
  public void close()
    throws IOException
  {
    if (!open) {
      return;
    }
    open = false;
    open = false;
    Socket sock = socket;
    try
    {
      doFlush();
      try
      {
        try {}catch (IOException ignore) {}
        try {}catch (IOException ignore) {}
      }
      catch (UnsupportedOperationException ignore) {}
    }
    finally
    {
      sock.close();
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.http.impl.SocketHttpServerConnection
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.http.impl;

import java.util.HashMap;
import org.apache.http.HttpConnectionMetrics;
import org.apache.http.io.HttpTransportMetrics;

public class HttpConnectionMetricsImpl
  implements HttpConnectionMetrics
{
  public static final String REQUEST_COUNT = "http.request-count";
  public static final String RESPONSE_COUNT = "http.response-count";
  public static final String SENT_BYTES_COUNT = "http.sent-bytes-count";
  public static final String RECEIVED_BYTES_COUNT = "http.received-bytes-count";
  private final HttpTransportMetrics inTransportMetric;
  private final HttpTransportMetrics outTransportMetric;
  private long requestCount = 0L;
  private long responseCount = 0L;
  private HashMap metricsCache;
  
  public HttpConnectionMetricsImpl(HttpTransportMetrics inTransportMetric, HttpTransportMetrics outTransportMetric)
  {
    this.inTransportMetric = inTransportMetric;
    this.outTransportMetric = outTransportMetric;
  }
  
  public long getReceivedBytesCount()
  {
    if (inTransportMetric != null) {
      return inTransportMetric.getBytesTransferred();
    }
    return -1L;
  }
  
  public long getSentBytesCount()
  {
    if (outTransportMetric != null) {
      return outTransportMetric.getBytesTransferred();
    }
    return -1L;
  }
  
  public long getRequestCount()
  {
    return requestCount;
  }
  
  public void incrementRequestCount()
  {
    requestCount += 1L;
  }
  
  public long getResponseCount()
  {
    return responseCount;
  }
  
  public void incrementResponseCount()
  {
    responseCount += 1L;
  }
  
  public Object getMetric(String metricName)
  {
    Object value = null;
    if (metricsCache != null) {
      value = metricsCache.get(metricName);
    }
    if (value == null) {
      if ("http.request-count".equals(metricName))
      {
        value = new Long(requestCount);
      }
      else if ("http.response-count".equals(metricName))
      {
        value = new Long(responseCount);
      }
      else
      {
        if ("http.received-bytes-count".equals(metricName))
        {
          if (inTransportMetric != null) {
            return new Long(inTransportMetric.getBytesTransferred());
          }
          return null;
        }
        if ("http.sent-bytes-count".equals(metricName))
        {
          if (outTransportMetric != null) {
            return new Long(outTransportMetric.getBytesTransferred());
          }
          return null;
        }
      }
    }
    return value;
  }
  
  public void setMetric(String metricName, Object obj)
  {
    if (metricsCache == null) {
      metricsCache = new HashMap();
    }
    metricsCache.put(metricName, obj);
  }
  
  public void reset()
  {
    if (outTransportMetric != null) {
      outTransportMetric.reset();
    }
    if (inTransportMetric != null)
1 2 3 4 5 6 7 8

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