diff options
Diffstat (limited to 'libjava/classpath/gnu/java/beans')
79 files changed, 1757 insertions, 1757 deletions
diff --git a/libjava/classpath/gnu/java/beans/BeanInfoEmbryo.java b/libjava/classpath/gnu/java/beans/BeanInfoEmbryo.java index 0cf73e5..cc474e8 100644 --- a/libjava/classpath/gnu/java/beans/BeanInfoEmbryo.java +++ b/libjava/classpath/gnu/java/beans/BeanInfoEmbryo.java @@ -7,7 +7,7 @@ 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 @@ -70,79 +70,79 @@ import java.util.Vector; public class BeanInfoEmbryo { - // by using a TreeMap the properties will be sorted alphabetically by name - // which matches the (undocumented) behavior of jdk - TreeMap properties = new TreeMap(); - 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; - Iterator it = properties.entrySet().iterator(); - while (it.hasNext()) { - Aproperties[i] = (PropertyDescriptor) (((Map.Entry)it.next()).getValue()); - if(defaultPropertyName != null && Aproperties[i].getName().equals(defaultPropertyName)) { - defaultProperty = i; - } - i++; - } - - EventSetDescriptor[] Aevents = new EventSetDescriptor[events.size()]; - i = 0; - Enumeration e = events.elements(); - while (e.hasMoreElements()) { - Aevents[i] = (EventSetDescriptor) e.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) { + // by using a TreeMap the properties will be sorted alphabetically by name + // which matches the (undocumented) behavior of jdk + TreeMap properties = new TreeMap(); + 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; + Iterator it = properties.entrySet().iterator(); + while (it.hasNext()) { + Aproperties[i] = (PropertyDescriptor) (((Map.Entry)it.next()).getValue()); + if(defaultPropertyName != null && Aproperties[i].getName().equals(defaultPropertyName)) { + defaultProperty = i; + } + i++; + } + + EventSetDescriptor[] Aevents = new EventSetDescriptor[events.size()]; + i = 0; + Enumeration e = events.elements(); + while (e.hasMoreElements()) { + Aevents[i] = (EventSetDescriptor) e.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()) @@ -152,20 +152,20 @@ public class BeanInfoEmbryo { } } 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; - } + } + 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/classpath/gnu/java/beans/DefaultExceptionListener.java b/libjava/classpath/gnu/java/beans/DefaultExceptionListener.java index 42b31fa..124ad9c 100644 --- a/libjava/classpath/gnu/java/beans/DefaultExceptionListener.java +++ b/libjava/classpath/gnu/java/beans/DefaultExceptionListener.java @@ -55,12 +55,12 @@ public class DefaultExceptionListener implements ExceptionListener { public final static DefaultExceptionListener INSTANCE = new DefaultExceptionListener(); - + public void exceptionThrown(Exception e) { System.err.println("exception thrown: " + e + " - message: " + e.getMessage()); } - + } diff --git a/libjava/classpath/gnu/java/beans/ExplicitBeanInfo.java b/libjava/classpath/gnu/java/beans/ExplicitBeanInfo.java index 6da5e86..30f1de4 100644 --- a/libjava/classpath/gnu/java/beans/ExplicitBeanInfo.java +++ b/libjava/classpath/gnu/java/beans/ExplicitBeanInfo.java @@ -7,7 +7,7 @@ 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 @@ -55,95 +55,95 @@ import java.beans.PropertyDescriptor; **/ 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 Image[] icons; - - public ExplicitBeanInfo(BeanDescriptor beanDescriptor, - BeanInfo[] additionalBeanInfo, - PropertyDescriptor[] propertyDescriptors, - int defaultPropertyIndex, - EventSetDescriptor[] eventSetDescriptors, - int defaultEventIndex, - MethodDescriptor[] methodDescriptors, - 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 Image getIcon(int iconType) { - return icons != null ? icons[iconType - 1] : null; - } + /** 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 Image[] icons; + + public ExplicitBeanInfo(BeanDescriptor beanDescriptor, + BeanInfo[] additionalBeanInfo, + PropertyDescriptor[] propertyDescriptors, + int defaultPropertyIndex, + EventSetDescriptor[] eventSetDescriptors, + int defaultEventIndex, + MethodDescriptor[] methodDescriptors, + 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 Image getIcon(int iconType) { + return icons != null ? icons[iconType - 1] : null; + } } diff --git a/libjava/classpath/gnu/java/beans/IntrospectionIncubator.java b/libjava/classpath/gnu/java/beans/IntrospectionIncubator.java index e0d9480..978429a 100644 --- a/libjava/classpath/gnu/java/beans/IntrospectionIncubator.java +++ b/libjava/classpath/gnu/java/beans/IntrospectionIncubator.java @@ -7,7 +7,7 @@ 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 @@ -69,373 +69,373 @@ import java.util.Vector; **/ public class IntrospectionIncubator { - Hashtable propertyMethods = new Hashtable(); - Hashtable listenerMethods = new Hashtable(); - Vector otherMethods = new Vector(); - - Class propertyStopClass; - Class eventStopClass; - Class methodStopClass; - - public IntrospectionIncubator() { - } - - /** Examines the given method and files it in a suitable collection. - * It files the method as a property method if it finds: - * <ul> - * <li>boolean "is" getter</li> - * <li>"get" style getter</li> - * <li>single argument setter</li> - * <li>indiced setter and getter</li> - * </ul> - * It files the method as a listener method if all of these rules apply: - * <ul> - * <li>the method name starts with "add" or "remove"</li> - * <li>there is only a single argument</li> - * <li>the argument type is a subclass of <code>java.util.EventListener</code></li> - * </ul> - * All public methods are filed as such. - * - * @param method The method instance to examine. - */ - public void addMethod(Method method) { - if(Modifier.isPublic(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(); - - /* Accepts the method for examination if no stop class is given or the method is declared in a subclass of the stop class. - * The rules for this are described in {@link java.beans.Introspector.getBeanInfo(Class, Class)}. - * This block finds out whether the method is a suitable getter or setter method (or read/write method). - */ - if(isReachable(propertyStopClass, methodClass)) { - /* At this point a method may regarded as a property's read or write method if its name - * starts with "is", "get" or "set". However, if a method is static it cannot be part - * of a property. - */ - if(Modifier.isStatic(method.getModifiers())) { - // files method as other because it is static - otherMethods.addElement(method); - } else if(name.startsWith("is") - && retType.equals(java.lang.Boolean.TYPE) - && params.length == 0) { - // files method as boolean "is" style getter - addToPropertyHash(name,method,IS); - } else if(name.startsWith("get") && !isVoid) { - if(params.length == 0) { - // files as legal non-argument getter - addToPropertyHash(name,method,GET); - } else if(params.length == 1 && params[0].equals(java.lang.Integer.TYPE)) { - // files as legal indiced getter - addToPropertyHash(name,method,GET_I); - } else { - // files as other because the method's signature is not Bean-like - otherMethods.addElement(method); - } - } else if(name.startsWith("set") && isVoid) { - if(params.length == 1) { - // files as legal single-argument setter method - addToPropertyHash(name,method,SET); - } else if(params.length == 2 && params[0].equals(java.lang.Integer.TYPE)) { - // files as legal indiced setter method - addToPropertyHash(name,method,SET_I); - } else { - // files as other because the method's signature is not Bean-like - otherMethods.addElement(method); - } - } - } - - if(isReachable(eventStopClass, 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(isReachable(methodStopClass, methodClass)) { - // files as reachable public method - 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); - if (newName.length() == 0) - return; - - 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); - if (newName.length() == 0) - return; - - 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; - } - - /* Determines whether <code>stopClass</code> is <code>null</code> - * or <code>declaringClass<code> is a true subclass of <code>stopClass</code>. - * This expression is useful to detect whether a method should be introspected or not. - * The rules for this are described in {@link java.beans.Introspector.getBeanInfo(Class, Class)}. - */ - static boolean isReachable(Class stopClass, Class declaringClass) { - return stopClass == null || (stopClass.isAssignableFrom(declaringClass) && !stopClass.equals(declaringClass)); - } - - /** Transforms a property name into a part of a method name. - * E.g. "value" becomes "Value" which can then concatenated with - * "set", "get" or "is" to form a valid method name. - * - * Implementation notes: - * If "" is the argument, it is returned without changes. - * If <code>null</code> is the argument, <code>null</code> is returned. - * - * @param name Name of a property. - * @return Part of a method name of a property. - */ - 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; - } - } + Hashtable propertyMethods = new Hashtable(); + Hashtable listenerMethods = new Hashtable(); + Vector otherMethods = new Vector(); + + Class propertyStopClass; + Class eventStopClass; + Class methodStopClass; + + public IntrospectionIncubator() { + } + + /** Examines the given method and files it in a suitable collection. + * It files the method as a property method if it finds: + * <ul> + * <li>boolean "is" getter</li> + * <li>"get" style getter</li> + * <li>single argument setter</li> + * <li>indiced setter and getter</li> + * </ul> + * It files the method as a listener method if all of these rules apply: + * <ul> + * <li>the method name starts with "add" or "remove"</li> + * <li>there is only a single argument</li> + * <li>the argument type is a subclass of <code>java.util.EventListener</code></li> + * </ul> + * All public methods are filed as such. + * + * @param method The method instance to examine. + */ + public void addMethod(Method method) { + if(Modifier.isPublic(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(); + + /* Accepts the method for examination if no stop class is given or the method is declared in a subclass of the stop class. + * The rules for this are described in {@link java.beans.Introspector.getBeanInfo(Class, Class)}. + * This block finds out whether the method is a suitable getter or setter method (or read/write method). + */ + if(isReachable(propertyStopClass, methodClass)) { + /* At this point a method may regarded as a property's read or write method if its name + * starts with "is", "get" or "set". However, if a method is static it cannot be part + * of a property. + */ + if(Modifier.isStatic(method.getModifiers())) { + // files method as other because it is static + otherMethods.addElement(method); + } else if(name.startsWith("is") + && retType.equals(java.lang.Boolean.TYPE) + && params.length == 0) { + // files method as boolean "is" style getter + addToPropertyHash(name,method,IS); + } else if(name.startsWith("get") && !isVoid) { + if(params.length == 0) { + // files as legal non-argument getter + addToPropertyHash(name,method,GET); + } else if(params.length == 1 && params[0].equals(java.lang.Integer.TYPE)) { + // files as legal indiced getter + addToPropertyHash(name,method,GET_I); + } else { + // files as other because the method's signature is not Bean-like + otherMethods.addElement(method); + } + } else if(name.startsWith("set") && isVoid) { + if(params.length == 1) { + // files as legal single-argument setter method + addToPropertyHash(name,method,SET); + } else if(params.length == 2 && params[0].equals(java.lang.Integer.TYPE)) { + // files as legal indiced setter method + addToPropertyHash(name,method,SET_I); + } else { + // files as other because the method's signature is not Bean-like + otherMethods.addElement(method); + } + } + } + + if(isReachable(eventStopClass, 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(isReachable(methodStopClass, methodClass)) { + // files as reachable public method + 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); + if (newName.length() == 0) + return; + + 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); + if (newName.length() == 0) + return; + + 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; + } + + /* Determines whether <code>stopClass</code> is <code>null</code> + * or <code>declaringClass<code> is a true subclass of <code>stopClass</code>. + * This expression is useful to detect whether a method should be introspected or not. + * The rules for this are described in {@link java.beans.Introspector.getBeanInfo(Class, Class)}. + */ + static boolean isReachable(Class stopClass, Class declaringClass) { + return stopClass == null || (stopClass.isAssignableFrom(declaringClass) && !stopClass.equals(declaringClass)); + } + + /** Transforms a property name into a part of a method name. + * E.g. "value" becomes "Value" which can then concatenated with + * "set", "get" or "is" to form a valid method name. + * + * Implementation notes: + * If "" is the argument, it is returned without changes. + * If <code>null</code> is the argument, <code>null</code> is returned. + * + * @param name Name of a property. + * @return Part of a method name of a property. + */ + 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; + } + } } /** This class is a hashmap key that consists of a <code>Class</code> and a * <code>String</code> element. - * + * * It is used for XXX: find out what this is used for - * + * * @author John Keiser * @author Robert Schuster - */ + */ 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(); - } + 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/classpath/gnu/java/beans/decoder/AbstractContext.java b/libjava/classpath/gnu/java/beans/decoder/AbstractContext.java index 0e95d43..e6f90e2 100644 --- a/libjava/classpath/gnu/java/beans/decoder/AbstractContext.java +++ b/libjava/classpath/gnu/java/beans/decoder/AbstractContext.java @@ -7,7 +7,7 @@ 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 diff --git a/libjava/classpath/gnu/java/beans/decoder/AbstractCreatableObjectContext.java b/libjava/classpath/gnu/java/beans/decoder/AbstractCreatableObjectContext.java index 47f04fa..d108f19 100644 --- a/libjava/classpath/gnu/java/beans/decoder/AbstractCreatableObjectContext.java +++ b/libjava/classpath/gnu/java/beans/decoder/AbstractCreatableObjectContext.java @@ -7,7 +7,7 @@ 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 @@ -65,7 +65,7 @@ abstract class AbstractCreatableObjectContext extends AbstractObjectContext /** Adds a parameter object to this Context. Implement this without caring * for illegal states because this has been done already. * - * @param obj The parameter object to be added. + * @param obj The parameter object to be added. */ protected abstract void addParameterObjectImpl(Object obj); @@ -83,7 +83,7 @@ abstract class AbstractCreatableObjectContext extends AbstractObjectContext /** Creates the result object. This method is called only once. Implement this * without checking for double invocations as this is already being prevented. * - * @param outerContext The Context that exists around this one. + * @param outerContext The Context that exists around this one. * @return The result object. * @throws AssemblerException if the object creation fails somehow. */ diff --git a/libjava/classpath/gnu/java/beans/decoder/AbstractElementHandler.java b/libjava/classpath/gnu/java/beans/decoder/AbstractElementHandler.java index e5578a9..5176565 100644 --- a/libjava/classpath/gnu/java/beans/decoder/AbstractElementHandler.java +++ b/libjava/classpath/gnu/java/beans/decoder/AbstractElementHandler.java @@ -7,7 +7,7 @@ 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 @@ -91,21 +91,21 @@ abstract class AbstractElementHandler implements ElementHandler { try { - // lets the subclass create the appropriate Context instance - context = startElement(attributes, exceptionListener); + // lets the subclass create the appropriate Context instance + context = startElement(attributes, exceptionListener); } catch (AssemblyException pe) { - Throwable t = pe.getCause(); + Throwable t = pe.getCause(); - if (t instanceof Exception) - exceptionListener.exceptionThrown((Exception) t); - else - throw new InternalError("Unexpected Throwable type in AssemblerException. Please file a bug report."); + if (t instanceof Exception) + exceptionListener.exceptionThrown((Exception) t); + else + throw new InternalError("Unexpected Throwable type in AssemblerException. Please file a bug report."); - notifyContextFailed(); + notifyContextFailed(); - return; + return; } } @@ -129,48 +129,48 @@ abstract class AbstractElementHandler implements ElementHandler // is then invalid or may not exist at all) if (!hasFailed) { - try - { - // note: the order of operations is very important here - // sends the stored character data to the Context - endElement(buffer.toString()); - - // reports to the parent handler if this handler's Context is a - // statement (returning no value BACK to the parent's Context) - if (context.isStatement()) - { - // This may create a valid result in the parent's Context - // or let it fail - parent.notifyStatement(exceptionListener); - - // skips any further processing if the parent handler is now marked - // as failed - if (parent.hasFailed()) - return; - } - - // processes the Context and stores the result - putObject(context.getId(), context.endContext(parent.getContext())); - - // transfers the Context's results to the parent's Context - // if it is an expression (rather than a statement) - if (! context.isStatement()) - parent.getContext().addParameterObject(context.getResult()); - } - catch (AssemblyException pe) - { - // notifies that an exception was thrown in this handler's Context - Throwable t = pe.getCause(); - - if (t instanceof Exception) - exceptionListener.exceptionThrown((Exception) t); - else - throw (InternalError) new InternalError("Severe problem while decoding XML data.") - .initCause(t); - - // marks the handler as failed - notifyContextFailed(); - } + try + { + // note: the order of operations is very important here + // sends the stored character data to the Context + endElement(buffer.toString()); + + // reports to the parent handler if this handler's Context is a + // statement (returning no value BACK to the parent's Context) + if (context.isStatement()) + { + // This may create a valid result in the parent's Context + // or let it fail + parent.notifyStatement(exceptionListener); + + // skips any further processing if the parent handler is now marked + // as failed + if (parent.hasFailed()) + return; + } + + // processes the Context and stores the result + putObject(context.getId(), context.endContext(parent.getContext())); + + // transfers the Context's results to the parent's Context + // if it is an expression (rather than a statement) + if (! context.isStatement()) + parent.getContext().addParameterObject(context.getResult()); + } + catch (AssemblyException pe) + { + // notifies that an exception was thrown in this handler's Context + Throwable t = pe.getCause(); + + if (t instanceof Exception) + exceptionListener.exceptionThrown((Exception) t); + else + throw (InternalError) new InternalError("Severe problem while decoding XML data.") + .initCause(t); + + // marks the handler as failed + notifyContextFailed(); + } } } @@ -184,31 +184,31 @@ abstract class AbstractElementHandler implements ElementHandler { try { - - // propagates to parent handler first to generate objects - // needed by this Context instance - if(context.isStatement()) - { - parent.notifyStatement(exceptionListener); - } - - // Some Context instances do stuff which can fail now. If that - // happens this handler is marked as failed. - context.notifyStatement(parent.getContext()); + + // propagates to parent handler first to generate objects + // needed by this Context instance + if(context.isStatement()) + { + parent.notifyStatement(exceptionListener); + } + + // Some Context instances do stuff which can fail now. If that + // happens this handler is marked as failed. + context.notifyStatement(parent.getContext()); } catch (AssemblyException ae) { - // notifies that an exception was thrown in this handler's Context - Throwable t = ae.getCause(); + // notifies that an exception was thrown in this handler's Context + Throwable t = ae.getCause(); - if (t instanceof Exception) - exceptionListener.exceptionThrown((Exception) t); - else - throw (InternalError) new InternalError("Severe problem while decoding XML data.") - .initCause(t); + if (t instanceof Exception) + exceptionListener.exceptionThrown((Exception) t); + else + throw (InternalError) new InternalError("Severe problem while decoding XML data.") + .initCause(t); - // marks the handler as failed - notifyContextFailed(); + // marks the handler as failed + notifyContextFailed(); } } diff --git a/libjava/classpath/gnu/java/beans/decoder/AbstractObjectContext.java b/libjava/classpath/gnu/java/beans/decoder/AbstractObjectContext.java index 202c33b..963ef09 100644 --- a/libjava/classpath/gnu/java/beans/decoder/AbstractObjectContext.java +++ b/libjava/classpath/gnu/java/beans/decoder/AbstractObjectContext.java @@ -7,7 +7,7 @@ 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 diff --git a/libjava/classpath/gnu/java/beans/decoder/ArrayContext.java b/libjava/classpath/gnu/java/beans/decoder/ArrayContext.java index cf4267f..bdec1c6 100644 --- a/libjava/classpath/gnu/java/beans/decoder/ArrayContext.java +++ b/libjava/classpath/gnu/java/beans/decoder/ArrayContext.java @@ -7,7 +7,7 @@ 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 @@ -67,7 +67,7 @@ class ArrayContext extends AbstractContext */ public void notifyStatement(Context outerContext) { - // method call intentionally ignored because there is not any useful effect + // method call intentionally ignored because there is not any useful effect } /* (non-Javadoc) @@ -92,11 +92,11 @@ class ArrayContext extends AbstractContext { try { - Array.set(array, index, o); + Array.set(array, index, o); } catch (ArrayIndexOutOfBoundsException aioobe) { - throw new AssemblyException(aioobe); + throw new AssemblyException(aioobe); } } @@ -104,11 +104,11 @@ class ArrayContext extends AbstractContext { try { - return Array.get(array, index); + return Array.get(array, index); } catch (ArrayIndexOutOfBoundsException aioobe) { - throw new AssemblyException(aioobe); + throw new AssemblyException(aioobe); } } diff --git a/libjava/classpath/gnu/java/beans/decoder/ArrayHandler.java b/libjava/classpath/gnu/java/beans/decoder/ArrayHandler.java index 23f0285..28930f5 100644 --- a/libjava/classpath/gnu/java/beans/decoder/ArrayHandler.java +++ b/libjava/classpath/gnu/java/beans/decoder/ArrayHandler.java @@ -7,7 +7,7 @@ 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 @@ -86,31 +86,31 @@ class ArrayHandler extends AbstractElementHandler if (className != null) { - try - { - Class klass; - - if (typeMap.containsKey(className)) - klass = (Class) typeMap.get(className); - else - klass = instantiateClass(className); - - String length = attributes.getValue("length"); - if (length != null) - // creates Array with predefined length - return new ArrayContext(id, klass, Integer.parseInt(length)); - else - // creates Array without length restriction - return new GrowableArrayContext(id, klass); - } - catch (ClassNotFoundException cnfe) - { - throw new AssemblyException(cnfe); - } - catch (NumberFormatException nfe) - { - throw new AssemblyException(nfe); - } + try + { + Class klass; + + if (typeMap.containsKey(className)) + klass = (Class) typeMap.get(className); + else + klass = instantiateClass(className); + + String length = attributes.getValue("length"); + if (length != null) + // creates Array with predefined length + return new ArrayContext(id, klass, Integer.parseInt(length)); + else + // creates Array without length restriction + return new GrowableArrayContext(id, klass); + } + catch (ClassNotFoundException cnfe) + { + throw new AssemblyException(cnfe); + } + catch (NumberFormatException nfe) + { + throw new AssemblyException(nfe); + } } throw new AssemblyException(new IllegalArgumentException("Missing 'class' attribute in <array> tag.")); diff --git a/libjava/classpath/gnu/java/beans/decoder/AssemblyException.java b/libjava/classpath/gnu/java/beans/decoder/AssemblyException.java index 29dfa65..206c584 100644 --- a/libjava/classpath/gnu/java/beans/decoder/AssemblyException.java +++ b/libjava/classpath/gnu/java/beans/decoder/AssemblyException.java @@ -7,7 +7,7 @@ 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 @@ -41,7 +41,7 @@ package gnu.java.beans.decoder; /** The AssemblyException is used to wrap the cause of problems when assembling objects. * In all cases only the wrapped exception is given to the PersistenceParser's * ExceptionListener instance (never the AssemblyException itself). - * + * * <p>Note: Often multiple steps are needed to construct a fully usuable object instance. * Such a construction can be called assembly and thats why this exception was * named AssemblyException.</p> diff --git a/libjava/classpath/gnu/java/beans/decoder/BooleanHandler.java b/libjava/classpath/gnu/java/beans/decoder/BooleanHandler.java index a675e8c..20aed9a 100644 --- a/libjava/classpath/gnu/java/beans/decoder/BooleanHandler.java +++ b/libjava/classpath/gnu/java/beans/decoder/BooleanHandler.java @@ -7,7 +7,7 @@ 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 diff --git a/libjava/classpath/gnu/java/beans/decoder/ByteHandler.java b/libjava/classpath/gnu/java/beans/decoder/ByteHandler.java index d6c33d1..830bbc7 100644 --- a/libjava/classpath/gnu/java/beans/decoder/ByteHandler.java +++ b/libjava/classpath/gnu/java/beans/decoder/ByteHandler.java @@ -7,7 +7,7 @@ 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 diff --git a/libjava/classpath/gnu/java/beans/decoder/CharHandler.java b/libjava/classpath/gnu/java/beans/decoder/CharHandler.java index 1b31e5b..114df8b 100644 --- a/libjava/classpath/gnu/java/beans/decoder/CharHandler.java +++ b/libjava/classpath/gnu/java/beans/decoder/CharHandler.java @@ -7,7 +7,7 @@ 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 diff --git a/libjava/classpath/gnu/java/beans/decoder/ClassHandler.java b/libjava/classpath/gnu/java/beans/decoder/ClassHandler.java index 1dbdd63..c67a79a 100644 --- a/libjava/classpath/gnu/java/beans/decoder/ClassHandler.java +++ b/libjava/classpath/gnu/java/beans/decoder/ClassHandler.java @@ -7,7 +7,7 @@ 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 @@ -56,11 +56,11 @@ class ClassHandler extends SimpleHandler { try { - return instantiateClass(characters); + return instantiateClass(characters); } catch (ClassNotFoundException cnfe) { - throw new AssemblyException(cnfe); + throw new AssemblyException(cnfe); } } } diff --git a/libjava/classpath/gnu/java/beans/decoder/ConstructorContext.java b/libjava/classpath/gnu/java/beans/decoder/ConstructorContext.java index 7838fb7..32365ee 100644 --- a/libjava/classpath/gnu/java/beans/decoder/ConstructorContext.java +++ b/libjava/classpath/gnu/java/beans/decoder/ConstructorContext.java @@ -7,7 +7,7 @@ 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 @@ -57,7 +57,7 @@ class ConstructorContext extends AbstractCreatableObjectContext ConstructorContext(String id, Class newClass) { setId(id); - // sets superclass field + // sets superclass field klass = newClass; } @@ -76,27 +76,27 @@ class ConstructorContext extends AbstractCreatableObjectContext try { - Constructor constructor = MethodFinder.getConstructor(klass, args); + Constructor constructor = MethodFinder.getConstructor(klass, args); - // instantiates object (klass field gets re-set by superclass) - return constructor.newInstance(args); + // instantiates object (klass field gets re-set by superclass) + return constructor.newInstance(args); } catch (NoSuchMethodException nsme) { - throw new AssemblyException(nsme); + throw new AssemblyException(nsme); } catch (InvocationTargetException ite) { - throw new AssemblyException(ite.getCause()); + throw new AssemblyException(ite.getCause()); } catch (IllegalAccessException iae) { - throw new AssemblyException(iae); + throw new AssemblyException(iae); } catch (InstantiationException ie) { - throw new AssemblyException(ie); + throw new AssemblyException(ie); } } - + } diff --git a/libjava/classpath/gnu/java/beans/decoder/Context.java b/libjava/classpath/gnu/java/beans/decoder/Context.java index a2db097..4bdbc9c 100644 --- a/libjava/classpath/gnu/java/beans/decoder/Context.java +++ b/libjava/classpath/gnu/java/beans/decoder/Context.java @@ -7,7 +7,7 @@ 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 diff --git a/libjava/classpath/gnu/java/beans/decoder/DecoderContext.java b/libjava/classpath/gnu/java/beans/decoder/DecoderContext.java index 69d84e5..174a3b7 100644 --- a/libjava/classpath/gnu/java/beans/decoder/DecoderContext.java +++ b/libjava/classpath/gnu/java/beans/decoder/DecoderContext.java @@ -7,7 +7,7 @@ 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 @@ -113,12 +113,12 @@ public class DecoderContext extends AbstractContext } /** Returns an Iterator that retrieves the assembled objects. - * + * * @return An Iterator retrieving assembled objects. */ public Iterator iterator() { return objects.iterator(); } - + } diff --git a/libjava/classpath/gnu/java/beans/decoder/DoubleHandler.java b/libjava/classpath/gnu/java/beans/decoder/DoubleHandler.java index 8f6be7e..1a14fba 100644 --- a/libjava/classpath/gnu/java/beans/decoder/DoubleHandler.java +++ b/libjava/classpath/gnu/java/beans/decoder/DoubleHandler.java @@ -7,7 +7,7 @@ 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 diff --git a/libjava/classpath/gnu/java/beans/decoder/DummyContext.java b/libjava/classpath/gnu/java/beans/decoder/DummyContext.java index f3b2454..03f209c 100644 --- a/libjava/classpath/gnu/java/beans/decoder/DummyContext.java +++ b/libjava/classpath/gnu/java/beans/decoder/DummyContext.java @@ -7,7 +7,7 @@ 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 @@ -60,7 +60,7 @@ public class DummyContext extends AbstractContext */ public void notifyStatement(Context outerContext) throws AssemblyException { - // intentionally ignored + // intentionally ignored } /* (non-Javadoc) @@ -69,7 +69,7 @@ public class DummyContext extends AbstractContext public Object endContext(Context outerContext) throws AssemblyException { fail(); - return null; + return null; } /* (non-Javadoc) @@ -78,7 +78,7 @@ public class DummyContext extends AbstractContext public boolean subContextFailed() { fail(); - return false; + return false; } /* (non-Javadoc) @@ -95,7 +95,7 @@ public class DummyContext extends AbstractContext public Object get(int index) throws AssemblyException { fail(); - return null; + return null; } /* (non-Javadoc) @@ -104,13 +104,13 @@ public class DummyContext extends AbstractContext public Object getResult() { fail(); - return null; + return null; } private void fail() { throw new InternalError("Invoking the DummyContext is not expected" - + " - Please file a bug report at" - + " http://www/gnu.org/software/classpath/."); + + " - Please file a bug report at" + + " http://www/gnu.org/software/classpath/."); } } diff --git a/libjava/classpath/gnu/java/beans/decoder/DummyHandler.java b/libjava/classpath/gnu/java/beans/decoder/DummyHandler.java index 880d76a..f9c133e 100644 --- a/libjava/classpath/gnu/java/beans/decoder/DummyHandler.java +++ b/libjava/classpath/gnu/java/beans/decoder/DummyHandler.java @@ -7,7 +7,7 @@ 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 @@ -89,7 +89,7 @@ class DummyHandler implements ElementHandler throws ClassNotFoundException { fail(); - return null; + return null; } /* (non-Javadoc) @@ -138,19 +138,19 @@ class DummyHandler implements ElementHandler public Object getObject(String objectId) { fail(); - return null; + return null; } public ElementHandler getParent() { fail(); - return null; + return null; } private void fail() { throw new InternalError("Invoking the DummyHandler is not expected" - + " - Please file a bug report at " - + " http://www.gnu.org/software/classpath/."); + + " - Please file a bug report at " + + " http://www.gnu.org/software/classpath/."); } } diff --git a/libjava/classpath/gnu/java/beans/decoder/ElementHandler.java b/libjava/classpath/gnu/java/beans/decoder/ElementHandler.java index e6ae60a..12e945b 100644 --- a/libjava/classpath/gnu/java/beans/decoder/ElementHandler.java +++ b/libjava/classpath/gnu/java/beans/decoder/ElementHandler.java @@ -7,7 +7,7 @@ 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 @@ -72,19 +72,19 @@ interface ElementHandler /** Returns whether a subelement of the given name is allowed. The rules * for evaluating this are derived from the javabeans.dtd which can be found * here: <a href="http://java.sun.com/products/jfc/tsc/articles/persistence3">Java Persistence Article</a>. - * - * @param subElementName + * + * @param subElementName * @return */ boolean isSubelementAllowed(String subElementName); /** Provides the same functionality as Class.forName() but allows the decoder * to use a different class loader. - * + * * @param className * @return * @throws ClassNotFoundException - */ + */ Class instantiateClass(String className) throws ClassNotFoundException; /** Notifies the handler's Context that its child Context will not return @@ -104,21 +104,21 @@ interface ElementHandler boolean hasFailed(); /** Returns the Context instance this handler is working on. - * + * * @return The handler's Context instance. */ Context getContext(); /** Notifies the handler that its Context failed and starts a recursive * invocation of the parent handler if it is affected by that failure. - * + * * Although the method is a public API member it is only used internally. */ void notifyContextFailed(); /** Stores the object under the given id. The object is not stored if the * id is null. - * + * * @param objectId * @param o */ diff --git a/libjava/classpath/gnu/java/beans/decoder/FloatHandler.java b/libjava/classpath/gnu/java/beans/decoder/FloatHandler.java index 5f0e15c..443f38f 100644 --- a/libjava/classpath/gnu/java/beans/decoder/FloatHandler.java +++ b/libjava/classpath/gnu/java/beans/decoder/FloatHandler.java @@ -7,7 +7,7 @@ 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 diff --git a/libjava/classpath/gnu/java/beans/decoder/GrowableArrayContext.java b/libjava/classpath/gnu/java/beans/decoder/GrowableArrayContext.java index f24a60b..fb386d1 100644 --- a/libjava/classpath/gnu/java/beans/decoder/GrowableArrayContext.java +++ b/libjava/classpath/gnu/java/beans/decoder/GrowableArrayContext.java @@ -7,7 +7,7 @@ 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 @@ -46,11 +46,11 @@ import java.lang.reflect.Array; class GrowableArrayContext extends AbstractContext { private static final int INITIAL_SIZE = 16; - + private Class klass; private Object array; private int length; - + GrowableArrayContext(String id, Class newClass) { setId(id); @@ -69,7 +69,7 @@ class GrowableArrayContext extends AbstractContext System.arraycopy(array, 0, tmp, 0, length); array = tmp; } - + try { Array.set(array, length++, o); } catch(IllegalArgumentException iae) { @@ -97,7 +97,7 @@ class GrowableArrayContext extends AbstractContext System.arraycopy(array, 0, tmp, 0, length); array = tmp; } - + return array; } @@ -119,7 +119,7 @@ class GrowableArrayContext extends AbstractContext try { Array.set(array, index, o); } catch(IllegalArgumentException iae) { - throw new AssemblyException(iae); + throw new AssemblyException(iae); } } diff --git a/libjava/classpath/gnu/java/beans/decoder/IndexContext.java b/libjava/classpath/gnu/java/beans/decoder/IndexContext.java index 11f840c..b5af901 100644 --- a/libjava/classpath/gnu/java/beans/decoder/IndexContext.java +++ b/libjava/classpath/gnu/java/beans/decoder/IndexContext.java @@ -7,7 +7,7 @@ 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 @@ -65,8 +65,8 @@ class IndexContext extends AbstractContext { if (! isSetter) { - argument = o; - isSetter = true; + argument = o; + isSetter = true; } else throw new AssemblyException(new IllegalStateException("More than one argument for indiced access is not possible.")); @@ -87,10 +87,10 @@ class IndexContext extends AbstractContext { if (isSetter) { - // setter - outerContext.set(index, argument); + // setter + outerContext.set(index, argument); - return null; + return null; } else // getter diff --git a/libjava/classpath/gnu/java/beans/decoder/IntHandler.java b/libjava/classpath/gnu/java/beans/decoder/IntHandler.java index a96f4a0..bbd3560 100644 --- a/libjava/classpath/gnu/java/beans/decoder/IntHandler.java +++ b/libjava/classpath/gnu/java/beans/decoder/IntHandler.java @@ -7,7 +7,7 @@ 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 diff --git a/libjava/classpath/gnu/java/beans/decoder/JavaHandler.java b/libjava/classpath/gnu/java/beans/decoder/JavaHandler.java index 3bc8c60..c4b4f92 100644 --- a/libjava/classpath/gnu/java/beans/decoder/JavaHandler.java +++ b/libjava/classpath/gnu/java/beans/decoder/JavaHandler.java @@ -7,7 +7,7 @@ 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 @@ -69,7 +69,7 @@ public class JavaHandler extends AbstractElementHandler protected Context startElement(Attributes attributes, ExceptionListener exceptionListener) throws AssemblyException { - // may expect version and class attribute but it not used in JDK + // may expect version and class attribute but it not used in JDK // so we do either return context; } diff --git a/libjava/classpath/gnu/java/beans/decoder/LongHandler.java b/libjava/classpath/gnu/java/beans/decoder/LongHandler.java index d7bfa54..13e0a8d 100644 --- a/libjava/classpath/gnu/java/beans/decoder/LongHandler.java +++ b/libjava/classpath/gnu/java/beans/decoder/LongHandler.java @@ -7,7 +7,7 @@ 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 diff --git a/libjava/classpath/gnu/java/beans/decoder/MethodContext.java b/libjava/classpath/gnu/java/beans/decoder/MethodContext.java index bad0a21..84eead7 100644 --- a/libjava/classpath/gnu/java/beans/decoder/MethodContext.java +++ b/libjava/classpath/gnu/java/beans/decoder/MethodContext.java @@ -7,7 +7,7 @@ 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 diff --git a/libjava/classpath/gnu/java/beans/decoder/MethodFinder.java b/libjava/classpath/gnu/java/beans/decoder/MethodFinder.java index 3968b17..82783fb 100644 --- a/libjava/classpath/gnu/java/beans/decoder/MethodFinder.java +++ b/libjava/classpath/gnu/java/beans/decoder/MethodFinder.java @@ -7,7 +7,7 @@ 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 @@ -43,135 +43,135 @@ import java.util.HashMap; class MethodFinder { - /** Provides a mapping between a wrapper class and its corresponding primitive's type. */ - private static HashMap typeMapping = new HashMap(); - - static { - typeMapping.put(Byte.class, Byte.TYPE); - typeMapping.put(Short.class, Short.TYPE); - typeMapping.put(Integer.class, Integer.TYPE); - typeMapping.put(Long.class, Long.TYPE); - typeMapping.put(Float.class, Float.TYPE); - typeMapping.put(Double.class, Double.TYPE); - - typeMapping.put(Character.class, Character.TYPE); - typeMapping.put(Boolean.class, Boolean.TYPE); - } - - private MethodFinder() - { - } - - /** Searches a Method which can accept the given arguments. - * - * @param klass - * @param name - * @param arguments - * @return - * @throws NoSuchMethodException - */ - static Method getMethod(Class klass, String name, Object[] arguments) - throws NoSuchMethodException - { - // prepares array containing the types of the arguments - Class[] argumentTypes = getArgumentTypes(arguments); - - Method[] methods = klass.getMethods(); - - // iterates over all public methods - for (int i = 0; i < methods.length; i++) - { - if (methods[i].getName().equals(name)) - { - if (matchingArgumentTypes(methods[i].getParameterTypes(), - argumentTypes)) - return methods[i]; - } - } - - throw new NoSuchMethodException( - "Could not find a matching method named " - + name - + "() in class " - + klass); - } - - static Constructor getConstructor(Class klass, Object[] arguments) - throws NoSuchMethodException - { - Class[] argumentTypes = getArgumentTypes(arguments); - Constructor[] constructors = klass.getConstructors(); - - // iterates over all public methods - for (int i = 0; i < constructors.length; i++) - { - if (matchingArgumentTypes(constructors[i].getParameterTypes(), - argumentTypes)) - return constructors[i]; - } - - throw new NoSuchMethodException( - "Could not find a matching constructor in class " + klass); - } - - /** Transforms an array of argument objects into an array of argument types. - * For each argument being null the argument is null, too. An argument type - * being null means: Accepts everything (although this can be ambigous). - * - * @param arguments - * @return - */ - private static Class[] getArgumentTypes(Object[] arguments) - { - if (arguments == null) - return new Class[0]; - - // prepares array containing the types of the arguments - Class[] argumentTypes = new Class[arguments.length]; - for (int i = 0; i < arguments.length; i++) - argumentTypes[i] = - (arguments[i] == null) ? null : arguments[i].getClass(); - return argumentTypes; - } - - /** Tests whether the argument types supplied to the method argument types - * are assignable. In addition to the assignment specifications this method - * handles the primitive's wrapper classes as if they were of their - * primitive type (e.g Boolean.class equals Boolean.TYPE). - * When a supplied argument type is null it is assumed that no argument - * object was supplied for it and the test for this particular parameter will - * pass. - * - * @param methodArgTypes - * @param suppliedArgTypes - * @return - */ - private static boolean matchingArgumentTypes( - Class[] methodArgTypes, - Class[] suppliedArgTypes) - { - if (methodArgTypes.length != suppliedArgTypes.length) - return false; - - for (int i = 0; i < methodArgTypes.length; i++) - { - if (suppliedArgTypes[i] == null) - { - // by definition a non-existant argument type (null) can be converted to everything - continue; - } - else if (typeMapping.containsKey(suppliedArgTypes[i])) - { - Class primitiveType = - (Class) typeMapping.get(suppliedArgTypes[i]); - if (!(methodArgTypes[i].isAssignableFrom(suppliedArgTypes[i]) - || methodArgTypes[i].isAssignableFrom(primitiveType))) - return false; - } - else if (!methodArgTypes[i].isAssignableFrom(suppliedArgTypes[i])) - return false; - } - - return true; - } + /** Provides a mapping between a wrapper class and its corresponding primitive's type. */ + private static HashMap typeMapping = new HashMap(); + + static { + typeMapping.put(Byte.class, Byte.TYPE); + typeMapping.put(Short.class, Short.TYPE); + typeMapping.put(Integer.class, Integer.TYPE); + typeMapping.put(Long.class, Long.TYPE); + typeMapping.put(Float.class, Float.TYPE); + typeMapping.put(Double.class, Double.TYPE); + + typeMapping.put(Character.class, Character.TYPE); + typeMapping.put(Boolean.class, Boolean.TYPE); + } + + private MethodFinder() + { + } + + /** Searches a Method which can accept the given arguments. + * + * @param klass + * @param name + * @param arguments + * @return + * @throws NoSuchMethodException + */ + static Method getMethod(Class klass, String name, Object[] arguments) + throws NoSuchMethodException + { + // prepares array containing the types of the arguments + Class[] argumentTypes = getArgumentTypes(arguments); + + Method[] methods = klass.getMethods(); + + // iterates over all public methods + for (int i = 0; i < methods.length; i++) + { + if (methods[i].getName().equals(name)) + { + if (matchingArgumentTypes(methods[i].getParameterTypes(), + argumentTypes)) + return methods[i]; + } + } + + throw new NoSuchMethodException( + "Could not find a matching method named " + + name + + "() in class " + + klass); + } + + static Constructor getConstructor(Class klass, Object[] arguments) + throws NoSuchMethodException + { + Class[] argumentTypes = getArgumentTypes(arguments); + Constructor[] constructors = klass.getConstructors(); + + // iterates over all public methods + for (int i = 0; i < constructors.length; i++) + { + if (matchingArgumentTypes(constructors[i].getParameterTypes(), + argumentTypes)) + return constructors[i]; + } + + throw new NoSuchMethodException( + "Could not find a matching constructor in class " + klass); + } + + /** Transforms an array of argument objects into an array of argument types. + * For each argument being null the argument is null, too. An argument type + * being null means: Accepts everything (although this can be ambigous). + * + * @param arguments + * @return + */ + private static Class[] getArgumentTypes(Object[] arguments) + { + if (arguments == null) + return new Class[0]; + + // prepares array containing the types of the arguments + Class[] argumentTypes = new Class[arguments.length]; + for (int i = 0; i < arguments.length; i++) + argumentTypes[i] = + (arguments[i] == null) ? null : arguments[i].getClass(); + return argumentTypes; + } + + /** Tests whether the argument types supplied to the method argument types + * are assignable. In addition to the assignment specifications this method + * handles the primitive's wrapper classes as if they were of their + * primitive type (e.g Boolean.class equals Boolean.TYPE). + * When a supplied argument type is null it is assumed that no argument + * object was supplied for it and the test for this particular parameter will + * pass. + * + * @param methodArgTypes + * @param suppliedArgTypes + * @return + */ + private static boolean matchingArgumentTypes( + Class[] methodArgTypes, + Class[] suppliedArgTypes) + { + if (methodArgTypes.length != suppliedArgTypes.length) + return false; + + for (int i = 0; i < methodArgTypes.length; i++) + { + if (suppliedArgTypes[i] == null) + { + // by definition a non-existant argument type (null) can be converted to everything + continue; + } + else if (typeMapping.containsKey(suppliedArgTypes[i])) + { + Class primitiveType = + (Class) typeMapping.get(suppliedArgTypes[i]); + if (!(methodArgTypes[i].isAssignableFrom(suppliedArgTypes[i]) + || methodArgTypes[i].isAssignableFrom(primitiveType))) + return false; + } + else if (!methodArgTypes[i].isAssignableFrom(suppliedArgTypes[i])) + return false; + } + + return true; + } } diff --git a/libjava/classpath/gnu/java/beans/decoder/NullHandler.java b/libjava/classpath/gnu/java/beans/decoder/NullHandler.java index 549617d..01c9727 100644 --- a/libjava/classpath/gnu/java/beans/decoder/NullHandler.java +++ b/libjava/classpath/gnu/java/beans/decoder/NullHandler.java @@ -7,7 +7,7 @@ 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 diff --git a/libjava/classpath/gnu/java/beans/decoder/ObjectContext.java b/libjava/classpath/gnu/java/beans/decoder/ObjectContext.java index cf88a2c..883c1d6 100644 --- a/libjava/classpath/gnu/java/beans/decoder/ObjectContext.java +++ b/libjava/classpath/gnu/java/beans/decoder/ObjectContext.java @@ -7,7 +7,7 @@ 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 diff --git a/libjava/classpath/gnu/java/beans/decoder/ObjectHandler.java b/libjava/classpath/gnu/java/beans/decoder/ObjectHandler.java index dc5b329..ececfbb 100644 --- a/libjava/classpath/gnu/java/beans/decoder/ObjectHandler.java +++ b/libjava/classpath/gnu/java/beans/decoder/ObjectHandler.java @@ -7,7 +7,7 @@ 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 @@ -90,78 +90,78 @@ public class ObjectHandler extends AbstractElementHandler // decides whether we are in a static (className present) or dynamic context if (className != null) { - try - { - Class klass = instantiateClass(className); - - // class name exists which means that we are in a static context. - // so we may want to ... - // access a static field if the fieldName exists - if (fieldName != null) - { - try - { - return new ObjectContext(id, - klass.getField(fieldName).get(null)); - } - catch (NoSuchFieldException nsfe) - { - throw new AssemblyException(nsfe); - } - catch (IllegalAccessException iae) - { - throw new AssemblyException(iae); - } - } - - // (falling through is important!) - // run a constructor if methodName is "new" or null - if (methodName == null || methodName.equals("new")) - return new ConstructorContext(id, klass); - - // (falling through is important!) - // run a static method on the given class (if methodName exists, which is implied already) - return new StaticMethodContext(id, klass, methodName); - // XXX: should fail if unexpected attributes are present? - } - catch (ClassNotFoundException cnfe) - { - throw new AssemblyException(cnfe); - } + try + { + Class klass = instantiateClass(className); + + // class name exists which means that we are in a static context. + // so we may want to ... + // access a static field if the fieldName exists + if (fieldName != null) + { + try + { + return new ObjectContext(id, + klass.getField(fieldName).get(null)); + } + catch (NoSuchFieldException nsfe) + { + throw new AssemblyException(nsfe); + } + catch (IllegalAccessException iae) + { + throw new AssemblyException(iae); + } + } + + // (falling through is important!) + // run a constructor if methodName is "new" or null + if (methodName == null || methodName.equals("new")) + return new ConstructorContext(id, klass); + + // (falling through is important!) + // run a static method on the given class (if methodName exists, which is implied already) + return new StaticMethodContext(id, klass, methodName); + // XXX: should fail if unexpected attributes are present? + } + catch (ClassNotFoundException cnfe) + { + throw new AssemblyException(cnfe); + } } else { - // className does not exist which means we are in the context of - // some object and want to ... - // access the get(int index) method if index != null - if (index != null) - { - try - { - // Note: http://java.sun.com/products/jfc/tsc/articles/persistence3/ says - // that <void index="4"/> will make up a get()-call. But this is wrong because - // <void/> tags never return values (to the surrounding context) - return new IndexContext(id, Integer.parseInt(index)); - } - catch (NumberFormatException nfe) - { - throw new AssemblyException(nfe); - } - } - - // access a method if methodName exists - if (methodName != null) - return new MethodContext(id, methodName); - - // (falling through is important!) - // access a property if a propertyName exists - if (propertyName != null && propertyName.length() > 0) - // this is reported as an ordinary method access where the propertyName is - // converted into a 'getter'-method name: convert first character of property name - // to upper case and prepend 'get' - // Note: This will be a getter-method because the <object> tag implies that a return - // value is expected. - return new PropertyContext(id, propertyName); + // className does not exist which means we are in the context of + // some object and want to ... + // access the get(int index) method if index != null + if (index != null) + { + try + { + // Note: http://java.sun.com/products/jfc/tsc/articles/persistence3/ says + // that <void index="4"/> will make up a get()-call. But this is wrong because + // <void/> tags never return values (to the surrounding context) + return new IndexContext(id, Integer.parseInt(index)); + } + catch (NumberFormatException nfe) + { + throw new AssemblyException(nfe); + } + } + + // access a method if methodName exists + if (methodName != null) + return new MethodContext(id, methodName); + + // (falling through is important!) + // access a property if a propertyName exists + if (propertyName != null && propertyName.length() > 0) + // this is reported as an ordinary method access where the propertyName is + // converted into a 'getter'-method name: convert first character of property name + // to upper case and prepend 'get' + // Note: This will be a getter-method because the <object> tag implies that a return + // value is expected. + return new PropertyContext(id, propertyName); } throw new AssemblyException(new IllegalArgumentException("Wrong or missing attributes for <object> tag.")); diff --git a/libjava/classpath/gnu/java/beans/decoder/PersistenceParser.java b/libjava/classpath/gnu/java/beans/decoder/PersistenceParser.java index 4eb37ab..c4c8866 100644 --- a/libjava/classpath/gnu/java/beans/decoder/PersistenceParser.java +++ b/libjava/classpath/gnu/java/beans/decoder/PersistenceParser.java @@ -62,424 +62,424 @@ import org.xml.sax.helpers.DefaultHandler; */ public class PersistenceParser extends DefaultHandler implements Context { - /** The ExceptionListener instance which is informed of non-critical parsing exceptions. - */ - private ExceptionListener exceptionListener; - - /** When an element was not usable all elements inside it should be skipped. - * This is done by skipping startElement() and endElement() invocations whenever - * this value is above 0. - */ - private int skipElement; - - /** Stores the Creator instances which can instantiate the appropriate handler implementation - * for a given element. - */ - private HashMap handlerCreators = new HashMap(); - - /** Denotes the current ElementHandler. To avoid checking for null-values it is pre-assigned - * with a DummyHandler instance which must not be used but acts as a root element. - */ - private ElementHandler currentHandler; - - /** The real root element that stores all objects created during parsing. - * Package-private to avoid an accessor method. - */ - JavaHandler javaHandler; - - /** Stores the decoded objects. */ - private List objects = new LinkedList(); - - /** The XMLDecoder instance that started this PersistenceParser */ - private XMLDecoder decoder; - - /** Creates a PersistenceParser which reads XML data from the given InputStream, reports - * exceptions to ExceptionListener instance, stores resulting object in the DecoderContext - * and uses the given ClassLoader to resolve classes. - * - * @param inputStream - * @param exceptionListener - * @param decoderContext - * @param cl - */ - public PersistenceParser( - InputStream inputStream, - ExceptionListener exceptionListener, - ClassLoader cl, - XMLDecoder decoder) - { - - this.exceptionListener = exceptionListener; - this.decoder = decoder; - - DummyHandler dummyHandler = new DummyHandler(); - currentHandler = dummyHandler; - javaHandler = new JavaHandler(dummyHandler, this, cl); - - SAXParserFactory factory = SAXParserFactory.newInstance(); - - SAXParser parser; - try - { - parser = factory.newSAXParser(); - } - catch (ParserConfigurationException pce) - { - // should not happen when a parser is available because we did - // not request any requirements on the XML parser - throw (InternalError) new InternalError( - "No SAX Parser available.").initCause( - pce); - } - catch (SAXException saxe) - { - // should not happen when a parser is available because we did - // not request any requirements on the XML parser - throw (InternalError) new InternalError( - "No SAX Parser available.").initCause( - saxe); - } - - // prepares a map of Creator instances which can instantiate a handler which is - // appropriate for the tag that is used as a key for the Creator - handlerCreators.put("java", new JavaHandlerCreator()); - - // calls methods (properties), constructors, access fields - handlerCreators.put("object", new ObjectHandlerCreator()); - handlerCreators.put("void", new VoidHandlerCreator()); - - handlerCreators.put("array", new ArrayHandlerCreator()); - - // these handler directly create an Object (or null) - handlerCreators.put("class", new ClassHandlerCreator()); - handlerCreators.put("null", new NullHandlerCreator()); - - handlerCreators.put("char", new CharHandlerCreator()); - handlerCreators.put("string", new StringHandlerCreator()); - handlerCreators.put("boolean", new BooleanHandlerCreator()); - handlerCreators.put("byte", new ByteHandlerCreator()); - handlerCreators.put("short", new ShortHandlerCreator()); - handlerCreators.put("int", new IntHandlerCreator()); - handlerCreators.put("long", new LongHandlerCreator()); - handlerCreators.put("float", new FloatHandlerCreator()); - handlerCreators.put("double", new DoubleHandlerCreator()); - - // parses the data and sends all exceptions to the ExceptionListener - try - { - parser.parse(inputStream, this); - } - catch (SAXException saxe) - { - exceptionListener.exceptionThrown( - new IllegalArgumentException("XML data not well-formed.")); - } - catch (IOException ioe) - { - exceptionListener.exceptionThrown(ioe); - } - } - - public void startElement( - String uri, - String localName, - String qName, - Attributes attributes) - throws SAXException - { - /* The element is skipped if - * a) the current handler has already failed or a previous error occured - * which makes all children obsolete - */ - if (currentHandler.hasFailed() || skipElement > 0) - { - exceptionListener.exceptionThrown( - new IllegalArgumentException( - "Element unusable due to previous error: " + qName)); - - skipElement++; - - return; - } - - /* b) Subelements are not allowed within the current ElementHandler. - */ - if (!currentHandler.isSubelementAllowed(qName)) - { - exceptionListener.exceptionThrown( - new IllegalArgumentException( - "Element is not allowed here: " + qName)); - - skipElement++; - - return; - } - - /* c) The tag name is not a key in the map of Creator instances. This means that - * either the XML data is of a newer version or simply contains a miss-spelled element. - */ - if (!handlerCreators.containsKey(qName)) - { - exceptionListener.exceptionThrown( - new IllegalArgumentException( - "Element unusable because tag is unknown: " + qName)); - - skipElement++; - - return; - } - - // creates a new handler for the new element - AbstractElementHandler handler = - ((Creator) handlerCreators.get(qName)).createHandler( - currentHandler); - - // makes it the current handler to receive character data - currentHandler = handler; - - // starts the handler - currentHandler.start(attributes, exceptionListener); - } - - public void endElement(String uri, String localName, String qName) - throws SAXException - { - // skips processing the current handler if we are parsing an element - // which was marked invalid (in startElement() ) - if (skipElement > 0) - { - skipElement--; - return; - } - - // invokes the handler's finishing method - currentHandler.end(exceptionListener); - - // removes the current handler and reactivates its parent - currentHandler = currentHandler.getParent(); - } - - /** Transfers character data to the current handler - */ - public void characters(char[] ch, int start, int length) - throws SAXException - { - // prevents sending character data of invalid elements - if (skipElement > 0) - return; - - currentHandler.characters(ch, start, length); - } - - /** Creator interface provided a mechanism to instantiate ElementHandler instances - * for the appropriate tag. - * - * @author Robert Schuster - */ - interface Creator - { - /** Creates an ElementHandler instance using the given ElementHandler as its parent. - * - * @param parent The parent ElementHandler of the result. - * @return A new ElementHandler instance. - */ - AbstractElementHandler createHandler(ElementHandler parent); - } - - class BooleanHandlerCreator implements Creator - { - public AbstractElementHandler createHandler(ElementHandler parent) - { - return new BooleanHandler(parent); - } - } - - class ByteHandlerCreator implements Creator - { - public AbstractElementHandler createHandler(ElementHandler parent) - { - return new ByteHandler(parent); - } - } - - class ShortHandlerCreator implements Creator - { - public AbstractElementHandler createHandler(ElementHandler parent) - { - return new ShortHandler(parent); - } - } - - class IntHandlerCreator implements Creator - { - public AbstractElementHandler createHandler(ElementHandler parent) - { - return new IntHandler(parent); - } - } - - class LongHandlerCreator implements Creator - { - public AbstractElementHandler createHandler(ElementHandler parent) - { - return new LongHandler(parent); - } - } - - class FloatHandlerCreator implements Creator - { - public AbstractElementHandler createHandler(ElementHandler parent) - { - return new FloatHandler(parent); - } - } - - class DoubleHandlerCreator implements Creator - { - public AbstractElementHandler createHandler(ElementHandler parent) - { - return new DoubleHandler(parent); - } - } - - class CharHandlerCreator implements Creator - { - public AbstractElementHandler createHandler(ElementHandler parent) - { - return new CharHandler(parent); - } - } - - class StringHandlerCreator implements Creator - { - public AbstractElementHandler createHandler(ElementHandler parent) - { - return new StringHandler(parent); - } - } - - class JavaHandlerCreator implements Creator - { - public AbstractElementHandler createHandler(ElementHandler parent) - { - return javaHandler; - } - } - - class ObjectHandlerCreator implements Creator - { - public AbstractElementHandler createHandler(ElementHandler parent) - { - return new ObjectHandler(parent); - } - } - - class VoidHandlerCreator implements Creator - { - public AbstractElementHandler createHandler(ElementHandler parent) - { - return new VoidHandler(parent); - } - } - - class ClassHandlerCreator implements Creator - { - public AbstractElementHandler createHandler(ElementHandler parent) - { - return new ClassHandler(parent); - } - } - - class NullHandlerCreator implements Creator - { - public AbstractElementHandler createHandler(ElementHandler parent) - { - return new NullHandler(parent); - } - } - - class ArrayHandlerCreator implements Creator - { - public AbstractElementHandler createHandler(ElementHandler parent) - { - return new ArrayHandler(parent); - } - } - - /** Adds a decoded object to the Context. */ - public void addParameterObject(Object o) throws AssemblyException - { - objects.add(o); - } - - public void notifyStatement(Context outerContext) throws AssemblyException - { - // can be ignored because theis Context does not react to statement and expressions - // differently - } - - public Object endContext(Context outerContext) throws AssemblyException - { - return null; - } - - public boolean subContextFailed() - { - // failing of subcontexts is no problem for the mother of all contexts - return false; - } - - public void set(int index, Object o) throws AssemblyException - { - // not supported - throw new AssemblyException( - new IllegalArgumentException("Set method is not allowed in decoder context.")); - } - - public Object get(int index) throws AssemblyException - { - // not supported - throw new AssemblyException( - new IllegalArgumentException("Get method is not allowed in decoder context.")); - } - - public Object getResult() - { - // returns the XMLDecoder instance which is requested by child contexts this way. - // That is needed to invoke methods on the decoder. - return decoder; - } - - public void setId(String id) - { - exceptionListener.exceptionThrown(new IllegalArgumentException("id attribute is not allowed for <java> tag.")); - } - - public String getId() - { - // appears to have no id - return null; - } - - public boolean isStatement() - { - // this context is a statement by definition because it never returns anything to a parent because - // there is no such parent (DummyContext does not count!) - return true; - } - - public void setStatement(boolean b) - { - // ignores that because this Context is always a statement - } - - /** Returns an Iterator instance which returns the decoded objects. - * - * This method is used by the XMLDecoder directly. - */ - public Iterator iterator() - { - return objects.iterator(); - } + /** The ExceptionListener instance which is informed of non-critical parsing exceptions. + */ + private ExceptionListener exceptionListener; + + /** When an element was not usable all elements inside it should be skipped. + * This is done by skipping startElement() and endElement() invocations whenever + * this value is above 0. + */ + private int skipElement; + + /** Stores the Creator instances which can instantiate the appropriate handler implementation + * for a given element. + */ + private HashMap handlerCreators = new HashMap(); + + /** Denotes the current ElementHandler. To avoid checking for null-values it is pre-assigned + * with a DummyHandler instance which must not be used but acts as a root element. + */ + private ElementHandler currentHandler; + + /** The real root element that stores all objects created during parsing. + * Package-private to avoid an accessor method. + */ + JavaHandler javaHandler; + + /** Stores the decoded objects. */ + private List objects = new LinkedList(); + + /** The XMLDecoder instance that started this PersistenceParser */ + private XMLDecoder decoder; + + /** Creates a PersistenceParser which reads XML data from the given InputStream, reports + * exceptions to ExceptionListener instance, stores resulting object in the DecoderContext + * and uses the given ClassLoader to resolve classes. + * + * @param inputStream + * @param exceptionListener + * @param decoderContext + * @param cl + */ + public PersistenceParser( + InputStream inputStream, + ExceptionListener exceptionListener, + ClassLoader cl, + XMLDecoder decoder) + { + + this.exceptionListener = exceptionListener; + this.decoder = decoder; + + DummyHandler dummyHandler = new DummyHandler(); + currentHandler = dummyHandler; + javaHandler = new JavaHandler(dummyHandler, this, cl); + + SAXParserFactory factory = SAXParserFactory.newInstance(); + + SAXParser parser; + try + { + parser = factory.newSAXParser(); + } + catch (ParserConfigurationException pce) + { + // should not happen when a parser is available because we did + // not request any requirements on the XML parser + throw (InternalError) new InternalError( + "No SAX Parser available.").initCause( + pce); + } + catch (SAXException saxe) + { + // should not happen when a parser is available because we did + // not request any requirements on the XML parser + throw (InternalError) new InternalError( + "No SAX Parser available.").initCause( + saxe); + } + + // prepares a map of Creator instances which can instantiate a handler which is + // appropriate for the tag that is used as a key for the Creator + handlerCreators.put("java", new JavaHandlerCreator()); + + // calls methods (properties), constructors, access fields + handlerCreators.put("object", new ObjectHandlerCreator()); + handlerCreators.put("void", new VoidHandlerCreator()); + + handlerCreators.put("array", new ArrayHandlerCreator()); + + // these handler directly create an Object (or null) + handlerCreators.put("class", new ClassHandlerCreator()); + handlerCreators.put("null", new NullHandlerCreator()); + + handlerCreators.put("char", new CharHandlerCreator()); + handlerCreators.put("string", new StringHandlerCreator()); + handlerCreators.put("boolean", new BooleanHandlerCreator()); + handlerCreators.put("byte", new ByteHandlerCreator()); + handlerCreators.put("short", new ShortHandlerCreator()); + handlerCreators.put("int", new IntHandlerCreator()); + handlerCreators.put("long", new LongHandlerCreator()); + handlerCreators.put("float", new FloatHandlerCreator()); + handlerCreators.put("double", new DoubleHandlerCreator()); + + // parses the data and sends all exceptions to the ExceptionListener + try + { + parser.parse(inputStream, this); + } + catch (SAXException saxe) + { + exceptionListener.exceptionThrown( + new IllegalArgumentException("XML data not well-formed.")); + } + catch (IOException ioe) + { + exceptionListener.exceptionThrown(ioe); + } + } + + public void startElement( + String uri, + String localName, + String qName, + Attributes attributes) + throws SAXException + { + /* The element is skipped if + * a) the current handler has already failed or a previous error occured + * which makes all children obsolete + */ + if (currentHandler.hasFailed() || skipElement > 0) + { + exceptionListener.exceptionThrown( + new IllegalArgumentException( + "Element unusable due to previous error: " + qName)); + + skipElement++; + + return; + } + + /* b) Subelements are not allowed within the current ElementHandler. + */ + if (!currentHandler.isSubelementAllowed(qName)) + { + exceptionListener.exceptionThrown( + new IllegalArgumentException( + "Element is not allowed here: " + qName)); + + skipElement++; + + return; + } + + /* c) The tag name is not a key in the map of Creator instances. This means that + * either the XML data is of a newer version or simply contains a miss-spelled element. + */ + if (!handlerCreators.containsKey(qName)) + { + exceptionListener.exceptionThrown( + new IllegalArgumentException( + "Element unusable because tag is unknown: " + qName)); + + skipElement++; + + return; + } + + // creates a new handler for the new element + AbstractElementHandler handler = + ((Creator) handlerCreators.get(qName)).createHandler( + currentHandler); + + // makes it the current handler to receive character data + currentHandler = handler; + + // starts the handler + currentHandler.start(attributes, exceptionListener); + } + + public void endElement(String uri, String localName, String qName) + throws SAXException + { + // skips processing the current handler if we are parsing an element + // which was marked invalid (in startElement() ) + if (skipElement > 0) + { + skipElement--; + return; + } + + // invokes the handler's finishing method + currentHandler.end(exceptionListener); + + // removes the current handler and reactivates its parent + currentHandler = currentHandler.getParent(); + } + + /** Transfers character data to the current handler + */ + public void characters(char[] ch, int start, int length) + throws SAXException + { + // prevents sending character data of invalid elements + if (skipElement > 0) + return; + + currentHandler.characters(ch, start, length); + } + + /** Creator interface provided a mechanism to instantiate ElementHandler instances + * for the appropriate tag. + * + * @author Robert Schuster + */ + interface Creator + { + /** Creates an ElementHandler instance using the given ElementHandler as its parent. + * + * @param parent The parent ElementHandler of the result. + * @return A new ElementHandler instance. + */ + AbstractElementHandler createHandler(ElementHandler parent); + } + + class BooleanHandlerCreator implements Creator + { + public AbstractElementHandler createHandler(ElementHandler parent) + { + return new BooleanHandler(parent); + } + } + + class ByteHandlerCreator implements Creator + { + public AbstractElementHandler createHandler(ElementHandler parent) + { + return new ByteHandler(parent); + } + } + + class ShortHandlerCreator implements Creator + { + public AbstractElementHandler createHandler(ElementHandler parent) + { + return new ShortHandler(parent); + } + } + + class IntHandlerCreator implements Creator + { + public AbstractElementHandler createHandler(ElementHandler parent) + { + return new IntHandler(parent); + } + } + + class LongHandlerCreator implements Creator + { + public AbstractElementHandler createHandler(ElementHandler parent) + { + return new LongHandler(parent); + } + } + + class FloatHandlerCreator implements Creator + { + public AbstractElementHandler createHandler(ElementHandler parent) + { + return new FloatHandler(parent); + } + } + + class DoubleHandlerCreator implements Creator + { + public AbstractElementHandler createHandler(ElementHandler parent) + { + return new DoubleHandler(parent); + } + } + + class CharHandlerCreator implements Creator + { + public AbstractElementHandler createHandler(ElementHandler parent) + { + return new CharHandler(parent); + } + } + + class StringHandlerCreator implements Creator + { + public AbstractElementHandler createHandler(ElementHandler parent) + { + return new StringHandler(parent); + } + } + + class JavaHandlerCreator implements Creator + { + public AbstractElementHandler createHandler(ElementHandler parent) + { + return javaHandler; + } + } + + class ObjectHandlerCreator implements Creator + { + public AbstractElementHandler createHandler(ElementHandler parent) + { + return new ObjectHandler(parent); + } + } + + class VoidHandlerCreator implements Creator + { + public AbstractElementHandler createHandler(ElementHandler parent) + { + return new VoidHandler(parent); + } + } + + class ClassHandlerCreator implements Creator + { + public AbstractElementHandler createHandler(ElementHandler parent) + { + return new ClassHandler(parent); + } + } + + class NullHandlerCreator implements Creator + { + public AbstractElementHandler createHandler(ElementHandler parent) + { + return new NullHandler(parent); + } + } + + class ArrayHandlerCreator implements Creator + { + public AbstractElementHandler createHandler(ElementHandler parent) + { + return new ArrayHandler(parent); + } + } + + /** Adds a decoded object to the Context. */ + public void addParameterObject(Object o) throws AssemblyException + { + objects.add(o); + } + + public void notifyStatement(Context outerContext) throws AssemblyException + { + // can be ignored because theis Context does not react to statement and expressions + // differently + } + + public Object endContext(Context outerContext) throws AssemblyException + { + return null; + } + + public boolean subContextFailed() + { + // failing of subcontexts is no problem for the mother of all contexts + return false; + } + + public void set(int index, Object o) throws AssemblyException + { + // not supported + throw new AssemblyException( + new IllegalArgumentException("Set method is not allowed in decoder context.")); + } + + public Object get(int index) throws AssemblyException + { + // not supported + throw new AssemblyException( + new IllegalArgumentException("Get method is not allowed in decoder context.")); + } + + public Object getResult() + { + // returns the XMLDecoder instance which is requested by child contexts this way. + // That is needed to invoke methods on the decoder. + return decoder; + } + + public void setId(String id) + { + exceptionListener.exceptionThrown(new IllegalArgumentException("id attribute is not allowed for <java> tag.")); + } + + public String getId() + { + // appears to have no id + return null; + } + + public boolean isStatement() + { + // this context is a statement by definition because it never returns anything to a parent because + // there is no such parent (DummyContext does not count!) + return true; + } + + public void setStatement(boolean b) + { + // ignores that because this Context is always a statement + } + + /** Returns an Iterator instance which returns the decoded objects. + * + * This method is used by the XMLDecoder directly. + */ + public Iterator iterator() + { + return objects.iterator(); + } } diff --git a/libjava/classpath/gnu/java/beans/decoder/PropertyContext.java b/libjava/classpath/gnu/java/beans/decoder/PropertyContext.java index 838ef81..15751cd 100644 --- a/libjava/classpath/gnu/java/beans/decoder/PropertyContext.java +++ b/libjava/classpath/gnu/java/beans/decoder/PropertyContext.java @@ -7,7 +7,7 @@ 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 @@ -74,7 +74,7 @@ class PropertyContext extends AbstractObjectContext throw new AssemblyException(new IllegalArgumentException("Property attribut allows zero or one argument only.")); argument = o; - setStatement(true); + setStatement(true); prefix = "set"; } @@ -91,8 +91,8 @@ class PropertyContext extends AbstractObjectContext if (outerObject == null) throw new AssemblyException(new NullPointerException("No object to access property " - + propertyName)); - + + propertyName)); + // converts property name into a method name String methodName = prefix + propertyName.substring(0, 1).toUpperCase() @@ -103,23 +103,23 @@ class PropertyContext extends AbstractObjectContext try { - Method method = MethodFinder.getMethod(outerObject.getClass(), - methodName, args); + Method method = MethodFinder.getMethod(outerObject.getClass(), + methodName, args); - // stores the result whether it is available or not - setObject(method.invoke(outerObject, args)); + // stores the result whether it is available or not + setObject(method.invoke(outerObject, args)); } catch (NoSuchMethodException nsme) { - throw new AssemblyException(nsme); + throw new AssemblyException(nsme); } catch (InvocationTargetException ite) { - throw new AssemblyException(ite.getCause()); + throw new AssemblyException(ite.getCause()); } catch (IllegalAccessException iae) { - throw new AssemblyException(iae); + throw new AssemblyException(iae); } } diff --git a/libjava/classpath/gnu/java/beans/decoder/ShortHandler.java b/libjava/classpath/gnu/java/beans/decoder/ShortHandler.java index ab6ddbe..c5de50a 100644 --- a/libjava/classpath/gnu/java/beans/decoder/ShortHandler.java +++ b/libjava/classpath/gnu/java/beans/decoder/ShortHandler.java @@ -7,7 +7,7 @@ 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 diff --git a/libjava/classpath/gnu/java/beans/decoder/SimpleHandler.java b/libjava/classpath/gnu/java/beans/decoder/SimpleHandler.java index bc187e8..1c43bb0 100644 --- a/libjava/classpath/gnu/java/beans/decoder/SimpleHandler.java +++ b/libjava/classpath/gnu/java/beans/decoder/SimpleHandler.java @@ -7,7 +7,7 @@ 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 @@ -65,7 +65,7 @@ abstract class SimpleHandler extends AbstractElementHandler protected final Context startElement(Attributes attributes, ExceptionListener exceptionListener) throws AssemblyException { - + // note: simple elements should not have any attributes. We inform // the user of this syntactical but uncritical problem by sending // an IllegalArgumentException for each unneccessary attribute @@ -79,7 +79,7 @@ abstract class SimpleHandler extends AbstractElementHandler + "' discarded."); exceptionListener.exceptionThrown(e); } - + return context = new ObjectContext(); } @@ -89,11 +89,11 @@ abstract class SimpleHandler extends AbstractElementHandler // reports the number when the character data can be parsed try { - context.setObject(parse(characters)); + context.setObject(parse(characters)); } catch (NumberFormatException nfe) { - throw new AssemblyException(nfe); + throw new AssemblyException(nfe); } } diff --git a/libjava/classpath/gnu/java/beans/decoder/StaticMethodContext.java b/libjava/classpath/gnu/java/beans/decoder/StaticMethodContext.java index 959c949..b2cf0e6 100644 --- a/libjava/classpath/gnu/java/beans/decoder/StaticMethodContext.java +++ b/libjava/classpath/gnu/java/beans/decoder/StaticMethodContext.java @@ -7,7 +7,7 @@ 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 @@ -75,21 +75,21 @@ class StaticMethodContext extends AbstractCreatableObjectContext try { - Method method = MethodFinder.getMethod(klass, methodName, args); - return method.invoke(null, args); + Method method = MethodFinder.getMethod(klass, methodName, args); + return method.invoke(null, args); } catch (NoSuchMethodException nsme) { - throw new AssemblyException(nsme); + throw new AssemblyException(nsme); } catch (InvocationTargetException ite) { - // rethrows the reason for the InvocationTargetsException (ie. the exception in the called code) - throw new AssemblyException(ite.getCause()); + // rethrows the reason for the InvocationTargetsException (ie. the exception in the called code) + throw new AssemblyException(ite.getCause()); } catch (IllegalAccessException iae) { - throw new AssemblyException(iae); + throw new AssemblyException(iae); } } } diff --git a/libjava/classpath/gnu/java/beans/decoder/StringHandler.java b/libjava/classpath/gnu/java/beans/decoder/StringHandler.java index 6f2311a..97fc57e 100644 --- a/libjava/classpath/gnu/java/beans/decoder/StringHandler.java +++ b/libjava/classpath/gnu/java/beans/decoder/StringHandler.java @@ -7,7 +7,7 @@ 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 diff --git a/libjava/classpath/gnu/java/beans/decoder/VoidHandler.java b/libjava/classpath/gnu/java/beans/decoder/VoidHandler.java index ca3664b..56f3156 100644 --- a/libjava/classpath/gnu/java/beans/decoder/VoidHandler.java +++ b/libjava/classpath/gnu/java/beans/decoder/VoidHandler.java @@ -7,7 +7,7 @@ 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 @@ -86,7 +86,7 @@ public class VoidHandler extends AbstractElementHandler return new ConstructorContext(id, klass); // (falling through is important!) - // run a static method on the given class (if methodName exists, which is implied already) + // run a static method on the given class (if methodName exists, which is implied already) return new StaticMethodContext(id, klass, methodName); } catch (ClassNotFoundException cnfe) diff --git a/libjava/classpath/gnu/java/beans/editors/ColorEditor.java b/libjava/classpath/gnu/java/beans/editors/ColorEditor.java index b099eb2..cb69344 100644 --- a/libjava/classpath/gnu/java/beans/editors/ColorEditor.java +++ b/libjava/classpath/gnu/java/beans/editors/ColorEditor.java @@ -7,7 +7,7 @@ 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 @@ -50,51 +50,51 @@ import java.beans.PropertyEditorSupport; **/ 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"}; + 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))); - } - } + /** 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); - } + /** 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; - } + /** getTags for Color returns a list of standard colors. **/ + public String[] getTags() { + return stdColorNames; + } } diff --git a/libjava/classpath/gnu/java/beans/editors/FontEditor.java b/libjava/classpath/gnu/java/beans/editors/FontEditor.java index 904f7be..dfccb4e 100644 --- a/libjava/classpath/gnu/java/beans/editors/FontEditor.java +++ b/libjava/classpath/gnu/java/beans/editors/FontEditor.java @@ -7,7 +7,7 @@ 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 @@ -52,26 +52,26 @@ import java.beans.PropertyEditorSupport; **/ public class FontEditor extends PropertyEditorSupport { - /** setAsText for Font calls Font.decode(). **/ - public void setAsText(String val) throws IllegalArgumentException { - setValue(Font.decode(val)); - } + /** 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(); - } - } + /** 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/classpath/gnu/java/beans/editors/NativeBooleanEditor.java b/libjava/classpath/gnu/java/beans/editors/NativeBooleanEditor.java index 3620cc1..1df9489 100644 --- a/libjava/classpath/gnu/java/beans/editors/NativeBooleanEditor.java +++ b/libjava/classpath/gnu/java/beans/editors/NativeBooleanEditor.java @@ -7,7 +7,7 @@ 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 @@ -52,25 +52,25 @@ import java.beans.PropertyEditorSupport; **/ public class NativeBooleanEditor extends PropertyEditorSupport { - String[] tags = {"true","false"}; + 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.TRUE); - } else if(val.equalsIgnoreCase("false") || val.equalsIgnoreCase("f") || val.equals("")) { - setValue(Boolean.FALSE); - } else { - throw new IllegalArgumentException("Value must be true, false, t, f or empty."); - } - } + /** + * 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.TRUE); + } else if(val.equalsIgnoreCase("false") || val.equalsIgnoreCase("f") || val.equals("")) { + setValue(Boolean.FALSE); + } 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(); - } + /** getAsText for boolean calls Boolean.toString(). **/ + public String getAsText() { + return getValue().toString(); + } } diff --git a/libjava/classpath/gnu/java/beans/editors/NativeByteEditor.java b/libjava/classpath/gnu/java/beans/editors/NativeByteEditor.java index f3ec5fa..d427a9e 100644 --- a/libjava/classpath/gnu/java/beans/editors/NativeByteEditor.java +++ b/libjava/classpath/gnu/java/beans/editors/NativeByteEditor.java @@ -7,7 +7,7 @@ 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 @@ -49,13 +49,13 @@ import java.beans.PropertyEditorSupport; **/ 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(); - } + /** 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/classpath/gnu/java/beans/editors/NativeDoubleEditor.java b/libjava/classpath/gnu/java/beans/editors/NativeDoubleEditor.java index 8d8aae1..aa229fa 100644 --- a/libjava/classpath/gnu/java/beans/editors/NativeDoubleEditor.java +++ b/libjava/classpath/gnu/java/beans/editors/NativeDoubleEditor.java @@ -7,7 +7,7 @@ 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 @@ -49,13 +49,13 @@ import java.beans.PropertyEditorSupport; **/ 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(); - } + /** 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/classpath/gnu/java/beans/editors/NativeFloatEditor.java b/libjava/classpath/gnu/java/beans/editors/NativeFloatEditor.java index 801377e..09f9d6b 100644 --- a/libjava/classpath/gnu/java/beans/editors/NativeFloatEditor.java +++ b/libjava/classpath/gnu/java/beans/editors/NativeFloatEditor.java @@ -7,7 +7,7 @@ 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 @@ -49,13 +49,13 @@ import java.beans.PropertyEditorSupport; **/ 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(); - } + /** 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/classpath/gnu/java/beans/editors/NativeIntEditor.java b/libjava/classpath/gnu/java/beans/editors/NativeIntEditor.java index a614884..28b6a67 100644 --- a/libjava/classpath/gnu/java/beans/editors/NativeIntEditor.java +++ b/libjava/classpath/gnu/java/beans/editors/NativeIntEditor.java @@ -7,7 +7,7 @@ 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 @@ -49,13 +49,13 @@ import java.beans.PropertyEditorSupport; **/ 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(); - } + /** 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/classpath/gnu/java/beans/editors/NativeLongEditor.java b/libjava/classpath/gnu/java/beans/editors/NativeLongEditor.java index 95e9dc8..77223fb 100644 --- a/libjava/classpath/gnu/java/beans/editors/NativeLongEditor.java +++ b/libjava/classpath/gnu/java/beans/editors/NativeLongEditor.java @@ -7,7 +7,7 @@ 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 @@ -49,13 +49,13 @@ import java.beans.PropertyEditorSupport; **/ 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(); - } + /** 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/classpath/gnu/java/beans/editors/NativeShortEditor.java b/libjava/classpath/gnu/java/beans/editors/NativeShortEditor.java index ffaa266..1d8845b 100644 --- a/libjava/classpath/gnu/java/beans/editors/NativeShortEditor.java +++ b/libjava/classpath/gnu/java/beans/editors/NativeShortEditor.java @@ -7,7 +7,7 @@ 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 @@ -49,13 +49,13 @@ import java.beans.PropertyEditorSupport; **/ 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(); - } + /** 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/classpath/gnu/java/beans/editors/StringEditor.java b/libjava/classpath/gnu/java/beans/editors/StringEditor.java index 8242d54..47fdce6 100644 --- a/libjava/classpath/gnu/java/beans/editors/StringEditor.java +++ b/libjava/classpath/gnu/java/beans/editors/StringEditor.java @@ -7,7 +7,7 @@ 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 @@ -49,13 +49,13 @@ import java.beans.PropertyEditorSupport; **/ 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(); - } + /** 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/classpath/gnu/java/beans/encoder/ArrayPersistenceDelegate.java b/libjava/classpath/gnu/java/beans/encoder/ArrayPersistenceDelegate.java index 12d757e..52fc457 100644 --- a/libjava/classpath/gnu/java/beans/encoder/ArrayPersistenceDelegate.java +++ b/libjava/classpath/gnu/java/beans/encoder/ArrayPersistenceDelegate.java @@ -7,7 +7,7 @@ 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 @@ -92,12 +92,12 @@ public class ArrayPersistenceDelegate extends PersistenceDelegate // Compares the array value against a prototypical // null value of the array's component type in order to skip // writing the default values of an array. - + // Note: I have no idea why the persistence delegate for arrays writes // an Expression that reads the value and then writes a Statement that sets // the value. However it turned out that object arrays work better with the // get-Expression and primitive array work fine with the set-Statement. - + type = type.getComponentType(); if (type.isPrimitive()) { @@ -113,7 +113,7 @@ public class ArrayPersistenceDelegate extends PersistenceDelegate new Object[] { oldInstance, Integer.valueOf(i), })); - + out.writeStatement(new Statement(Array.class, "set", new Object[] { oldInstance, @@ -122,7 +122,7 @@ public class ArrayPersistenceDelegate extends PersistenceDelegate })); } } - + } else { @@ -130,14 +130,14 @@ public class ArrayPersistenceDelegate extends PersistenceDelegate for (int i = 0; i < length; i++) { Object oldValue = Array.get(oldInstance, i); - + if (oldValue != null) { out.writeExpression(new Expression(Array.class, "get", new Object[] { oldInstance, Integer.valueOf(i), })); - + out.writeStatement(new Statement(Array.class, "set", new Object[] { oldInstance, @@ -147,7 +147,7 @@ public class ArrayPersistenceDelegate extends PersistenceDelegate } } } - + } } diff --git a/libjava/classpath/gnu/java/beans/encoder/ClassPersistenceDelegate.java b/libjava/classpath/gnu/java/beans/encoder/ClassPersistenceDelegate.java index 7b0656a..1430a6d 100644 --- a/libjava/classpath/gnu/java/beans/encoder/ClassPersistenceDelegate.java +++ b/libjava/classpath/gnu/java/beans/encoder/ClassPersistenceDelegate.java @@ -7,7 +7,7 @@ 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 @@ -43,7 +43,7 @@ import java.beans.PersistenceDelegate; /** <p>The <code>ClassPersistenceDelegate</code> creates * <code>Expression</code> instances which denote class resolutions.</p> - * + * * <p>The class resolution is always the last step when serializing a tree * of objects. Due to the recursive nature of the algorithm we need a way * to end the recursion. This is achieved by the implementation of this @@ -52,8 +52,8 @@ import java.beans.PersistenceDelegate; * we call <code>getClass()</code> on a <code>String.class</code> instance. * This in turn lead to the resolution of the String class which is always * encoded as <code>"".getClass()</code>. Finally the <code>Encoder</code> - * treats strings in a special way so that the recursion ends here. - * + * treats strings in a special way so that the recursion ends here. + * * @author Robert Schuster (robertschuster@fsfe.org) */ public class ClassPersistenceDelegate extends PersistenceDelegate @@ -62,7 +62,7 @@ public class ClassPersistenceDelegate extends PersistenceDelegate protected Expression instantiate(Object oldInstance, Encoder out) { Class oldClass = (Class) oldInstance; - + // Due to the special handling of String instances in the Encoder // this Expression does not lead to further class resolutions. if (oldClass == String.class) @@ -72,7 +72,7 @@ public class ClassPersistenceDelegate extends PersistenceDelegate if (oldClass == Class.class) return new Expression(oldClass, String.class, "getClass", null); - // This Expression will lead to the class resolution of Class.class. + // This Expression will lead to the class resolution of Class.class. return new Expression(oldClass, Class.class, "forName", new Object[] { oldClass.getName() }); } diff --git a/libjava/classpath/gnu/java/beans/encoder/CollectionPersistenceDelegate.java b/libjava/classpath/gnu/java/beans/encoder/CollectionPersistenceDelegate.java index f1375d2..bdf6fda 100644 --- a/libjava/classpath/gnu/java/beans/encoder/CollectionPersistenceDelegate.java +++ b/libjava/classpath/gnu/java/beans/encoder/CollectionPersistenceDelegate.java @@ -7,7 +7,7 @@ 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 @@ -49,10 +49,10 @@ import java.util.Iterator; /** <p>A <code>PersistenceDelegate</code> implementation that calls * the no-argument constructor to create the Collection instance and * uses an iterator to add all the objects it reaches through it.</p> - * + * * <p>It is used for <code>Set</code> and <code>List</code> * implementations.</p> - * + * * @author Robert Schuster (robertschuster@fsfe.org) */ public class CollectionPersistenceDelegate extends PersistenceDelegate diff --git a/libjava/classpath/gnu/java/beans/encoder/Context.java b/libjava/classpath/gnu/java/beans/encoder/Context.java index 9126d49..8acc490 100644 --- a/libjava/classpath/gnu/java/beans/encoder/Context.java +++ b/libjava/classpath/gnu/java/beans/encoder/Context.java @@ -41,20 +41,20 @@ package gnu.java.beans.encoder; /** A <code>Contect</code> object describes the current state * and the call number while processing the original object * tree in the {@link ScanEngine}. - * + * * <p>The class allows to distinguish the different calling states * and is neccessary for the child element skipping feature of - * the {@link GenericScannerState}.</p> - * + * the {@link GenericScannerState}.</p> + * * @author Robert Schuster (robertschuster@fsfe.org) * */ public class Context { private String state; - + private int call; - + Context(String newState, int newCall) { state = newState; @@ -66,21 +66,21 @@ public class Context int hc = 7; hc = 31 * hc + state.hashCode(); hc = 31 * hc + call; - + return hc; } - + public boolean equals(Object o) { if (!(o instanceof Context)) return false; - + Context that = (Context) o; - + return state.equals(that.state) && call == that.call; } - + public String toString() { return "Context [state=" + state + ", call=" + call + "]"; diff --git a/libjava/classpath/gnu/java/beans/encoder/GenericScannerState.java b/libjava/classpath/gnu/java/beans/encoder/GenericScannerState.java index 3c3f8a3..b07771d 100644 --- a/libjava/classpath/gnu/java/beans/encoder/GenericScannerState.java +++ b/libjava/classpath/gnu/java/beans/encoder/GenericScannerState.java @@ -60,12 +60,12 @@ import gnu.java.beans.encoder.elements.StringReference; * This class is a {@link ScannerState} implementation that creates * suitable {@link gnu.java.beans.encoder.elements.Element} instances * for each transition variant. - * + * * <p>Furthermore it can optionally skip a certain number of child - * elements. The algorithm can cope with the fact that one + * elements. The algorithm can cope with the fact that one * <code>GenericScannerState</code> instance may be called at * different levels of recursions.</p> - * + * * @author Robert Schuster (robertschuster@fsfe.org) */ class GenericScannerState extends ScannerState @@ -89,19 +89,19 @@ class GenericScannerState extends ScannerState if (skipElements > 0) skipValues = new HashMap(); } - + protected void enterImpl(Context ctx) { if (skipValues != null) { Integer skip = (Integer) skipValues.get(ctx); - + if (skip == null) { skip = Integer.valueOf(initialSkipElements); skipValues.put(ctx, skip); } - + skipElements = skip.intValue(); } } diff --git a/libjava/classpath/gnu/java/beans/encoder/IgnoringScannerState.java b/libjava/classpath/gnu/java/beans/encoder/IgnoringScannerState.java index 054f1f0..3ec78cd 100644 --- a/libjava/classpath/gnu/java/beans/encoder/IgnoringScannerState.java +++ b/libjava/classpath/gnu/java/beans/encoder/IgnoringScannerState.java @@ -40,7 +40,7 @@ package gnu.java.beans.encoder; /** A special {@link ScannerState} implementation that ignores all child * elements. - * + * * <p>Consider the call hierarchy: * <code> * methodInvocation @@ -50,16 +50,16 @@ package gnu.java.beans.encoder; * classResolution * </code> * </p> - * + * * <p>When the ignoring state is active one can filter the elements of * one level. One has to set up the state machine that a transition * via "class resolution" from a state that was reached via "object * instantation" reaches an <code>IgnoringScannerState</code>.</p> - * + * * <p>Setting the default successor of a <code>IgnoringScannerState</code> * to itself causes all elements of the call hierarchy to be skipped - * until another state is reached by going back.</p> - * + * until another state is reached by going back.</p> + * * @author Robert Schuster (robertschuster@fsfe.org) * */ @@ -125,9 +125,9 @@ class IgnoringScannerState extends ScannerState void objectReference(ObjectId id) { } - + void end() { } - + } diff --git a/libjava/classpath/gnu/java/beans/encoder/MapPersistenceDelegate.java b/libjava/classpath/gnu/java/beans/encoder/MapPersistenceDelegate.java index 84cdce9..9ffdb56 100644 --- a/libjava/classpath/gnu/java/beans/encoder/MapPersistenceDelegate.java +++ b/libjava/classpath/gnu/java/beans/encoder/MapPersistenceDelegate.java @@ -8,7 +8,7 @@ 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 diff --git a/libjava/classpath/gnu/java/beans/encoder/ObjectId.java b/libjava/classpath/gnu/java/beans/encoder/ObjectId.java index eca5c3d..13d75d6 100644 --- a/libjava/classpath/gnu/java/beans/encoder/ObjectId.java +++ b/libjava/classpath/gnu/java/beans/encoder/ObjectId.java @@ -45,7 +45,7 @@ import java.util.HashMap; * ObjectId provides an object identification mechanism which gives each object * a name in the form <code><class><Nameindex></code>. * </p> - * + * * <p> * Each id can be in an unused state which means that only one instance of the * object is in use and a special id is not needed. Certain {@link @@ -57,7 +57,7 @@ import java.util.HashMap; * The second user should then invoke the {@link #init} method to generate the * identification string and bring the id in the 'used' state. * </p> - * + * * @author Robert Schuster (robertschuster@fsfe.org) */ public class ObjectId diff --git a/libjava/classpath/gnu/java/beans/encoder/PrimitivePersistenceDelegate.java b/libjava/classpath/gnu/java/beans/encoder/PrimitivePersistenceDelegate.java index 8cb3705..55626b5 100644 --- a/libjava/classpath/gnu/java/beans/encoder/PrimitivePersistenceDelegate.java +++ b/libjava/classpath/gnu/java/beans/encoder/PrimitivePersistenceDelegate.java @@ -8,7 +8,7 @@ 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 @@ -44,7 +44,7 @@ import java.beans.PersistenceDelegate; /** * A shared PersistenceDelegate implementation for all primitive types. - * + * * @author Robert Schuster (robertschuster@fsfe.org) */ public class PrimitivePersistenceDelegate extends PersistenceDelegate @@ -70,5 +70,5 @@ public class PrimitivePersistenceDelegate extends PersistenceDelegate out.writeExpression(new Expression(oldInstance, oldInstance.getClass(), "new", new Object[] { oldInstance.toString() })); } - + } diff --git a/libjava/classpath/gnu/java/beans/encoder/ReportingScannerState.java b/libjava/classpath/gnu/java/beans/encoder/ReportingScannerState.java index fb6e061..c91bb15 100644 --- a/libjava/classpath/gnu/java/beans/encoder/ReportingScannerState.java +++ b/libjava/classpath/gnu/java/beans/encoder/ReportingScannerState.java @@ -42,7 +42,7 @@ package gnu.java.beans.encoder; * A <code>ScannerState</code> implementation that prints useful details * about its arguments. Use it when the XML encoding does not work correctly * and you want to find out how things relate to each other. - * + * * @author Robert Schuster (robertschuster@fsfe.org) */ class ReportingScannerState extends ScannerState @@ -50,12 +50,12 @@ class ReportingScannerState extends ScannerState void methodInvocation(String methodName) { - System.out.println("methodInvocation: " + methodName + "()"); + System.out.println("methodInvocation: " + methodName + "()"); } void staticMethodInvocation(String className, String methodName) { - System.out.println("staticMethodInvocation: " + className + "." + methodName + "()"); + System.out.println("staticMethodInvocation: " + className + "." + methodName + "()"); } void staticFieldAccess(String className, String fieldName) @@ -65,17 +65,17 @@ class ReportingScannerState extends ScannerState void classResolution(String className) { - System.out.println("classResolution: " + className); + System.out.println("classResolution: " + className); } void objectInstantiation(String className, ObjectId objectId) { - System.out.println("objectInstantiation: " + className); + System.out.println("objectInstantiation: " + className); } void primitiveInstantiation(String primitiveName, String valueAsString) { - System.out.println("primitiveInstantiation: (" + primitiveName + ") " + valueAsString); + System.out.println("primitiveInstantiation: (" + primitiveName + ") " + valueAsString); } void objectArrayInstantiation(String arrayClassName, String lengthAsString, ObjectId objectId) @@ -90,27 +90,27 @@ class ReportingScannerState extends ScannerState void arraySet(String indexAsString) { - System.out.println("arraySet: " + indexAsString); + System.out.println("arraySet: " + indexAsString); } void arrayGet(String indexAsString) { - System.out.println("arrayGet: " + indexAsString); + System.out.println("arrayGet: " + indexAsString); } void listGet() { - System.out.println("listGet"); + System.out.println("listGet"); } void listSet() { - System.out.println("listSet"); + System.out.println("listSet"); } void nullObject() { - System.out.println("nullObject"); + System.out.println("nullObject"); } void stringReference(String string) @@ -125,7 +125,7 @@ class ReportingScannerState extends ScannerState void end() { - System.out.println("-close"); + System.out.println("-close"); } - + } diff --git a/libjava/classpath/gnu/java/beans/encoder/Root.java b/libjava/classpath/gnu/java/beans/encoder/Root.java index f4eade1..a6410d7 100644 --- a/libjava/classpath/gnu/java/beans/encoder/Root.java +++ b/libjava/classpath/gnu/java/beans/encoder/Root.java @@ -46,14 +46,14 @@ import gnu.java.beans.encoder.elements.Element; /** <p><code>Root</code> provides a simple interface to a tree of * objects.</p> - * + * * <p>Using an instance of this class a logical representation of * the real object tree that is serialized can be built. When the * actual data should be written as XML <code>Root</code> and * {@link gnu.java.beans.encoder.elements.Element} class can provide * context information which is used to write the best fitting * XML representation.</p> - * + * * @author Robert Schuster (robertschuster@fsfe.org) */ public class Root @@ -61,7 +61,7 @@ public class Root private Stack parents = new Stack(); private Element rootElement, current; - + private boolean started; public Root() @@ -70,10 +70,10 @@ public class Root } /** <p>Adds another child element to the tree.</p> - * + * * <p>The new element automatically becomes the current * element.</p> - * + * * @param elem The new child element. */ public void addChild(Element elem) @@ -88,7 +88,7 @@ public class Root * <p>Marks that the end of the current element * is reached and that no more childs are added to * it.</p> - * + * * <p>The behavior is to return to the nearest parent * element.</p> */ @@ -100,7 +100,7 @@ public class Root /** * <p>Goes back to the nearest parent element but * deletes the just created child.</p> - * + * * <p>This is used if something went wrong while * processing the child element's {@link java.beans.Expression} * or {@link java.beans.Statement}.</p> @@ -117,9 +117,9 @@ public class Root * <p>Traverses the elements in the object tree * and creates their XML representation in the output * stream of the given {@link Writer}.</p> - * + * * <p>Finally the <code>Writer</code> is flushed.</p> - * + * * @param writer The Writer instance that generates the XML representation. */ public void traverse(Writer writer) @@ -130,16 +130,16 @@ public class Root rootElement.writeStart(writer); } started = true; - + traverse(writer, rootElement.iterator()); - + rootElement.clear(); - + writer.flush(); } /** Writes the closing element and closes the {@link Writer} - * + * * @param writer The Writer instance that generates the XML representation. */ public void close(Writer writer) @@ -149,7 +149,7 @@ public class Root } /** Recursively traverses the object tree. - * + * * @param writer The Writer instance that generates the XML representation. * @param ite An Iterator returning Element instances. */ @@ -163,19 +163,19 @@ public class Root traverse(writer, e.iterator()); e.writeEnd(writer); - + e.clear(); } } /** <p>A special Element implementation that represents the * encoder's context.</p> - * + * * <p>This element is written only once per Writer.</p> - * + * * <p>It is assumed that this element is never empty to simplify * the implementation.</p> - * + * * @author Robert Schuster (robertschuster@fsfe.org); * */ @@ -187,7 +187,7 @@ public class Root new String[] { System.getProperty("java.version"), XMLEncoder.class.getName() }, false); } - + public void writeEnd(Writer writer) { writer.writeEnd(false); diff --git a/libjava/classpath/gnu/java/beans/encoder/ScanEngine.java b/libjava/classpath/gnu/java/beans/encoder/ScanEngine.java index b78a814..9ced143 100644 --- a/libjava/classpath/gnu/java/beans/encoder/ScanEngine.java +++ b/libjava/classpath/gnu/java/beans/encoder/ScanEngine.java @@ -1,4 +1,4 @@ -/* ScanEngine.java +/* ScanEngine.java -- Scans the input and generates an object tree that can be written as XML. Copyright (C) 2005 Free Software Foundation, Inc. @@ -54,7 +54,7 @@ import java.util.Stack; * {@link #writeObject} method and feeds it to a state machine. The * state machine then constructs and object tree which is finally * written as XML by a {@link Writer} implementation.</p> - * + * * <p>How does it work?</p> * <p>The <code>ScanEngine</code> sits below the {@link java.beans.XMLEncoder} * class and is called by it exclusively. The <code>XMLEncoder</code> sends @@ -65,7 +65,7 @@ import java.util.Stack; * Furthermore the meaning of certain <code>Expressions</code> differs * depending on the enclosing elements or the inner elements have to be * simply discarded.</p> - * + * * <p>To cope with this state dependant nature the <code>ScanEngine</code> * contains a state machine which is programmed statically (no adjustments are * needed, all <code>ScanEngine</code> engines use the same setup). The @@ -83,7 +83,7 @@ import java.util.Stack; * the current state and then the event method is called in the new current * state. The last step allows the state instance to do something meaningful * to the object tree.</p> - * + * * <p>The state machine knows the concept of returning to the previous * state. This is done using a stack of states which is popped every * time a call to <code>writeStatement</code>, <code>writeExpression</code> @@ -93,7 +93,7 @@ import java.util.Stack; * <code>ScanEngine</code> itself to decide when an expression or statement * ended. This can only be done in case of {@link #writeObject} calls because * they are not nested.</p> - * + * * <p>When the XML persistence mechanism reaches an object twice (and more) * it should generate an XML element using the "idref" attribute and add * an "id" attribute to its first instantiation. This complicates things a bit @@ -106,12 +106,12 @@ import java.util.Stack; * instance is stored in the <code>ScanEngine</code> and gets cleared whenever * the {@link #flush} method is called. This method also writes the currently * built object tree and generates the XML representation.</p> - * + * * @author Robert Schuster (robertschuster@fsfe.org) */ public class ScanEngine { - + /** Change this to true to let the ScanEngine print state transition * information. */ @@ -145,7 +145,7 @@ public class ScanEngine /** Stores the relationship between objects and their {@link ObjectId} instance. */ IdentityHashMap objects = new IdentityHashMap(); - + public ScanEngine(OutputStream os) { // TODO: Provide another Writer implementation (e.g. one that does not use @@ -182,7 +182,7 @@ public class ScanEngine "newObj0"); conf = register("newObj0", new GenericScannerState(root)); conf.setDefaultSuccessor("ignoreAll"); - + // Simply use the start state to encode method invocations inside of // objects. conf.putSuccessor(ScannerState.TRANSITION_METHOD_INVOCATION, "start"); @@ -203,14 +203,14 @@ public class ScanEngine conf.putSuccessor(ScannerState.TRANSITION_CLASS_RESOLUTION, "ignoreAll"); conf.putSuccessor(ScannerState.TRANSITION_PRIMITIVE_INSTANTIATION, "ignoreAll"); - + // Get here when a value is set in the array. register("newOArrayGet", conf = new GenericScannerState(root)); - + conf.putSuccessor(ScannerState.TRANSITION_PRIMITIVE_INSTANTIATION, "newOArrayGet_ignoreFirstInteger"); - + // "newArrayGet_ignoreFirstInteger" is set up mostly identical like the "start" // state. Otherwise things would not behave the same when done inside // arrays. @@ -223,21 +223,21 @@ public class ScanEngine "newPrimitiveArray"); conf.putSuccessor(ScannerState.TRANSITION_OBJECT_ARRAY_INSTANTIATION, "newObjectArray"); - + conf = register("newOArrayGet_ignoreFirstInteger", new GenericScannerState(root, 1)); - + // In non-int primitive arrays class resolutions can happen // but they should be ignored. conf.putSuccessor(ScannerState.TRANSITION_CLASS_RESOLUTION, "ignoreAll"); - + // Spurious object and string references occur when setting array // elements. This suppresses them. conf.putSuccessor(ScannerState.TRANSITION_PRIMITIVE_INSTANTIATION, "ignoreAll"); conf.putSuccessor(ScannerState.TRANSITION_OBJECT_REFERENCE, "ignoreAll"); conf.putSuccessor(ScannerState.TRANSITION_STRING_REFERENCE, "ignoreAll"); - + conf.setDefaultSuccessor("start"); // Primitive arrays use the ARRAY_SET transition to create setting the @@ -252,11 +252,11 @@ public class ScanEngine conf.putSuccessor(ScannerState.TRANSITION_CLASS_RESOLUTION, "ignoreAll"); conf.putSuccessor(ScannerState.TRANSITION_PRIMITIVE_INSTANTIATION, "ignoreAll"); - + conf = register("newPArraySet", new GenericScannerState(root)); conf.putSuccessor(ScannerState.TRANSITION_PRIMITIVE_INSTANTIATION, "newPArraySet_ignoreFirstInteger"); - + // Primitive arrays ignore all kinds of non-primitive object information. conf.putSuccessor(ScannerState.TRANSITION_OBJECT_REFERENCE, "ignoreAll"); @@ -271,11 +271,11 @@ public class ScanEngine conf = register("newPArraySet_ignoreFirstInteger", new GenericScannerState(root, 1)); - + // In non-int primitive arrays class resolutions can happen // but they should be ignored. conf.putSuccessor(ScannerState.TRANSITION_CLASS_RESOLUTION, "ignoreAll"); - + // Spurious object and string references occur when setting array // elements. This suppresses them. conf.putSuccessor(ScannerState.TRANSITION_PRIMITIVE_INSTANTIATION, @@ -287,7 +287,7 @@ public class ScanEngine } /** Registers a <code>ScannerState</code> under a certain name. - * + * * @param name Name of the state * @param state The <code>ScannerState</code> instance. * @return The second argument. @@ -295,26 +295,26 @@ public class ScanEngine private ScannerState register(String name, ScannerState state) { state.init(name); - + states.put(name, state); return state; } - + /** Generates or returns an id for the given object which can be activated * later if the object is suitable. - * + * * <p>Objects are unsuitable if they are an instance of a primitive wrapper * or String.</p> - * - * @param value The object to retrieve an id for. + * + * @param value The object to retrieve an id for. * @return The id for the object or <code>null</code>. */ private ObjectId retrieveId(Object value) { Class valueClass = value.getClass(); ObjectId id = null; - + // Although multiple accesses to Class objects are not handled // through ids we generate one for them, too. This allows us to detect // second time references to such objects in the writeObject method @@ -329,13 +329,13 @@ public class ScanEngine objects.put(value, id); } } - + return id; } /** Scans the argument and calls one of event methods. See * the introduction of this class for details. - * + * * @param expr The expression to serialize. */ public void writeExpression(Expression expr) @@ -344,7 +344,7 @@ public class ScanEngine Object[] args = expr.getArguments(); Object target = expr.getTarget(); Object value = null; - + try { value = expr.getValue(); @@ -366,9 +366,9 @@ public class ScanEngine if (methodName.equals("newInstance")) { id = retrieveId(value); - + Class ct = (Class) args[0]; - + if (ct.isPrimitive() || ct == Boolean.class || ct == Byte.class || ct == Short.class || ct == Integer.class || ct == Long.class || ct == Float.class || ct == Double.class) @@ -379,7 +379,7 @@ public class ScanEngine objectArrayInstantiation(ct.getName(), args[1].toString(), id); - + return; } else if (methodName.equals("get")) @@ -398,7 +398,7 @@ public class ScanEngine objectReference(id); end(); } - + return; } else if (methodName.equals("set")) @@ -407,7 +407,7 @@ public class ScanEngine return; } } - + id = retrieveId(value); if (target instanceof Class) @@ -517,7 +517,7 @@ public class ScanEngine /** Scans the argument and calls one of event methods. See * the introduction of this class for details. - * + * * @param stmt The statement to serialize. */ public void writeStatement(Statement stmt) @@ -553,7 +553,7 @@ public class ScanEngine /** Scans the argument and calls one of event methods. See * the introduction of this class for details. - * + * * @param o The object to serialize. */ public boolean writeObject(Object o) @@ -585,9 +585,9 @@ public class ScanEngine end(); return false; } - + // If our object has a corresponding ObjectId instance - // then generate an objectReference. This will + // then generate an objectReference. This will // initialize the id (= brings it in the "used" state) // when this is the first referal. objectReference(id); @@ -622,10 +622,10 @@ public class ScanEngine /** * Does a transition from one state to another using the given event. - * + * * <p>This involves saving the current state, retrieving it's * successor and setting it as the current state.</p> - * + * * @param transition One of {@link ScannerStates]'s transition constants. */ private void transition(int transition) @@ -633,7 +633,7 @@ public class ScanEngine parents.push(current); String stateName = current.getSuccessor(transition); - + if (DEBUG) { System.err.println("from state: " + current.getName() + "\n\troute: " @@ -641,9 +641,9 @@ public class ScanEngine + "\n\t\tto state: " + stateName); } - + ScannerState newState = (ScannerState) states.get(stateName); - + newState.enter(new Context(current.getName(), current.getCalls())); assert (newState != null) : "State '" + stateName + "' was not defined."; @@ -655,7 +655,7 @@ public class ScanEngine * * <p>More details about this method can be found in this * class' introduction.</p> - * + * * @param methodName The name of the method which is called. */ void methodInvocation(String methodName) @@ -669,7 +669,7 @@ public class ScanEngine * * <p>More details about this method can be found in this * class' introduction.</p> - * + * * @param methodName The name of the method which is called. * @param className The name of the class in which the method is called. */ @@ -684,7 +684,7 @@ public class ScanEngine * * <p>More details about this method can be found in this * class' introduction.</p> - * + * * @param fieldName The name of the field whose value is retrieved. * @param className The name of the class in which the method is called. */ @@ -699,7 +699,7 @@ public class ScanEngine * * <p>More details about this method can be found in this * class' introduction.</p> - * + * * @param className The name of the class in which the method is called. */ void classResolution(String className) @@ -713,7 +713,7 @@ public class ScanEngine * * <p>More details about this method can be found in this * class' introduction.</p> - * + * * @param className The name of the class in which the method is called. * @param objectId An ObjectId instance which can be activated later. */ @@ -728,7 +728,7 @@ public class ScanEngine * * <p>More details about this method can be found in this * class' introduction.</p> - * + * * @param primitiveName One of "boolean, "byte", "short", "int", "long" * , "float" or "double" * @param valueAsString The value of the primitive as a String. @@ -744,7 +744,7 @@ public class ScanEngine * * <p>More details about this method can be found in this * class' introduction.</p> - * + * * @param arrayClassName The array's class name. * @param objectId An ObjectId instance which can be activated later. * @param lengthAsString The array's length as String. @@ -761,7 +761,7 @@ public class ScanEngine * * <p>More details about this method can be found in this * class' introduction.</p> - * + * * @param arrayClassName The array's class name. * @param objectId An ObjectId instance which can be activated later. * @param lengthAsString The array's length as String. @@ -773,12 +773,12 @@ public class ScanEngine current.objectArrayInstantiation(arrayClassName, lengthAsString, objectId); } - + /** Event method that denotes the setting of a value in an array. * * <p>More details about this method can be found in this * class' introduction.</p> - * + * * @param indexAsString The index to as a String. */ void arraySet(String indexAsString) @@ -792,7 +792,7 @@ public class ScanEngine * * <p>More details about this method can be found in this * class' introduction.</p> - * + * * @param indexAsString The index to as a String. */ void arrayGet(String indexAsString) @@ -836,7 +836,7 @@ public class ScanEngine } /** Event method that denotes a string. - * + * * @param string The string that should be written. */ void stringReference(String string) @@ -847,7 +847,7 @@ public class ScanEngine } /** Event method that denotes a reference to an existing object. - * + * * @param id The ObjectId to be used. */ void objectReference(ObjectId id) diff --git a/libjava/classpath/gnu/java/beans/encoder/ScannerState.java b/libjava/classpath/gnu/java/beans/encoder/ScannerState.java index 888478a..14d6305 100644 --- a/libjava/classpath/gnu/java/beans/encoder/ScannerState.java +++ b/libjava/classpath/gnu/java/beans/encoder/ScannerState.java @@ -42,12 +42,12 @@ import java.util.HashMap; /** <p>Provides the infrastructure for the state machine and the transition * mechanism.</p> - * + * * <p>Each states knows a set of successor. There can be one successor for * every transition variant. Furthermore a state knows about a default * successor which is taken when there is no special setup for a * transition.</p> - * + * * @author Robert Schuster (robertschuster@fsfe.org) * */ @@ -105,42 +105,42 @@ public abstract class ScannerState * transition->successor's state name. */ HashMap transitions = new HashMap(); - + int calls; - + Context context; - + String name; - + final void init(String newName) { assert (name == null); - + name = newName; } - + final String getName() { return name; } - + final void enter(Context ctx) { calls++; context = ctx; - + enterImpl(ctx); } - + protected void enterImpl(Context ctx) { } - + final Context context() { return context; } - + final int getCalls() { return calls; @@ -148,10 +148,10 @@ public abstract class ScannerState /** * <p>Stores a successor's state name for a certain transition.</p> - * + * * <p>This method is only used at the configuration time of the state * machine.</p> - * + * * @param transition One of the transition constants. * @param stateName The state name of the successor. */ @@ -165,10 +165,10 @@ public abstract class ScannerState /** <p>Retrieves a the state name of a successor for the given transition * constant.</p> - * + * * <p>Returns the default successor's state name if no special setup was * prepared.</p> - * + * * @param transition One of the transition constants. * @return The state name of the successor. */ @@ -181,7 +181,7 @@ public abstract class ScannerState /** * Sets the name for the default successor state. - * + * * @param newDefaultSuccessor The default successor's state name. */ final void setDefaultSuccessor(String newDefaultSuccessor) @@ -203,7 +203,7 @@ public abstract class ScannerState String valueAsString); abstract void objectArrayInstantiation(String arrayClassName, String lengthAsString, ObjectId objectId); - + abstract void primitiveArrayInstantiation(String arrayClassName, String lengthAsString, ObjectId objectId); abstract void arraySet(String indexAsString); @@ -222,7 +222,7 @@ public abstract class ScannerState /** * <p>A special event that does not provoke a direct transition.</p> - * + * * <p>Instead the transition is done by the <code>ScanEngine</code>: It goes * back to the previous state and just uses this method to inform the state * about this happening.</p> @@ -232,5 +232,5 @@ public abstract class ScannerState void enter() { } - + } diff --git a/libjava/classpath/gnu/java/beans/encoder/StAXWriter.java b/libjava/classpath/gnu/java/beans/encoder/StAXWriter.java index fdb5f7d4..da88c53 100644 --- a/libjava/classpath/gnu/java/beans/encoder/StAXWriter.java +++ b/libjava/classpath/gnu/java/beans/encoder/StAXWriter.java @@ -45,7 +45,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; /** A {@link Writer} implementation based on the StAX API. - * + * * @author Robert Schuster (robertschuster@fsfe.org) * */ @@ -54,7 +54,7 @@ public class StAXWriter implements Writer XMLStreamWriter writer; int indent = 0; - + public StAXWriter(OutputStream os) { try @@ -71,7 +71,7 @@ public class StAXWriter implements Writer } } - + public void flush() { if (writer != null) @@ -138,7 +138,7 @@ public class StAXWriter implements Writer } } - + public void writeEndNoChildren() { try diff --git a/libjava/classpath/gnu/java/beans/encoder/Writer.java b/libjava/classpath/gnu/java/beans/encoder/Writer.java index 57203d2..e08c786 100644 --- a/libjava/classpath/gnu/java/beans/encoder/Writer.java +++ b/libjava/classpath/gnu/java/beans/encoder/Writer.java @@ -40,20 +40,20 @@ package gnu.java.beans.encoder; /** A <code>Writer</code> represents a simplified interface to an XML * writer that is used for the XML persistence mechanism. - * + * * <p>Its sole purpose is to allow multiple backends which may remove * the need to have certain APIs in the classpath. Eg. it is possible * to write a stripped down XML Writer that does not rely on SAX, StAX * or DOM APIs.</p> - * + * * <p>The caller may assume that every action is done immediately. However * it is possible that the underlying implementation uses buffering streams. * To make sure the data is written call the {@link flush} method.</p> - * + * * <p>The <code>Writer</code> implementation should care about the formatting * of the XML stream making it possible to generate three types of formats using * a special method invocation chain.</p> - * + * * <p>Write * <code> * <element/> @@ -61,13 +61,13 @@ package gnu.java.beans.encoder; * by issuing <code>write("element", true)</code> (or any of the other * write-variants that allows specifying the <code>isEmpty</code> argument) * and <code>writeEnd(true)</code>.</p> - * + * * <p>Write * <code> * <element>body</element> * </code> * by issuing <code>writeNoChildren("element", "body")</code> and <code>writeNoChildrenEnd()</code>.</p> - * + * * <p> * Write * <code> @@ -80,7 +80,7 @@ package gnu.java.beans.encoder; * by issuing <code>write("element", false)</code> (or any of the other * write-variants that allows specifying the <code>isEmpty</code> argument) * and <code>writeEnd(false)</code>.</p> - * + * * <p>Note: It is important that the values of <code>isEmpty</code> and * <code>wasEmpty</code> match. Otherwise strange things might happen to * the layout.</p> @@ -90,40 +90,40 @@ package gnu.java.beans.encoder; */ public interface Writer { - // TODO: This interface's design is not the best. Feel free to + // TODO: This interface's design is not the best. Feel free to // improve it as you like. /** Writes the XML preamble. */ void writePreamble(); /** Writes the end of an XML tag. - * + * * <p>If your tag has not generated any body text or child * elements provide <code>true</code> as the argument to generate - * more space efficient variant of the tag.>/p> - * + * more space efficient variant of the tag.>/p> + * * @param wasEmpty Whether the tag was empty or not. */ void writeEnd(boolean wasEmpty); - /** Writes an XML tag without any attributes. - * + /** Writes an XML tag without any attributes. + * * @param tagName The name of the tag to write. * @param empty Whether the element has child elements. */ void write(String tagName, boolean empty); /** Writes an XML tag with one attribute name and value. - * + * * @param tagName The name of the tag to write. - * @param attributeName The name of attribute. + * @param attributeName The name of attribute. * @param attributeValue The attribute's value. * @param empty Whether the element has child elements. */ void write(String tagName, String attributeName, String attributeValue, boolean empty); /** Writes an XML tag with multiple attributes and a body text. - * + * * @param tagName The name of the tag to write. * @param value The element's body content. * @param attributeNames A set of attribute names. @@ -134,7 +134,7 @@ public interface Writer String[] attributeValues, boolean empty); /** Writes an XML tag with multiple attributes without a body text. - * + * * @param tagName The name of the tag to write. * @param attributeNames A set of attribute names. * @param attributeValues A set of attribute values. @@ -144,7 +144,7 @@ public interface Writer /** Writes an XML tag with no attributes but with a body text * that may have child elements. - * + * * @param tagName The name of the tag to write. * @param value The element's body content. */ @@ -152,14 +152,14 @@ public interface Writer /** Writes an XML tag with no attributes but with a body text * that does not have child elements. - * + * * @param tagName The name of the tag to write. * @param value The element's body content. */ void writeNoChildren(String tagName, String value); - + /** Writes the end of an XML tag that has no child elements. - * + * * <p>Must be used in combination with {@link writeNoChildren} only.</p> */ void writeEndNoChildren(); diff --git a/libjava/classpath/gnu/java/beans/encoder/elements/ArrayInstantiation.java b/libjava/classpath/gnu/java/beans/encoder/elements/ArrayInstantiation.java index a9aef89..51e00c3 100644 --- a/libjava/classpath/gnu/java/beans/encoder/elements/ArrayInstantiation.java +++ b/libjava/classpath/gnu/java/beans/encoder/elements/ArrayInstantiation.java @@ -42,7 +42,7 @@ import gnu.java.beans.encoder.ObjectId; import gnu.java.beans.encoder.Writer; /** Generates an XML element denoting the instantiation of an array. - * + * * @author Robert Schuster (robertschuster@fsfe.org) * */ diff --git a/libjava/classpath/gnu/java/beans/encoder/elements/Array_Get.java b/libjava/classpath/gnu/java/beans/encoder/elements/Array_Get.java index ca2ce0f..912eceb 100644 --- a/libjava/classpath/gnu/java/beans/encoder/elements/Array_Get.java +++ b/libjava/classpath/gnu/java/beans/encoder/elements/Array_Get.java @@ -42,7 +42,7 @@ import gnu.java.beans.encoder.Writer; /** * Generates an XML element denoting the retrieval of an array value. - * + * * @author Robert Schuster (robertschuster@fsfe.org) */ public class Array_Get extends Element diff --git a/libjava/classpath/gnu/java/beans/encoder/elements/ClassResolution.java b/libjava/classpath/gnu/java/beans/encoder/elements/ClassResolution.java index 8e640d1..cb736d5 100644 --- a/libjava/classpath/gnu/java/beans/encoder/elements/ClassResolution.java +++ b/libjava/classpath/gnu/java/beans/encoder/elements/ClassResolution.java @@ -41,7 +41,7 @@ package gnu.java.beans.encoder.elements; import gnu.java.beans.encoder.Writer; /** Generates an XML element denoting the resolution of a class. - * + * * @author Robert Schuster (robertschuster@fsfe.org) * */ @@ -58,7 +58,7 @@ public class ClassResolution extends Element { writer.writeNoChildren("class", className); } - + public void writeEnd(Writer writer) { writer.writeEndNoChildren(); diff --git a/libjava/classpath/gnu/java/beans/encoder/elements/Element.java b/libjava/classpath/gnu/java/beans/encoder/elements/Element.java index 5681d2b..a8c0ecd 100644 --- a/libjava/classpath/gnu/java/beans/encoder/elements/Element.java +++ b/libjava/classpath/gnu/java/beans/encoder/elements/Element.java @@ -45,11 +45,11 @@ import gnu.java.beans.encoder.ObjectId; import gnu.java.beans.encoder.Writer; /** <code>Element</code> is the base class for the object tree elements. - * + * * <p>It provides the neccessary infrastructure every element subclass * needs in order to interact with the {@link gnu.java.beans.encoder.Root} * class.</p> - * + * * @author Robert Schuster (robertschuster@fsfe.org) */ public abstract class Element @@ -58,100 +58,100 @@ public abstract class Element * Stores the child elements. */ private LinkedList children = new LinkedList(); - + /** * An optional ObjectId instance which is needed for certain subclasses * only. */ private ObjectId objectId; - + /** Sets an {@link gnu.java.beans.encoder.ObjectId} instance in this * <code>Element</code>. - * + * * <p>This can only be done once.</p> - * + * * @param objectId An ObjectId instance. */ public final void initId(ObjectId objectId) { assert (this.objectId == null); assert (objectId != null); - + this.objectId = objectId; } /** Adds a child element to this <code>Element</code>. - * + * * @param elem The new child. */ public final void addChild(Element elem) { children.add(elem); } - + /** Removes the child element added last. */ public final void removeLast() { children.removeLast(); } - + /** Provides access to the child elements via an iterator. - * + * * @return An iterator for the child elements. */ public final Iterator iterator(){ return children.iterator(); } - + /** Clears all the stored child elements. - * + * */ public final void clear() { - children.clear(); + children.clear(); } - + /** Returns whether this element contains child elements. - * + * * <p>This method is useful to decide which formatting variant * for the XML element can be chosen.</p> - * + * * @return Whether the element has child elements. */ public final boolean isEmpty() { - return children.isEmpty(); + return children.isEmpty(); } - + /** Retrieves the element's {@link gnu.java.beans.encoder.ObjectId} instance * if it has one. - * + * * @return The ObjectId instance or <code>null</code>. */ public final ObjectId getId() { return objectId; } - + /** Writes the opening XML tag. - * + * * @param writer The writer to be used for XML writing. */ public abstract void writeStart(Writer writer); - + /** Writes the closing XML tag. - * + * * <p>By default this does <code>writer.writeEnd(children.isEmpty())</code>. * Override if neccessary, for example when using the * {@link gnu.java.beans.encoder.Writer#writeNoChildren}</code> method - * variants. - * + * variants. + * * @param writer The writer to be used for XML writing. */ public void writeEnd(Writer writer) { writer.writeEnd(children.isEmpty()); } - + } diff --git a/libjava/classpath/gnu/java/beans/encoder/elements/List_Get.java b/libjava/classpath/gnu/java/beans/encoder/elements/List_Get.java index e73afa8..c14ab91 100644 --- a/libjava/classpath/gnu/java/beans/encoder/elements/List_Get.java +++ b/libjava/classpath/gnu/java/beans/encoder/elements/List_Get.java @@ -41,7 +41,7 @@ package gnu.java.beans.encoder.elements; import gnu.java.beans.encoder.Writer; /** Generates an XML element denoting the retrieval of a list's element. - * + * * @author Robert Schuster (robertschuster@fsfe.org) * */ @@ -52,5 +52,5 @@ public class List_Get extends Element { writer.write("object", "get"); } - + } diff --git a/libjava/classpath/gnu/java/beans/encoder/elements/List_Set.java b/libjava/classpath/gnu/java/beans/encoder/elements/List_Set.java index 03c73fd..3e7cca6 100644 --- a/libjava/classpath/gnu/java/beans/encoder/elements/List_Set.java +++ b/libjava/classpath/gnu/java/beans/encoder/elements/List_Set.java @@ -41,7 +41,7 @@ package gnu.java.beans.encoder.elements; import gnu.java.beans.encoder.Writer; /** Generates an XML element denoting the setting of a list's element. - * + * * @author Robert Schuster (robertschuster@fsfe.org) * */ @@ -52,5 +52,5 @@ public class List_Set extends Element { writer.write("object", "set"); } - + } diff --git a/libjava/classpath/gnu/java/beans/encoder/elements/MethodInvocation.java b/libjava/classpath/gnu/java/beans/encoder/elements/MethodInvocation.java index d5b3174..1de5bb6 100644 --- a/libjava/classpath/gnu/java/beans/encoder/elements/MethodInvocation.java +++ b/libjava/classpath/gnu/java/beans/encoder/elements/MethodInvocation.java @@ -41,22 +41,22 @@ package gnu.java.beans.encoder.elements; import gnu.java.beans.encoder.Writer; /** Generates an XML element denoting a non-static method call. - * + * * @author Robert Schuster (robertschuster@fsfe.org) * */ public class MethodInvocation extends Element { final String methodName; - + public MethodInvocation(String newMethodName) { methodName = newMethodName; } - + public void writeStart(Writer writer) { writer.write("void", "method", methodName, isEmpty()); } - + } diff --git a/libjava/classpath/gnu/java/beans/encoder/elements/NullObject.java b/libjava/classpath/gnu/java/beans/encoder/elements/NullObject.java index 599c4d8..211e2a7 100644 --- a/libjava/classpath/gnu/java/beans/encoder/elements/NullObject.java +++ b/libjava/classpath/gnu/java/beans/encoder/elements/NullObject.java @@ -41,7 +41,7 @@ package gnu.java.beans.encoder.elements; import gnu.java.beans.encoder.Writer; /** Generates an XML element denoting the <code>null</code> value. - * + * * @author Robert Schuster (robertschuster@fsfe.org) * */ diff --git a/libjava/classpath/gnu/java/beans/encoder/elements/ObjectInstantiation.java b/libjava/classpath/gnu/java/beans/encoder/elements/ObjectInstantiation.java index 692227d..9861480 100644 --- a/libjava/classpath/gnu/java/beans/encoder/elements/ObjectInstantiation.java +++ b/libjava/classpath/gnu/java/beans/encoder/elements/ObjectInstantiation.java @@ -42,7 +42,7 @@ import gnu.java.beans.encoder.ObjectId; import gnu.java.beans.encoder.Writer; /** Generates an XML element denoting the instantiation of an object. - * + * * @author Robert Schuster (robertschuster@fsfe.org) * */ diff --git a/libjava/classpath/gnu/java/beans/encoder/elements/ObjectReference.java b/libjava/classpath/gnu/java/beans/encoder/elements/ObjectReference.java index a44c2ee..13a597a 100644 --- a/libjava/classpath/gnu/java/beans/encoder/elements/ObjectReference.java +++ b/libjava/classpath/gnu/java/beans/encoder/elements/ObjectReference.java @@ -42,7 +42,7 @@ import gnu.java.beans.encoder.ObjectId; import gnu.java.beans.encoder.Writer; /** Generates an XML element denoting referencing an existing object. - * + * * @author Robert Schuster (robertschuster@fsfe.org) * */ @@ -53,7 +53,7 @@ public class ObjectReference extends Element public ObjectReference(ObjectId newId) { id = newId; - + // Initializing the Id here is making sure it gets // actually used. This step modifies the Id instance // in other elements. @@ -64,5 +64,5 @@ public class ObjectReference extends Element { writer.write("object", "idref", id.toString(), isEmpty()); } - + } diff --git a/libjava/classpath/gnu/java/beans/encoder/elements/PrimitiveInstantiation.java b/libjava/classpath/gnu/java/beans/encoder/elements/PrimitiveInstantiation.java index db08edb..ae34b9d 100644 --- a/libjava/classpath/gnu/java/beans/encoder/elements/PrimitiveInstantiation.java +++ b/libjava/classpath/gnu/java/beans/encoder/elements/PrimitiveInstantiation.java @@ -41,7 +41,7 @@ package gnu.java.beans.encoder.elements; import gnu.java.beans.encoder.Writer; /** Generates an XML element denoting a primitive data value. - * + * * @author Robert Schuster (robertschuster@fsfe.org) * */ diff --git a/libjava/classpath/gnu/java/beans/encoder/elements/StaticFieldAccess.java b/libjava/classpath/gnu/java/beans/encoder/elements/StaticFieldAccess.java index 7ed935d..7fcbf52 100644 --- a/libjava/classpath/gnu/java/beans/encoder/elements/StaticFieldAccess.java +++ b/libjava/classpath/gnu/java/beans/encoder/elements/StaticFieldAccess.java @@ -41,7 +41,7 @@ package gnu.java.beans.encoder.elements; import gnu.java.beans.encoder.Writer; /** Generates an XML element denoting a static method call. - * + * * @author Robert Schuster (robertschuster@fsfe.org) * */ diff --git a/libjava/classpath/gnu/java/beans/encoder/elements/StaticMethodInvocation.java b/libjava/classpath/gnu/java/beans/encoder/elements/StaticMethodInvocation.java index 40c46a5..92d49dc 100644 --- a/libjava/classpath/gnu/java/beans/encoder/elements/StaticMethodInvocation.java +++ b/libjava/classpath/gnu/java/beans/encoder/elements/StaticMethodInvocation.java @@ -42,26 +42,26 @@ package gnu.java.beans.encoder.elements; import gnu.java.beans.encoder.Writer; /** - * + * * @author Robert Schuster (robertschuster@fsfe.org) * */ public class StaticMethodInvocation extends Element { final String className; - + final String methodName; - + public StaticMethodInvocation(String newClassName, String newMethodName) { className = newClassName; methodName = newMethodName; } - + public void writeStart(Writer writer) { writer.write("void", new String[] { "class", "method" }, new String[] { className, methodName }, isEmpty()); } - + } diff --git a/libjava/classpath/gnu/java/beans/encoder/elements/StringReference.java b/libjava/classpath/gnu/java/beans/encoder/elements/StringReference.java index c368e65..7e6787d 100644 --- a/libjava/classpath/gnu/java/beans/encoder/elements/StringReference.java +++ b/libjava/classpath/gnu/java/beans/encoder/elements/StringReference.java @@ -54,7 +54,7 @@ public class StringReference extends Element { writer.writeNoChildren("string", string); } - + public void writeEnd(Writer writer) { writer.writeEndNoChildren(); |