jetty-util-6.1.26

16:37:34.472 INFO  jd.cli.Main - Decompiling jetty-util-6.1.26.jar
package org.mortbay.util;

import java.io.Serializable;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class LazyList
  implements Cloneable, Serializable
{
  private static final String[] __EMTPY_STRING_ARRAY = new String[0];
  
  public static Object add(Object list, Object item)
  {
    if (list == null)
    {
      if (((item instanceof List)) || (item == null))
      {
        List l = new ArrayList();
        l.add(item);
        return l;
      }
      return item;
    }
    if ((list instanceof List))
    {
      ((List)list).add(item);
      return list;
    }
    List l = new ArrayList();
    l.add(list);
    l.add(item);
    return l;
  }
  
  public static Object add(Object list, int index, Object item)
  {
    if (list == null)
    {
      if ((index > 0) || ((item instanceof List)) || (item == null))
      {
        List l = new ArrayList();
        l.add(index, item);
        return l;
      }
      return item;
    }
    if ((list instanceof List))
    {
      ((List)list).add(index, item);
      return list;
    }
    List l = new ArrayList();
    l.add(list);
    l.add(index, item);
    return l;
  }
  
  public static Object addCollection(Object list, Collection collection)
  {
    Iterator i = collection.iterator();
    while (i.hasNext()) {
      list = add(list, i.next());
    }
    return list;
  }
  
  public static Object addArray(Object list, Object[] array)
  {
    for (int i = 0; (array != null) && (i < array.length); i++) {
      list = add(list, array[i]);
    }
    return list;
  }
  
  public static Object ensureSize(Object list, int initialSize)
  {
    if (list == null) {
      return new ArrayList(initialSize);
    }
    if ((list instanceof ArrayList))
    {
      ArrayList ol = (ArrayList)list;
      if (ol.size() > initialSize) {
        return ol;
      }
      ArrayList nl = new ArrayList(initialSize);
      nl.addAll(ol);
      return nl;
    }
    List l = new ArrayList(initialSize);
    l.add(list);
    return l;
  }
  
  public static Object remove(Object list, Object o)
  {
    if (list == null) {
      return null;
    }
    if ((list instanceof List))
    {
      List l = (List)list;
      l.remove(o);
      if (l.size() == 0) {
        return null;
      }
      return list;
    }
    if (list.equals(o)) {
      return null;
    }
    return list;
  }
  
  public static Object remove(Object list, int i)
  {
    if (list == null) {
      return null;
    }
    if ((list instanceof List))
    {
      List l = (List)list;
      l.remove(i);
      if (l.size() == 0) {
        return null;
      }
      return list;
    }
    if (i == 0) {
      return null;
    }
    return list;
  }
  
  public static List getList(Object list)
  {
    return getList(list, false);
  }
  
  public static List getList(Object list, boolean nullForEmpty)
  {
    if (list == null) {
      return nullForEmpty ? null : Collections.EMPTY_LIST;
    }
    if ((list instanceof List)) {
      return (List)list;
    }
    List l = new ArrayList(1);
    l.add(list);
    return l;
  }
  
  public static String[] toStringArray(Object list)
  {
    if (list == null) {
      return __EMTPY_STRING_ARRAY;
    }
    if ((list instanceof List))
    {
      List l = (List)list;
      String[] a = new String[l.size()];
      for (int i = l.size(); i-- > 0;)
      {
        Object o = l.get(i);
        if (o != null) {
          a[i] = o.toString();
        }
      }
      return a;
    }
    return new String[] { list.toString() };
  }
  
  public static Object toArray(Object list, Class aClass)
  {
    if (list == null) {
      return (Object[])Array.newInstance(aClass, 0);
    }
    if ((list instanceof List))
    {
      List l = (List)list;
      if (aClass.isPrimitive())
      {
        Object a = Array.newInstance(aClass, l.size());
        for (int i = 0; i < l.size(); i++) {
          Array.set(a, i, l.get(i));
        }
        return a;
      }
      return l.toArray((Object[])Array.newInstance(aClass, l.size()));
    }
    Object a = Array.newInstance(aClass, 1);
    Array.set(a, 0, list);
    return a;
  }
  
  public static int size(Object list)
  {
    if (list == null) {
      return 0;
    }
    if ((list instanceof List)) {
      return ((List)list).size();
    }
    return 1;
  }
  
  public static Object get(Object list, int i)
  {
    if (list == null) {
      throw new IndexOutOfBoundsException();
    }
    if ((list instanceof List)) {
      return ((List)list).get(i);
    }
    if (i == 0) {
      return list;
    }
    throw new IndexOutOfBoundsException();
  }
  
  public static boolean contains(Object list, Object item)
  {
    if (list == null) {
      return false;
    }
    if ((list instanceof List)) {
      return ((List)list).contains(item);
    }
    return list.equals(item);
  }
  
  public static Object clone(Object list)
  {
    if (list == null) {
      return null;
    }
    if ((list instanceof List)) {
      return new ArrayList((List)list);
    }
    return list;
  }
  
  public static String toString(Object list)
  {
    if (list == null) {
      return "[]";
    }
    if ((list instanceof List)) {
      return ((List)list).toString();
    }
    return "[" + list + "]";
  }
  
  public static Iterator iterator(Object list)
  {
    if (list == null) {
      return Collections.EMPTY_LIST.iterator();
    }
    if ((list instanceof List)) {
      return ((List)list).iterator();
    }
    return getList(list).iterator();
  }
  
  public static ListIterator listIterator(Object list)
  {
    if (list == null) {
      return Collections.EMPTY_LIST.listIterator();
    }
    if ((list instanceof List)) {
      return ((List)list).listIterator();
    }
    return getList(list).listIterator();
  }
  
  public static List array2List(Object[] array)
  {
    if ((array == null) || (array.length == 0)) {
      return new ArrayList();
    }
    return new ArrayList(Arrays.asList(array));
  }
  
  public static Object[] addToArray(Object[] array, Object item, Class type)
  {
    if (array == null)
    {
      if ((type == null) && (item != null)) {
        type = item.getClass();
      }
      Object[] na = (Object[])Array.newInstance(type, 1);
      na[0] = item;
      return na;
    }
    Class c = array.getClass().getComponentType();
    Object[] na = (Object[])Array.newInstance(c, Array.getLength(array) + 1);
    System.arraycopy(array, 0, na, 0, array.length);
    na[array.length] = item;
    return na;
  }
  
  public static Object[] removeFromArray(Object[] array, Object item)
  {
    if ((item == null) || (array == null)) {
      return array;
    }
    for (int i = array.length; i-- > 0;) {
      if (item.equals(array[i]))
      {
        Class c = array == null ? item.getClass() : array.getClass().getComponentType();
        Object[] na = (Object[])Array.newInstance(c, Array.getLength(array) - 1);
        if (i > 0) {
          System.arraycopy(array, 0, na, 0, i);
        }
        if (i + 1 < array.length) {
          System.arraycopy(array, i + 1, na, i, array.length - (i + 1));
        }
        return na;
      }
    }
    return array;
  }
}

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

