home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML in Action / Dynamicke-HTML-v-akci-covermount.bin / XML / PARSER / XMLINST.EXE / classes / com / ms / xml / om / ElementImplBeanInfo.java < prev    next >
Encoding:
Java Source  |  1997-10-30  |  3.2 KB  |  77 lines

  1. package com.ms.xml.om;
  2. import java.beans.*;
  3. import java.lang.reflect.Method;
  4.  
  5. /**
  6.  * This class provides specialized JavaBeans support for the
  7.  * <code>ElementImpl</code> class to resolve which overloaded functions
  8.  * are accessible through scripting.
  9.  */
  10. public class ElementImplBeanInfo extends SimpleBeanInfo {
  11.     private final static Class beanClass =
  12.         ElementImpl.class;
  13.  
  14. /**
  15.  * Returns the method descriptions for the methods that are 
  16.  * to be made available through scripting.
  17.  * @return an array of <code>MethodDescriptor</code> objects.
  18.  */
  19.     public MethodDescriptor[] getMethodDescriptors() 
  20.     {
  21.         // First find the "method" objects.
  22.         Method numElementMethod;
  23.         Method addChildMethod;
  24.         Method getChildMethod;
  25.         Method removeChildMethod;
  26.         Method numAttributesMethod;
  27.         Method getAttributeMethod;
  28.         Method setAttributeMethod;
  29.         Method removeAttributeMethod;
  30.         Method qualifyNameMethod;
  31. //        Method saveMethod;
  32.         
  33.         Class args[] = { };
  34.         Class addChildArgs[] = { Element.class, int.class, int.class };
  35.         Class getChildArgs[] = { int.class };
  36.         Class removeChildArgs[] = { Element.class };
  37.         Class getAttributeArgs[] = { String.class };
  38.         Class setAttributeArgs[] = { String.class , Object.class };
  39.         Class qualifyNameArgs[] = { String.class };
  40. //        Class saveArgs[] = { XMLOutputStream.class };
  41.  
  42.         try {
  43.             numElementMethod = ElementImpl.class.getMethod("numElements", args);
  44.             addChildMethod = ElementImpl.class.getMethod("addChild", addChildArgs);
  45.             getChildMethod = ElementImpl.class.getMethod("getChild", getChildArgs);
  46.             removeChildMethod = ElementImpl.class.getMethod("removeChild", removeChildArgs);
  47.             numAttributesMethod = ElementImpl.class.getMethod("numAttributes", args);
  48.             getAttributeMethod = ElementImpl.class.getMethod("getAttribute", getAttributeArgs);
  49.             setAttributeMethod = ElementImpl.class.getMethod("setAttribute", setAttributeArgs);
  50.             removeAttributeMethod = ElementImpl.class.getMethod("removeAttribute", getAttributeArgs);
  51.             qualifyNameMethod = ElementImpl.class.getMethod("qualifyName", qualifyNameArgs);
  52. //            saveMethod = ElementImpl.class.getMethod("save", saveArgs);
  53.         } catch (Exception ex) {
  54.             // "should never happen"
  55.             throw new Error("Missing method: " + ex);
  56.         }
  57.  
  58.         // Now create the MethodDescriptor array
  59.         // with visible event response methods:
  60.         MethodDescriptor result[] = { 
  61.             new MethodDescriptor(numElementMethod),
  62.             new MethodDescriptor(addChildMethod),
  63.             new MethodDescriptor(getChildMethod),
  64.             new MethodDescriptor(removeChildMethod),
  65.             new MethodDescriptor(numAttributesMethod),
  66.             new MethodDescriptor(getAttributeMethod),
  67.             new MethodDescriptor(setAttributeMethod),
  68.             new MethodDescriptor(removeAttributeMethod),
  69.             new MethodDescriptor(qualifyNameMethod)
  70. //            new MethodDescriptor(saveMethod)
  71.         };          
  72.  
  73.         return result;
  74.     }
  75.  
  76. }
  77.