001    /*
002     *                    BioJava development code
003     *
004     * This code may be freely distributed and modified under the
005     * terms of the GNU Lesser General Public Licence.  This should
006     * be distributed with the code.  If you do not have a copy,
007     * see:
008     *
009     *      http://www.gnu.org/copyleft/lesser.html
010     *
011     * Copyright for this code is held jointly by the individual
012     * authors.  These should be listed in @author doc comments.
013     *
014     * For more information on the BioJava project and its aims,
015     * or to join the biojava-l mailing list, visit the home page
016     * at:
017     *
018     *      http://www.biojava.org/
019     *
020     */
021    package org.biojava.utils.bytecode;
022    
023    import java.util.*;
024    
025    /**
026     * Interface for Java classes within the bytecode generation framework.
027     * Any class (or interface) can be viewed as a CodeClass, whether it
028     * is pre-existing or being generated.
029     *
030     * @author Thomas Down
031     * @author Matthew Pocock
032     */
033    
034    public interface CodeClass {
035      String getName();
036    
037      String getJName();
038    
039      String getDescriptor();
040    
041      CodeClass getSuperClass();
042    
043      List getInterfaces();
044    
045      /**
046       * Get all methods declared by this class and its super classes, removing
047       * all super class methods that are over ridden.
048       *
049       * <p>
050       * This should return methods, regardless of their accessability.
051       * </p>
052       *
053       * @return a Set containing all methods
054       */
055      Set getMethods();
056    
057      /**
058       * Get the name of all methods that could be invoked through this class with
059       * a given name.
060       *
061       * @param name  the name of the method
062       * @return a Set of CodeMethod instances with that name
063       */
064      Set getMethodsByName(String name);
065    
066      /**
067       * Get a method by name and argument list.
068       *
069       * @param name  the name of the method
070       * @param args  the arguments it takes
071       * @return      a matching method
072       * @throws NoSuchMethodException  if there is no maching method
073       */
074      CodeMethod getMethod(String name, CodeClass[] args)
075              throws NoSuchMethodException;
076    
077      /**
078       * Get a constructor by argument list.
079       *
080       * @param args  the arguments it takes
081       * @return      a matching constructor
082       * @throws NoSuchMethodException  if there is no matching constructor
083       */
084      CodeMethod getConstructor(CodeClass[] args)
085              throws NoSuchMethodException;
086    
087      /**
088       * Get a field by its name.
089       *
090       * @param name  the field name
091       * @return      a CodeField representing the field
092       * @throws NoSuchFieldException if there is no field by that name accessible
093       *   through this class
094       */
095      CodeField getFieldByName(String name)
096              throws NoSuchFieldException;
097    
098      /**
099       * Get all fields accessible through this class.
100       *
101       * @return  a Set of all accessible fields
102       */
103      Set getFields();
104    
105      /**
106       * Get the modifiers associated with the class.
107       *
108       * @return  the modifier integer
109       */
110      int getModifiers();
111    
112      /**
113       * Discover if the class represents a primitive type.
114       *
115       * @return  true if the class represents a primative type
116       */
117      public boolean isPrimitive();
118    
119      /**
120       * Discover if the class is an array type.
121       *
122       * @return  true if the class is an array type
123       */
124      public boolean isArray();
125    }