home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / beans / MethodDescriptor.java < prev    next >
Encoding:
Java Source  |  1998-03-20  |  2.7 KB  |  99 lines

  1. /*
  2.  * @(#)MethodDescriptor.java    1.19 98/03/18
  3.  *
  4.  * Copyright 1996, 1997 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.beans;
  16.  
  17. import java.lang.reflect.*;
  18.  
  19. /**
  20.  * A MethodDescriptor describes a particular method that a Java Bean
  21.  * supports for external access from other components.
  22.  */
  23.  
  24. public class MethodDescriptor extends FeatureDescriptor {
  25.  
  26.     /**
  27.      * @param method    The low-level method information.
  28.      */
  29.     public MethodDescriptor(Method method) {
  30.     this.method = method;
  31.     setName(method.getName());
  32.     }
  33.  
  34.  
  35.     /**
  36.      * @param method    The low-level method information.
  37.      * @param parameterDescriptors  Descriptive information for each of the
  38.      *                 method's parameters.
  39.      */
  40.     public MethodDescriptor(Method method, 
  41.         ParameterDescriptor parameterDescriptors[]) {
  42.     this.method = method;
  43.     this.parameterDescriptors = parameterDescriptors;
  44.     setName(method.getName());
  45.     }
  46.  
  47.     /**
  48.      * @return The low-level description of the method
  49.      */
  50.     public Method getMethod() {
  51.     return method;
  52.     }
  53.  
  54.  
  55.     /**
  56.      * @return The locale-independent names of the parameters.  May return
  57.      *        a null array if the parameter names aren't known.
  58.      */
  59.     public ParameterDescriptor[] getParameterDescriptors() {
  60.     return parameterDescriptors;
  61.     }
  62.  
  63.     /*
  64.      * Package-private constructor
  65.      * Merge two method descriptors.  Where they conflict, give the
  66.      * second argument (y) priority over the first argument (x).
  67.      * @param x  The first (lower priority) MethodDescriptor
  68.      * @param y  The second (higher priority) MethodDescriptor
  69.      */
  70.  
  71.     MethodDescriptor(MethodDescriptor x, MethodDescriptor y) {
  72.     super(x,y);
  73.     method = x.method;
  74.     parameterDescriptors = x.parameterDescriptors;
  75.     if (y.parameterDescriptors != null) {
  76.         parameterDescriptors = y.parameterDescriptors;
  77.     }
  78.     }
  79.  
  80.     /*
  81.      * Package-private dup constructor
  82.      * This must isolate the new object from any changes to the old object.
  83.      */
  84.     MethodDescriptor(MethodDescriptor old) {
  85.     super(old);
  86.     method = old.method;    
  87.     if (old.parameterDescriptors != null) {
  88.         int len = old.parameterDescriptors.length;
  89.         parameterDescriptors = new ParameterDescriptor[len];
  90.         for (int i = 0; i < len ; i++) {
  91.             parameterDescriptors[i] = new ParameterDescriptor(old.parameterDescriptors[i]);
  92.         }
  93.     }
  94.     }
  95.  
  96.     private Method method;
  97.     private ParameterDescriptor parameterDescriptors[];
  98. }
  99.