import java.util.List;

public abstract interface Scanner$BulkListener
  extends Scanner.Listener
{
  public abstract void filesChanged(List paramList)
    throws Exception;
}

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

import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.AbstractMap;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Set;

public class StringMap
  extends AbstractMap
  implements Externalizable
{
  public static final boolean CASE_INSENSTIVE = true;
  protected static final int __HASH_WIDTH = 17;
  protected int _width = 17;
  protected Node _root = new Node();
  protected boolean _ignoreCase = false;
  protected NullEntry _nullEntry = null;
  protected Object _nullValue = null;
  protected HashSet _entrySet = new HashSet(3);
  protected Set _umEntrySet = Collections.unmodifiableSet(_entrySet);
  
  public StringMap() {}
  
  public StringMap(boolean ignoreCase)
  {
    this();
    _ignoreCase = ignoreCase;
  }
  
  public StringMap(boolean ignoreCase, int width)
  {
    this();
    _ignoreCase = ignoreCase;
  }
  
  public void setIgnoreCase(boolean ic)
  {
    if (_root._children != null) {
      throw new IllegalStateException("Must be set before first put");
    }
    _ignoreCase = ic;
  }
  
  public boolean isIgnoreCase()
  {
    return _ignoreCase;
  }
  
  public void setWidth(int width)
  {
    _width = width;
  }
  
  public int getWidth()
  {
    return _width;
  }
  
  public Object put(Object key, Object value)
  {
    if (key == null) {
      return put(null, value);
    }
    return put(key.toString(), value);
  }
  
  public Object put(String key, Object value)
  {
    if (key == null)
    {
      Object oldValue = _nullValue;
      _nullValue = value;
      if (_nullEntry == null)
      {
        _nullEntry = new NullEntry(null);
        _entrySet.add(_nullEntry);
      }
      return oldValue;
    }
    Node node = _root;
    int ni = -1;
    Node prev = null;
    Node parent = null;
    label383:
    for (int i = 0; i < key.length(); i++)
    {
      char c = key.charAt(i);
      if (ni == -1)
      {
        parent = node;
        prev = null;
        ni = 0;
        node = _children == null ? null : _children[(c % _width)];
      }
      while (node != null)
      {
        if ((_char[ni] == c) || ((_ignoreCase) && (_ochar[ni] == c)))
        {
          prev = null;
          ni++;
          if (ni != _char.length) {
            break label383;
          }
          ni = -1;
          break label383;
        }
        if (ni == 0)
        {
          prev = node;
          node = _next;
        }
        else
        {
          node.split(this, ni);
          i--;
          ni = -1;
          break label383;
        }
      }
      node = new Node(_ignoreCase, key, i);
      if (prev != null)
      {
        _next = node; break;
      }
      if (parent != null)
      {
        if (_children == null) {
          _children = new Node[_width];
        }
        _children[(c % _width)] = node;
        int oi = _ochar[0] % _width;
        if ((_ochar != null) && (_char[0] % _width != oi)) {
          if (_children[oi] == null)
          {
            _children[oi] = node;
          }
          else
          {
            Node n = _children[oi];
            while (_next != null) {
              n = _next;
            }
            _next = node;
          }
        }
        break;
      }
      _root = node;
      break;
    }
    if (node != null)
    {
      if (ni > 0) {
        node.split(this, ni);
      }
      Object old = _value;
      _key = key;
      _value = value;
      _entrySet.add(node);
      return old;
    }
    return null;
  }
  
  public Object get(Object key)
  {
    if (key == null) {
      return _nullValue;
    }
    if ((key instanceof String)) {
      return get((String)key);
    }
    return get(key.toString());
  }
  
  public Object get(String key)
  {
    if (key == null) {
      return _nullValue;
    }
    Map.Entry entry = getEntry(key, 0, key.length());
    if (entry == null) {
      return null;
    }
    return entry.getValue();
  }
  
  public Map.Entry getEntry(String key, int offset, int length)
  {
    if (key == null) {
      return _nullEntry;
    }
    Node node = _root;
    int ni = -1;
    label150:
    for (int i = 0; i < length; i++)
    {
      char c = key.charAt(offset + i);
      if (ni == -1)
      {
        ni = 0;
        node = _children == null ? null : _children[(c % _width)];
      }
      while (node != null)
      {
        if ((_char[ni] == c) || ((_ignoreCase) && (_ochar[ni] == c)))
        {
          ni++;
          if (ni != _char.length) {
            break label150;
          }
          ni = -1;
          break label150;
        }
        if (ni > 0) {
          return null;
        }
        node = _next;
      }
      return null;
    }
    if (ni > 0) {
      return null;
    }
    if ((node != null) && (_key == null)) {
      return null;
    }
    return node;
  }
  
  public Map.Entry getEntry(char[] key, int offset, int length)
  {
    if (key == null) {
      return _nullEntry;
    }
    Node node = _root;
    int ni = -1;
    label148:
    for (int i = 0; i < length; i++)
    {
      char c = key[(offset + i)];
      if (ni == -1)
      {
        ni = 0;
        node = _children == null ? null : _children[(c % _width)];
      }
      while (node != null)
      {
        if ((_char[ni] == c) || ((_ignoreCase) && (_ochar[ni] == c)))
        {
          ni++;
          if (ni != _char.length) {
            break label148;
          }
          ni = -1;
          break label148;
        }
        if (ni > 0) {
          return null;
        }
        node = _next;
      }
      return null;
    }
    if (ni > 0) {
      return null;
    }
    if ((node != null) && (_key == null)) {
      return null;
    }
    return node;
  }
  
  public Map.Entry getBestEntry(byte[] key, int offset, int maxLength)
  {
    if (key == null) {
      return _nullEntry;
    }
    Node node = _root;
    int ni = -1;
    label166:
    for (int i = 0; i < maxLength; i++)
    {
      char c = (char)key[(offset + i)];
      if (ni == -1)
      {
        ni = 0;
        
        Node child = _children == null ? null : _children[(c % _width)];
        if ((child == null) && (i > 0)) {
          return node;
        }
        node = child;
      }
      while (node != null)
      {
        if ((_char[ni] == c) || ((_ignoreCase) && (_ochar[ni] == c)))
        {
          ni++;
          if (ni != _char.length) {
            break label166;
          }
          ni = -1;
          break label166;
        }
        if (ni > 0) {
          return null;
        }
        node = _next;
      }
      return null;
    }
    if (ni > 0) {
      return null;
    }
    if ((node != null) && (_key == null)) {
      return null;
    }
    return node;
  }
  
  public Object remove(Object key)
  {
    if (key == null) {
      return remove(null);
    }
    return remove(key.toString());
  }
  
  public Object remove(String key)
  {
    if (key == null)
    {
      Object oldValue = _nullValue;
      if (_nullEntry != null)
      {
        _entrySet.remove(_nullEntry);
        _nullEntry = null;
        _nullValue = null;
      }
      return oldValue;
    }
    Node node = _root;
    int ni = -1;
    label164:
    for (int i = 0; i < key.length(); i++)
    {
      char c = key.charAt(i);
      if (ni == -1)
      {
        ni = 0;
        node = _children == null ? null : _children[(c % _width)];
      }
      while (node != null)
      {
        if ((_char[ni] == c) || ((_ignoreCase) && (_ochar[ni] == c)))
        {
          ni++;
          if (ni != _char.length) {
            break label164;
          }
          ni = -1;
          break label164;
        }
        if (ni > 0) {
          return null;
        }
        node = _next;
      }
      return null;
    }
    if (ni > 0) {
      return null;
    }
    if ((node != null) && (_key == null)) {
      return null;
    }
    Object old = _value;
    _entrySet.remove(node);
    _value = null;
    _key = null;
    
    return old;
  }
  
  public Set entrySet()
  {
    return _umEntrySet;
  }
  
  public int size()
  {
    return _entrySet.size();
  }
  
  public boolean isEmpty()
  {
    return _entrySet.isEmpty();
  }
  
  public boolean containsKey(Object key)
  {
    if (key == null) {
      return _nullEntry != null;
    }
    return getEntry(key.toString(), 0, key == null ? 0 : key.toString().length()) != null;
  }
  
  public void clear()
  {
    _root = new Node();
    _nullEntry = null;
    _nullValue = null;
    _entrySet.clear();
  }
  
  private static class Node
    implements Map.Entry
  {
    char[] _char;
    char[] _ochar;
    Node _next;
    Node[] _children;
    String _key;
    Object _value;
    
    Node() {}
    
    Node(boolean ignoreCase, String s, int offset)
    {
      int l = s.length() - offset;
      _char = new char[l];
      _ochar = new char[l];
      for (int i = 0; i < l; i++)
      {
        char c = s.charAt(offset + i);
        _char[i] = c;
        if (ignoreCase)
        {
          char o = c;
          if (Character.isUpperCase(c)) {
            o = Character.toLowerCase(c);
          } else if (Character.isLowerCase(c)) {
            o = Character.toUpperCase(c);
          }
          _ochar[i] = o;
        }
      }
    }
    
    Node split(StringMap map, int offset)
    {
      Node split = new Node();
      int sl = _char.length - offset;
      
      char[] tmp = _char;
      _char = new char[offset];
      _char = new char[sl];
      System.arraycopy(tmp, 0, _char, 0, offset);
      System.arraycopy(tmp, offset, _char, 0, sl);
      if (_ochar != null)
      {
        tmp = _ochar;
        _ochar = new char[offset];
        _ochar = new char[sl];
        System.arraycopy(tmp, 0, _ochar, 0, offset);
        System.arraycopy(tmp, offset, _ochar, 0, sl);
      }
      _key = _key;
      _value = _value;
      _key = null;
      _value = null;
      if (_entrySet.remove(this)) {
        _entrySet.add(split);
      }
      _children = _children;
      _children = new Node[_width];
      _children[(_char[0] % _width)] = split;
      if ((_ochar != null) && (_children[(_ochar[0] % _width)] != split)) {
        _children[(_ochar[0] % _width)] = split;
      }
      return split;
    }
    
    public Object getKey()
    {
      return _key;
    }
    
    public Object getValue()
    {
      return _value;
    }
    
    public Object setValue(Object o)
    {
      Object old = _value;_value = o;return old;
    }
    
    public String toString()
    {
      StringBuffer buf = new StringBuffer();
      synchronized (buf)
      {
        toString(buf);
      }
      return buf.toString();
    }
    
    private void toString(StringBuffer buf)
    {
      buf.append("{[");
      if (_char == null) {
        buf.append('-');
      } else {
        for (int i = 0; i < _char.length; i++) {
          buf.append(_char[i]);
        }
      }
      buf.append(':');
      buf.append(_key);
      buf.append('=');
      buf.append(_value);
      buf.append(']');
      if (_children != null) {
        for (int i = 0; i < _children.length; i++)
        {
          buf.append('|');
          if (_children[i] != null) {
            _children[i].toString(buf);
          } else {
            buf.append("-");
          }
        }
      }
      buf.append('}');
      if (_next != null)
      {
        buf.append(",\n");
        _next.toString(buf);
      }
    }
  }
  
  private class NullEntry
    implements Map.Entry
  {
    NullEntry(StringMap.1 x1)
    {
      this();
    }
    
    public Object getKey()
    {
      return null;
    }
    
    public Object getValue()
    {
      return _nullValue;
    }
    
    public Object setValue(Object o)
    {
      Object old = _nullValue;_nullValue = o;return old;
    }
    
    public String toString()
    {
      return "[:null=" + _nullValue + "]";
    }
    
    private NullEntry() {}
  }
  
  public void writeExternal(ObjectOutput out)
    throws IOException
  {
    HashMap map = new HashMap(this);
    out.writeBoolean(_ignoreCase);
    out.writeObject(map);
  }
  
  public void readExternal(ObjectInput in)
    throws IOException, ClassNotFoundException
  {
    boolean ic = in.readBoolean();
    HashMap map = (HashMap)in.readObject();
    setIgnoreCase(ic);
    putAll(map);
  }
}

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

