org.mortbay.jetty.server_6.1.23.v201012071420

16:49:42.782 INFO  jd.cli.Main - Decompiling org.mortbay.jetty.server_6.1.23.v201012071420.jar
package org.mortbay.io;

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

public abstract class AbstractBuffer
  implements Buffer
{
  protected static final String __IMMUTABLE = "IMMUTABLE";
  protected static final String __READONLY = "READONLY";
  protected static final String __READWRITE = "READWRITE";
  protected static final String __VOLATILE = "VOLATILE";
  protected int _access;
  protected boolean _volatile;
  protected int _get;
  protected int _put;
  protected int _hash;
  protected int _hashGet;
  protected int _hashPut;
  protected int _mark;
  protected String _string;
  protected View _view;
  
  public AbstractBuffer(int access, boolean isVolatile)
  {
    if ((access == 0) && (isVolatile)) {
      throw new IllegalArgumentException("IMMUTABLE && VOLATILE");
    }
    setMarkIndex(-1);
    _access = access;
    _volatile = isVolatile;
  }
  
  public byte[] asArray()
  {
    byte[] bytes = new byte[length()];
    byte[] array = array();
    if (array != null) {
      Portable.arraycopy(array, getIndex(), bytes, 0, bytes.length);
    } else {
      peek(getIndex(), bytes, 0, length());
    }
    return bytes;
  }
  
  public ByteArrayBuffer duplicate(int access)
  {
    Buffer b = buffer();
    if ((b instanceof Buffer.CaseInsensitve)) {
      return new ByteArrayBuffer.CaseInsensitive(asArray(), 0, length(), access);
    }
    return new ByteArrayBuffer(asArray(), 0, length(), access);
  }
  
  public Buffer asNonVolatileBuffer()
  {
    if (!isVolatile()) {
      return this;
    }
    return duplicate(_access);
  }
  
  public Buffer asImmutableBuffer()
  {
    if (isImmutable()) {
      return this;
    }
    return duplicate(0);
  }
  
  public Buffer asReadOnlyBuffer()
  {
    if (isReadOnly()) {
      return this;
    }
    return new View(this, markIndex(), getIndex(), putIndex(), 1);
  }
  
  public Buffer asMutableBuffer()
  {
    if (!isImmutable()) {
      return this;
    }
    Buffer b = buffer();
    if (b.isReadOnly()) {
      return duplicate(2);
    }
    return new View(b, markIndex(), getIndex(), putIndex(), _access);
  }
  
  public Buffer buffer()
  {
    return this;
  }
  
  public void clear()
  {
    setMarkIndex(-1);
    setGetIndex(0);
    setPutIndex(0);
  }
  
  public void compact()
  {
    if (isReadOnly()) {
      throw new IllegalStateException("READONLY");
    }
    int s = markIndex() >= 0 ? markIndex() : getIndex();
    if (s > 0)
    {
      byte[] array = array();
      int length = putIndex() - s;
      if (length > 0) {
        if (array != null) {
          Portable.arraycopy(array(), s, array(), 0, length);
        } else {
          poke(0, peek(s, length));
        }
      }
      if (markIndex() > 0) {
        setMarkIndex(markIndex() - s);
      }
      setGetIndex(getIndex() - s);
      setPutIndex(putIndex() - s);
    }
  }
  
  public boolean equals(Object obj)
  {
    if (obj == this) {
      return true;
    }
    if ((obj == null) || (!(obj instanceof Buffer))) {
      return false;
    }
    Buffer b = (Buffer)obj;
    if (((this instanceof Buffer.CaseInsensitve)) || ((b instanceof Buffer.CaseInsensitve))) {
      return equalsIgnoreCase(b);
    }
    if (b.length() != length()) {
      return false;
    }
    if ((_hash != 0) && ((obj instanceof AbstractBuffer)))
    {
      AbstractBuffer ab = (AbstractBuffer)obj;
      if ((_hash != 0) && (_hash != _hash)) {
        return false;
      }
    }
    int get = getIndex();
    int bi = b.putIndex();
    for (int i = putIndex(); i-- > get;)
    {
      byte b1 = peek(i);
      byte b2 = b.peek(--bi);
      if (b1 != b2) {
        return false;
      }
    }
    return true;
  }
  
  public boolean equalsIgnoreCase(Buffer b)
  {
    if (b == this) {
      return true;
    }
    if (b.length() != length()) {
      return false;
    }
    if ((_hash != 0) && ((b instanceof AbstractBuffer)))
    {
      AbstractBuffer ab = (AbstractBuffer)b;
      if ((_hash != 0) && (_hash != _hash)) {
        return false;
      }
    }
    int get = getIndex();
    int bi = b.putIndex();
    
    byte[] array = array();
    byte[] barray = b.array();
    int i;
    int i;
    if ((array != null) && (barray != null)) {
      for (i = putIndex(); i-- > get;)
      {
        byte b1 = array[i];
        byte b2 = barray[(--bi)];
        if (b1 != b2)
        {
          if ((97 <= b1) && (b1 <= 122)) {
            b1 = (byte)(b1 - 97 + 65);
          }
          if ((97 <= b2) && (b2 <= 122)) {
            b2 = (byte)(b2 - 97 + 65);
          }
          if (b1 != b2) {
            return false;
          }
        }
      }
    } else {
      for (i = putIndex(); i-- > get;)
      {
        byte b1 = peek(i);
        byte b2 = b.peek(--bi);
        if (b1 != b2)
        {
          if ((97 <= b1) && (b1 <= 122)) {
            b1 = (byte)(b1 - 97 + 65);
          }
          if ((97 <= b2) && (b2 <= 122)) {
            b2 = (byte)(b2 - 97 + 65);
          }
          if (b1 != b2) {
            return false;
          }
        }
      }
    }
    return true;
  }
  
  public byte get()
  {
    return peek(_get++);
  }
  
  public int get(byte[] b, int offset, int length)
  {
    int gi = getIndex();
    int l = length();
    if (l == 0) {
      return -1;
    }
    if (length > l) {
      length = l;
    }
    length = peek(gi, b, offset, length);
    if (length > 0) {
      setGetIndex(gi + length);
    }
    return length;
  }
  
  public Buffer get(int length)
  {
    int gi = getIndex();
    Buffer view = peek(gi, length);
    setGetIndex(gi + length);
    return view;
  }
  
  public final int getIndex()
  {
    return _get;
  }
  
  public boolean hasContent()
  {
    return _put > _get;
  }
  
  public int hashCode()
  {
    if ((_hash == 0) || (_hashGet != _get) || (_hashPut != _put))
    {
      int get = getIndex();
      byte[] array = array();
      int i;
      int i;
      if (array == null) {
        for (i = putIndex(); i-- > get;)
        {
          byte b = peek(i);
          if ((97 <= b) && (b <= 122)) {
            b = (byte)(b - 97 + 65);
          }
          _hash = (31 * _hash + b);
        }
      } else {
        for (i = putIndex(); i-- > get;)
        {
          byte b = array[i];
          if ((97 <= b) && (b <= 122)) {
            b = (byte)(b - 97 + 65);
          }
          _hash = (31 * _hash + b);
        }
      }
      if (_hash == 0) {
        _hash = -1;
      }
      _hashGet = _get;
      _hashPut = _put;
    }
    return _hash;
  }
  
  public boolean isImmutable()
  {
    return _access <= 0;
  }
  
  public boolean isReadOnly()
  {
    return _access <= 1;
  }
  
  public boolean isVolatile()
  {
    return _volatile;
  }
  
  public int length()
  {
    return _put - _get;
  }
  
  public void mark()
  {
    setMarkIndex(_get - 1);
  }
  
  public void mark(int offset)
  {
    setMarkIndex(_get + offset);
  }
  
  public int markIndex()
  {
    return _mark;
  }
  
  public byte peek()
  {
    return peek(_get);
  }
  
  public Buffer peek(int index, int length)
  {
    if (_view == null)
    {
      _view = new View(this, -1, index, index + length, isReadOnly() ? 1 : 2);
    }
    else
    {
      _view.update(buffer());
      _view.setMarkIndex(-1);
      _view.setGetIndex(0);
      _view.setPutIndex(index + length);
      _view.setGetIndex(index);
    }
    return _view;
  }
  
  public int poke(int index, Buffer src)
  {
    _hash = 0;
    
    int length = src.length();
    if (index + length > capacity()) {
      length = capacity() - index;
    }
    byte[] src_array = src.array();
    byte[] dst_array = array();
    if ((src_array != null) && (dst_array != null))
    {
      Portable.arraycopy(src_array, src.getIndex(), dst_array, index, length);
    }
    else if (src_array != null)
    {
      int s = src.getIndex();
      for (int i = 0; i < length; i++) {
        poke(index++, src_array[(s++)]);
      }
    }
    else if (dst_array != null)
    {
      int s = src.getIndex();
      for (int i = 0; i < length; i++) {
        dst_array[(index++)] = src.peek(s++);
      }
    }
    else
    {
      int s = src.getIndex();
      for (int i = 0; i < length; i++) {
        poke(index++, src.peek(s++));
      }
    }
    return length;
  }
  
  public int poke(int index, byte[] b, int offset, int length)
  {
    _hash = 0;
    if (index + length > capacity()) {
      length = capacity() - index;
    }
    byte[] dst_array = array();
    if (dst_array != null)
    {
      Portable.arraycopy(b, offset, dst_array, index, length);
    }
    else
    {
      int s = offset;
      for (int i = 0; i < length; i++) {
        poke(index++, b[(s++)]);
      }
    }
    return length;
  }
  
  public int put(Buffer src)
  {
    int pi = putIndex();
    int l = poke(pi, src);
    setPutIndex(pi + l);
    return l;
  }
  
  public void put(byte b)
  {
    int pi = putIndex();
    poke(pi, b);
    setPutIndex(pi + 1);
  }
  
  public int put(byte[] b, int offset, int length)
  {
    int pi = putIndex();
    int l = poke(pi, b, offset, length);
    setPutIndex(pi + l);
    return l;
  }
  
  public int put(byte[] b)
  {
    int pi = putIndex();
    int l = poke(pi, b, 0, b.length);
    setPutIndex(pi + l);
    return l;
  }
  
  public final int putIndex()
  {
    return _put;
  }
  
  public void reset()
  {
    if (markIndex() >= 0) {
      setGetIndex(markIndex());
    }
  }
  
  public void rewind()
  {
    setGetIndex(0);
    setMarkIndex(-1);
  }
  
  public void setGetIndex(int getIndex)
  {
    _get = getIndex;
    _hash = 0;
  }
  
  public void setMarkIndex(int index)
  {
    _mark = index;
  }
  
  public void setPutIndex(int putIndex)
  {
    _put = putIndex;
    _hash = 0;
  }
  
  public int skip(int n)
  {
    if (length() < n) {
      n = length();
    }
    setGetIndex(getIndex() + n);
    return n;
  }
  
  public Buffer slice()
  {
    return peek(getIndex(), length());
  }
  
  public Buffer sliceFromMark()
  {
    return sliceFromMark(getIndex() - markIndex() - 1);
  }
  
  public Buffer sliceFromMark(int length)
  {
    if (markIndex() < 0) {
      return null;
    }
    Buffer view = peek(markIndex(), length);
    setMarkIndex(-1);
    return view;
  }
  
  public int space()
  {
    return capacity() - _put;
  }
  
  public String toDetailString()
  {
    StringBuffer buf = new StringBuffer();
    buf.append("[");
    buf.append(super.hashCode());
    buf.append(",");
    buf.append(array().hashCode());
    buf.append(",m=");
    buf.append(markIndex());
    buf.append(",g=");
    buf.append(getIndex());
    buf.append(",p=");
    buf.append(putIndex());
    buf.append(",c=");
    buf.append(capacity());
    buf.append("]={");
    if (markIndex() >= 0)
    {
      for (int i = markIndex(); i < getIndex(); i++)
      {
        char c = (char)peek(i);
        if (Character.isISOControl(c))
        {
          buf.append(c < '\020' ? "\\0" : "\\");
          buf.append(Integer.toString(c, 16));
        }
        else
        {
          buf.append(c);
        }
      }
      buf.append("}{");
    }
    int count = 0;
    for (int i = getIndex(); i < putIndex(); i++)
    {
      char c = (char)peek(i);
      if (Character.isISOControl(c))
      {
        buf.append(c < '\020' ? "\\0" : "\\");
        buf.append(Integer.toString(c, 16));
      }
      else
      {
        buf.append(c);
      }
      if (count++ == 50) {
        if (putIndex() - i > 20)
        {
          buf.append(" ... ");
          i = putIndex() - 20;
        }
      }
    }
    buf.append('}');
    return buf.toString();
  }
  
  public String toString()
  {
    if (isImmutable())
    {
      if (_string == null) {
        _string = new String(asArray(), 0, length());
      }
      return _string;
    }
    return new String(asArray(), 0, length());
  }
  
  public String toDebugString()
  {
    return getClass() + "@" + super.hashCode();
  }
  
  public void writeTo(OutputStream out)
    throws IOException
  {
    byte[] array = array();
    if (array != null)
    {
      out.write(array, getIndex(), length());
    }
    else
    {
      int len = length();
      byte[] buf = new byte[len > 1024 ? 1024 : len];
      int offset = _get;
      while (len > 0)
      {
        int l = peek(offset, buf, 0, len > buf.length ? buf.length : len);
        out.write(buf, 0, l);
        offset += l;
        len -= l;
      }
    }
    clear();
  }
  
  public int readFrom(InputStream in, int max)
    throws IOException
  {
    byte[] array = array();
    int s = space();
    if (s > max) {
      s = max;
    }
    if (array != null)
    {
      int l = in.read(array, _put, s);
      if (l > 0) {
        _put += l;
      }
      return l;
    }
    byte[] buf = new byte[s > 1024 ? 1024 : s];
    int total = 0;
    while (s > 0)
    {
      int l = in.read(buf, 0, buf.length);
      if (l < 0) {
        return total > 0 ? total : -1;
      }
      int p = put(buf, 0, l);
      assert (l == p);
      s -= l;
    }
    return total;
  }
}

