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 / DocumentBeanInfo.java < prev    next >
Encoding:
Java Source  |  1997-10-13  |  3.4 KB  |  81 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>Document</code> class to resolve which overloaded functions
  8.  * are accessible through scripting.
  9.  */
  10. public class DocumentBeanInfo extends SimpleBeanInfo {
  11.     private final static Class beanClass =
  12.         Document.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 addChildMethod;
  23.         Method removeChildMethod;
  24.         Method createElement1Method;  
  25.         Method createElement2Method;  
  26.         Method parsedMethod;  
  27.         Method loadMethod;  
  28. //        Method reportErrorMethod;  
  29. //        Method createOutputStreamMethod;  
  30. //        Method saveMethod;  
  31.         Method elementDeclarationsMethod;  
  32.         Method clearMethod;  
  33.  
  34.         Class args[] = { };
  35.         Class addChildArgs[] = { Element.class, Element.class };
  36.         Class elementArgs[] = { Element.class };
  37.         Class createElement1Args[] = { int.class, String.class };
  38.         Class createElement2Args[] = { int.class };
  39.         Class loadArgs[] = { String.class };
  40. //        Class reportErrorArgs[] = { ParseException.class, OutputStream.class };
  41. //        Class createOutputStreamArgs[] = { OutputStream.class };
  42. //        Class saveArgs[] = { XMLOutputStream.class };
  43.  
  44.         try {
  45.             addChildMethod = Document.class.getMethod("addChild", addChildArgs);
  46.             removeChildMethod = Document.class.getMethod("removeChild", elementArgs);
  47.             createElement1Method = Document.class.getMethod("createElement", createElement1Args);
  48.             createElement2Method = Document.class.getMethod("createElement", createElement2Args);
  49.             parsedMethod = Document.class.getMethod("parsed", elementArgs);
  50.             loadMethod = Document.class.getMethod("load", loadArgs);
  51. //            reportErrorMethod = Document.class.getMethod("reportError", reportErrorArgs);
  52. //            createOutputStreamMethod = Document.class.getMethod("createOutputStream", createOutputStreamArgs);
  53. //            saveMethod = Document.class.getMethod("save", saveArgs);
  54.             elementDeclarationsMethod = Document.class.getMethod("elementDeclarations", args);
  55.             clearMethod = Document.class.getMethod("clear", args);        
  56.         } catch (Exception ex) {
  57.             // "should never happen"
  58.             throw new Error("Missing method: " + ex);
  59.         }
  60.  
  61.         // Now create the MethodDescriptor array
  62.         // with visible event response methods:
  63.         MethodDescriptor result[] = { 
  64.             new MethodDescriptor(addChildMethod),
  65.             new MethodDescriptor(removeChildMethod),
  66.             new MethodDescriptor(createElement1Method),
  67.             new MethodDescriptor(createElement2Method),
  68.             new MethodDescriptor(parsedMethod),
  69.             new MethodDescriptor(loadMethod),
  70. //            new MethodDescriptor(reportErrorMethod),
  71. //            new MethodDescriptor(createOutputStreamMethod),
  72. //            new MethodDescriptor(saveMethod),
  73.             new MethodDescriptor(elementDeclarationsMethod),
  74.             new MethodDescriptor(clearMethod),
  75.         };          
  76.  
  77.         return result;
  78.     }
  79.  
  80. }
  81.