import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.List;

public class IntrospectionUtil
{
  public static boolean isJavaBeanCompliantSetter(Method method)
  {
    if (method == null) {
      return false;
    }
    if (method.getReturnType() != Void.TYPE) {
      return false;
    }
    if (!method.getName().startsWith("set")) {
      return false;
    }
    if (method.getParameterTypes().length != 1) {
      return false;
    }
    return true;
  }
  
  public static Method findMethod(Class clazz, String methodName, Class[] args, boolean checkInheritance, boolean strictArgs)
    throws NoSuchMethodException
  {
    if (clazz == null) {
      throw new NoSuchMethodException("No class");
    }
    if ((methodName == null) || (methodName.trim().equals(""))) {
      throw new NoSuchMethodException("No method name");
    }
    Method method = null;
    Method[] methods = clazz.getDeclaredMethods();
    for (int i = 0; (i < methods.length) && (method == null); i++) {
      if (methods[i].getName().equals(methodName)) {
        if (checkParams(methods[i].getParameterTypes(), args == null ? new Class[0] : args, strictArgs)) {
          method = methods[i];
        }
      }
    }
    if (method != null) {
      return method;
    }
    if (checkInheritance) {
      return findInheritedMethod(clazz.getPackage(), clazz.getSuperclass(), methodName, args, strictArgs);
    }
    throw new NoSuchMethodException("No such method " + methodName + " on class " + clazz.getName());
  }
  
