diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-01-27 14:00:22 +0100 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-01-27 14:00:22 +0100 |
commit | 5aec25ac0501352e4cb6645c86869dde6e91f0d0 (patch) | |
tree | ee9adfd55cddf25f098e5e028d585a72de7cd70c /libraries/spongycastle/core/src/main/jdk1.1/java/util | |
parent | 8ca42b9bf953c6195ee0c17ef48a3154c126cc04 (diff) | |
download | open-keychain-5aec25ac0501352e4cb6645c86869dde6e91f0d0.tar.gz open-keychain-5aec25ac0501352e4cb6645c86869dde6e91f0d0.tar.bz2 open-keychain-5aec25ac0501352e4cb6645c86869dde6e91f0d0.zip |
Add spongy castle sources to libraries folder
Diffstat (limited to 'libraries/spongycastle/core/src/main/jdk1.1/java/util')
16 files changed, 1922 insertions, 0 deletions
diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/util/AbstractCollection.java b/libraries/spongycastle/core/src/main/jdk1.1/java/util/AbstractCollection.java new file mode 100644 index 000000000..0ea61b772 --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/util/AbstractCollection.java @@ -0,0 +1,242 @@ +package java.util; + +import java.lang.reflect.Array; +/** + * Title: + * Description: + * Copyright: Copyright (c) 2001 + * Company: + * @version 1.0 + */ + + +public abstract class AbstractCollection implements Collection + { + protected AbstractCollection() + { + } + + public abstract Iterator iterator(); + + public abstract int size(); + + public boolean isEmpty() + { + return size()==0; + } + + public boolean contains(Object o) + { + Iterator it=iterator(); + while(it.hasNext()) + { + Object e=it.next(); + if(o==null) + { + if(e==null) + return true; + } + else + { + if(o.equals(e)) + return true; + } + } + return false; + } + + public Object[] toArray() + { + Object[] arObjects=new Object[size()]; + Iterator it=iterator(); + int i=0; + while(it.hasNext()) + { + arObjects[i++]=it.next(); + } + return arObjects; + } + + public Object[] toArray(Object[] a) throws NullPointerException,ArrayStoreException + //TODO: Check if this is realy compatible to SUN!!! + { + if(a==null) + throw new NullPointerException(); + + if (isEmpty()) return a; + Object[] arObjects=null; + int size=size(); + if(a.length<size) + { + Iterator it=iterator(); + Object o=it.next(); + if(o==null) //no object or object is null + throw new ArrayStoreException(); //correct ? + arObjects=(Object[])Array.newInstance(o.getClass(),size); + } + else + { + arObjects=a; + if(a.length>size) + arObjects[size]=null; + + } + + Iterator it=iterator(); + int i=0; + while(it.hasNext()) + { + Object o=it.next(); + arObjects[i++]=o; + } + return arObjects; + } + + public boolean add(Object o) throws UnsupportedOperationException,NullPointerException,ClassCastException,IllegalArgumentException + { + throw new UnsupportedOperationException(); + } + + public boolean remove(Object o) throws UnsupportedOperationException + { + Iterator it=iterator(); + while(it.hasNext()) + { + Object e=it.next(); + if(o==null) + { + if(e==null) + { + try + { + it.remove(); + } + catch(UnsupportedOperationException ue) + { + throw ue; + } + return true; + } + } + else + { + if(o.equals(e)) + { + try + { + it.remove(); + } + catch(UnsupportedOperationException ue) + { + throw ue; + } + return true; + } + } + } + return false; + } + + public boolean containsAll(Collection c) + { + Iterator it=c.iterator(); + while(it.hasNext()) + { + if(!contains(it.next())) + return false; + } + return true; + } + + public boolean addAll(Collection c) throws UnsupportedOperationException + { + Iterator it=c.iterator(); + boolean ret=false; + while(it.hasNext()) + { + try + { + ret|=add(it.next()); + } + catch(UnsupportedOperationException ue) + { + throw ue; + } + } + return ret; + } + + public boolean removeAll(Collection c) throws UnsupportedOperationException + { + Iterator it=iterator(); + boolean ret=false; + while(it.hasNext()) + { + if(c.contains(it.next())) + try + { + it.remove(); + ret=true; + } + catch(UnsupportedOperationException ue) + { + throw ue; + } + } + return ret; + } + + public boolean retainAll(Collection c) throws UnsupportedOperationException + { + Iterator it=iterator(); + boolean ret=false; + while(it.hasNext()) + { + if(!c.contains(it.next())) + try + { + it.remove(); + ret=true; + } + catch(UnsupportedOperationException ue) + { + throw ue; + } + } + return ret; + } + + public void clear() throws UnsupportedOperationException + { + Iterator it=iterator(); + while(it.hasNext()) + { + try + { + it.next(); + it.remove(); + } + catch(UnsupportedOperationException ue) + { + throw ue; + } + } + } + + public String toString() + { + String ret="["; + Iterator it=iterator(); + if(it.hasNext()) + ret+=String.valueOf(it.next()); + while(it.hasNext()) + { + ret+=", "; + ret+=String.valueOf(it.next()); + + } + ret+="]"; + return ret; + } + +} diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/util/AbstractList.java b/libraries/spongycastle/core/src/main/jdk1.1/java/util/AbstractList.java new file mode 100644 index 000000000..363b57aec --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/util/AbstractList.java @@ -0,0 +1,281 @@ +package java.util; + +/** + * Title: + * Description: + * Copyright: Copyright (c) 2001 + * Company: + * @version 1.0 + */ + +public abstract class AbstractList extends AbstractCollection implements List + +{ + protected AbstractList al = this; + + + protected AbstractList() + { + } + + public boolean add(Object o) throws UnsupportedOperationException, ClassCastException, IllegalArgumentException + { + try + { + add(size(),o); + return true; + } + catch(UnsupportedOperationException ue) + { + throw ue; + } + } + + public abstract Object get(int index) throws IndexOutOfBoundsException; + + public Object set(int index,Object element) throws UnsupportedOperationException, ClassCastException, IllegalArgumentException, IndexOutOfBoundsException + { + throw new UnsupportedOperationException(); + } + + public void add(int index,Object element) throws UnsupportedOperationException, ClassCastException, IllegalArgumentException, IndexOutOfBoundsException + { + throw new UnsupportedOperationException(); + } + + public Object remove(int index) throws UnsupportedOperationException, IndexOutOfBoundsException + { + Object o = get(index); + + removeRange(index,index+1); + return o; + } + + public int indexOf(Object o) + { + ListIterator li = listIterator(); + Object e; + while(li.hasNext()) + { + int index=li.nextIndex(); + e=li.next(); + System.out.println(e); + if(o==null) + { + if(e==null) + return index; + } + else + { + if(o.equals(e)) + return index; + } + } + return -1; + } + + public int lastIndexOf(Object o) + { + ListIterator li=listIterator(size()); + while(li.hasPrevious()) + { + int index=li.previousIndex(); + Object e=li.previous(); + if(o==null) + { + if(e==null) + return index; + } + else + { + if(o.equals(e)) + return index; + } + } + return -1; + } + + public void clear() throws UnsupportedOperationException + { + try + { + removeRange(0,size()); + } + catch(UnsupportedOperationException ue) + { + throw ue; + } + } + + public boolean addAll(int index,Collection c) throws UnsupportedOperationException, ClassCastException, IllegalArgumentException, IndexOutOfBoundsException + { + Iterator it=c.iterator(); + boolean ret=false; + while(it.hasNext()) + { + try + { + add(index++,it.next()); + ret=true; + } + catch(UnsupportedOperationException ue) + { + throw ue; + } + } + return ret; + } + + public Iterator iterator() + { + return new AbstractListIterator(this,0); + } + + public ListIterator listIterator() + { + return listIterator(0); + } + + public ListIterator listIterator(int index) throws IndexOutOfBoundsException + { + if(index<0||index>size()) throw new IndexOutOfBoundsException(); + return new AbstractListListIterator(this,index); + } + + public List subList(int fromIndex,int toIndex) throws IndexOutOfBoundsException,IllegalArgumentException + { + if(fromIndex < 0 || toIndex > size()) + throw new IndexOutOfBoundsException(); + if(fromIndex>toIndex) + throw new IllegalArgumentException(); + return (List) new Sublist(this,fromIndex,toIndex); + } + + public boolean equals(Object o) + { + if(o==this) + return true; + if(!(o instanceof List)) + return false; + Iterator it1=iterator(); + Iterator it2=((List)o).iterator(); + while(it1.hasNext()) + { + if(!it2.hasNext()) + return false; + Object e1=it1.next(); + Object e2=it2.next(); + if(e1==null) + { + if(e2!=null) + return false; + } + if(!e1.equals(e2)) + return false; + } + return true; + } + + public int hashCode() + { + int hashCode = 1; + Iterator it = iterator(); + while (it.hasNext()) + { + Object o = it.next(); + hashCode = 31*hashCode + (o==null ? 0 : o.hashCode()); + } + return hashCode; + } + + protected void removeRange(int fromIndex,int toIndex) + { + System.out.println("breakpoint 1"); + if(fromIndex==toIndex) return; + System.out.println("breakpoint 2"); + ListIterator li=listIterator(fromIndex); + System.out.println("breakpoint 3"); + int i=fromIndex; + do + { + li.next(); + li.remove(); + i++; + }while(li.hasNext()&&i<toIndex); + } + +//////////////////////////////////////////////////////////// +/////////////innere Klasse AbstractIterator///////////////// +//////////////////////////////////////////////////////////// + +private class AbstractListIterator implements Iterator + { + AbstractList m_al=null; + int m_nextIndex=0; + public AbstractListIterator(AbstractList al,int index) + { + m_al=al; + m_nextIndex=index; + } + + public boolean hasNext() + { + return m_nextIndex < m_al.size(); + } + + public Object next() + { + return m_al.get(m_nextIndex++); + } + + public void remove() + { + m_al.remove(m_nextIndex - 1); + } + } + +/////////////////////////////////////////////////////////////////////////////// +//////////// innere Klasse AbstraktListListIterator +/////////////////////////////////////////////////////////////////////////////// + + +private class AbstractListListIterator extends AbstractListIterator implements ListIterator + { + public AbstractListListIterator(AbstractList al,int index) + { + super(al,index); + } + + public boolean hasPrevious() + { + return m_nextIndex>0; + } + + public Object previous()// throws NoSuchElementException; + { + return m_al.get(--m_nextIndex); + } + + public int nextIndex() + { + return m_nextIndex; + } + + public int previousIndex() + { + return m_nextIndex-1; + } + + public void set(Object o) //throws UnsupportedOperationException, ClassCastException, IllegalArgumentException,IllegalStateException; + { + m_al.set(m_nextIndex-1,o); + } + + public void add(Object o)// throws UnsupportedOperationException, ClassCastException, IllegalArgumentException; + { + m_al.add(m_nextIndex-1,o); + } + } + + +} diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/util/AbstractMap.java b/libraries/spongycastle/core/src/main/jdk1.1/java/util/AbstractMap.java new file mode 100644 index 000000000..d5b2e02e1 --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/util/AbstractMap.java @@ -0,0 +1,164 @@ +package java.util; + +/************* + * Title: + * Description: + * Copyright: Copyright (c) 2001 + * Company: + * @version 1.0 + */ + +public abstract class AbstractMap implements Map{ + + protected AbstractMap() + { + } + + public int size() + { + return entrySet().size(); + } + + public boolean isEmpty() + { + return size()==0; + } + + public boolean containsValue(Object value) + { + Iterator it=entrySet().iterator(); + while(it.hasNext()) + { + Map.Entry v=(Map.Entry)it.next(); + if(value==null) + { + if(v.getValue()==null) + return true; + } + else + { + if(value.equals(v.getValue())) + return true; + } + } + return false; + } + + public boolean containsKey(Object key) throws ClassCastException,NullPointerException + { + Iterator it=entrySet().iterator(); + while(it.hasNext()) + { + Map.Entry v=(Map.Entry)it.next(); + if(key==null) + { + if(v.getKey()==null) + return true; + } + else + { + if(key.equals(v.getKey())) + return true; + } + } + return false; + } + + public Object get(Object key)throws ClassCastException,NullPointerException + { + Iterator it=entrySet().iterator(); + while(it.hasNext()) + { + Map.Entry v=(Map.Entry)it.next(); + if(key==null) + { + if(v.getKey()==null) + return v.getValue(); + } + else + { + if(key.equals(v.getKey())) + return v.getValue(); + } + } + return null; + } + + public Object put(Object key,Object value) throws UnsupportedOperationException + { + throw new UnsupportedOperationException(); + } + + public Object remove(Object key) + { + Iterator it=entrySet().iterator(); + Object o=null; + while(it.hasNext()) + { + Map.Entry v=(Map.Entry)it.next(); + if(key==null) + { + if(v.getKey()==null) + { + o=v.getValue(); + it.remove(); + return o; + } + } + else + { + if(key.equals(v.getKey())) + { + o=v.getValue(); + it.remove(); + return o; + } + } + } + return null; + } + + public void putAll(Map t) + { + Iterator it=t.entrySet().iterator(); + while(it.hasNext()) + { + Map.Entry v=(Map.Entry)it.next(); + put(v.getKey(),v.getValue()); + } + } + + public void clear() + { + entrySet().clear(); + } + + public Set keySet() + { + throw new UnsupportedOperationException("no keySet in AbstractMap()"); + } + + public Collection values() + { + throw new UnsupportedOperationException("no values in AbstractMap()"); + } + + public abstract Set entrySet(); + + public boolean equals(Object o) + { + throw new UnsupportedOperationException("no equals in AbstractMap()"); + } + + public int hashCode() + { + throw new UnsupportedOperationException("no hashCode in AbstractMap()"); + } + + public String toString() + { + throw new UnsupportedOperationException("no toString in AbstractMap()"); + } + + +} diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/util/AbstractSet.java b/libraries/spongycastle/core/src/main/jdk1.1/java/util/AbstractSet.java new file mode 100644 index 000000000..45bbb22f6 --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/util/AbstractSet.java @@ -0,0 +1,42 @@ +package java.util; + +/** + * Title: + * Description: + * Copyright: Copyright (c) 2001 + * Company: + * @version 1.0 + */ + +public abstract class AbstractSet extends AbstractCollection implements Set + { + protected AbstractSet() + { + } + + public boolean equals(Object o) + { + if(this==o) + return true; + if(o==null) + return false; + if(!(o instanceof Set)) + return false; + if(((Set)o).size()!=size()) + return false; + return containsAll((Collection)o); + } + + public int hashCode() + { + int hashCode=0; + Iterator it=iterator(); + while(it.hasNext()) + { + Object o=it.next(); + if(o!=null) + hashCode+=o.hashCode(); + } + return hashCode; + } + } diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/util/ArrayList.java b/libraries/spongycastle/core/src/main/jdk1.1/java/util/ArrayList.java new file mode 100644 index 000000000..7e3cbbc3d --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/util/ArrayList.java @@ -0,0 +1,107 @@ +package java.util; + +public class ArrayList extends AbstractList + implements List + { + Vector m_Vector=null; + + public ArrayList() + { + m_Vector=new Vector(); + } + + public ArrayList(Collection c) + { + m_Vector=new Vector((int)(c.size()*1.1)); + addAll(c); + } + + public ArrayList(int initialCapacity) + { + m_Vector=new Vector(initialCapacity); + } + + public void trimToSize() + { + m_Vector.trimToSize(); + } + + public void ensureCapacity(int minCapacity) + { + m_Vector.ensureCapacity(minCapacity); + } + + public int size() + { + return m_Vector.size(); + } + + public boolean contains(Object elem) + { + return m_Vector.contains(elem); + } + + public int indexOf(Object elem) + { + return m_Vector.indexOf(elem); + } + + public int lastIndexOf(Object elem) + { + return m_Vector.lastIndexOf(elem); + } + + public Object clone() + { + ArrayList al=new ArrayList(); + al.m_Vector=(Vector)m_Vector.clone(); + return al; + } + + public Object[] toArray() + { + Object[] o=new Object[m_Vector.size()]; + m_Vector.copyInto(o); + return o; + } + + public Object get(int index) + { + return m_Vector.elementAt(index); + } + + public Object set(int index,Object elem) + { + Object o=m_Vector.elementAt(index); + m_Vector.setElementAt(elem,index); + return o; + } + + public boolean add(Object o) + { + m_Vector.addElement(o); + return true; + } + + public void add(int index,Object elem) + { + m_Vector.insertElementAt(elem,index); + } + + public Object remove(int index) + { + Object o=m_Vector.elementAt(index); + m_Vector.removeElementAt(index); + return o; + } + + public void clear() + { + m_Vector.removeAllElements(); + } + + + + + + } diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/util/Arrays.java b/libraries/spongycastle/core/src/main/jdk1.1/java/util/Arrays.java new file mode 100644 index 000000000..0591e8d7f --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/util/Arrays.java @@ -0,0 +1,90 @@ +package java.util; + +public class Arrays +{ + + private Arrays() {} + + public static void fill(byte[] ret, byte v) + { + for (int i = 0; i != ret.length; i++) + { + ret[i] = v; + } + } + + public static boolean equals(byte[] a, byte[] a2) { + if (a==a2) + return true; + if (a==null || a2==null) + return false; + + int length = a.length; + if (a2.length != length) + return false; + + for (int i=0; i<length; i++) + if (a[i] != a2[i]) + return false; + + return true; + } + public static List asList(Object[] a) { + return new ArrayList(a); + } + + private static class ArrayList extends AbstractList implements java.io.Serializable + { + private Object[] a; + + ArrayList(Object[] array) + { + a = array; + } + + public int size() + { + return a.length; + } + + public Object[] toArray() + { + return (Object[]) a.clone(); + } + + public Object get(int index) + { + return a[index]; + } + + public Object set(int index, Object element) + { + Object oldValue = a[index]; + a[index] = element; + return oldValue; + } + + public int indexOf(Object o) + { + if (o==null) + { + for (int i=0; i<a.length; i++) + if (a[i]==null) + return i; + } + else + { + for (int i=0; i<a.length; i++) + if (o.equals(a[i])) + return i; + } + return -1; + } + + public boolean contains(Object o) + { + return indexOf(o) != -1; + } + } + +} diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/util/Collection.java b/libraries/spongycastle/core/src/main/jdk1.1/java/util/Collection.java new file mode 100644 index 000000000..650eeb850 --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/util/Collection.java @@ -0,0 +1,21 @@ + +package java.util; + +public interface Collection + { + public boolean add(Object o) throws UnsupportedOperationException,ClassCastException,IllegalArgumentException; + public boolean addAll(Collection c) throws UnsupportedOperationException,ClassCastException,IllegalArgumentException; + public void clear() throws UnsupportedOperationException; + public boolean contains(Object o); + public boolean containsAll(Collection c); + public boolean equals(Object o); + public int hashCode(); + public boolean isEmpty(); + public Iterator iterator(); + public /*SK13*/boolean remove(Object o) throws UnsupportedOperationException; + public boolean removeAll(Collection c) throws UnsupportedOperationException; + public boolean retainAll(Collection c) throws UnsupportedOperationException; + public int size(); + public Object[] toArray(); + public Object[] toArray(Object[] a) throws ArrayStoreException; + } diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/util/Collections.java b/libraries/spongycastle/core/src/main/jdk1.1/java/util/Collections.java new file mode 100644 index 000000000..1b7f2e930 --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/util/Collections.java @@ -0,0 +1,376 @@ +package java.util; + +import java.io.Serializable; + +public class Collections +{ + public static List EMPTY_LIST = new ArrayList(); + + private Collections() + { + } + + public static Collection unmodifiableCollection(Collection c) + { + return new UnmodifiableCollection(c); + } + + static class UnmodifiableCollection + implements Collection, Serializable + { + Collection c; + + UnmodifiableCollection(Collection c) + { + this.c = c; + } + + public int size() + { + return c.size(); + } + + public boolean isEmpty() + { + return c.isEmpty(); + } + + public boolean contains(Object o) + { + return c.contains(o); + } + + public Object[] toArray() + { + return c.toArray(); + } + + public Object[] toArray(Object[] a) + { + return c.toArray(a); + } + + public Iterator iterator() + { + return new Iterator() + { + Iterator i = c.iterator(); + + public boolean hasNext() + { + return i.hasNext(); + } + + public Object next() + { + return i.next(); + } + + public void remove() + { + throw new UnsupportedOperationException(); + } + }; + } + + public boolean add(Object o) + { + throw new UnsupportedOperationException(); + } + + public boolean remove(Object o) + { + throw new UnsupportedOperationException(); + } + + public boolean containsAll(Collection coll) + { + return c.containsAll(coll); + } + + public boolean addAll(Collection coll) + { + throw new UnsupportedOperationException(); + } + + public boolean removeAll(Collection coll) + { + throw new UnsupportedOperationException(); + } + + public boolean retainAll(Collection coll) + { + throw new UnsupportedOperationException(); + } + + public void clear() + { + throw new UnsupportedOperationException(); + } + + public String toString() + { + return c.toString(); + } + } + + public static Set unmodifiableSet(Set s) + { + return new UnmodifiableSet(s); + } + + static class UnmodifiableSet + extends UnmodifiableCollection + implements Set, Serializable + { + UnmodifiableSet(Set s) + { + super(s); + } + + public boolean equals(Object o) + { + return c.equals(o); + } + + public int hashCode() + { + return c.hashCode(); + } + } + + public static List unmodifiableList(List list) + { + return new UnmodifiableList(list); + } + + static class UnmodifiableList + extends UnmodifiableCollection + implements List + { + private List list; + + UnmodifiableList(List list) + { + super(list); + this.list = list; + } + + public boolean equals(Object o) + { + return list.equals(o); + } + + public int hashCode() + { + return list.hashCode(); + } + + public Object get(int index) + { + return list.get(index); + } + + public Object set(int index, Object element) + { + throw new UnsupportedOperationException(); + } + + public void add(int index, Object element) + { + throw new UnsupportedOperationException(); + } + + public Object remove(int index) + { + throw new UnsupportedOperationException(); + } + + public int indexOf(Object o) + { + return list.indexOf(o); + } + + public int lastIndexOf(Object o) + { + return list.lastIndexOf(o); + } + + public boolean addAll(int index, Collection c) + { + throw new UnsupportedOperationException(); + } + + public ListIterator listIterator() + { + return listIterator(0); + } + + public ListIterator listIterator(final int index) + { + return new ListIterator() + { + ListIterator i = list.listIterator(index); + + public boolean hasNext() + { + return i.hasNext(); + } + + public Object next() + { + return i.next(); + } + + public boolean hasPrevious() + { + return i.hasPrevious(); + } + + public Object previous() + { + return i.previous(); + } + + public int nextIndex() + { + return i.nextIndex(); + } + + public int previousIndex() + { + return i.previousIndex(); + } + + public void remove() + { + throw new UnsupportedOperationException(); + } + + public void set(Object o) + { + throw new UnsupportedOperationException(); + } + + public void add(Object o) + { + throw new UnsupportedOperationException(); + } + }; + } + + public List subList(int fromIndex, int toIndex) + { + return new UnmodifiableList(list.subList(fromIndex, toIndex)); + } + } + + public static Enumeration enumeration(final Collection c) + { + return new Enumeration() + { + Iterator i = c.iterator(); + + public boolean hasMoreElements() + { + return i.hasNext(); + } + + public Object nextElement() + { + return i.next(); + } + }; + } + + public static Map unmodifiableMap(Map s) + { + return new UnmodifiableMap(s); + } + + static class UnmodifiableMap + implements Map + { + private Map c; + + UnmodifiableMap(Map map) + { + this.c = map; + } + + public int size() + { + return c.size(); + } + + public boolean isEmpty() + { + return c.isEmpty(); + } + + public boolean containsKey(Object o) + { + return c.containsKey(o); + } + + public boolean containsValue(Object o) + { + return c.containsValue(o); + } + + public Object get(Object o) + { + return c.get(o); + } + + public Object put(Object o, Object o2) + { + throw new UnsupportedOperationException(); + } + + public Object remove(Object o) + { + throw new UnsupportedOperationException(); + } + + public void putAll(Map map) + { + throw new UnsupportedOperationException(); + } + + public void clear() + { + throw new UnsupportedOperationException(); + } + + public Set keySet() + { + return Collections.unmodifiableSet(c.keySet()); + } + + public Collection values() + { + return new UnmodifiableCollection(c.values()); + } + + public Set entrySet() + { + return Collections.unmodifiableSet(c.entrySet()); + } + + public boolean equals(Object o) + { + return c.equals(o); + } + + public int hashCode() + { + return c.hashCode(); + } + + public String toString() + { + return c.toString(); + } + } +} diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/util/HashMap.java b/libraries/spongycastle/core/src/main/jdk1.1/java/util/HashMap.java new file mode 100644 index 000000000..e9bdbda5d --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/util/HashMap.java @@ -0,0 +1,285 @@ +package java.util; + + +public class HashMap extends AbstractMap{ + + ////////////////////////////////////////////////////////////// + ///// innere Klasse Null //////////////////////////////////// + ////////////////////////////////////////////////////////////// +public class Null extends Object + { + public Null() + { + + } + + public String toString() + { + return "Nullobject"; + } + } + + + ////////////////////////////////////////////////////////////// + ///// innere Klasse innerSet //////////////////////////////////// + ////////////////////////////////////////////////////////////// + + class ISet extends AbstractSet implements java.util.Set + { + + Vector vec = null; + + public ISet() + { + + vec = new Vector(); + + } + + public boolean add(Object o) + { + vec.addElement(o); + return true; + } + + public int size() + { + return vec.size(); + } + + public Iterator iterator() + { + return new IIterator(vec); + } + } + + ////////////////////////////////////////////////////////////// + ///// innere Klasse Iterator //////////////////////////////////// + ////////////////////////////////////////////////////////////// + class IIterator implements java.util.Iterator + { + int index = 0; + Vector vec = null; + public IIterator(Vector ve) + { + vec = ve; + } + + public boolean hasNext() + { + if (vec.size() > index) return true; + return false; + } + + public Object next() + { + Object o = vec.elementAt(index); + if (o==Nullobject) o=null; + index++; + return o; + + } + + public void remove() + { + index--; + vec.removeElementAt(index); + } + + } + + ////////////////////////////////////////////////////////////// + ///// innere Klasse Entry //////////////////////////////////// + ////////////////////////////////////////////////////////////// + + + class Entry implements Map.Entry + { + public Object key=null; + public Object value=null; + + public Entry(Object ke,Object valu) + { + key = ke; + value = valu; + } + public boolean equals(Object o) + { + if (value == ((Entry)o).value && key == ((Entry)o).key ) return true; + else return false; + + } + + public Object getValue() + { + return value; + } + + public Object getKey() + { + return (Object)key; + } + + public int hashCode() + { + return value.hashCode() + key.hashCode(); + + } + + public Object setValue(Object valu) + { + value = (String)valu; + return this; + } + } + + //////////////////////////////////////////////////////////////////// + + private Hashtable m_HashTable=null; + private Null Nullobject = null; + + public HashMap() + { + Nullobject = new Null(); + m_HashTable=new Hashtable(); + } + + public HashMap(int initialCapacity) + { + Nullobject = new Null(); + m_HashTable=new Hashtable(initialCapacity); + } + + public HashMap(int initialCapacity, float loadFactor) + { + Nullobject = new Null(); + m_HashTable=new Hashtable(initialCapacity, loadFactor); + } + + public HashMap(Map t) + { + Nullobject = new Null(); + m_HashTable=new Hashtable(); + this.putAll(t); + } + + public void clear() + { + m_HashTable.clear(); + } + + public Object clone() + { + HashMap hm=new HashMap(); + hm.m_HashTable=(Hashtable)m_HashTable.clone(); + return hm; + } + + public boolean containsKey(Object key) + { + if (key == null) key = Nullobject; + boolean b = m_HashTable.containsKey(key); + return b; + + } + + public boolean containsValue(Object value) + { + if (value == null ) value = Nullobject; + boolean b = m_HashTable.contains(value); + return b; + } + + public Set entrySet() + { + + Object Key = null; + ISet s = new ISet(); + Enumeration enum = m_HashTable.keys(); + while (enum.hasMoreElements()) + { + Key = enum.nextElement(); + s.add(new Entry(Key,m_HashTable.get(Key))); + } + return s; + } + + public Object get(Object key) + { + + if (key==null) key= Nullobject; + + Object o = m_HashTable.get(key); + + if (o == Nullobject) o=null; + + return o; + } + + public boolean isEmpty() + { + return m_HashTable.isEmpty(); + } + + public Set keySet() + { + ISet s=new ISet(); + Enumeration enum = m_HashTable.keys(); + + while (enum.hasMoreElements()) + { + s.add(enum.nextElement()); + } + + return s; + } + + public Object put(Object key, Object value) + { + if (key==null) key=Nullobject; + if (value==null) value = Nullobject; + return m_HashTable.put(key,value); + } + + public void putAll(Map m) + { + Iterator it = m.entrySet().iterator(); + Object key=null; + Object value=null; + + while (it.hasNext()) + { + Map.Entry me = (Map.Entry)it.next(); + if (me.getKey() == null) key = Nullobject; + else key= me.getKey(); + if (me.getValue()==null) value = Nullobject; + else value = me.getValue(); + m_HashTable.put(key,value); + } + } + + public Object remove(Object key) + { + return m_HashTable.remove(key); + } + + public int size() + { + return m_HashTable.size(); + } + + public Collection values() + { + + ISet s=new ISet(); + Enumeration enum = m_HashTable.keys(); + + while (enum.hasMoreElements()) + { + Object Key = enum.nextElement(); + //s.add(((Map.Entry)m_HashTable.get(Key)).getValue()); + s.add(m_HashTable.get(Key)); + } + return s; + } +} diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/util/HashSet.java b/libraries/spongycastle/core/src/main/jdk1.1/java/util/HashSet.java new file mode 100644 index 000000000..5721cd20e --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/util/HashSet.java @@ -0,0 +1,83 @@ +package java.util; + +import java.io.*; +///*sk13*/import java.util.Hashtable; + +public class HashSet extends /*sk13*/AbstractSet + /*sk13*/ /*extends Hashmap*/ + +{ + private HashMap m_HashMap=null; + + public HashSet() + { + m_HashMap=new HashMap(); + + } + + public HashSet(Collection c) + { + m_HashMap=new HashMap(Math.max(11,c.size()*2)); + addAll(c); + + } + + public HashSet(int initialCapacity, float loadFactor) + { + m_HashMap=new HashMap(initialCapacity,loadFactor); + + } + + public HashSet(int initialCapacity) + { + m_HashMap=new HashMap(initialCapacity); + + } + + public Iterator iterator() + { + return (m_HashMap.keySet()).iterator(); + } + + public int size() + { + return m_HashMap.size(); + } + + public boolean contains(Object o) + { + return m_HashMap.containsKey(o); + } + + public boolean add(Object o) + { + if (!m_HashMap.containsValue(o)) + { + m_HashMap.put(o, o); + + return true; + + } + + return false; + } + + public boolean remove(Object o) + { + return (m_HashMap.remove(o)!=null); + } + + public void clear() + { + m_HashMap.clear(); + } + + + public Object clone() + { + HashSet hs=new HashSet(); + hs.m_HashMap=(HashMap)m_HashMap.clone(); + return hs; + } + +} diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/util/Iterator.java b/libraries/spongycastle/core/src/main/jdk1.1/java/util/Iterator.java new file mode 100644 index 000000000..9f977fe8c --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/util/Iterator.java @@ -0,0 +1,9 @@ + +package java.util; + +public interface Iterator +{ + public abstract boolean hasNext(); + public abstract Object next() throws NoSuchElementException; + public abstract void remove() throws UnsupportedOperationException,IllegalStateException; +} diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/util/List.java b/libraries/spongycastle/core/src/main/jdk1.1/java/util/List.java new file mode 100644 index 000000000..ee5896ea8 --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/util/List.java @@ -0,0 +1,15 @@ +package java.util; + +public interface List extends Collection + { + void add(int index, Object element)throws UnsupportedOperationException,ClassCastException,IllegalArgumentException,IndexOutOfBoundsException; + boolean addAll(int index, Collection c) throws UnsupportedOperationException,ClassCastException,IllegalArgumentException,IndexOutOfBoundsException; + Object get(int index) throws IndexOutOfBoundsException; + int indexOf(Object o); + int lastIndexOf(Object o); + ListIterator listIterator(); + ListIterator listIterator(int index)throws IndexOutOfBoundsException; + Object remove(int index)throws UnsupportedOperationException,IndexOutOfBoundsException; + Object set(int index, Object element) throws UnsupportedOperationException,ClassCastException,IllegalArgumentException,IndexOutOfBoundsException; + List subList(int fromIndex, int toIndex) throws IndexOutOfBoundsException; + } diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/util/ListIterator.java b/libraries/spongycastle/core/src/main/jdk1.1/java/util/ListIterator.java new file mode 100644 index 000000000..15e17896e --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/util/ListIterator.java @@ -0,0 +1,19 @@ +package java.util; + +/** + * Title: + * Description: + * Copyright: Copyright (c) 2001 + * Company: + * @version 1.0 + */ + +public interface ListIterator extends Iterator + { + public boolean hasPrevious(); + public Object previous() throws NoSuchElementException; + public int nextIndex(); + public int previousIndex(); + public void set(Object o) throws UnsupportedOperationException, ClassCastException, IllegalArgumentException,IllegalStateException; + public void add(Object o) throws UnsupportedOperationException, ClassCastException, IllegalArgumentException; + } diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/util/Map.java b/libraries/spongycastle/core/src/main/jdk1.1/java/util/Map.java new file mode 100644 index 000000000..e0040a383 --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/util/Map.java @@ -0,0 +1,37 @@ +package java.util; + +/** + * Title: + * Description: + * Copyright: Copyright (c) 2001 + * Company: + * @version 1.0 + */ + +public interface Map { + + public static interface Entry + { + public Object getKey(); + public Object getValue(); + public Object setValue(Object value) throws UnsupportedOperationException, ClassCastException,IllegalArgumentException,NullPointerException; + public boolean equals(Object o); + public int hashCode(); + }; + + public int size(); + public boolean isEmpty(); + public boolean containsKey(Object Key) throws ClassCastException,NullPointerException; + public boolean containsValue(Object value); + public Object get(Object key)throws ClassCastException,NullPointerException; + public Object put(Object key,Object value)throws UnsupportedOperationException, ClassCastException,IllegalArgumentException,NullPointerException; + public Object remove(Object key)throws UnsupportedOperationException; + public void putAll(Map t)throws UnsupportedOperationException, ClassCastException,IllegalArgumentException,NullPointerException; + public void clear()throws UnsupportedOperationException; + public Set keySet(); + public Collection values(); + public Set entrySet(); + public boolean equals(Object o); + public int hashCode(); + + } diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/util/Set.java b/libraries/spongycastle/core/src/main/jdk1.1/java/util/Set.java new file mode 100644 index 000000000..e312d6b83 --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/util/Set.java @@ -0,0 +1,26 @@ + +package java.util; + +public interface Set extends Collection + { + + public int size(); + public boolean isEmpty(); + public boolean contains(Object o); + public Iterator iterator(); + public Object[] toArray(); + public Object[] toArray(Object[] a); + public boolean add(Object o); + public boolean remove(Object o); + public boolean containsAll(Collection c); + public boolean addAll(Collection c); + public boolean retainAll(Collection c); + public boolean removeAll(Collection c); + public void clear(); + public boolean equals(Object o); + public int hashCode(); + + + + + } diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/util/Sublist.java b/libraries/spongycastle/core/src/main/jdk1.1/java/util/Sublist.java new file mode 100644 index 000000000..3f1a4a1bd --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/util/Sublist.java @@ -0,0 +1,125 @@ +package java.util; + +/** + * Title: + * Description: + * Copyright: Copyright (c) 2001 + * Company: + * @version 1.0 + */ + +public class Sublist extends AbstractList + + { + AbstractList m_al=null; + int m_fromIndex=0; + int m_toIndex=0; + int size=0; + + public Sublist(AbstractList ali,int fromIndex,int toIndex) + { + m_al=ali; + m_toIndex=toIndex; + m_fromIndex=fromIndex; + size = size(); + } + public Object set(int index,Object o) + { + if (index < size) + { + o = m_al.set(index+m_fromIndex,o); + if (o != null) + { + size++; + m_toIndex++; + } + return o; + } + else throw new IndexOutOfBoundsException(); + } + + public Object get(int index) throws IndexOutOfBoundsException + { + if (index < size) return m_al.get(index+m_fromIndex); + else throw new IndexOutOfBoundsException(); + } + + public void add (int index,Object o) + { + + if (index <= size) + { + m_al.add(index + m_fromIndex,o); + m_toIndex++; + size++; + + } + else throw new IndexOutOfBoundsException(); + + } + + public Object remove(int index,Object o) + { + if (index < size) + { + Object ob = m_al.remove(index + m_fromIndex); + if (ob !=null) + { + m_toIndex--; + size--; + } + return ob; + } + else throw new IndexOutOfBoundsException(); + } + + public boolean addAll(int index, Collection c) + { + if (index < size) + { + boolean bool = m_al.addAll(index + m_fromIndex,c); + if (bool) + { + int lange = c.size(); + m_toIndex = m_toIndex + lange; + size = size + lange; + } + return bool; + } + else throw new IndexOutOfBoundsException(); + } + + public boolean addAll(Collection c) + { + boolean bool = m_al.addAll(m_toIndex,c); + if (bool) + { + int lange = c.size(); + m_toIndex = m_toIndex + lange; + size = size + lange; + } + return bool; + } + + public void removeRange (int from,int to) + { + if ((from <= to) && (from <= size) && (to <= size)) + { + m_al.removeRange(from,to); + int lange = to - from; + m_toIndex = m_toIndex - lange; + size = size - lange; + } + else + { + if (from > to) throw new IllegalArgumentException(); + else throw new IndexOutOfBoundsException(); + } + } + + public int size() + { + return (m_toIndex - m_fromIndex); + } + +} |