/* Location:
 * Qualified Name:     org.mortbay.io.AbstractBuffer
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.mortbay.io;

public abstract interface Buffer$CaseInsensitve {}

/* Location:
 * Qualified Name:     org.mortbay.io.Buffer.CaseInsensitve
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.mortbay.io;

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

public abstract interface Buffer
  extends Cloneable
{
  public static final int IMMUTABLE = 0;
  public static final int READONLY = 1;
  public static final int READWRITE = 2;
  public static final boolean VOLATILE = true;
  public static final boolean NON_VOLATILE = false;
  
  public abstract byte[] array();
  
  public abstract byte[] asArray();
  
  public abstract Buffer buffer();
  
  public abstract Buffer asNonVolatileBuffer();
  
  public abstract Buffer asReadOnlyBuffer();
  
  public abstract Buffer asImmutableBuffer();
  
  public abstract Buffer asMutableBuffer();
  
  public abstract int capacity();
  
  public abstract int space();
  
  public abstract void clear();
  
  public abstract void compact();
  
  public abstract byte get();
  
  public abstract int get(byte[] paramArrayOfByte, int paramInt1, int paramInt2);
  
  public abstract Buffer get(int paramInt);
  
  public abstract int getIndex();
  
  public abstract boolean hasContent();
  
  public abstract boolean equalsIgnoreCase(Buffer paramBuffer);
  
  public abstract boolean isImmutable();
  
  public abstract boolean isReadOnly();
  
  public abstract boolean isVolatile();
  
  public abstract int length();
  
  public abstract void mark();
  
  public abstract void mark(int paramInt);
  
  public abstract int markIndex();
  
  public abstract byte peek();
  
  public abstract byte peek(int paramInt);
  
  public abstract Buffer peek(int paramInt1, int paramInt2);
  
  public abstract int peek(int paramInt1, byte[] paramArrayOfByte, int paramInt2, int paramInt3);
  
  public abstract int poke(int paramInt, Buffer paramBuffer);
  
  public abstract void poke(int paramInt, byte paramByte);
  
  public abstract int poke(int paramInt1, byte[] paramArrayOfByte, int paramInt2, int paramInt3);
  
  public abstract int put(Buffer paramBuffer);
  
  public abstract void put(byte paramByte);
  
  public abstract int put(byte[] paramArrayOfByte, int paramInt1, int paramInt2);
  
  public abstract int put(byte[] paramArrayOfByte);
  
  public abstract int putIndex();
  
  public abstract void reset();
  
  public abstract void setGetIndex(int paramInt);
  
  public abstract void setMarkIndex(int paramInt);
  
  public abstract void setPutIndex(int paramInt);
  
  public abstract int skip(int paramInt);
  
  public abstract Buffer slice();
  
  public abstract Buffer sliceFromMark();
  
  public abstract Buffer sliceFromMark(int paramInt);
  
  public abstract String toDetailString();
  
  public abstract void writeTo(OutputStream paramOutputStream)
    throws IOException;
  
  public abstract int readFrom(InputStream paramInputStream, int paramInt)
    throws IOException;
  
  public static abstract interface CaseInsensitve {}
}

/* Location:
 * Qualified Name:     org.mortbay.io.Buffer
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.mortbay.io;

import java.util.HashMap;

public class BufferCache$CachedBuffer
  extends ByteArrayBuffer.CaseInsensitive
{
  private int _ordinal;
  private HashMap _associateMap = null;
  
  public BufferCache$CachedBuffer(String value, int ordinal)
  {
    super(value);
    _ordinal = ordinal;
  }
  
  public int getOrdinal()
  {
    return _ordinal;
  }
  
  public CachedBuffer getAssociate(Object key)
  {
    if (_associateMap == null) {
      return null;
    }
    return (CachedBuffer)_associateMap.get(key);
  }
  
  public void setAssociate(Object key, CachedBuffer associate)
  {
    if (_associateMap == null) {
      _associateMap = new HashMap();
    }
    _associateMap.put(key, associate);
  }
}

/* Location:
 * Qualified Name:     org.mortbay.io.BufferCache.CachedBuffer
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.mortbay.io;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
import org.mortbay.util.StringMap;

public class BufferCache
{
  private HashMap _bufferMap;
  private StringMap _stringMap;
  private ArrayList _index;
  
  public BufferCache()
  {
    _bufferMap = new HashMap();
    _stringMap = new StringMap(true);
    _index = new ArrayList();
  }
  
  public CachedBuffer add(String value, int ordinal)
  {
    CachedBuffer buffer = new CachedBuffer(value, ordinal);
    _bufferMap.put(buffer, buffer);
    _stringMap.put(value, buffer);
    while (ordinal - _index.size() > 0) {
      _index.add(null);
    }
    _index.add(ordinal, buffer);
    return buffer;
  }
  
  public CachedBuffer get(int ordinal)
  {
    if ((ordinal < 0) || (ordinal >= _index.size())) {
      return null;
    }
    return (CachedBuffer)_index.get(ordinal);
  }
  
  public CachedBuffer get(Buffer buffer)
  {
    return (CachedBuffer)_bufferMap.get(buffer);
  }
  
  public CachedBuffer get(String value)
  {
    return (CachedBuffer)_stringMap.get(value);
  }
  
  public Buffer lookup(Buffer buffer)
  {
    Buffer b = get(buffer);
    if (b == null)
    {
      if ((buffer instanceof Buffer.CaseInsensitve)) {
        return buffer;
      }
      return new View.CaseInsensitive(buffer);
    }
    return b;
  }
  
  public CachedBuffer getBest(byte[] value, int offset, int maxLength)
  {
    Map.Entry entry = _stringMap.getBestEntry(value, offset, maxLength);
    if (entry != null) {
      return (CachedBuffer)entry.getValue();
    }
    return null;
  }
  
  public Buffer lookup(String value)
  {
    Buffer b = get(value);
    if (b == null) {
      return new CachedBuffer(value, -1);
    }
    return b;
  }
  
  public String toString(Buffer buffer)
  {
    return lookup(buffer).toString();
  }
  
  public int getOrdinal(Buffer buffer)
  {
    if ((buffer instanceof CachedBuffer)) {
      return ((CachedBuffer)buffer).getOrdinal();
    }
    buffer = lookup(buffer);
    if ((buffer != null) && ((buffer instanceof CachedBuffer))) {
      return ((CachedBuffer)buffer).getOrdinal();
    }
    return -1;
  }
  
  public static class CachedBuffer
    extends ByteArrayBuffer.CaseInsensitive
  {
    private int _ordinal;
    private HashMap _associateMap = null;
    
    public CachedBuffer(String value, int ordinal)
    {
      super();
      _ordinal = ordinal;
    }
    
    public int getOrdinal()
    {
      return _ordinal;
    }
    
    public CachedBuffer getAssociate(Object key)
    {
      if (_associateMap == null) {
        return null;
      }
      return (CachedBuffer)_associateMap.get(key);
    }
    
    public void setAssociate(Object key, CachedBuffer associate)
    {
      if (_associateMap == null) {
        _associateMap = new HashMap();
      }
      _associateMap.put(key, associate);
    }
  }
  
  public String toString()
  {
    return "CACHE[bufferMap=" + _bufferMap + ",stringMap=" + _stringMap + ",index=" + _index + "]";
  }
}

/* Location:
 * Qualified Name:     org.mortbay.io.BufferCache
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.mortbay.io;

import java.text.DateFormatSymbols;
import java.util.Locale;
import org.mortbay.util.DateCache;

public class BufferDateCache
  extends DateCache
{
  Buffer _buffer;
  String _last;
  
  public BufferDateCache() {}
  
  public BufferDateCache(String format, DateFormatSymbols s)
  {
    super(format, s);
  }
  
  public BufferDateCache(String format, Locale l)
  {
    super(format, l);
  }
  
  public BufferDateCache(String format)
  {
    super(format);
  }
  
  public synchronized Buffer formatBuffer(long date)
  {
    String d = super.format(date);
    if (d == _last) {
      return _buffer;
    }
    _last = d;
    _buffer = new ByteArrayBuffer(d);
    
    return _buffer;
  }
}

/* Location:
 * Qualified Name:     org.mortbay.io.BufferDateCache
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.mortbay.io;

import java.io.UnsupportedEncodingException;
import org.mortbay.util.StringUtil;

public class BufferUtil
{
  static final byte SPACE = 32;
  static final byte MINUS = 45;
  static final byte[] DIGIT = { 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70 };
  
  public static int toInt(Buffer buffer)
  {
    int val = 0;
    boolean started = false;
    boolean minus = false;
    for (int i = buffer.getIndex(); i < buffer.putIndex(); i++)
    {
      byte b = buffer.peek(i);
      if (b <= 32)
      {
        if (started) {
          break;
        }
      }
      else if ((b >= 48) && (b <= 57))
      {
        val = val * 10 + (b - 48);
        started = true;
      }
      else
      {
        if ((b != 45) || (started)) {
          break;
        }
        minus = true;
      }
    }
    if (started) {
      return minus ? -val : val;
    }
    throw new NumberFormatException(buffer.toString());
  }
  
  public static long toLong(Buffer buffer)
  {
    long val = 0L;
    boolean started = false;
    boolean minus = false;
    for (int i = buffer.getIndex(); i < buffer.putIndex(); i++)
    {
      byte b = buffer.peek(i);
      if (b <= 32)
      {
        if (started) {
          break;
        }
      }
      else if ((b >= 48) && (b <= 57))
      {
        val = val * 10L + (b - 48);
        started = true;
      }
      else
      {
        if ((b != 45) || (started)) {
          break;
        }
        minus = true;
      }
    }
    if (started) {
      return minus ? -val : val;
    }
    throw new NumberFormatException(buffer.toString());
  }
  
  public static void putHexInt(Buffer buffer, int n)
  {
    if (n < 0)
    {
      buffer.put((byte)45);
      if (n == Integer.MIN_VALUE)
      {
        buffer.put((byte)56);
        buffer.put((byte)48);
        buffer.put((byte)48);
        buffer.put((byte)48);
        buffer.put((byte)48);
        buffer.put((byte)48);
        buffer.put((byte)48);
        buffer.put((byte)48);
        
        return;
      }
      n = -n;
    }
    if (n < 16)
    {
      buffer.put(DIGIT[n]);
    }
    else
    {
      boolean started = false;
      for (int i = 0; i < hexDivisors.length; i++) {
        if (n < hexDivisors[i])
        {
          if (started) {
            buffer.put((byte)48);
          }
        }
        else
        {
          started = true;
          int d = n / hexDivisors[i];
          buffer.put(DIGIT[d]);
          n -= d * hexDivisors[i];
        }
      }
    }
  }
  
  public static void prependHexInt(Buffer buffer, int n)
  {
    if (n == 0)
    {
      int gi = buffer.getIndex();
      buffer.poke(--gi, (byte)48);
      buffer.setGetIndex(gi);
    }
    else
    {
      boolean minus = false;
      if (n < 0)
      {
        minus = true;
        n = -n;
      }
      int gi = buffer.getIndex();
      while (n > 0)
      {
        int d = 0xF & n;
        n >>= 4;
        buffer.poke(--gi, DIGIT[d]);
      }
      if (minus) {
        buffer.poke(--gi, (byte)45);
      }
      buffer.setGetIndex(gi);
    }
  }
  
  public static void putDecInt(Buffer buffer, int n)
  {
    if (n < 0)
    {
      buffer.put((byte)45);
      if (n == Integer.MIN_VALUE)
      {
        buffer.put((byte)50);
        n = 147483648;
      }
      else
      {
        n = -n;
      }
    }
    if (n < 10)
    {
      buffer.put(DIGIT[n]);
    }
    else
    {
      boolean started = false;
      for (int i = 0; i < decDivisors.length; i++) {
        if (n < decDivisors[i])
        {
          if (started) {
            buffer.put((byte)48);
          }
        }
        else
        {
          started = true;
          int d = n / decDivisors[i];
          buffer.put(DIGIT[d]);
          n -= d * decDivisors[i];
        }
      }
    }
  }
  
  public static void putDecLong(Buffer buffer, long n)
  {
    if (n < 0L)
    {
      buffer.put((byte)45);
      if (n == Long.MIN_VALUE)
      {
        buffer.put((byte)57);
        n = 223372036854775808L;
      }
      else
      {
        n = -n;
      }
    }
    if (n < 10L)
    {
      buffer.put(DIGIT[((int)n)]);
    }
    else
    {
      boolean started = false;
      for (int i = 0; i < decDivisors.length; i++) {
        if (n < decDivisors[i])
        {
          if (started) {
            buffer.put((byte)48);
          }
        }
        else
        {
          started = true;
          long d = n / decDivisors[i];
          buffer.put(DIGIT[((int)d)]);
          n -= d * decDivisors[i];
        }
      }
    }
  }
  
  public static Buffer toBuffer(long value)
  {
    ByteArrayBuffer buf = new ByteArrayBuffer(16);
    putDecLong(buf, value);
    return buf;
  }
  
  private static int[] decDivisors = { 1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1 };
  private static int[] hexDivisors = { 268435456, 16777216, 1048576, 65536, 4096, 256, 16, 1 };
  
  public static void putCRLF(Buffer buffer)
  {
    buffer.put((byte)13);
    buffer.put((byte)10);
  }
  
  public static boolean isPrefix(Buffer prefix, Buffer buffer)
  {
    if (prefix.length() > buffer.length()) {
      return false;
    }
    int bi = buffer.getIndex();
    for (int i = prefix.getIndex(); i < prefix.putIndex(); i++) {
      if (prefix.peek(i) != buffer.peek(bi++)) {
        return false;
      }
    }
    return true;
  }
  
  public static String to8859_1_String(Buffer buffer)
  {
    if (buffer.isImmutable()) {
      return buffer.toString();
    }
    try
    {
      byte[] bytes = buffer.array();
      if (bytes != null) {
        return new String(bytes, buffer.getIndex(), buffer.length(), StringUtil.__ISO_8859_1);
      }
      StringBuffer b = new StringBuffer(buffer.length());
      int i = buffer.getIndex();
      for (int c = 0; c < buffer.length(); c++)
      {
        b.append((char)(0x7F & buffer.peek(i)));i++;
      }
      return b.toString();
    }
    catch (UnsupportedEncodingException e)
    {
      e.printStackTrace();
    }
    return buffer.toString();
  }
}

/* Location:
 * Qualified Name:     org.mortbay.io.BufferUtil
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.mortbay.io;

public abstract interface Buffers
{
  public abstract Buffer getBuffer(int paramInt);
  
  public abstract void returnBuffer(Buffer paramBuffer);
}

/* Location:
 * Qualified Name:     org.mortbay.io.Buffers
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.mortbay.io;

public class ByteArrayBuffer$CaseInsensitive
  extends ByteArrayBuffer
  implements Buffer.CaseInsensitve
{
  public ByteArrayBuffer$CaseInsensitive(String s)
  {
    super(s);
  }
  
  public ByteArrayBuffer$CaseInsensitive(byte[] b, int o, int l, int rw)
  {
    super(b, o, l, rw);
  }
  
  public boolean equals(Object obj)
  {
    return equalsIgnoreCase((Buffer)obj);
  }
}

/* Location:
 * Qualified Name:     org.mortbay.io.ByteArrayBuffer.CaseInsensitive
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.mortbay.io;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;

public class ByteArrayBuffer
  extends AbstractBuffer
{
  protected byte[] _bytes;
  
  protected ByteArrayBuffer(int access, boolean isVolatile)
  {
    super(access, isVolatile);
  }
  
  public ByteArrayBuffer(byte[] bytes)
  {
    this(bytes, 0, bytes.length, 2);
  }
  
  public ByteArrayBuffer(byte[] bytes, int index, int length)
  {
    this(bytes, index, length, 2);
  }
  
  public ByteArrayBuffer(byte[] bytes, int index, int length, int access)
  {
    super(2, false);
    _bytes = bytes;
    setPutIndex(index + length);
    setGetIndex(index);
    _access = access;
  }
  
  public ByteArrayBuffer(byte[] bytes, int index, int length, int access, boolean isVolatile)
  {
    super(2, isVolatile);
    _bytes = bytes;
    setPutIndex(index + length);
    setGetIndex(index);
    _access = access;
  }
  
  public ByteArrayBuffer(int size)
  {
    this(new byte[size], 0, size, 2);
    setPutIndex(0);
  }
  
  public ByteArrayBuffer(String value)
  {
    super(2, false);
    _bytes = Portable.getBytes(value);
    setGetIndex(0);
    setPutIndex(_bytes.length);
    _access = 0;
    _string = value;
  }
  
  public ByteArrayBuffer(String value, String encoding)
    throws UnsupportedEncodingException
  {
    super(2, false);
    _bytes = value.getBytes(encoding);
    setGetIndex(0);
    setPutIndex(_bytes.length);
    _access = 0;
    _string = value;
  }
  
  public byte[] array()
  {
    return _bytes;
  }
  
  public int capacity()
  {
    return _bytes.length;
  }
  
  public void compact()
  {
    if (isReadOnly()) {
      throw new IllegalStateException("READONLY");
    }
    int s = markIndex() >= 0 ? markIndex() : getIndex();
    if (s > 0)
    {
      int length = putIndex() - s;
      if (length > 0) {
        Portable.arraycopy(_bytes, s, _bytes, 0, length);
      }
      if (markIndex() > 0) {
        setMarkIndex(markIndex() - s);
      }
      setGetIndex(getIndex() - s);
      setPutIndex(putIndex() - s);
    }
  }
  
  public boolean equals(Object obj)
  {
    if (obj == this) {
      return true;
    }
    if ((obj == null) || (!(obj instanceof Buffer))) {
      return false;
    }
    if ((obj instanceof Buffer.CaseInsensitve)) {
      return equalsIgnoreCase((Buffer)obj);
    }
    Buffer b = (Buffer)obj;
    if (b.length() != length()) {
      return false;
    }
    if ((_hash != 0) && ((obj instanceof AbstractBuffer)))
    {
      AbstractBuffer ab = (AbstractBuffer)obj;
      if ((_hash != 0) && (_hash != _hash)) {
        return false;
      }
    }
    int get = getIndex();
    int bi = b.putIndex();
    for (int i = putIndex(); i-- > get;)
    {
      byte b1 = _bytes[i];
      byte b2 = b.peek(--bi);
      if (b1 != b2) {
        return false;
      }
    }
    return true;
  }
  
  public boolean equalsIgnoreCase(Buffer b)
  {
    if (b == this) {
      return true;
    }
    if ((b == null) || (b.length() != length())) {
      return false;
    }
    if ((_hash != 0) && ((b instanceof AbstractBuffer)))
    {
      AbstractBuffer ab = (AbstractBuffer)b;
      if ((_hash != 0) && (_hash != _hash)) {
        return false;
      }
    }
    int get = getIndex();
    int bi = b.putIndex();
    byte[] barray = b.array();
    int i;
    int i;
    if (barray == null) {
      for (i = putIndex(); i-- > get;)
      {
        byte b1 = _bytes[i];
        byte b2 = b.peek(--bi);
        if (b1 != b2)
        {
          if ((97 <= b1) && (b1 <= 122)) {
            b1 = (byte)(b1 - 97 + 65);
          }
          if ((97 <= b2) && (b2 <= 122)) {
            b2 = (byte)(b2 - 97 + 65);
          }
          if (b1 != b2) {
            return false;
          }
        }
      }
    } else {
      for (i = putIndex(); i-- > get;)
      {
        byte b1 = _bytes[i];
        byte b2 = barray[(--bi)];
        if (b1 != b2)
        {
          if ((97 <= b1) && (b1 <= 122)) {
            b1 = (byte)(b1 - 97 + 65);
          }
          if ((97 <= b2) && (b2 <= 122)) {
            b2 = (byte)(b2 - 97 + 65);
          }
          if (b1 != b2) {
            return false;
          }
        }
      }
    }
    return true;
  }
  
  public byte get()
  {
    return _bytes[(_get++)];
  }
  
  public int hashCode()
  {
    if ((_hash == 0) || (_hashGet != _get) || (_hashPut != _put))
    {
      int get = getIndex();
      for (int i = putIndex(); i-- > get;)
      {
        byte b = _bytes[i];
        if ((97 <= b) && (b <= 122)) {
          b = (byte)(b - 97 + 65);
        }
        _hash = (31 * _hash + b);
      }
      if (_hash == 0) {
        _hash = -1;
      }
      _hashGet = _get;
      _hashPut = _put;
    }
    return _hash;
  }
  
  public byte peek(int index)
  {
    return _bytes[index];
  }
  
  public int peek(int index, byte[] b, int offset, int length)
  {
    int l = length;
    if (index + l > capacity())
    {
      l = capacity() - index;
      if (l == 0) {
        return -1;
      }
    }
    if (l < 0) {
      return -1;
    }
    Portable.arraycopy(_bytes, index, b, offset, l);
    return l;
  }
  
  public void poke(int index, byte b)
  {
    _bytes[index] = b;
  }
  
  public int poke(int index, Buffer src)
  {
    _hash = 0;
    
    int length = src.length();
    if (index + length > capacity()) {
      length = capacity() - index;
    }
    byte[] src_array = src.array();
    if (src_array != null)
    {
      Portable.arraycopy(src_array, src.getIndex(), _bytes, index, length);
    }
    else if (src_array != null)
    {
      int s = src.getIndex();
      for (int i = 0; i < length; i++) {
        poke(index++, src_array[(s++)]);
      }
    }
    else
    {
      int s = src.getIndex();
      for (int i = 0; i < length; i++) {
        _bytes[(index++)] = src.peek(s++);
      }
    }
    return length;
  }
  
  public int poke(int index, byte[] b, int offset, int length)
  {
    _hash = 0;
    if (index + length > capacity()) {
      length = capacity() - index;
    }
    Portable.arraycopy(b, offset, _bytes, index, length);
    
    return length;
  }
  
  public void wrap(byte[] b, int off, int len)
  {
    if (isReadOnly()) {
      throw new IllegalStateException("READONLY");
    }
    if (isImmutable()) {
      throw new IllegalStateException("IMMUTABLE");
    }
    _bytes = b;
    clear();
    setGetIndex(off);
    setPutIndex(off + len);
  }
  
  public void wrap(byte[] b)
  {
    if (isReadOnly()) {
      throw new IllegalStateException("READONLY");
    }
    if (isImmutable()) {
      throw new IllegalStateException("IMMUTABLE");
    }
    _bytes = b;
    setGetIndex(0);
    setPutIndex(b.length);
  }
  
  public void writeTo(OutputStream out)
    throws IOException
  {
    out.write(_bytes, getIndex(), length());
    clear();
  }
  
  public int readFrom(InputStream in, int max)
    throws IOException
  {
    if ((max < 0) || (max > space())) {
      max = space();
    }
    int p = putIndex();
    
    int len = 0;int total = 0;int available = max;
    while (total < max)
    {
      len = in.read(_bytes, p, available);
      if (len >= 0)
      {
        if (len > 0)
        {
          p += len;
          total += len;
          available -= len;
          setPutIndex(p);
        }
        if (in.available() <= 0) {
          break;
        }
      }
    }
    if ((len < 0) && (total == 0)) {
      return -1;
    }
    return total;
  }
  
  public int space()
  {
    return _bytes.length - _put;
  }
  
  public static class CaseInsensitive
    extends ByteArrayBuffer
    implements Buffer.CaseInsensitve
  {
    public CaseInsensitive(String s)
    {
      super();
    }
    
    public CaseInsensitive(byte[] b, int o, int l, int rw)
    {
      super(o, l, rw);
    }
    
    public boolean equals(Object obj)
    {
      return equalsIgnoreCase((Buffer)obj);
    }
  }
}

/* Location:
 * Qualified Name:     org.mortbay.io.ByteArrayBuffer
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.mortbay.io;

import java.io.IOException;

public class ByteArrayEndPoint
  implements EndPoint
{
  byte[] _inBytes;
  ByteArrayBuffer _in;
  ByteArrayBuffer _out;
  boolean _closed;
  boolean _nonBlocking;
  boolean _growOutput;
  
  public ByteArrayEndPoint() {}
  
  public boolean isNonBlocking()
  {
    return _nonBlocking;
  }
  
  public void setNonBlocking(boolean nonBlocking)
  {
    _nonBlocking = nonBlocking;
  }
  
  public ByteArrayEndPoint(byte[] input, int outputSize)
  {
    _inBytes = input;
    _in = new ByteArrayBuffer(input);
    _out = new ByteArrayBuffer(outputSize);
  }
  
  public ByteArrayBuffer getIn()
  {
    return _in;
  }
  
  public void setIn(ByteArrayBuffer in)
  {
    _in = in;
  }
  
  public ByteArrayBuffer getOut()
  {
    return _out;
  }
  
  public void setOut(ByteArrayBuffer out)
  {
    _out = out;
  }
  
  public boolean isOpen()
  {
    return !_closed;
  }
  
  public boolean isBlocking()
  {
    return !_nonBlocking;
  }
  
  public boolean blockReadable(long millisecs)
  {
    return true;
  }
  
  public boolean blockWritable(long millisecs)
  {
    return true;
  }
  
  public void close()
    throws IOException
  {
    _closed = true;
  }
  
  public int fill(Buffer buffer)
    throws IOException
  {
    if (_closed) {
      throw new IOException("CLOSED");
    }
    if (_in == null) {
      return -1;
    }
    if (_in.length() <= 0) {
      return _nonBlocking ? 0 : -1;
    }
    int len = buffer.put(_in);
    _in.skip(len);
    return len;
  }
  
  public int flush(Buffer buffer)
    throws IOException
  {
    if (_closed) {
      throw new IOException("CLOSED");
    }
    if ((_growOutput) && (buffer.length() > _out.space()))
    {
      _out.compact();
      if (buffer.length() > _out.space())
      {
        ByteArrayBuffer n = new ByteArrayBuffer(_out.putIndex() + buffer.length());
        
        n.put(_out.peek(0, _out.putIndex()));
        if (_out.getIndex() > 0)
        {
          n.mark();
          n.setGetIndex(_out.getIndex());
        }
        _out = n;
      }
    }
    int len = _out.put(buffer);
    buffer.skip(len);
    return len;
  }
  
  public int flush(Buffer header, Buffer buffer, Buffer trailer)
    throws IOException
  {
    if (_closed) {
      throw new IOException("CLOSED");
    }
    int flushed = 0;
    if ((header != null) && (header.length() > 0)) {
      flushed = flush(header);
    }
    if ((header == null) || (header.length() == 0))
    {
      if ((buffer != null) && (buffer.length() > 0)) {
        flushed += flush(buffer);
      }
      if ((buffer == null) || (buffer.length() == 0)) {
        if ((trailer != null) && (trailer.length() > 0)) {
          flushed += flush(trailer);
        }
      }
    }
    return flushed;
  }
  
  public void reset()
  {
    _closed = false;
    _in.clear();
    _out.clear();
    if (_inBytes != null) {
      _in.setPutIndex(_inBytes.length);
    }
  }
  
  public String getLocalAddr()
  {
    return null;
  }
  
  public String getLocalHost()
  {
    return null;
  }
  
  public int getLocalPort()
  {
    return 0;
  }
  
  public String getRemoteAddr()
  {
    return null;
  }
  
  public String getRemoteHost()
  {
    return null;
  }
  
  public int getRemotePort()
  {
    return 0;
  }
  
  public Object getTransport()
  {
    return _inBytes;
  }
  
  public void flush()
    throws IOException
  {}
  
  public boolean isBufferingInput()
  {
    return false;
  }
  
  public boolean isBufferingOutput()
  {
    return false;
  }
  
  public boolean isBufferred()
  {
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

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