  public static Field findField(Class clazz, String targetName, Class targetType, boolean checkInheritance, boolean strictType)
    throws NoSuchFieldException
  {
    if (clazz == null) {
      throw new NoSuchFieldException("No class");
    }
    if (targetName == null) {
      throw new NoSuchFieldException("No field name");
    }
    try
    {
      Field field = clazz.getDeclaredField(targetName);
      if (strictType)
      {
        if (field.getType().equals(targetType)) {
          return field;
        }
      }
      else if (field.getType().isAssignableFrom(targetType)) {
        return field;
      }
      if (checkInheritance) {
        return findInheritedField(clazz.getPackage(), clazz.getSuperclass(), targetName, targetType, strictType);
      }
      throw new NoSuchFieldException("No field with name " + targetName + " in class " + clazz.getName() + " of type " + targetType);
    }
    catch (NoSuchFieldException e) {}
    return findInheritedField(clazz.getPackage(), clazz.getSuperclass(), targetName, targetType, strictType);
  }
  
  public static boolean isInheritable(Package pack, Member member)
  {
    if (pack == null) {
      return false;
    }
    if (member == null) {
      return false;
    }
    int modifiers = member.getModifiers();
    if (Modifier.isPublic(modifiers)) {
      return true;
    }
    if (Modifier.isProtected(modifiers)) {
      return true;
    }
    if ((!Modifier.isPrivate(modifiers)) && (pack.equals(member.getDeclaringClass().getPackage()))) {
      return true;
    }
    return false;
  }
  
  public static boolean checkParams(Class[] formalParams, Class[] actualParams, boolean strict)
  {
    if ((formalParams == null) && (actualParams == null)) {
      return true;
    }
    if ((formalParams == null) && (actualParams != null)) {
      return false;
    }
    if ((formalParams != null) && (actualParams == null)) {
      return false;
    }
    if (formalParams.length != actualParams.length) {
      return false;
    }
    if (formalParams.length == 0) {
      return true;
    }
    int j = 0;
    if (strict) {
      while ((j < formalParams.length) && (formalParams[j].equals(actualParams[j]))) {
        j++;
      }
    }
    while ((j < formalParams.length) && (formalParams[j].isAssignableFrom(actualParams[j]))) {
      j++;
    }
    if (j != formalParams.length) {
      return false;
    }
    return true;
  }
  
  public static boolean isSameSignature(Method methodA, Method methodB)
  {
    if (methodA == null) {
      return false;
    }
    if (methodB == null) {
      return false;
    }
    List parameterTypesA = Arrays.asList(methodA.getParameterTypes());
    List parameterTypesB = Arrays.asList(methodB.getParameterTypes());
    if ((methodA.getName().equals(methodB.getName())) && (parameterTypesA.containsAll(parameterTypesB))) {
      return true;
    }
    return false;
  }
  
  public static boolean isTypeCompatible(Class formalType, Class actualType, boolean strict)
  {
    if ((formalType == null) && (actualType != null)) {
      return false;
    }
    if ((formalType != null) && (actualType == null)) {
      return false;
    }
    if ((formalType == null) && (actualType == null)) {
      return true;
    }
    if (strict) {
      return formalType.equals(actualType);
    }
    return formalType.isAssignableFrom(actualType);
  }
  
  public static boolean containsSameMethodSignature(Method method, Class c, boolean checkPackage)
  {
    if (checkPackage) {
      if (!c.getPackage().equals(method.getDeclaringClass().getPackage())) {
        return false;
      }
    }
    boolean samesig = false;
    Method[] methods = c.getDeclaredMethods();
    for (int i = 0; (i < methods.length) && (!samesig); i++) {
      if (isSameSignature(method, methods[i])) {
        samesig = true;
      }
    }
    return samesig;
  }
  
