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    /**
024     * Wrap up details about a field in a Java class file.
025     *
026     * <p>
027     * Instances of this type will be instantiated by CodeClass instances, using
028     * the getField() methods.
029     * </p>
030     *
031     * @author Thomas Down
032     * @author Matthew Pocock
033     */
034    public final class CodeField {
035      private final String name;
036      private final CodeClass clazz;
037      private final int modifiers;
038      private final CodeClass container;
039    
040      CodeField(CodeClass container, String name, CodeClass clazz, int mods) {
041        this.container = container;
042        this.name = name;
043        this.clazz = clazz;
044        this.modifiers = mods;
045      }
046    
047      /**
048       * Get the name of the field.
049       *
050       * @return  the name of the field
051       */
052      public String getName() {
053        return name;
054      }
055    
056      /**
057       * Get the fully qualified name of the field.
058       *
059       * @return the fully qualified name
060       */
061      public String getFullName() {
062        return container.getName() + "." + getName();
063      }
064    
065      /**
066       * Get the class that contains this field.
067       *
068       * @return the containing class
069       */
070      public CodeClass getContainingClass() {
071        return container;
072      }
073    
074      /**
075       * Get the type of the field.
076       *
077       * @return
078       */
079      public CodeClass getType() {
080        return clazz;
081      }
082    
083      /**
084       * Get the moddifiers applied to this field.
085       *
086       * @return the modifiers
087       */
088      public int getModifiers() {
089        return modifiers;
090      }
091    
092      public String toString() {
093        return super.toString() +
094                " type: " + getType() +
095                " class: " + clazz.getName() +
096                " name: " + getName();
097      }
098    }