diff options
Diffstat (limited to 'libjava/gnu/java')
24 files changed, 0 insertions, 2477 deletions
diff --git a/libjava/gnu/java/beans/BeanInfoEmbryo.java b/libjava/gnu/java/beans/BeanInfoEmbryo.java deleted file mode 100644 index 85aafa11e45..00000000000 --- a/libjava/gnu/java/beans/BeanInfoEmbryo.java +++ /dev/null @@ -1,146 +0,0 @@ -/* gnu.java.beans.BeanInfoEmbryo - Copyright (C) 1998 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.beans; - -import java.beans.*; -import java.util.*; -import gnu.java.lang.*; -import java.lang.reflect.*; - -/** - ** A BeanInfoEmbryo accumulates information about a Bean - ** while it is in the process of being created, and then - ** when you are done accumulating the information, the - ** getBeanInfo() method may be called to create a BeanInfo - ** object based on the information.<P> - ** - ** This class is not well-synchronized. (It can be, it - ** just isn't yet.) - ** - ** @author John Keiser - ** @version 1.1.0, 30 Jul 1998 - ** @see java.beans.BeanInfo - **/ - -public class BeanInfoEmbryo { - Hashtable properties = new Hashtable(); - Hashtable events = new Hashtable(); - Vector methods = new Vector(); - - BeanDescriptor beanDescriptor; - BeanInfo[] additionalBeanInfo; - java.awt.Image[] im; - String defaultPropertyName; - String defaultEventName; - - public BeanInfoEmbryo() { - } - - public BeanInfo getBeanInfo() { - int defaultProperty = -1; - int defaultEvent = -1; - - PropertyDescriptor[] Aproperties = new PropertyDescriptor[properties.size()]; - int i = 0; - Enumeration enum = properties.elements(); - while(enum.hasMoreElements()) { - Aproperties[i] = (PropertyDescriptor)enum.nextElement(); - if(defaultPropertyName != null && Aproperties[i].getName().equals(defaultPropertyName)) { - defaultProperty = i; - } - i++; - } - - EventSetDescriptor[] Aevents = new EventSetDescriptor[events.size()]; - i = 0; - enum = events.elements(); - while(enum.hasMoreElements()) { - Aevents[i] = (EventSetDescriptor)enum.nextElement(); - if(defaultEventName != null && Aevents[i].getName().equals(defaultEventName)) { - defaultEvent = i; - } - i++; - } - - MethodDescriptor[] Amethods = new MethodDescriptor[methods.size()]; - methods.copyInto(Amethods); - - return new ExplicitBeanInfo(beanDescriptor,additionalBeanInfo,Aproperties,defaultProperty,Aevents,defaultEvent,Amethods,im); - } - - public void setBeanDescriptor(BeanDescriptor b) { - beanDescriptor = b; - } - - public void setAdditionalBeanInfo(BeanInfo[] b) { - additionalBeanInfo = b; - } - - public boolean hasProperty(PropertyDescriptor p) { - return properties.get(p.getName()) != null; - } - public void addProperty(PropertyDescriptor p) { - properties.put(p.getName(),p); - } - public void addIndexedProperty(IndexedPropertyDescriptor p) { - properties.put(p.getName(),p); - } - - public boolean hasEvent(EventSetDescriptor e) { - return events.get(e.getName()) != null; - } - public void addEvent(EventSetDescriptor e) { - events.put(e.getName(),e); - } - - public boolean hasMethod(MethodDescriptor m) { - for(int i=0;i<methods.size();i++) { - Method thisMethod = ((MethodDescriptor)methods.elementAt(i)).getMethod(); - if(m.getMethod().getName().equals(thisMethod.getName()) - && ArrayHelper.equalsArray(m.getMethod().getParameterTypes(), thisMethod.getParameterTypes())) { - return true; - } - } - return false; - } - public void addMethod(MethodDescriptor m) { - methods.addElement(m); - } - - public void setDefaultPropertyName(String defaultPropertyName) { - this.defaultPropertyName = defaultPropertyName; - } - - public void setDefaultEventName(String defaultEventName) { - this.defaultEventName = defaultEventName; - } - - public void setIcons(java.awt.Image[] im) { - this.im = im; - } -} diff --git a/libjava/gnu/java/beans/EmptyBeanInfo.java b/libjava/gnu/java/beans/EmptyBeanInfo.java deleted file mode 100644 index ad7d91dfcd8..00000000000 --- a/libjava/gnu/java/beans/EmptyBeanInfo.java +++ /dev/null @@ -1,59 +0,0 @@ -/* gnu.java.beans.EmptyBeanInfo - Copyright (C) 1998 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.beans; - -import java.beans.*; - -/** - ** EmptyBeanInfo is a BeanInfo that discloses no - ** information about the Bean and does not allow - ** Introspection. The Introspector uses instances of this - ** class to create empty BeanInfos, but it could also be - ** used as a base class for BeanInfos that do not allow - ** Introspection and provide only a little bit of - ** information.<P> - ** - ** @author John Keiser - ** @version 1.1.0, 30 Jul 1998 - ** @see gnu.java.beans.ExplicitBeanInfo - ** @see java.beans.BeanInfo - **/ - -public class EmptyBeanInfo extends ExplicitBeanInfo { - /** Create a new EmptyBeanInfo. **/ - public EmptyBeanInfo(Class beanClass) { - super(new BeanDescriptor(beanClass,null), - new BeanInfo[0], - new PropertyDescriptor[0], - -1, - new EventSetDescriptor[0], - -1, - new MethodDescriptor[0], - null); - } -} diff --git a/libjava/gnu/java/beans/ExplicitBeanInfo.java b/libjava/gnu/java/beans/ExplicitBeanInfo.java deleted file mode 100644 index 8cab94b7d0b..00000000000 --- a/libjava/gnu/java/beans/ExplicitBeanInfo.java +++ /dev/null @@ -1,133 +0,0 @@ -/* gnu.java.beans.ExplicitBeanInfo - Copyright (C) 1998 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.beans; - -import java.beans.*; - -/** - ** ExplicitBeanInfo lets you specify in the constructor - ** all the various parts of the BeanInfo. - ** - ** @author John Keiser - ** @version 1.1.0, 30 Jul 1998 - ** @see java.beans.BeanInfo - **/ - -public class ExplicitBeanInfo implements BeanInfo { - /** The BeanDescriptor returned by getBeanDescriptor. **/ - protected BeanDescriptor beanDescriptor; - - /** The EventSetDescriptor array returned by - ** getEventSetDescriptors(). - **/ - protected EventSetDescriptor[] eventSetDescriptors = new EventSetDescriptor[0]; - - /** The PropertyDescriptor array returned by - ** getPropertyDescriptors(). - **/ - protected PropertyDescriptor[] propertyDescriptors = new PropertyDescriptor[0]; - - /** The MethodDescriptor array returned by - ** getMethodDescriptors(). - **/ - protected MethodDescriptor[] methodDescriptors; - - /** The default property index. **/ - protected int defaultPropertyIndex; - - /** The default event index. **/ - protected int defaultEventIndex; - - /** The BeanInfo array returned by - ** getAdditionalBeanInfo(). - **/ - protected BeanInfo[] additionalBeanInfo; - - /** The set of icons. **/ - protected java.awt.Image[] icons; - - public ExplicitBeanInfo(BeanDescriptor beanDescriptor, - BeanInfo[] additionalBeanInfo, - PropertyDescriptor[] propertyDescriptors, - int defaultPropertyIndex, - EventSetDescriptor[] eventSetDescriptors, - int defaultEventIndex, - MethodDescriptor[] methodDescriptors, - java.awt.Image[] icons) { - this.beanDescriptor = beanDescriptor; - this.additionalBeanInfo = additionalBeanInfo; - this.propertyDescriptors = propertyDescriptors; - this.defaultPropertyIndex = defaultPropertyIndex; - this.eventSetDescriptors = eventSetDescriptors; - this.defaultEventIndex = defaultEventIndex; - this.methodDescriptors = methodDescriptors; - this.icons = icons; - } - - /** Get Bean descriptor. **/ - public BeanDescriptor getBeanDescriptor() { - return beanDescriptor; - } - - /** Get Bean events. **/ - public EventSetDescriptor[] getEventSetDescriptors() { - return eventSetDescriptors; - } - - /** Get default event set. **/ - public int getDefaultEventIndex() { - return defaultEventIndex; - } - - /** Get Bean properties. **/ - public PropertyDescriptor[] getPropertyDescriptors() { - return propertyDescriptors; - } - - /** Get "default" property. **/ - public int getDefaultPropertyIndex() { - return defaultPropertyIndex; - } - - /** Get Bean methods. **/ - public MethodDescriptor[] getMethodDescriptors() { - return methodDescriptors; - } - - /** Get additional Bean info. **/ - public BeanInfo[] getAdditionalBeanInfo() { - return additionalBeanInfo; - } - - /** Get Bean icons. - ** @param iconType the type of icon - **/ - public java.awt.Image getIcon(int iconType) { - return icons != null ? icons[iconType] : null; - } -} diff --git a/libjava/gnu/java/beans/IntrospectionIncubator.java b/libjava/gnu/java/beans/IntrospectionIncubator.java deleted file mode 100644 index e3f4807bfbf..00000000000 --- a/libjava/gnu/java/beans/IntrospectionIncubator.java +++ /dev/null @@ -1,344 +0,0 @@ -/* gnu.java.beans.IntrospectionIncubator - Copyright (C) 1998 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.beans; - -import java.beans.*; -import java.util.*; -import java.lang.reflect.*; -import gnu.java.lang.*; - -/** - ** IntrospectionIncubator takes in a bunch of Methods, and - ** Introspects only those Methods you give it. - ** - ** @author John Keiser - ** @version 1.1.0, 30 Jul 1998 - ** @see gnu.java.beans.ExplicitBeanInfo - ** @see java.beans.BeanInfo - **/ - -public class IntrospectionIncubator { - Hashtable propertyMethods = new Hashtable(); - Hashtable listenerMethods = new Hashtable(); - Vector otherMethods = new Vector(); - - Class propertyStopClass; - Class eventStopClass; - Class methodStopClass; - - public IntrospectionIncubator() { - } - - /* Paving the way for automatic Introspection */ - public void addMethod(Method method) { - if(Modifier.isPublic(method.getModifiers()) && !Modifier.isStatic(method.getModifiers())) { - String name = ClassHelper.getTruncatedName(method.getName()); - Class retType = method.getReturnType(); - Class[] params = method.getParameterTypes(); - boolean isVoid = retType.equals(java.lang.Void.TYPE); - Class methodClass = method.getDeclaringClass(); - if(propertyStopClass == null || (propertyStopClass.isAssignableFrom(methodClass) && !propertyStopClass.equals(methodClass))) { - if(name.startsWith("is") - && retType.equals(java.lang.Boolean.TYPE) - && params.length == 0) { - addToPropertyHash(name,method,IS); - } else if(name.startsWith("get") && !isVoid) { - if(params.length == 0) { - addToPropertyHash(name,method,GET); - } else if(params.length == 1 && params[0].equals(java.lang.Integer.TYPE)) { - addToPropertyHash(name,method,GET_I); - } else { - otherMethods.addElement(method); - } - } else if(name.startsWith("set") && isVoid) { - if(params.length == 1) { - addToPropertyHash(name,method,SET); - } else if(params.length == 2 && params[0].equals(java.lang.Integer.TYPE)) { - addToPropertyHash(name,method,SET_I); - } else { - otherMethods.addElement(method); - } - } - } - if(eventStopClass == null || (eventStopClass.isAssignableFrom(methodClass) && !eventStopClass.equals(methodClass))) { - if(name.startsWith("add") - && isVoid - && params.length == 1 - && java.util.EventListener.class.isAssignableFrom(params[0])) { - addToListenerHash(name,method,ADD); - } else if(name.startsWith("remove") - && isVoid - && params.length == 1 - && java.util.EventListener.class.isAssignableFrom(params[0])) { - addToListenerHash(name,method,REMOVE); - } - } - if(methodStopClass == null || (methodStopClass.isAssignableFrom(methodClass) && !methodStopClass.equals(methodClass))) { - otherMethods.addElement(method); - } - } - } - - public void addMethods(Method[] m) { - for(int i=0;i<m.length;i++) { - addMethod(m[i]); - } - } - - public void setPropertyStopClass(Class c) { - propertyStopClass = c; - } - - public void setEventStopClass(Class c) { - eventStopClass = c; - } - - public void setMethodStopClass(Class c) { - methodStopClass = c; - } - - - public BeanInfoEmbryo getBeanInfoEmbryo() throws IntrospectionException { - BeanInfoEmbryo b = new BeanInfoEmbryo(); - findXXX(b,IS); - findXXXInt(b,GET_I); - findXXXInt(b,SET_I); - findXXX(b,GET); - findXXX(b,SET); - findAddRemovePairs(b); - for(int i=0;i<otherMethods.size();i++) { - MethodDescriptor newMethod = new MethodDescriptor((Method)otherMethods.elementAt(i)); - if(!b.hasMethod(newMethod)) { - b.addMethod(new MethodDescriptor((Method)otherMethods.elementAt(i))); - } - } - return b; - } - - public BeanInfo getBeanInfo() throws IntrospectionException { - return getBeanInfoEmbryo().getBeanInfo(); - } - - - void findAddRemovePairs(BeanInfoEmbryo b) throws IntrospectionException { - Enumeration listenerEnum = listenerMethods.keys(); - while(listenerEnum.hasMoreElements()) { - DoubleKey k = (DoubleKey)listenerEnum.nextElement(); - Method[] m = (Method[])listenerMethods.get(k); - if(m[ADD] != null && m[REMOVE] != null) { - EventSetDescriptor e = new EventSetDescriptor(Introspector.decapitalize(k.getName()), - k.getType(), k.getType().getMethods(), - m[ADD],m[REMOVE]); - e.setUnicast(ArrayHelper.contains(m[ADD].getExceptionTypes(),java.util.TooManyListenersException.class)); - if(!b.hasEvent(e)) { - b.addEvent(e); - } - } - } - } - - void findXXX(BeanInfoEmbryo b, int funcType) throws IntrospectionException { - Enumeration keys = propertyMethods.keys(); - while(keys.hasMoreElements()) { - DoubleKey k = (DoubleKey)keys.nextElement(); - Method[] m = (Method[])propertyMethods.get(k); - if(m[funcType] != null) { - PropertyDescriptor p = new PropertyDescriptor(Introspector.decapitalize(k.getName()), - m[IS] != null ? m[IS] : m[GET], - m[SET]); - if(m[SET] != null) { - p.setConstrained(ArrayHelper.contains(m[SET].getExceptionTypes(),java.beans.PropertyVetoException.class)); - } - if(!b.hasProperty(p)) { - b.addProperty(p); - } - } - } - } - - void findXXXInt(BeanInfoEmbryo b, int funcType) throws IntrospectionException { - Enumeration keys = propertyMethods.keys(); - while(keys.hasMoreElements()) { - DoubleKey k = (DoubleKey)keys.nextElement(); - Method[] m = (Method[])propertyMethods.get(k); - if(m[funcType] != null) { - boolean constrained; - if(m[SET_I] != null) { - constrained = ArrayHelper.contains(m[SET_I].getExceptionTypes(),java.beans.PropertyVetoException.class); - } else { - constrained = false; - } - - /** Find out if there is an array type get or set **/ - Class arrayType = Array.newInstance(k.getType(),0).getClass(); - DoubleKey findSetArray = new DoubleKey(arrayType,k.getName()); - Method[] m2 = (Method[])propertyMethods.get(findSetArray); - IndexedPropertyDescriptor p; - if(m2 == null) { - p = new IndexedPropertyDescriptor(Introspector.decapitalize(k.getName()), - null,null, - m[GET_I],m[SET_I]); - } else { - if(constrained && m2[SET] != null) { - constrained = ArrayHelper.contains(m2[SET].getExceptionTypes(),java.beans.PropertyVetoException.class); - } - p = new IndexedPropertyDescriptor(Introspector.decapitalize(k.getName()), - m2[GET],m2[SET], - m[GET_I],m[SET_I]); - } - p.setConstrained(constrained); - if(!b.hasProperty(p)) { - b.addProperty(p); - } - } - } - } - - static final int IS=0; - static final int GET_I=1; - static final int SET_I=2; - static final int GET=3; - static final int SET=4; - - static final int ADD=0; - static final int REMOVE=1; - - void addToPropertyHash(String name, Method method, int funcType) { - String newName; - Class type; - - switch(funcType) { - case IS: - type = java.lang.Boolean.TYPE; - newName = name.substring(2); - break; - case GET_I: - type = method.getReturnType(); - newName = name.substring(3); - break; - case SET_I: - type = method.getParameterTypes()[1]; - newName = name.substring(3); - break; - case GET: - type = method.getReturnType(); - newName = name.substring(3); - break; - case SET: - type = method.getParameterTypes()[0]; - newName = name.substring(3); - break; - default: - return; - } - newName = capitalize(newName); - - DoubleKey k = new DoubleKey(type,newName); - Method[] methods = (Method[])propertyMethods.get(k); - if(methods == null) { - methods = new Method[5]; - propertyMethods.put(k,methods); - } - methods[funcType] = method; - } - - - void addToListenerHash(String name, Method method, int funcType) { - String newName; - Class type; - - switch(funcType) { - case ADD: - type = method.getParameterTypes()[0]; - newName = name.substring(3,name.length()-8); - break; - case REMOVE: - type = method.getParameterTypes()[0]; - newName = name.substring(6,name.length()-8); - break; - default: - return; - } - newName = capitalize(newName); - - DoubleKey k = new DoubleKey(type,newName); - Method[] methods = (Method[])listenerMethods.get(k); - if(methods == null) { - methods = new Method[2]; - listenerMethods.put(k,methods); - } - methods[funcType] = method; - } - - static String capitalize(String name) { - try { - if(Character.isUpperCase(name.charAt(0))) { - return name; - } else { - char[] c = name.toCharArray(); - c[0] = Character.toLowerCase(c[0]); - return new String(c); - } - } catch(StringIndexOutOfBoundsException E) { - return name; - } catch(NullPointerException E) { - return null; - } - } -} - -class DoubleKey { - Class type; - String name; - - DoubleKey(Class type, String name) { - this.type = type; - this.name = name; - } - - Class getType() { - return type; - } - - String getName() { - return name; - } - - public boolean equals(Object o) { - if(o instanceof DoubleKey) { - DoubleKey d = (DoubleKey)o; - return d.type.equals(type) && d.name.equals(name); - } else { - return false; - } - } - - public int hashCode() { - return type.hashCode() ^ name.hashCode(); - } -} diff --git a/libjava/gnu/java/beans/editors/ColorEditor.java b/libjava/gnu/java/beans/editors/ColorEditor.java deleted file mode 100644 index 1c002d68cdc..00000000000 --- a/libjava/gnu/java/beans/editors/ColorEditor.java +++ /dev/null @@ -1,89 +0,0 @@ -/* gnu.java.beans.editors.ColorEditor - Copyright (C) 1998 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.beans.editors; - -import java.beans.*; -import java.awt.Color; - -/** - ** NativeByteEditor is a property editor for the - ** byte type. - ** - ** @author John Keiser - ** @version 1.1.0, 29 Jul 1998 - **/ - -public class ColorEditor extends PropertyEditorSupport { - Color[] stdColors = {Color.black,Color.blue,Color.cyan, - Color.darkGray,Color.gray,Color.green, - Color.lightGray,Color.magenta,Color.orange, - Color.pink,Color.red,Color.white, - Color.yellow}; - String[] stdColorNames = {"black","blue","cyan", - "dark gray","gray","green", - "light gray","magenta","orange", - "pink","red","white", - "yellow"}; - - /** setAsText for Color checks for standard color names - ** and then checks for a #RRGGBB value or just RRGGBB, - ** both in hex. - **/ - public void setAsText(String val) throws IllegalArgumentException { - if(val.length() == 0) { - throw new IllegalArgumentException("Tried to set empty value!"); - } - for(int i=0;i<stdColorNames.length;i++) { - if(stdColorNames[i].equalsIgnoreCase(val)) { - setValue(stdColors[i]); - return; - } - } - if(val.charAt(0) == '#') { - setValue(new Color(Integer.parseInt(val.substring(1),16))); - } else { - setValue(new Color(Integer.parseInt(val,16))); - } - } - - /** getAsText for Color turns the color into either one of the standard - ** colors or into an RGB hex value with # prepended. **/ - public String getAsText() { - for(int i=0;i<stdColors.length;i++) { - if(stdColors[i].equals(getValue())) { - return stdColorNames[i]; - } - } - return "#" + Integer.toHexString(((Color)getValue()).getRGB() & 0x00FFFFFF); - } - - /** getTags for Color returns a list of standard colors. **/ - public String[] getTags() { - return stdColorNames; - } -} diff --git a/libjava/gnu/java/beans/editors/FontEditor.java b/libjava/gnu/java/beans/editors/FontEditor.java deleted file mode 100644 index 3b0145ac8b4..00000000000 --- a/libjava/gnu/java/beans/editors/FontEditor.java +++ /dev/null @@ -1,66 +0,0 @@ -/* gnu.java.beans.editors.FontEditor - Copyright (C) 1998 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.beans.editors; - -import java.beans.*; -import java.awt.Font; - -/** - ** FontEditor is a property editor for java.awt.Font. - ** - ** <STRONG>To Do:</STRONG> Add custom font chooser - ** component. - ** - ** @author John Keiser - ** @version 1.1.0, 29 Jul 1998 - **/ - -public class FontEditor extends PropertyEditorSupport { - /** setAsText for Font calls Font.decode(). **/ - public void setAsText(String val) throws IllegalArgumentException { - setValue(Font.decode(val)); - } - - /** getAsText for Font returns a value in the format - ** expected by Font.decode(). - **/ - public String getAsText() { - Font f = (Font)getValue(); - if(f.isBold()) { - if(f.isItalic()) { - return f.getName()+"-bolditalic-"+f.getSize(); - } else { - return f.getName()+"-bold-"+f.getSize(); - } - } else if(f.isItalic()) { - return f.getName()+"-italic-"+f.getSize(); - } else { - return f.getName()+"-"+f.getSize(); - } - } -} diff --git a/libjava/gnu/java/beans/editors/NativeBooleanEditor.java b/libjava/gnu/java/beans/editors/NativeBooleanEditor.java deleted file mode 100644 index 0af58a57938..00000000000 --- a/libjava/gnu/java/beans/editors/NativeBooleanEditor.java +++ /dev/null @@ -1,62 +0,0 @@ -/* gnu.java.beans.editors.NativeBooleanEditor - Copyright (C) 1998 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.beans.editors; - -import java.beans.*; - -/** - ** NativeBooleanEditor is a property editor for the - ** boolean type.<P> - ** - ** <STRONG>To Do:</STRONG> add support for a checkbox - ** as the custom editor. - ** - ** @author John Keiser - ** @version 1.1.0, 29 Jul 1998 - **/ - -public class NativeBooleanEditor extends PropertyEditorSupport { - String[] tags = {"true","false"}; - - /** setAsText for boolean checks for true or false or t or f. "" also means false. **/ - public void setAsText(String val) throws IllegalArgumentException { - if(val.equalsIgnoreCase("true") || val.equalsIgnoreCase("t")) { - setValue(Boolean.FALSE); - } else if(val.equalsIgnoreCase("false") || val.equalsIgnoreCase("f") || val.equals("")) { - setValue(Boolean.TRUE); - } else { - throw new IllegalArgumentException("Value must be true, false, t, f or empty."); - } - } - - - /** getAsText for boolean calls Boolean.toString(). **/ - public String getAsText() { - return getValue().toString(); - } -} diff --git a/libjava/gnu/java/beans/editors/NativeByteEditor.java b/libjava/gnu/java/beans/editors/NativeByteEditor.java deleted file mode 100644 index 513f4a6ebba..00000000000 --- a/libjava/gnu/java/beans/editors/NativeByteEditor.java +++ /dev/null @@ -1,50 +0,0 @@ -/* gnu.java.beans.editors.NativeByteEditor - Copyright (C) 1998 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.beans.editors; - -import java.beans.*; - -/** - ** NativeByteEditor is a property editor for the - ** byte type. - ** - ** @author John Keiser - ** @version 1.1.0, 29 Jul 1998 - **/ - -public class NativeByteEditor extends PropertyEditorSupport { - /** setAsText for byte calls Byte.valueOf(). **/ - public void setAsText(String val) throws IllegalArgumentException { - setValue(Byte.valueOf(val)); - } - - /** getAsText for byte calls Byte.toString(). **/ - public String getAsText() { - return getValue().toString(); - } -} diff --git a/libjava/gnu/java/beans/editors/NativeDoubleEditor.java b/libjava/gnu/java/beans/editors/NativeDoubleEditor.java deleted file mode 100644 index 45eb095f4cf..00000000000 --- a/libjava/gnu/java/beans/editors/NativeDoubleEditor.java +++ /dev/null @@ -1,50 +0,0 @@ -/* gnu.java.beans.editors.NativeDoubleEditor - Copyright (C) 1998 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.beans.editors; - -import java.beans.*; - -/** - ** NativeDoubleEditor is a property editor for the - ** double type. - ** - ** @author John Keiser - ** @version 1.1.0, 29 Jul 1998 - **/ - -public class NativeDoubleEditor extends PropertyEditorSupport { - /** setAsText for double calls Double.valueOf(). **/ - public void setAsText(String val) throws IllegalArgumentException { - setValue(Double.valueOf(val)); - } - - /** getAsText for double calls Double.toString(). **/ - public String getAsText() { - return getValue().toString(); - } -} diff --git a/libjava/gnu/java/beans/editors/NativeFloatEditor.java b/libjava/gnu/java/beans/editors/NativeFloatEditor.java deleted file mode 100644 index d0ec98dd6b3..00000000000 --- a/libjava/gnu/java/beans/editors/NativeFloatEditor.java +++ /dev/null @@ -1,50 +0,0 @@ -/* gnu.java.beans.editors.NativeFloatEditor - Copyright (C) 1998 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.beans.editors; - -import java.beans.*; - -/** - ** NativeFloatEditor is a property editor for the - ** float type. - ** - ** @author John Keiser - ** @version 1.1.0, 29 Jul 1998 - **/ - -public class NativeFloatEditor extends PropertyEditorSupport { - /** setAsText for float calls Float.valueOf(). **/ - public void setAsText(String val) throws IllegalArgumentException { - setValue(Float.valueOf(val)); - } - - /** getAsText for float calls Float.toString(). **/ - public String getAsText() { - return getValue().toString(); - } -} diff --git a/libjava/gnu/java/beans/editors/NativeIntEditor.java b/libjava/gnu/java/beans/editors/NativeIntEditor.java deleted file mode 100644 index 16b7c6edd45..00000000000 --- a/libjava/gnu/java/beans/editors/NativeIntEditor.java +++ /dev/null @@ -1,50 +0,0 @@ -/* gnu.java.beans.editors.NativeIntEditor - Copyright (C) 1998 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.beans.editors; - -import java.beans.*; - -/** - ** NativeIntEditor is a property editor for the - ** int type. - ** - ** @author John Keiser - ** @version 1.1.0, 29 Jul 1998 - **/ - -public class NativeIntEditor extends PropertyEditorSupport { - /** setAsText for int calls Integer.valueOf(). **/ - public void setAsText(String val) throws IllegalArgumentException { - setValue(Integer.valueOf(val)); - } - - /** getAsText for int calls Integer.toString(). **/ - public String getAsText() { - return getValue().toString(); - } -} diff --git a/libjava/gnu/java/beans/editors/NativeLongEditor.java b/libjava/gnu/java/beans/editors/NativeLongEditor.java deleted file mode 100644 index e9a33454542..00000000000 --- a/libjava/gnu/java/beans/editors/NativeLongEditor.java +++ /dev/null @@ -1,50 +0,0 @@ -/* gnu.java.beans.editors.NativeLongEditor - Copyright (C) 1998 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.beans.editors; - -import java.beans.*; - -/** - ** NativeLongEditor is a property editor for the - ** long type. - ** - ** @author John Keiser - ** @version 1.1.0, 29 Jul 1998 - **/ - -public class NativeLongEditor extends PropertyEditorSupport { - /** setAsText for long calls Long.valueOf(). **/ - public void setAsText(String val) throws IllegalArgumentException { - setValue(Long.valueOf(val)); - } - - /** getAsText for long calls Long.toString(). **/ - public String getAsText() { - return getValue().toString(); - } -} diff --git a/libjava/gnu/java/beans/editors/NativeShortEditor.java b/libjava/gnu/java/beans/editors/NativeShortEditor.java deleted file mode 100644 index b32bb6a2946..00000000000 --- a/libjava/gnu/java/beans/editors/NativeShortEditor.java +++ /dev/null @@ -1,50 +0,0 @@ -/* gnu.java.beans.editors.NativeShortEditor - Copyright (C) 1998 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.beans.editors; - -import java.beans.*; - -/** - ** NativeShortEditor is a property editor for the - ** short type. - ** - ** @author John Keiser - ** @version 1.1.0, 29 Jul 1998 - **/ - -public class NativeShortEditor extends PropertyEditorSupport { - /** setAsText for short calls Short.valueOf(). **/ - public void setAsText(String val) throws IllegalArgumentException { - setValue(Short.valueOf(val)); - } - - /** getAsText for short calls Short.toString(). **/ - public String getAsText() { - return getValue().toString(); - } -} diff --git a/libjava/gnu/java/beans/editors/StringEditor.java b/libjava/gnu/java/beans/editors/StringEditor.java deleted file mode 100644 index bb3988cb189..00000000000 --- a/libjava/gnu/java/beans/editors/StringEditor.java +++ /dev/null @@ -1,50 +0,0 @@ -/* gnu.java.beans.editors.StringEditor - Copyright (C) 1998 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.beans.editors; - -import java.beans.*; - -/** - ** NativeByteEditor is a property editor for the - ** byte type. - ** - ** @author John Keiser - ** @version 1.1.0, 29 Jul 1998 - **/ - -public class StringEditor extends PropertyEditorSupport { - /** setAsText just sets the value. **/ - public void setAsText(String val) throws IllegalArgumentException { - setValue(val); - } - - /** getAsText just returns the value. **/ - public String getAsText() { - return (String)getValue(); - } -} diff --git a/libjava/gnu/java/beans/info/ComponentBeanInfo.java b/libjava/gnu/java/beans/info/ComponentBeanInfo.java deleted file mode 100644 index 4cf45fab39b..00000000000 --- a/libjava/gnu/java/beans/info/ComponentBeanInfo.java +++ /dev/null @@ -1,63 +0,0 @@ -/* gnu.java.beans.info.ComponentBeanInfo - Copyright (C) 1998 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.beans.info; - -import gnu.java.beans.*; -import java.beans.*; - -/** BeanInfo class for java.awt.Component. - ** This provides a few properties, but that's - ** it. - ** @author John Keiser - ** @version 1.1.0, Aug 1 1998 - **/ -public class ComponentBeanInfo extends SimpleBeanInfo { - static PropertyDescriptor[] properties; - static { - try { - properties = new PropertyDescriptor[6]; - properties[0] = new PropertyDescriptor("name",java.awt.Component.class); - properties[1] = new PropertyDescriptor("background",java.awt.Component.class); - properties[2] = new PropertyDescriptor("foreground",java.awt.Component.class); - properties[3] = new PropertyDescriptor("font",java.awt.Component.class); - properties[4] = new PropertyDescriptor("enabled",java.awt.Component.class); - properties[5] = new PropertyDescriptor("visible",java.awt.Component.class); - } catch(IntrospectionException E) { - properties = null; - throw new UnknownError("Could not introspect some java.awt.Component properties."); - } - } - public ComponentBeanInfo() { - super(); - } - - public PropertyDescriptor[] getPropertyDescriptors() { - return properties; - } -} - diff --git a/libjava/gnu/java/io/ClassLoaderObjectInputStream.java b/libjava/gnu/java/io/ClassLoaderObjectInputStream.java deleted file mode 100644 index 76e1f058f1d..00000000000 --- a/libjava/gnu/java/io/ClassLoaderObjectInputStream.java +++ /dev/null @@ -1,59 +0,0 @@ -/* gnu.java.io.ClassLoaderObjectInputStream - Copyright (C) 1998 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.io; - -import java.io.*; - -/** - * ClassLoaderObjectInputStream is ObjectInputStream, with - * the ability to use a specific ClassLoader. - * - * @author Geoff Berry - * @version 1.1.0, 29 Jul 1998 - */ - -public class ClassLoaderObjectInputStream extends ObjectInputStream { - ClassLoader myClassLoader; - - /** Create the new ClassLoaderObjectInputStream. - * @param in the InputStream to read the Objects from. - * @param myClassLoader the ClassLoader to load classes - * with. - */ - public ClassLoaderObjectInputStream(InputStream in, ClassLoader myClassLoader) throws IOException,StreamCorruptedException { - super(in); - this.myClassLoader = myClassLoader; - } - - /** Overriden method to use the loadClass() method from - * the ClassLoader. - */ - public Class resolveClass(String name) throws IOException, ClassNotFoundException { - return myClassLoader.loadClass(name); - } -} diff --git a/libjava/gnu/java/io/NullOutputStream.java b/libjava/gnu/java/io/NullOutputStream.java deleted file mode 100644 index caf8ade2fbc..00000000000 --- a/libjava/gnu/java/io/NullOutputStream.java +++ /dev/null @@ -1,45 +0,0 @@ -/* NullOutputStream.java -- OutputStream that does absolutely nothing - Copyright (C) 1998 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.io; - -import java.io.OutputStream; - -/** - This is a placeholder OutputStream that does absolutley nothing - when written to. It is intended to be used in the same manner as - /dev/null. None of this class's methods do anything at all. -*/ -public class NullOutputStream extends OutputStream -{ - public NullOutputStream() {} - public void write( int b ) {} - public void write( byte b[] ) {} - public void write( byte b[], int off, int len ) {} - public void flush() {} - public void close() {} -} diff --git a/libjava/gnu/java/io/ObjectIdentityWrapper.java b/libjava/gnu/java/io/ObjectIdentityWrapper.java deleted file mode 100644 index f06e2057ecb..00000000000 --- a/libjava/gnu/java/io/ObjectIdentityWrapper.java +++ /dev/null @@ -1,89 +0,0 @@ -/* ObjectIdentityWrapper.java -- Wrapper class used to override equals() - and hashCode() to be as discriminating as possible - Copyright (C) 1998 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.io; - -/** - This class is a thin wrapper around <code>Object</code> that makes - the methods <code>hashCode()</code> and <code>equals(Object)</code> - as discriminating as possible. -*/ -public class ObjectIdentityWrapper -{ - - /** - Constructs a <code>ObjectIdentityWrapper</code> that is wrapped - around o. - */ - public ObjectIdentityWrapper( Object o ) - { - object = o; - } - - /** - Uses <code>System.identityHashCode(Object)</code> to compute a - hash code for the object wrapped by this - <code>ObjectIdentityWrapper</code>. - - @see java.lang.System#identityHashCode(java.lang.Object) - @see java.util.Hashtable - @see java.lang.Object#hashCode() - */ - public int hashCode() - { - return System.identityHashCode( object ); - } - - /** - Uses the <code>==</code> operator to test for equality between - the object wrapped by this <code>ObjectIdentityWrapper</code> and - the object wrapped by the <code>ObjectIdentityWrapper</code> o. - Returns false if o is not a <code>ObjectIdentityWrapper</code>. - - @see java.util.Hashtable - @see java.lang.Object#equals() - */ - public boolean equals( Object o ) - { - if( o instanceof ObjectIdentityWrapper ) - return object == ((ObjectIdentityWrapper)o).object; - else - return false; - } - - public String toString() - { - return "ObjectIdentityWrapper< " + object + ", " + hashCode() + " >"; - } - - /** - The <code>Object</code> wrapped by this - <code>ObjectIdentityWrapper</code>. - */ - public Object object; -} diff --git a/libjava/gnu/java/lang/ArrayHelper.java b/libjava/gnu/java/lang/ArrayHelper.java deleted file mode 100644 index a04551ea4f7..00000000000 --- a/libjava/gnu/java/lang/ArrayHelper.java +++ /dev/null @@ -1,63 +0,0 @@ -/* gnu.java.lang.ArrayHelper - Copyright (C) 1998 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.lang; - -/** - ** ArrayHelper helps you do things with arrays. - ** - ** @author John Keiser - ** @version 1.1.0, 29 Jul 1998 - **/ - -public class ArrayHelper { - public static boolean contains(Object[] array, Object searchFor) { - return indexOf(array,searchFor) != -1; - } - - public static int indexOf(Object[] array, Object searchFor) { - for(int i=0;i<array.length;i++) { - if(array[i].equals(searchFor)) { - return i; - } - } - return -1; - } - - public static boolean equalsArray(Object[] a, Object[] b) { - if(a.length == b.length) { - for(int i=0;i<a.length;i++) { - if(!a[i].equals(b[i])) { - return false; - } - } - return true; - } else { - return false; - } - } -} diff --git a/libjava/gnu/java/lang/ClassHelper.java b/libjava/gnu/java/lang/ClassHelper.java deleted file mode 100644 index a4f32dcd6fb..00000000000 --- a/libjava/gnu/java/lang/ClassHelper.java +++ /dev/null @@ -1,232 +0,0 @@ -/* gnu.java.lang.ClassHelper - Copyright (C) 1998 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.lang; - -import java.util.*; -import java.lang.reflect.*; - -/** - ** ClassHelper has various methods that ought to have been - ** in class. - ** - ** @author John Keiser - ** @version 1.1.0, 29 Jul 1998 - **/ - -public class ClassHelper { - /** Strip the package part from the class name. - ** @param clazz the class to get the truncated name from - ** @return the truncated class name. - **/ - public static String getTruncatedClassName(Class clazz) { - return getTruncatedName(clazz.getName()); - } - /** Strip the package part from the class name, or the - ** class part from the method or field name. - ** @param name the name to truncate. - ** @return the truncated name. - **/ - public static String getTruncatedName(String name) { - int lastInd = name.lastIndexOf('.'); - if(lastInd == -1) { - return name; - } else { - return name.substring(lastInd+1); - } - } - - /** Strip the last portion of the name (after the last - ** dot). - ** @param name the name to get package of. - ** @return the package name. "" if no package. - **/ - public static String getPackagePortion(String name) { - int lastInd = name.lastIndexOf('.'); - if(lastInd == -1) { - return ""; - } else { - return name.substring(0,lastInd); - } - } - - static Hashtable allMethods = new Hashtable(); - static Hashtable allMethodsAtDeclaration = new Hashtable(); - - /** Get all the methods, public, private and - ** otherwise, from the class, getting them - ** from the most recent class to find them. - **/ - public static Method[] getAllMethods(Class clazz) { - Method[] retval = (Method[])allMethods.get(clazz); - if(retval == null) { - Method[] superMethods; - if(clazz.getSuperclass() != null) { - superMethods = getAllMethods(clazz.getSuperclass()); - } else { - superMethods = new Method[0]; - } - Vector v = new Vector(); - Method[] currentMethods = clazz.getDeclaredMethods(); - for(int i=0;i<currentMethods.length;i++) { - v.addElement(currentMethods[i]); - } - for(int i=0;i<superMethods.length;i++) { - boolean addOK = true; - for(int j=0;j<currentMethods.length;j++) { - if(getTruncatedName(superMethods[i].getName()).equals(getTruncatedName(currentMethods[j].getName())) - && ArrayHelper.equalsArray(superMethods[i].getParameterTypes(),currentMethods[j].getParameterTypes())) { - addOK = false; - } - } - if(addOK) { - v.addElement(superMethods[i]); - } - } - - retval = new Method[v.size()]; - v.copyInto(retval); - allMethods.put(clazz,retval); - } - return retval; - } - - /** Get all the methods, public, private and - ** otherwise, from the class, and get them from - ** their point of declaration. - **/ - public static Method[] getAllMethodsAtDeclaration(Class clazz) { - Method[] retval = (Method[])allMethodsAtDeclaration.get(clazz); - if(retval == null) { - Method[] superMethods; - if(clazz.getSuperclass() != null) { - superMethods = getAllMethodsAtDeclaration(clazz.getSuperclass()); - } else { - superMethods = new Method[0]; - } - Vector v = new Vector(); - Method[] currentMethods = clazz.getDeclaredMethods(); - for(int i=0;i<superMethods.length;i++) { - v.addElement(superMethods[i]); - } - for(int i=0;i<superMethods.length;i++) { - boolean addOK = true; - for(int j=0;j<currentMethods.length;j++) { - if(getTruncatedName(superMethods[i].getName()).equals(getTruncatedName(currentMethods[j].getName())) - && ArrayHelper.equalsArray(superMethods[i].getParameterTypes(),currentMethods[j].getParameterTypes())) { - addOK = false; - } - } - if(addOK) { - v.addElement(superMethods[i]); - } - } - - retval = new Method[v.size()]; - v.copyInto(retval); - allMethodsAtDeclaration.put(clazz,retval); - } - return retval; - } - - static Hashtable allFields = new Hashtable(); - static Hashtable allFieldsAtDeclaration = new Hashtable(); - - /** Get all the fields, public, private and - ** otherwise, from the class, getting them - ** from the most recent class to find them. - **/ - public static Field[] getAllFields(Class clazz) { - Field[] retval = (Field[])allFields.get(clazz); - if(retval == null) { - Field[] superFields; - if(clazz.getSuperclass() != null) { - superFields = getAllFields(clazz.getSuperclass()); - } else { - superFields = new Field[0]; - } - Vector v = new Vector(); - Field[] currentFields = clazz.getDeclaredFields(); - for(int i=0;i<currentFields.length;i++) { - v.addElement(currentFields[i]); - } - for(int i=0;i<superFields.length;i++) { - boolean addOK = true; - for(int j=0;j<currentFields.length;j++) { - if(getTruncatedName(superFields[i].getName()).equals(getTruncatedName(currentFields[j].getName()))) { - addOK = false; - } - } - if(addOK) { - v.addElement(superFields[i]); - } - } - - retval = new Field[v.size()]; - v.copyInto(retval); - allFields.put(clazz,retval); - } - return retval; - } - - /** Get all the fields, public, private and - ** otherwise, from the class, and get them from - ** their point of declaration. - **/ - public static Field[] getAllFieldsAtDeclaration(Class clazz) { - Field[] retval = (Field[])allFieldsAtDeclaration.get(clazz); - if(retval == null) { - Field[] superFields; - if(clazz.getSuperclass() != null) { - superFields = getAllFieldsAtDeclaration(clazz.getSuperclass()); - } else { - superFields = new Field[0]; - } - Vector v = new Vector(); - Field[] currentFields = clazz.getDeclaredFields(); - for(int i=0;i<superFields.length;i++) { - v.addElement(superFields[i]); - } - for(int i=0;i<superFields.length;i++) { - boolean addOK = true; - for(int j=0;j<currentFields.length;j++) { - if(getTruncatedName(superFields[i].getName()).equals(getTruncatedName(currentFields[j].getName()))) { - addOK = false; - } - } - if(addOK) { - v.addElement(superFields[i]); - } - } - - retval = new Field[v.size()]; - v.copyInto(retval); - allFieldsAtDeclaration.put(clazz,retval); - } - return retval; - } -} diff --git a/libjava/gnu/java/lang/reflect/TypeSignature.java b/libjava/gnu/java/lang/reflect/TypeSignature.java deleted file mode 100644 index 5a11e8c17a7..00000000000 --- a/libjava/gnu/java/lang/reflect/TypeSignature.java +++ /dev/null @@ -1,262 +0,0 @@ -/* TypeSignature.java -- Class used to compute type signatures - Copyright (C) 1998 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.lang.reflect; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Member; -import java.lang.reflect.Method; - -/** - This class provides static methods that can be used to compute - type-signatures of <code>Class</code>s or <code>Member</code>s. - More specific methods are also provided for computing the - type-signature of <code>Constructor</code>s and - <code>Method</code>s. Methods are also provided to go in the - reverse direction. -*/ -public class TypeSignature -{ - - /** - Returns a <code>String</code> representing the type-encoding of - CLAZZ. Type-encodings are computed as follows: - - <pre> - boolean -> "Z" - byte -> "B" - char -> "C" - double -> "D" - float -> "F" - int -> "I" - long -> "J" - short -> "S" - void -> "V" - arrays -> "[" + type-encoding of component type - object -> "L" - + fully qualified class name with "."'s replaced by "/"'s - + ";"</pre> - */ - public static String getEncodingOfClass( Class clazz ) - { - if( clazz.isPrimitive() ) - { - if( clazz == Boolean.TYPE ) - return "Z"; - if( clazz == Byte.TYPE ) - return "B"; - if( clazz == Character.TYPE ) - return "C"; - if( clazz == Double.TYPE ) - return "D"; - if( clazz == Float.TYPE ) - return "F"; - if( clazz == Integer.TYPE ) - return "I"; - if( clazz == Long.TYPE ) - return "J"; - if( clazz == Short.TYPE ) - return "S"; - if( clazz == Void.TYPE ) - return "V"; - else - throw new RuntimeException( "Unknown primitive class " + clazz ); - } - else if( clazz.isArray() ) - { - return '[' + getEncodingOfClass( clazz.getComponentType() ); - } - else - { - String classname = clazz.getName(); - int name_len = classname.length(); - char[] buf = new char[ name_len + 2 ]; - buf[0] = 'L'; - classname.getChars( 0, name_len, buf, 1 ); - - int i; - for( i=1; i <= name_len; i++ ) - { - if( buf[i] == '.' ) - buf[i] = '/'; - } - - buf[i] = ';'; - return new String( buf ); - } - } - - - /** - This function is the inverse of <code>getEncodingOfClass</code>. - - @see getEncodingOfClass - - @exception ClassNotFoundException If class encoded as type_code - cannot be located. - */ - public static Class getClassForEncoding( String type_code ) - throws ClassNotFoundException - { - if( type_code.equals( "B" ) ) - return Byte.TYPE; - if( type_code.equals( "C" ) ) - return Character.TYPE; - if( type_code.equals( "D" ) ) - return Double.TYPE; - if( type_code.equals( "F" ) ) - return Float.TYPE; - if( type_code.equals( "I" ) ) - return Integer.TYPE; - if( type_code.equals( "J" ) ) - return Long.TYPE; - if( type_code.equals( "S" ) ) - return Short.TYPE; - if( type_code.equals( "Z" ) ) - return Boolean.TYPE; - if( type_code.charAt( 0 ) == 'L' ) - { - return Class.forName( - type_code.substring( 1, type_code.length() - 1 ).replace( '/', '.' )); - } - if( type_code.charAt( 0 ) == '[' ) - { - int last_bracket = type_code.lastIndexOf( '[' ); - String brackets = type_code.substring( 0, last_bracket + 1 ); - String component = type_code.substring( last_bracket + 1 ); - -// ??? This is what the Classpath implementation did, but I don't -// think that it's correct. The JLS says that Class.forName takes the -// classname of an array element in fully qualified form, whereas this -// code is tring to strip off the punctuation. - -// if( component.charAt( 0 ) == 'L' ) -// component = -// component.substring( 1, component.length() - 1 ).replace('/', '.'); - - if( component.charAt( 0 ) == 'L' ) - component = component.replace('/', '.'); - - return Class.forName( brackets + component ); - } - else - throw new ClassNotFoundException( "Type code cannot be parsed as a valid class name" ); - } - - - /** - Returns a <code>String</code> representing the type-encoding of - M. The type-encoding of a method is: - - "(" + type-encodings of parameter types + ")" - + type-encoding of return type - */ - public static String getEncodingOfMethod( Method m ) - { - String returnEncoding = getEncodingOfClass( m.getReturnType() ); - Class[] paramTypes = m.getParameterTypes(); - String[] paramEncodings = new String[ paramTypes.length ]; - - String paramEncoding; - int size = 2; // make room for parens - for( int i=0; i < paramTypes.length; i++ ) - { - paramEncoding = getEncodingOfClass( paramTypes[i] ); - size += paramEncoding.length(); - paramEncodings[i] = paramEncoding; - } - - size += returnEncoding.length(); - - StringBuffer buf = new StringBuffer( size ); - buf.append( '(' ); - - for( int i=0; i < paramTypes.length; i++ ) - { - buf.append( paramEncodings[i] ); - } - - buf.append( ')' ); - buf.append( returnEncoding ); - - return buf.toString(); - } - - - /** - Returns a <code>String</code> representing the type-encoding of - C. The type-encoding of a method is: - - "(" + type-encodings of parameter types + ")V" - */ - public static String getEncodingOfConstructor( Constructor c ) - { - Class[] paramTypes = c.getParameterTypes(); - String[] paramEncodings = new String[ paramTypes.length ]; - - String paramEncoding; - int size = 3; // make room for parens and V for return type - for( int i=0; i < paramTypes.length; i++ ) - { - paramEncoding = getEncodingOfClass( paramTypes[i] ); - size += paramEncoding.length(); - paramEncodings[i] = paramEncoding; - } - - StringBuffer buf = new StringBuffer( size ); - buf.append( '(' ); - - for( int i=0; i < paramTypes.length; i++ ) - { - buf.append( paramEncodings[i] ); - } - - buf.append( ")V" ); - - return buf.toString(); - } - - - /** - Returns a <code>String</code> representing the type-encoding of - MEM. <code>Constructor</code>s are handled by - <code>getEncodingOfConstructor</code>. <code>Method</code>s are - handled by <code>getEncodingOfMethod</code>. <code>Field</code>s - are handled by returning the encoding of the type of the - <code>Field</code>. - */ - public static String getEncodingOfMember( Member mem ) - { - if( mem instanceof Constructor ) - return getEncodingOfConstructor( (Constructor)mem ); - if( mem instanceof Method ) - return getEncodingOfMethod( (Method)mem ); - else // Field - return getEncodingOfClass( ((Field)mem).getType() ); - } -} diff --git a/libjava/gnu/java/security/provider/Gnu.java b/libjava/gnu/java/security/provider/Gnu.java deleted file mode 100644 index f215bcd6a5c..00000000000 --- a/libjava/gnu/java/security/provider/Gnu.java +++ /dev/null @@ -1,79 +0,0 @@ -/* Gnu.java --- Gnu provider main class - Copyright (C) 1999 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.security.provider; -import java.security.Provider; - -public final class Gnu extends Provider -{ - public Gnu() - { - super( "GNU", 1.0, "GNU provider v1.0 implementing SHA-1, MD5, DSA"); - - // Signature - put("Signature.SHA1withDSA", "gnu.java.security.provider.DSASignature"); - - put("Alg.Alias.Signature.DSS", "SHA1withDSA"); - put("Alg.Alias.Signature.DSA", "SHA1withDSA"); - put("Alg.Alias.Signature.SHAwithDSA", "SHA1withDSA"); - put("Alg.Alias.Signature.DSAwithSHA", "SHA1withDSA"); - put("Alg.Alias.Signature.DSAwithSHA1", "SHA1withDSA"); - put("Alg.Alias.Signature.SHA/DSA", "SHA1withDSA"); - put("Alg.Alias.Signature.SHA-1/DSA", "SHA1withDSA"); - put("Alg.Alias.Signature.SHA1/DSA", "SHA1withDSA"); - put("Alg.Alias.Signature.OID.1.2.840.10040.4.3", "SHA1withDSA"); - put("Alg.Alias.Signature.1.2.840.10040.4.3", "SHA1withDSA"); - put("Alg.Alias.Signature.1.3.14.3.2.13", "SHA1withDSA"); - put("Alg.Alias.Signature.1.3.14.3.2.27", "SHA1withDSA"); - - // Key Pair Generator - put("KeyPairGenerator.DSA", "gnu.java.security.provider.DSAKeyPairGenerator"); - - put("Alg.Alias.KeyPairGenerator.OID.1.2.840.10040.4.1", "DSA"); - put("Alg.Alias.KeyPairGenerator.1.2.840.10040.4.1", "DSA"); - put("Alg.Alias.KeyPairGenerator.1.3.14.3.2.12", "DSA"); - - // Message Digests - put("MessageDigest.SHA", "gnu.java.security.provider.SHA"); - put("MessageDigest.MD5", "gnu.java.security.provider.MD5"); - - // Format "Alias", "Actual Name" - put("Alg.Alias.MessageDigest.SHA1", "SHA"); - put("Alg.Alias.MessageDigest.SHA-1", "SHA"); - - // Algorithm Parameters - put("AlgorithmParameters.DSA", "gnu.java.security.provider.DSAAlgorithmParameters"); - - // Algorithm Parameter Generator - put("AlgorithmParameterGenerator.DSA", "gnu.java.security.provider.DSAAlgorithmParameterGenerator"); - - // SecureRandom - put("SecureRandom.SHA1PRNG", "gnu.java.security.provider.SHA1PRNG"); - - - } -} diff --git a/libjava/gnu/java/security/provider/SHA.java b/libjava/gnu/java/security/provider/SHA.java deleted file mode 100644 index cb3d3bf5d09..00000000000 --- a/libjava/gnu/java/security/provider/SHA.java +++ /dev/null @@ -1,227 +0,0 @@ -/* SHA.java -- Class implementing the SHA-1 algorithm as specified in [1]. - Copyright (C) 1999 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.security.provider; - -import java.security.MessageDigest; - -/** - This class implements the SHA-1 algorithm as described in [1]. - - [1] Federal Information Processing Standards Publication 180-1. - Specifications for the Secure Hash Standard. April 17, 1995. - - @see java.security.MessageDigest -*/ -public class SHA extends MessageDigest implements Cloneable -{ - public SHA () - { - super("SHA"); - engineReset (); - } - - public int engineGetDigestLength() - { - return 16; - } - - public void engineUpdate (byte b) - { - int i = (int)bytecount % 64; - int shift = (3 - i % 4) * 8; - int idx = i / 4; - - // if you could index ints, this would be: W[idx][shift/8] = b - W[idx] = (W[idx] & ~(0xff << shift)) | ((b & 0xff) << shift); - - // if we've filled up a block, then process it - if ((++ bytecount) % 64 == 0) - munch (); - } - - // This could be optimized. - public void engineUpdate (byte bytes[], int off, int len) - { - if (len < 0) - throw new ArrayIndexOutOfBoundsException (); - - int end = off + len; - while (off < end) - engineUpdate (bytes[off++]); - } - - public void engineReset () - { - bytecount = 0; - // magic numbers from [1] p. 10. - H0 = 0x67452301; - H1 = 0xefcdab89; - H2 = 0x98badcfe; - H3 = 0x10325476; - H4 = 0xc3d2e1f0; - } - - public byte[] engineDigest () - { - long bitcount = bytecount * 8; - engineUpdate ((byte)0x80); // 10000000 in binary; the start of the padding - - // add the rest of the padding to fill this block out, but leave 8 - // bytes to put in the original bytecount - while ((int)bytecount % 64 != 56) - engineUpdate ((byte)0); - - // add the length of the original, unpadded block to the end of - // the padding - W[14] = (int)(bitcount >>> 32); - W[15] = (int)bitcount; - bytecount += 8; - - // digest the fully padded block - munch (); - - byte[] result - = new byte[] {(byte)(H0 >>> 24), (byte)(H0 >>> 16), - (byte)(H0 >>> 8), (byte)H0, - (byte)(H1 >>> 24), (byte)(H1 >>> 16), - (byte)(H1 >>> 8), (byte)H1, - (byte)(H2 >>> 24), (byte)(H2 >>> 16), - (byte)(H2 >>> 8), (byte)H2, - (byte)(H3 >>> 24), (byte)(H3 >>> 16), - (byte)(H3 >>> 8), (byte)H3, - (byte)(H4 >>> 24), (byte)(H4 >>> 16), - (byte)(H4 >>> 8), (byte)H4}; - - engineReset (); - return result; - } - - // Process a single block. This is pretty much copied verbatim from - // [1] pp. 9, 10. - private void munch () - { - for (int t = 16; t < 80; ++ t) - { - int Wt = W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16]; - W[t] = Wt << 1 | Wt >>> 31; - } - - int A = H0; - int B = H1; - int C = H2; - int D = H3; - int E = H4; - - for (int t = 0; t < 20; ++ t) - { - int TEMP = (A << 5 | A >>> 27) // S^5(A) - + ((B & C) | (~B & D)) // f_t(B,C,D) - + E + W[t] - + 0x5a827999; // K_t - - E = D; - D = C; - C = B << 30 | B >>> 2; // S^30(B) - B = A; - A = TEMP; - } - - for (int t = 20; t < 40; ++ t) - { - int TEMP = (A << 5 | A >>> 27) // S^5(A) - + (B ^ C ^ D) // f_t(B,C,D) - + E + W[t] - + 0x6ed9eba1; // K_t - - E = D; - D = C; - C = B << 30 | B >>> 2; // S^30(B) - B = A; - A = TEMP; - } - - for (int t = 40; t < 60; ++ t) - { - int TEMP = (A << 5 | A >>> 27) // S^5(A) - + (B & C | B & D | C & D) // f_t(B,C,D) - + E + W[t] - + 0x8f1bbcdc; // K_t - - E = D; - D = C; - C = B << 30 | B >>> 2; // S^30(B) - B = A; - A = TEMP; - } - - for (int t = 60; t < 80; ++ t) - { - int TEMP = (A << 5 | A >>> 27) // S^5(A) - + (B ^ C ^ D) // f_t(B,C,D) - + E + W[t] - + 0xca62c1d6; // K_t - - E = D; - D = C; - C = B << 30 | B >>> 2; // S^30(B) - B = A; - A = TEMP; - } - - H0 += A; - H1 += B; - H2 += C; - H3 += D; - H4 += E; - } - - public Object clone () - { - return new SHA (this); - } - - private SHA (SHA copy) - { - this (); - bytecount = copy.bytecount; - H0 = copy.H0; - H1 = copy.H1; - H2 = copy.H2; - H3 = copy.H3; - H4 = copy.H4; - System.arraycopy (copy.W, 0, W, 0, 80); - } - - private final int W[] = new int[80]; - private long bytecount; - private int H0; - private int H1; - private int H2; - private int H3; - private int H4; -} diff --git a/libjava/gnu/java/security/provider/SHA1PRNG.java b/libjava/gnu/java/security/provider/SHA1PRNG.java deleted file mode 100644 index 3aaf652bb46..00000000000 --- a/libjava/gnu/java/security/provider/SHA1PRNG.java +++ /dev/null @@ -1,109 +0,0 @@ -/* SHA1PRNG.java --- Secure Random SPI SHA1PRNG - Copyright (C) 1999 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -As a special exception, if you link this library with other files to -produce an executable, this library does not by itself cause the -resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why the -executable file might be covered by the GNU General Public License. */ - - -package gnu.java.security.provider; - -import java.util.Random; -// import java.security.SecureRandomSpi; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.io.Serializable; - -// public class SHA1PRNG extends SecureRandomSpi implements Serializable -public class SHA1PRNG implements Serializable -{ - MessageDigest digest; - byte seed[]; - byte data[]; - int seedpos; - int datapos; - - public SHA1PRNG() - { - try { - digest = MessageDigest.getInstance("SHA"); - } catch ( NoSuchAlgorithmException nsae) { - System.out.println("Failed to find SHA Message Digest: " + nsae); - nsae.printStackTrace(); - } - - seed = new byte[20]; - seedpos = 0; - data = new byte[40]; - datapos = 0; - - new Random().nextBytes(seed); - - byte digestdata[]; - digestdata = digest.digest( data ); - System.arraycopy( digestdata, 0, data, 0, 20); - - } - - public void engineSetSeed(byte[] seed) - { - for(int i = 0; i < seed.length; i++) - this.seed[seedpos++ % 20] ^= seed[i]; - seedpos %= 20; - - } - - public void engineNextBytes(byte[] bytes) - { - - if( bytes.length < (20 - datapos) ) { - System.arraycopy( bytes, 0, data, datapos, bytes.length); - datapos += bytes.length; - return; - } - - int i, blen = bytes.length, bpos = 0; - byte digestdata[]; - while( bpos < blen ) { - i = 20 - datapos; - System.arraycopy( bytes, bpos, data, datapos, i); - bpos += i; - datapos += i; - if( datapos >= 20) { - //System.out.println( (0 + 20) + "\n" + (20 + 20) ); - System.arraycopy( seed, 0, data, 20, 20); - digestdata = digest.digest( data ); - System.arraycopy( digestdata, 0, data, 0, 20); - datapos = 0; - } - } - - } - - public byte[] engineGenerateSeed(int numBytes) - { - byte tmp[] = new byte[numBytes]; - - engineNextBytes( tmp ); - return tmp; - } -} |