  public static boolean containsSameFieldName(Field field, Class c, boolean checkPackage)
  {
    if (checkPackage) {
      if (!c.getPackage().equals(field.getDeclaringClass().getPackage())) {
        return false;
      }
    }
    boolean sameName = false;
    Field[] fields = c.getDeclaredFields();
    for (int i = 0; (i < fields.length) && (!sameName); i++) {
      if (fields[i].getName().equals(field.getName())) {
        sameName = true;
      }
    }
    return sameName;
  }
  
  protected static Method findInheritedMethod(Package pack, Class clazz, String methodName, Class[] args, boolean strictArgs)
    throws NoSuchMethodException
  {
    if (clazz == null) {
      throw new NoSuchMethodException("No class");
    }
    if (methodName == null) {
      throw new NoSuchMethodException("No method name");
    }
    Method method = null;
    Method[] methods = clazz.getDeclaredMethods();
    for (int i = 0; (i < methods.length) && (method == null); i++) {
      if ((methods[i].getName().equals(methodName)) && (isInheritable(pack, methods[i])) && (checkParams(methods[i].getParameterTypes(), args, strictArgs))) {
        method = methods[i];
      }
    }
    if (method != null) {
      return method;
    }
    return findInheritedMethod(clazz.getPackage(), clazz.getSuperclass(), methodName, args, strictArgs);
  }
  
  protected static Field findInheritedField(Package pack, Class clazz, String fieldName, Class fieldType, boolean strictType)
    throws NoSuchFieldException
  {
    if (clazz == null) {
      throw new NoSuchFieldException("No class");
    }
    if (fieldName == null) {
      throw new NoSuchFieldException("No field name");
    }
    try
    {
      Field field = clazz.getDeclaredField(fieldName);
      if ((isInheritable(pack, field)) && (isTypeCompatible(fieldType, field.getType(), strictType))) {
        return field;
      }
      return findInheritedField(clazz.getPackage(), clazz.getSuperclass(), fieldName, fieldType, strictType);
    }
    catch (NoSuchFieldException e) {}
    return findInheritedField(clazz.getPackage(), clazz.getSuperclass(), fieldName, fieldType, strictType);
  }
}

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

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.HashMap;
import org.mortbay.log.Log;

public class TypeUtil
{
  public static int CR = 13;
  public static int LF = 10;
  private static final HashMap name2Class = new HashMap();
  private static final HashMap class2Name;
  private static final HashMap class2Value;
  
