📄 objectlist.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3)
// Source File Name: ObjectList.java
package com.sap.mw.jco.util;
import java.io.Serializable;
public class ObjectList
implements Cloneable, Serializable
{
public ObjectList()
{
this(10, 0);
}
public ObjectList(int initialCapacity)
{
this(initialCapacity, 0);
}
public ObjectList(int initialCapacity, int capacityIncrement)
{
m_list = null;
m_size = 0;
m_capacityIncrement = 0;
m_idxLastAccess = 0;
if(initialCapacity < 0)
throw new IllegalArgumentException("initialCapacity < 0 [" + initialCapacity + "<0]");
if(capacityIncrement < 0)
{
throw new IllegalArgumentException("capacityIncrement < 0 [" + capacityIncrement + "<0]");
} else
{
m_list = new Object[initialCapacity];
m_capacityIncrement = capacityIncrement;
return;
}
}
public ObjectList(Object object)
{
this(object, 0);
}
public ObjectList(Object object, int capacityIncrement)
{
m_list = null;
m_size = 0;
m_capacityIncrement = 0;
m_idxLastAccess = 0;
if(object == null)
throw new IllegalArgumentException("object == null");
if(capacityIncrement < 0)
{
throw new IllegalArgumentException("capacityIncrement < 0 [" + capacityIncrement + "<0]");
} else
{
m_list = (new Object[] {
object
});
m_size = 1;
m_capacityIncrement = capacityIncrement;
return;
}
}
public ObjectList(Object objectArray[])
{
this(objectArray, 0);
}
public ObjectList(Object objectArray[], int capacityIncrement)
{
m_list = null;
m_size = 0;
m_capacityIncrement = 0;
m_idxLastAccess = 0;
if(objectArray == null)
throw new IllegalArgumentException("objectArray == null");
for(int i = 0; i < objectArray.length; i++)
if(objectArray[i] == null)
throw new IllegalArgumentException("objectArray[" + i + "] == null");
if(capacityIncrement < 0)
{
throw new IllegalArgumentException("capacityIncrement < 0 [" + capacityIncrement + "<0]");
} else
{
m_list = (Object[])objectArray.clone();
m_size = objectArray.length;
m_capacityIncrement = capacityIncrement;
return;
}
}
public final boolean add(Object object)
{
if(object == null)
throw new IllegalArgumentException("object == null");
if(m_size == m_list.length)
{
Object oldList[] = m_list;
if(m_capacityIncrement <= 0)
{
if(m_size > 0)
m_list = new Object[m_size * 2];
else
m_list = new Object[1];
} else
{
m_list = new Object[m_size + m_capacityIncrement];
}
System.arraycopy(((Object) (oldList)), 0, ((Object) (m_list)), 0, m_size);
}
m_idxLastAccess = m_size;
m_list[m_size++] = object;
return true;
}
public final void add(int index, Object object)
{
if(index < 0)
throw new IndexOutOfBoundsException("index < 0 [" + index + "<0]");
if(index > m_size)
throw new IndexOutOfBoundsException("index > size() [" + index + ">" + m_size + "]");
if(object == null)
throw new IllegalArgumentException("object == null");
Object oldList[] = m_list;
if(m_size == m_list.length)
{
if(m_capacityIncrement <= 0)
{
if(m_size > 0)
m_list = new Object[m_size * 2];
else
m_list = new Object[1];
} else
{
m_list = new Object[m_size + m_capacityIncrement];
}
System.arraycopy(((Object) (oldList)), 0, ((Object) (m_list)), 0, index);
}
System.arraycopy(((Object) (oldList)), index, ((Object) (m_list)), index + 1, m_size - index);
m_idxLastAccess = index;
m_list[index] = object;
m_size++;
}
public final int addAfter(Object afterObject, Object newObject)
{
if(newObject == null)
throw new IllegalArgumentException("newObject == null");
int addedIndex = indexOf(afterObject, m_idxLastAccess, true, true);
if(addedIndex >= 0)
add(++addedIndex, newObject);
return addedIndex;
}
public final boolean addAll(Object objectArray[])
{
if(objectArray == null)
throw new IllegalArgumentException("objectArray == null");
if(objectArray.length == 0)
throw new IllegalArgumentException("objectArray.length == 0");
for(int i = 0; i < objectArray.length; i++)
if(objectArray[i] == null)
throw new IllegalArgumentException("objectArray[" + i + "] == null");
if(m_size + objectArray.length > m_list.length)
{
Object oldList[] = m_list;
int newCapacity = 0;
if(m_capacityIncrement <= 0)
{
int minCapacity = m_size + objectArray.length;
if(m_list.length > 0)
newCapacity = m_list.length * 2;
else
newCapacity = 1;
for(; newCapacity < minCapacity; newCapacity *= 2);
} else
{
int lack = (m_size + objectArray.length) - m_list.length;
int factor = lack / m_capacityIncrement + (lack % m_capacityIncrement <= 0 ? 0 : 1);
newCapacity = m_list.length + factor * m_capacityIncrement;
}
m_list = new Object[newCapacity];
System.arraycopy(((Object) (oldList)), 0, ((Object) (m_list)), 0, m_size);
}
System.arraycopy(((Object) (objectArray)), 0, ((Object) (m_list)), m_size, objectArray.length);
m_size += objectArray.length;
m_idxLastAccess = m_size - 1;
return true;
}
public final int addBefore(Object beforeObject, Object newObject)
{
if(newObject == null)
throw new IllegalArgumentException("newObject == null");
int addedIndex = indexOf(beforeObject, m_idxLastAccess, false, true);
if(addedIndex >= 0)
add(addedIndex, newObject);
return addedIndex;
}
public final int capacity()
{
return m_list.length;
}
public final void clear()
{
for(int i = 0; i < m_size; i++)
m_list[i] = null;
m_size = 0;
m_idxLastAccess = 0;
}
public final Object clone()
{
try
{
ObjectList cloned = (ObjectList)super.clone();
cloned.m_list = (Object[])m_list.clone();
return cloned;
}
catch(CloneNotSupportedException ex)
{
return null;
}
}
public final boolean contains(Object object)
{
return indexOf(object, 0, true, false) > -1;
}
public final void ensureCapacity(int minCapacity)
{
if(minCapacity <= m_list.length)
{
return;
} else
{
Object oldList[] = m_list;
m_list = new Object[minCapacity];
System.arraycopy(((Object) (oldList)), 0, ((Object) (m_list)), 0, m_size);
return;
}
}
public final Object first()
{
if(m_size == 0)
{
return null;
} else
{
m_idxLastAccess = 0;
return m_list[0];
}
}
public final Object get(int index)
{
if(index < 0)
throw new IndexOutOfBoundsException("index < 0 [" + index + "<0]");
if(index >= m_size)
{
throw new IndexOutOfBoundsException("index >= size() [" + index + ">=" + m_size + "]");
} else
{
m_idxLastAccess = index;
return m_list[index];
}
}
public final Object getNext(Object object)
{
Object nextObject = null;
int index = indexOf(object, m_idxLastAccess, true, true);
if(index >= 0 && index + 1 < m_size)
{
nextObject = m_list[index + 1];
m_idxLastAccess = index + 1;
}
return nextObject;
}
public final Object getPrevious(Object object)
{
Object previousObject = null;
int index = indexOf(object, m_idxLastAccess, false, true);
if(index > 0)
{
previousObject = m_list[index - 1];
m_idxLastAccess = index - 1;
}
return previousObject;
}
public final int indexOf(Object object)
{
return indexOf(object, 0, true, false);
}
public final int indexOf(Object object, int startIndex)
{
return indexOf(object, startIndex, true, false);
}
public final int indexOf(Object object, int startIndex, boolean searchForward)
{
return indexOf(object, startIndex, searchForward, false);
}
public final int indexOf(Object object, int startIndex, boolean searchForward, boolean wrapAround)
{
if(startIndex < 0)
throw new IndexOutOfBoundsException("startIndex < 0 [" + startIndex + "<0]");
if(startIndex > 0 && startIndex >= m_size)
throw new IndexOutOfBoundsException("startIndex >= size() [" + startIndex + ">=" + m_size + "]");
if(object != null)
{
if(searchForward)
{
for(int i = startIndex; i < m_size; i++)
if(object.equals(m_list[i]))
return i;
} else
{
for(int i = startIndex; i >= 0; i--)
if(object.equals(m_list[i]))
return i;
}
if(wrapAround)
if(searchForward)
{
for(int i = 0; i < startIndex; i++)
if(object.equals(m_list[i]))
return i;
} else
{
for(int i = m_size - 1; i > startIndex; i--)
if(object.equals(m_list[i]))
return i;
}
}
return -1;
}
public final boolean isEmpty()
{
return m_size == 0;
}
public final Object last()
{
if(m_size == 0)
{
return null;
} else
{
m_idxLastAccess = m_size - 1;
return m_list[m_idxLastAccess];
}
}
public final int lastIndexOf(Object object)
{
if(m_size == 0)
return -1;
else
return indexOf(object, m_size - 1, false, false);
}
public final Object peek()
{
return last();
}
public final Object pop()
{
if(m_size == 0)
return null;
Object object = m_list[--m_size];
m_list[m_size] = null;
if(m_size > 0)
m_idxLastAccess = m_size - 1;
else
m_idxLastAccess = 0;
return object;
}
public final Object push(Object object)
{
add(object);
return object;
}
public final Object remove(int index)
{
if(index < 0)
throw new IndexOutOfBoundsException("index < 0 [" + index + "<0]");
if(index >= m_size)
throw new IndexOutOfBoundsException("index >= size() [" + index + ">=" + m_size + "]");
Object removedObject = m_list[index];
int numToMove = m_size - index - 1;
if(numToMove > 0)
System.arraycopy(((Object) (m_list)), index + 1, ((Object) (m_list)), index, numToMove);
m_list[--m_size] = null;
if(index < m_size)
m_idxLastAccess = index;
else
if(m_size > 0)
m_idxLastAccess = m_size - 1;
else
m_idxLastAccess = 0;
return removedObject;
}
public final boolean remove(Object object)
{
int index = indexOf(object, m_idxLastAccess, true, true);
if(index >= 0)
remove(index);
return index >= 0;
}
public final boolean removeAll(Object objects[])
{
boolean removed = false;
if(objects != null)
{
int i = 0;
int index = 0;
for(; i < objects.length; i++)
{
index = indexOf(objects[i], m_idxLastAccess, true, true);
if(index >= 0)
{
remove(index);
removed = true;
}
}
}
return removed;
}
public final Object set(int index, Object object)
{
if(index < 0)
throw new IndexOutOfBoundsException("index < 0 [" + index + "<0]");
if(index >= m_size)
throw new IndexOutOfBoundsException("index >= size() [" + index + ">=" + m_size + "]");
if(object == null)
{
throw new IllegalArgumentException("object == null");
} else
{
Object replacedObject = m_list[index];
m_list[index] = object;
m_idxLastAccess = index;
return replacedObject;
}
}
public final int size()
{
return m_size;
}
public final Object[] toArray()
{
Object array[] = new Object[m_size];
System.arraycopy(((Object) (m_list)), 0, ((Object) (array)), 0, m_size);
return array;
}
public final void trimToSize()
{
if(m_size == m_list.length)
{
return;
} else
{
Object oldList[] = m_list;
m_list = new Object[m_size];
System.arraycopy(((Object) (oldList)), 0, ((Object) (m_list)), 0, m_size);
return;
}
}
protected Object m_list[];
protected int m_size;
protected int m_capacityIncrement;
protected transient int m_idxLastAccess;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -