home *** CD-ROM | disk | FTP | other *** search
Java Source | 2000-08-10 | 17.1 KB | 456 lines |
- package com.ibm.ivj.wte.samples.leapyear;
-
- // Licensed Material - Property of IBM
- // (C) Copyright IBM Corp. 2000 - All Rights Reserved
- //
- // DISCLAIMER:
- // The following [enclosed] code is sample code created by IBM
- // Corporation. This sample code is not part of any standard IBM product
- // and is provided to you solely for the purpose of assisting you in the
- // development of your applications. The code is provided 'AS IS',
- // without warranty or condition of any kind. IBM shall not be liable for any damages
- // arising out of your use of the sample code, even if IBM has been
- // advised of the possibility of such damages.
-
- /**
- * The bean information class for com.ibm.ivj.wte.samples.leapyear.LeapYearBean.
- */
- public class LeapYearBeanBeanInfo extends java.beans.SimpleBeanInfo {
- private static final String copyright =
- "(c) Copyright IBM Corporation 2000.";
-
- /**
- * Gets the findLeapYears() method descriptor.
- * @return java.beans.MethodDescriptor
- */
- public java.beans.MethodDescriptor findLeapYearsMethodDescriptor() {
- java.beans.MethodDescriptor aDescriptor = null;
- try {
- /* Create and return the findLeapYears() method descriptor. */
- java.lang.reflect.Method aMethod = null;
- try {
- /* Attempt to find the method using getMethod with parameter types. */
- java.lang.Class aParameterTypes[] = {};
- aMethod = getBeanClass().getMethod("findLeapYears", aParameterTypes);
- } catch (Throwable exception) {
- /* Since getMethod failed, call findMethod. */
- handleException(exception);
- aMethod = findMethod(getBeanClass(), "findLeapYears", 0);
- };
- try {
- /* Try creating the method descriptor with parameter descriptors. */
- java.beans.ParameterDescriptor aParameterDescriptors[] = {};
- aDescriptor = new java.beans.MethodDescriptor(aMethod, aParameterDescriptors);
- } catch (Throwable exception) {
- /* Try creating the method descriptor without parameter descriptors. */
- handleException(exception);
- aDescriptor = new java.beans.MethodDescriptor(aMethod);
- };
- /* aDescriptor.setDisplayName("findLeapYears()"); */
- /* aDescriptor.setShortDescription("findLeapYears()"); */
- /* aDescriptor.setExpert(false); */
- /* aDescriptor.setHidden(false); */
- /* aDescriptor.setValue("preferred", new Boolean(false)); */
- } catch (Throwable exception) {
- handleException(exception);
- };
- return aDescriptor;
- }
- /**
- * Find the method by comparing (name & parameter size) against the methods in the class.
- * @return java.lang.reflect.Method
- * @param aClass java.lang.Class
- * @param methodName java.lang.String
- * @param parameterCount int
- */
- public static java.lang.reflect.Method findMethod(java.lang.Class aClass, java.lang.String methodName, int parameterCount) {
- try {
- /* Since this method attempts to find a method by getting all methods from the class,
- this method should only be called if getMethod cannot find the method. */
- java.lang.reflect.Method methods[] = aClass.getMethods();
- for (int index = 0; index < methods.length; index++){
- java.lang.reflect.Method method = methods[index];
- if ((method.getParameterTypes().length == parameterCount) && (method.getName().equals(methodName))) {
- return method;
- }
- }
- } catch (java.lang.Throwable exception) {
- return null;
- }
- return null;
- }
- /**
- * Returns the BeanInfo of the superclass of this bean to inherit its features.
- * @return java.beans.BeanInfo[]
- */
- public java.beans.BeanInfo[] getAdditionalBeanInfo() {
- java.lang.Class superClass;
- java.beans.BeanInfo superBeanInfo = null;
-
- try {
- superClass = getBeanDescriptor().getBeanClass().getSuperclass();
- } catch (java.lang.Throwable exception) {
- return null;
- }
-
- try {
- superBeanInfo = java.beans.Introspector.getBeanInfo(superClass);
- } catch (java.beans.IntrospectionException ie) {}
-
- if (superBeanInfo != null) {
- java.beans.BeanInfo[] ret = new java.beans.BeanInfo[1];
- ret[0] = superBeanInfo;
- return ret;
- }
- return null;
- }
- /**
- * Gets the bean class.
- * @return java.lang.Class
- */
- public static java.lang.Class getBeanClass() {
- return com.ibm.ivj.wte.samples.leapyear.LeapYearBean.class;
- }
- /**
- * Gets the bean class name.
- * @return java.lang.String
- */
- public static java.lang.String getBeanClassName() {
- return "com.ibm.ivj.wte.samples.leapyear.LeapYearBean";
- }
- public java.beans.BeanDescriptor getBeanDescriptor() {
- java.beans.BeanDescriptor aDescriptor = null;
- try {
- /* Create and return the LeapYearBeanBeanInfo bean descriptor. */
- aDescriptor = new java.beans.BeanDescriptor(com.ibm.ivj.wte.samples.leapyear.LeapYearBean.class);
- /* aDescriptor.setExpert(false); */
- /* aDescriptor.setHidden(false); */
- /* aDescriptor.setValue("hidden-state", Boolean.FALSE); */
- } catch (Throwable exception) {
- };
- return aDescriptor;
- }
- /**
- * Return the event set descriptors for this bean.
- * @return java.beans.EventSetDescriptor[]
- */
- public java.beans.EventSetDescriptor[] getEventSetDescriptors() {
- try {
- java.beans.EventSetDescriptor aDescriptorList[] = {};
- return aDescriptorList;
- } catch (Throwable exception) {
- handleException(exception);
- };
- return null;
- }
- /**
- * Gets the getLeapYears(int) method descriptor.
- * @return java.beans.MethodDescriptor
- */
- public java.beans.MethodDescriptor getLeapYears_intMethodDescriptor() {
- java.beans.MethodDescriptor aDescriptor = null;
- try {
- /* Create and return the getLeapYears(int) method descriptor. */
- java.lang.reflect.Method aMethod = null;
- try {
- /* Attempt to find the method using getMethod with parameter types. */
- java.lang.Class aParameterTypes[] = {
- int.class
- };
- aMethod = getBeanClass().getMethod("getLeapYears", aParameterTypes);
- } catch (Throwable exception) {
- /* Since getMethod failed, call findMethod. */
- handleException(exception);
- aMethod = findMethod(getBeanClass(), "getLeapYears", 1);
- };
- try {
- /* Try creating the method descriptor with parameter descriptors. */
- java.beans.ParameterDescriptor aParameterDescriptor1 = new java.beans.ParameterDescriptor();
- aParameterDescriptor1.setName("arg1");
- aParameterDescriptor1.setDisplayName("index");
- java.beans.ParameterDescriptor aParameterDescriptors[] = {
- aParameterDescriptor1
- };
- aDescriptor = new java.beans.MethodDescriptor(aMethod, aParameterDescriptors);
- } catch (Throwable exception) {
- /* Try creating the method descriptor without parameter descriptors. */
- handleException(exception);
- aDescriptor = new java.beans.MethodDescriptor(aMethod);
- };
- /* aDescriptor.setDisplayName("getLeapYears(int)"); */
- /* aDescriptor.setShortDescription("getLeapYears(int)"); */
- /* aDescriptor.setExpert(false); */
- /* aDescriptor.setHidden(false); */
- /* aDescriptor.setValue("preferred", new Boolean(false)); */
- } catch (Throwable exception) {
- handleException(exception);
- };
- return aDescriptor;
- }
- /**
- * Return the method descriptors for this bean.
- * @return java.beans.MethodDescriptor[]
- */
- public java.beans.MethodDescriptor[] getMethodDescriptors() {
- try {
- java.beans.MethodDescriptor aDescriptorList[] = {
- findLeapYearsMethodDescriptor()
- ,getLeapYears_intMethodDescriptor()
- ,isLeapYear_intMethodDescriptor()
- ,setLeapYears_int_intMethodDescriptor()
- };
- return aDescriptorList;
- } catch (Throwable exception) {
- handleException(exception);
- };
- return null;
- }
- /**
- * Return the property descriptors for this bean.
- * @return java.beans.PropertyDescriptor[]
- */
- public java.beans.PropertyDescriptor[] getPropertyDescriptors() {
- try {
- java.beans.PropertyDescriptor aDescriptorList[] = {
- startYearPropertyDescriptor()
- };
- return aDescriptorList;
- } catch (Throwable exception) {
- handleException(exception);
- };
- return null;
- }
- /**
- * Called whenever the bean information class throws an exception.
- * @param exception java.lang.Throwable
- */
- private void handleException(java.lang.Throwable exception) {
-
- /* Uncomment the following lines to print uncaught exceptions to stdout */
- // System.out.println("--------- UNCAUGHT EXCEPTION ---------");
- // exception.printStackTrace(System.out);
- }
- /**
- * Gets the isLeapYear(int) method descriptor.
- * @return java.beans.MethodDescriptor
- */
- public java.beans.MethodDescriptor isLeapYear_intMethodDescriptor() {
- java.beans.MethodDescriptor aDescriptor = null;
- try {
- /* Create and return the isLeapYear(int) method descriptor. */
- java.lang.reflect.Method aMethod = null;
- try {
- /* Attempt to find the method using getMethod with parameter types. */
- java.lang.Class aParameterTypes[] = {
- int.class
- };
- aMethod = getBeanClass().getMethod("isLeapYear", aParameterTypes);
- } catch (Throwable exception) {
- /* Since getMethod failed, call findMethod. */
- handleException(exception);
- aMethod = findMethod(getBeanClass(), "isLeapYear", 1);
- };
- try {
- /* Try creating the method descriptor with parameter descriptors. */
- java.beans.ParameterDescriptor aParameterDescriptor1 = new java.beans.ParameterDescriptor();
- aParameterDescriptor1.setName("arg1");
- aParameterDescriptor1.setDisplayName("argYear");
- java.beans.ParameterDescriptor aParameterDescriptors[] = {
- aParameterDescriptor1
- };
- aDescriptor = new java.beans.MethodDescriptor(aMethod, aParameterDescriptors);
- } catch (Throwable exception) {
- /* Try creating the method descriptor without parameter descriptors. */
- handleException(exception);
- aDescriptor = new java.beans.MethodDescriptor(aMethod);
- };
- /* aDescriptor.setDisplayName("isLeapYear(int)"); */
- /* aDescriptor.setShortDescription("isLeapYear(int)"); */
- /* aDescriptor.setExpert(false); */
- /* aDescriptor.setHidden(false); */
- /* aDescriptor.setValue("preferred", new Boolean(false)); */
- } catch (Throwable exception) {
- handleException(exception);
- };
- return aDescriptor;
- }
- /**
- * Gets the leapYears property descriptor.
- * @return java.beans.IndexedPropertyDescriptor
- */
- public java.beans.IndexedPropertyDescriptor leapYearsPropertyDescriptor() {
- java.beans.IndexedPropertyDescriptor aDescriptor = null;
- try {
- try {
- /* Using methods via getMethod is the faster way to create the leapYears property descriptor. */
- java.lang.reflect.Method aGetMethod = null;
- try {
- /* Attempt to find the method using getMethod with parameter types. */
- java.lang.Class aGetMethodParameterTypes[] = {};
- aGetMethod = getBeanClass().getMethod("getLeapYears", aGetMethodParameterTypes);
- } catch (Throwable exception) {
- /* Since getMethod failed, call findMethod. */
- handleException(exception);
- aGetMethod = findMethod(getBeanClass(), "getLeapYears", 0);
- };
- java.lang.reflect.Method aSetMethod = null;
- try {
- /* Attempt to find the method using getMethod with parameter types. */
- java.lang.Class aSetMethodParameterTypes[] = {
- int[].class
- };
- aSetMethod = getBeanClass().getMethod("setLeapYears", aSetMethodParameterTypes);
- } catch (Throwable exception) {
- /* Since getMethod failed, call findMethod. */
- handleException(exception);
- aSetMethod = findMethod(getBeanClass(), "setLeapYears", 1);
- };
- java.lang.reflect.Method aGetIndexedMethod = null;
- try {
- /* Attempt to find the method using getMethod with parameter types. */
- java.lang.Class aGetIndexedMethodParameterTypes[] = {
- int.class
- };
- aGetIndexedMethod = getBeanClass().getMethod("getLeapYears", aGetIndexedMethodParameterTypes);
- } catch (Throwable exception) {
- /* Since getMethod failed, call findMethod. */
- handleException(exception);
- aGetIndexedMethod = findMethod(getBeanClass(), "getLeapYears", 1);
- };
- java.lang.reflect.Method aSetIndexedMethod = null;
- try {
- /* Attempt to find the method using getMethod with parameter types. */
- java.lang.Class aSetIndexedMethodParameterTypes[] = {
- int.class,
- int.class
- };
- aSetIndexedMethod = getBeanClass().getMethod("setLeapYears", aSetIndexedMethodParameterTypes);
- } catch (Throwable exception) {
- /* Since getMethod failed, call findMethod. */
- handleException(exception);
- aSetIndexedMethod = findMethod(getBeanClass(), "setLeapYears", 2);
- };
- aDescriptor = new java.beans.IndexedPropertyDescriptor("leapYears"
- , aGetMethod, aSetMethod, aGetIndexedMethod, aSetIndexedMethod);
- } catch (Throwable exception) {
- /* Since we failed using methods, try creating a default property descriptor. */
- handleException(exception);
- aDescriptor = new java.beans.IndexedPropertyDescriptor("leapYears"
- , getBeanClass());
- };
- /* aDescriptor.setBound(false); */
- /* aDescriptor.setConstrained(false); */
- /* aDescriptor.setDisplayName("leapYears"); */
- /* aDescriptor.setShortDescription("leapYears"); */
- /* aDescriptor.setExpert(false); */
- /* aDescriptor.setHidden(false); */
- /* aDescriptor.setValue("preferred", new Boolean(false)); */
- /* aDescriptor.setValue("ivjDesignTimeProperty", new Boolean(true)); */
- } catch (Throwable exception) {
- handleException(exception);
- };
- return aDescriptor;
- }
- /**
- * Gets the setLeapYears(int, int) method descriptor.
- * @return java.beans.MethodDescriptor
- */
- public java.beans.MethodDescriptor setLeapYears_int_intMethodDescriptor() {
- java.beans.MethodDescriptor aDescriptor = null;
- try {
- /* Create and return the setLeapYears(int, int) method descriptor. */
- java.lang.reflect.Method aMethod = null;
- try {
- /* Attempt to find the method using getMethod with parameter types. */
- java.lang.Class aParameterTypes[] = {
- int.class,
- int.class
- };
- aMethod = getBeanClass().getMethod("setLeapYears", aParameterTypes);
- } catch (Throwable exception) {
- /* Since getMethod failed, call findMethod. */
- handleException(exception);
- aMethod = findMethod(getBeanClass(), "setLeapYears", 2);
- };
- try {
- /* Try creating the method descriptor with parameter descriptors. */
- java.beans.ParameterDescriptor aParameterDescriptor1 = new java.beans.ParameterDescriptor();
- aParameterDescriptor1.setName("arg1");
- aParameterDescriptor1.setDisplayName("index");
- java.beans.ParameterDescriptor aParameterDescriptor2 = new java.beans.ParameterDescriptor();
- aParameterDescriptor2.setName("arg2");
- aParameterDescriptor2.setDisplayName("leapYears");
- java.beans.ParameterDescriptor aParameterDescriptors[] = {
- aParameterDescriptor1,
- aParameterDescriptor2
- };
- aDescriptor = new java.beans.MethodDescriptor(aMethod, aParameterDescriptors);
- } catch (Throwable exception) {
- /* Try creating the method descriptor without parameter descriptors. */
- handleException(exception);
- aDescriptor = new java.beans.MethodDescriptor(aMethod);
- };
- /* aDescriptor.setDisplayName("setLeapYears(int, int)"); */
- /* aDescriptor.setShortDescription("setLeapYears(int, int)"); */
- /* aDescriptor.setExpert(false); */
- /* aDescriptor.setHidden(false); */
- /* aDescriptor.setValue("preferred", new Boolean(false)); */
- } catch (Throwable exception) {
- handleException(exception);
- };
- return aDescriptor;
- }
- /**
- * Gets the startYear property descriptor.
- * @return java.beans.PropertyDescriptor
- */
- public java.beans.PropertyDescriptor startYearPropertyDescriptor() {
- java.beans.PropertyDescriptor aDescriptor = null;
- try {
- try {
- /* Using methods via getMethod is the faster way to create the startYear property descriptor. */
- java.lang.reflect.Method aGetMethod = null;
- try {
- /* Attempt to find the method using getMethod with parameter types. */
- java.lang.Class aGetMethodParameterTypes[] = {};
- aGetMethod = getBeanClass().getMethod("getStartYear", aGetMethodParameterTypes);
- } catch (Throwable exception) {
- /* Since getMethod failed, call findMethod. */
- handleException(exception);
- aGetMethod = findMethod(getBeanClass(), "getStartYear", 0);
- };
- java.lang.reflect.Method aSetMethod = null;
- try {
- /* Attempt to find the method using getMethod with parameter types. */
- java.lang.Class aSetMethodParameterTypes[] = {
- int.class
- };
- aSetMethod = getBeanClass().getMethod("setStartYear", aSetMethodParameterTypes);
- } catch (Throwable exception) {
- /* Since getMethod failed, call findMethod. */
- handleException(exception);
- aSetMethod = findMethod(getBeanClass(), "setStartYear", 1);
- };
- aDescriptor = new java.beans.PropertyDescriptor("startYear"
- , aGetMethod, aSetMethod);
- } catch (Throwable exception) {
- /* Since we failed using methods, try creating a default property descriptor. */
- handleException(exception);
- aDescriptor = new java.beans.PropertyDescriptor("startYear"
- , getBeanClass());
- };
- /* aDescriptor.setBound(false); */
- /* aDescriptor.setConstrained(false); */
- /* aDescriptor.setDisplayName("startYear"); */
- /* aDescriptor.setShortDescription("startYear"); */
- /* aDescriptor.setExpert(false); */
- /* aDescriptor.setHidden(false); */
- /* aDescriptor.setValue("preferred", new Boolean(false)); */
- /* aDescriptor.setValue("ivjDesignTimeProperty", new Boolean(true)); */
- } catch (Throwable exception) {
- handleException(exception);
- };
- return aDescriptor;
- }
- }
-