  static
  {
    name2Class.put("boolean", Boolean.TYPE);
    name2Class.put("byte", Byte.TYPE);
    name2Class.put("char", Character.TYPE);
    name2Class.put("double", Double.TYPE);
    name2Class.put("float", Float.TYPE);
    name2Class.put("int", Integer.TYPE);
    name2Class.put("long", Long.TYPE);
    name2Class.put("short", Short.TYPE);
    name2Class.put("void", Void.TYPE);
    
    name2Class.put("java.lang.Boolean.TYPE", Boolean.TYPE);
    name2Class.put("java.lang.Byte.TYPE", Byte.TYPE);
    name2Class.put("java.lang.Character.TYPE", Character.TYPE);
    name2Class.put("java.lang.Double.TYPE", Double.TYPE);
    name2Class.put("java.lang.Float.TYPE", Float.TYPE);
    name2Class.put("java.lang.Integer.TYPE", Integer.TYPE);
    name2Class.put("java.lang.Long.TYPE", Long.TYPE);
    name2Class.put("java.lang.Short.TYPE", Short.TYPE);
    name2Class.put("java.lang.Void.TYPE", Void.TYPE);
    
    name2Class.put("java.lang.Boolean", Boolean.class);
    name2Class.put("java.lang.Byte", Byte.class);
    name2Class.put("java.lang.Character", Character.class);
    name2Class.put("java.lang.Double", Double.class);
    name2Class.put("java.lang.Float", Float.class);
    name2Class.put("java.lang.Integer", Integer.class);
    name2Class.put("java.lang.Long", Long.class);
    name2Class.put("java.lang.Short", Short.class);
    
    name2Class.put("Boolean", Boolean.class);
    name2Class.put("Byte", Byte.class);
    name2Class.put("Character", Character.class);
    name2Class.put("Double", Double.class);
    name2Class.put("Float", Float.class);
    name2Class.put("Integer", Integer.class);
    name2Class.put("Long", Long.class);
    name2Class.put("Short", Short.class);
    
    name2Class.put(null, Void.TYPE);
    name2Class.put("string", String.class);
    name2Class.put("String", String.class);
    name2Class.put("java.lang.String", String.class);
    
    class2Name = new HashMap();
    
    class2Name.put(Boolean.TYPE, "boolean");
    class2Name.put(Byte.TYPE, "byte");
    class2Name.put(Character.TYPE, "char");
    class2Name.put(Double.TYPE, "double");
    class2Name.put(Float.TYPE, "float");
    class2Name.put(Integer.TYPE, "int");
    class2Name.put(Long.TYPE, "long");
    class2Name.put(Short.TYPE, "short");
    class2Name.put(Void.TYPE, "void");
    
    class2Name.put(Boolean.class, "java.lang.Boolean");
    class2Name.put(Byte.class, "java.lang.Byte");
    class2Name.put(Character.class, "java.lang.Character");
    class2Name.put(Double.class, "java.lang.Double");
    class2Name.put(Float.class, "java.lang.Float");
    class2Name.put(Integer.class, "java.lang.Integer");
    class2Name.put(Long.class, "java.lang.Long");
    class2Name.put(Short.class, "java.lang.Short");
    
    class2Name.put(null, "void");
    class2Name.put(String.class, "java.lang.String");
    
    class2Value = new HashMap();
    try
    {
      Class[] s = { String.class };
      
      class2Value.put(Boolean.TYPE, Boolean.class.getMethod("valueOf", s));
      
      class2Value.put(Byte.TYPE, Byte.class.getMethod("valueOf", s));
      
      class2Value.put(Double.TYPE, Double.class.getMethod("valueOf", s));
      
      class2Value.put(Float.TYPE, Float.class.getMethod("valueOf", s));
      
      class2Value.put(Integer.TYPE, Integer.class.getMethod("valueOf", s));
      
      class2Value.put(Long.TYPE, Long.class.getMethod("valueOf", s));
      
      class2Value.put(Short.TYPE, Short.class.getMethod("valueOf", s));
      
      class2Value.put(Boolean.class, Boolean.class.getMethod("valueOf", s));
      
      class2Value.put(Byte.class, Byte.class.getMethod("valueOf", s));
      
      class2Value.put(Double.class, Double.class.getMethod("valueOf", s));
      
      class2Value.put(Float.class, Float.class.getMethod("valueOf", s));
      
      class2Value.put(Integer.class, Integer.class.getMethod("valueOf", s));
      
      class2Value.put(Long.class, Long.class.getMethod("valueOf", s));
      
      class2Value.put(Short.class, Short.class.getMethod("valueOf", s));
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
  }
  
  private static Class[] stringArg = { String.class };
  private static int intCacheSize = Integer.getInteger("org.mortbay.util.TypeUtil.IntegerCacheSize", 600).intValue();
  private static Integer[] integerCache = new Integer[intCacheSize];
  private static String[] integerStrCache = new String[intCacheSize];
  private static Integer minusOne = new Integer(-1);
  private static int longCacheSize = Integer.getInteger("org.mortbay.util.TypeUtil.LongCacheSize", 64).intValue();
  private static Long[] longCache = new Long[longCacheSize];
  private static Long minusOneL = new Long(-1L);
  
  public static Class fromName(String name)
  {
    return (Class)name2Class.get(name);
  }
  
  public static String toName(Class type)
  {
    return (String)class2Name.get(type);
  }
  
  public static Object valueOf(Class type, String value)
  {
    try
    {
      if (type.equals(String.class)) {
        return value;
      }
      Method m = (Method)class2Value.get(type);
      if (m != null) {
        return m.invoke(null, new Object[] { value });
      }
      if ((type.equals(Character.TYPE)) || (type.equals(Character.class))) {
        return new Character(value.charAt(0));
      }
      Constructor c = type.getConstructor(stringArg);
      return c.newInstance(new Object[] { value });
    }
    catch (NoSuchMethodException e) {}catch (IllegalAccessException e) {}catch (InstantiationException e) {}catch (InvocationTargetException e)
    {
      if ((e.getTargetException() instanceof Error)) {
        throw ((Error)e.getTargetException());
      }
    }
    return null;
  }
  
  public static Object valueOf(String type, String value)
  {
    return valueOf(fromName(type), value);
  }
  
  public static Integer newInteger(int i)
  {
    if ((i >= 0) && (i < intCacheSize))
    {
      if (integerCache[i] == null) {
        integerCache[i] = new Integer(i);
      }
      return integerCache[i];
    }
    if (i == -1) {
      return minusOne;
    }
    return new Integer(i);
  }
  
  public static Long newLong(long i)
  {
    if ((i >= 0L) && (i < longCacheSize))
    {
      if (longCache[((int)i)] == null) {
        longCache[((int)i)] = new Long(i);
      }
      return longCache[((int)i)];
    }
    if (i == -1L) {
      return minusOneL;
    }
    return new Long(i);
  }
  
  public static String toString(int i)
  {
    if ((i >= 0) && (i < intCacheSize))
    {
      if (integerStrCache[i] == null) {
        integerStrCache[i] = Integer.toString(i);
      }
      return integerStrCache[i];
    }
    if (i == -1) {
      return "-1";
    }
    return Integer.toString(i);
  }
  
  public static String toString(long i)
  {
    if ((i >= 0L) && (i < intCacheSize))
    {
      if (integerStrCache[((int)i)] == null) {
        integerStrCache[((int)i)] = Long.toString(i);
      }
      return integerStrCache[((int)i)];
    }
    if (i == -1L) {
      return "-1";
    }
    return Long.toString(i);
  }
  
  public static int parseInt(String s, int offset, int length, int base)
    throws NumberFormatException
  {
    int value = 0;
    if (length < 0) {
      length = s.length() - offset;
    }
    for (int i = 0; i < length; i++)
    {
      char c = s.charAt(offset + i);
      
      int digit = c - '0';
      if ((digit < 0) || (digit >= base) || (digit >= 10))
      {
        digit = '\n' + c - 65;
        if ((digit < 10) || (digit >= base)) {
          digit = '\n' + c - 97;
        }
      }
      if ((digit < 0) || (digit >= base)) {
        throw new NumberFormatException(s.substring(offset, offset + length));
      }
      value = value * base + digit;
    }
    return value;
  }
  
  public static int parseInt(byte[] b, int offset, int length, int base)
    throws NumberFormatException
  {
    int value = 0;
    if (length < 0) {
      length = b.length - offset;
    }
    for (int i = 0; i < length; i++)
    {
      char c = (char)(0xFF & b[(offset + i)]);
      
      int digit = c - '0';
      if ((digit < 0) || (digit >= base) || (digit >= 10))
      {
        digit = '\n' + c - 65;
        if ((digit < 10) || (digit >= base)) {
          digit = '\n' + c - 97;
        }
      }
      if ((digit < 0) || (digit >= base)) {
        throw new NumberFormatException(new String(b, offset, length));
      }
      value = value * base + digit;
    }
    return value;
  }
  
  public static byte[] parseBytes(String s, int base)
  {
    byte[] bytes = new byte[s.length() / 2];
    for (int i = 0; i < s.length(); i += 2) {
      bytes[(i / 2)] = ((byte)parseInt(s, i, 2, base));
    }
    return bytes;
  }
  
  public static String toString(byte[] bytes, int base)
  {
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < bytes.length; i++)
    {
      int bi = 0xFF & bytes[i];
      int c = 48 + bi / base % base;
      if (c > 57) {
        c = 97 + (c - 48 - 10);
      }
      buf.append((char)c);
      c = 48 + bi % base;
      if (c > 57) {
        c = 97 + (c - 48 - 10);
      }
      buf.append((char)c);
    }
    return buf.toString();
  }
  
