001    /* MBEL: The Microsoft Bytecode Engineering Library
002     * Copyright (C) 2003 The University of Arizona
003     * http://www.cs.arizona.edu/mbel/license.html
004     *
005     * This library is free software; you can redistribute it and/or
006     * modify it under the terms of the GNU Lesser General Public
007     * License as published by the Free Software Foundation; either
008     * version 2.1 of the License, or (at your option) any later version.
009     * 
010     * This library is distributed in the hope that it will be useful,
011     * but WITHOUT ANY WARRANTY; without even the implied warranty of
012     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013     * Lesser General Public License for more details.
014     * 
015     * You should have received a copy of the GNU Lesser General Public
016     * License along with this library; if not, write to the Free Software
017     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
018     */
019    
020    package edu.arizona.cs.mbel.mbel;
021    
022    /** This class represents a set of special semantics for a method. These special
023      * semantics can be property getters or setters, or event methods. While a MethodSemantics
024      * has both getEvent and getProperty methods, only one of these will be valid for a 
025      * given instance.
026      * @author Michael Stepp
027      */
028    public class MethodSemantics implements edu.arizona.cs.mbel.signature.MethodSemanticsAttributes{
029       // Setter, Getter, Other, AddOn, RemoveOn, Fire
030       private int Semantics;  // 2 bytes
031       private Event event;
032       private Property property;
033       // only one of these will be nonnull
034    
035       /** Makes a MethodSemantics object with the given semantics code and Event parent.
036         * @param sem the semantics code value (from MethodSemanticsAttributes). Legal values are AddOn, RemoveOn, Fire, or Other
037         * @param e the event parent
038         */
039       public MethodSemantics(int sem, Event e){
040          Semantics = sem;
041          event = e;
042       }
043       
044       /** Makes a MethodSemantics object with the given semantics code and Property parent.
045         * @param sem the semantics code value (from MethodSemanticsAttributes). Legal values are Setter, Getter, or Other
046         * @param p the Property parent
047         */
048       public MethodSemantics(int sem, Property p){
049          Semantics = sem;
050          property = p;
051       }
052       
053       /** Returns the semantics code value (defined in MethodSemanticsAttributes)
054         */
055       public int getSemantics(){
056          return Semantics;
057       }
058       /** Returns the Event parent for these MethodSemantics (if this is a property method, this will return null)
059         */
060       public Event getEvent(){
061          return event;
062       }
063       /** Returns the Property parent for these MethodSemantics (if this is an event method, this will return null)
064         */
065       public Property getProperty(){
066          return property;
067       }
068       
069    /*
070       public void output(){
071          System.out.print("MethodSemantics[Semantics="+Semantics);
072          if (event!=null){
073             System.out.print(", Event=");
074             event.output();
075          }else{
076             System.out.print(", Property=");
077             property.output();
078          }
079          System.out.print("]");
080       }
081    */
082    }