KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > bcel > generic > ReturnaddressType


1 /*
2  * Copyright 2000-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17 package org.apache.bcel.generic;
18
19 import org.apache.bcel.Constants;
20
21 /**
22  * Returnaddress, the type JSR or JSR_W instructions push upon the stack.
23  *
24  * see vmspec2 3.3.3
25  * @version $Id: ReturnaddressType.java 386056 2006-03-15 11:31:56Z tcurdt $
26  * @author Enver Haase
27  */

28 public class ReturnaddressType extends Type {
29
30     public static final ReturnaddressType NO_TARGET = new ReturnaddressType();
31     private InstructionHandle returnTarget;
32
33
34     /**
35      * A Returnaddress [that doesn't know where to return to].
36      */

37     private ReturnaddressType() {
38         super(Constants.T_ADDRESS, "<return address>");
39     }
40
41
42     /**
43      * Creates a ReturnaddressType object with a target.
44      */

45     public ReturnaddressType(InstructionHandle returnTarget) {
46         super(Constants.T_ADDRESS, "<return address targeting " + returnTarget + ">");
47         this.returnTarget = returnTarget;
48     }
49
50
51     /** @return a hash code value for the object.
52      */

53     public int hashCode() {
54         if (returnTarget == null) {
55             return 0;
56         }
57         return returnTarget.hashCode();
58     }
59
60
61     /**
62      * Returns if the two Returnaddresses refer to the same target.
63      */

64     public boolean equals( Object JavaDoc rat ) {
65         if (!(rat instanceof ReturnaddressType)) {
66             return false;
67         }
68         ReturnaddressType that = (ReturnaddressType) rat;
69         if (this.returnTarget == null || that.returnTarget == null) {
70             return that.returnTarget == this.returnTarget;
71         }
72         return that.returnTarget.equals(this.returnTarget);
73     }
74
75
76     /**
77      * @return the target of this ReturnaddressType
78      */

79     public InstructionHandle getTarget() {
80         return returnTarget;
81     }
82 }
83
Popular Tags