  public static byte convertHexDigit(byte b)
  {
    if ((b >= 48) && (b <= 57)) {
      return (byte)(b - 48);
    }
    if ((b >= 97) && (b <= 102)) {
      return (byte)(b - 97 + 10);
    }
    if ((b >= 65) && (b <= 70)) {
      return (byte)(b - 65 + 10);
    }
    return 0;
  }
  
  public static String toHexString(byte[] b)
  {
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < b.length; i++)
    {
      int bi = 0xFF & b[i];
      int c = 48 + bi / 16 % 16;
      if (c > 57) {
        c = 65 + (c - 48 - 10);
      }
      buf.append((char)c);
      c = 48 + bi % 16;
      if (c > 57) {
        c = 97 + (c - 48 - 10);
      }
      buf.append((char)c);
    }
    return buf.toString();
  }
  
  public static String toHexString(byte[] b, int offset, int length)
  {
    StringBuffer buf = new StringBuffer();
    for (int i = offset; i < offset + length; i++)
    {
      int bi = 0xFF & b[i];
      int c = 48 + bi / 16 % 16;
      if (c > 57) {
        c = 65 + (c - 48 - 10);
      }
      buf.append((char)c);
      c = 48 + bi % 16;
      if (c > 57) {
        c = 97 + (c - 48 - 10);
      }
      buf.append((char)c);
    }
    return buf.toString();
  }
  
  public static byte[] fromHexString(String s)
  {
    if (s.length() % 2 != 0) {
      throw new IllegalArgumentException(s);
    }
    byte[] array = new byte[s.length() / 2];
    for (int i = 0; i < array.length; i++)
    {
      int b = Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16);
      array[i] = ((byte)(0xFF & b));
    }
    return array;
  }
  
  public static void dump(Class c)
  {
    System.err.println("Dump: " + c);
    dump(c.getClassLoader());
  }
  
  public static void dump(ClassLoader cl)
  {
    System.err.println("Dump Loaders:");
    while (cl != null)
    {
      System.err.println("  loader " + cl);
      cl = cl.getParent();
    }
  }
  
  public static byte[] readLine(InputStream in)
    throws IOException
  {
    byte[] buf = new byte['?'];
    
    int i = 0;
    int loops = 0;
    int ch = 0;
    for (;;)
    {
      ch = in.read();
      if (ch < 0) {
        break;
      }
      loops++;
      if ((loops != 1)
1 2 3 4 5 6 7 8 9 10

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