KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > refactoring > java > api > PushDownRefactoring


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.refactoring.java.api;
20
21 import java.util.Collection JavaDoc;
22 import org.netbeans.api.java.source.TreePathHandle;
23 import org.netbeans.modules.refactoring.api.AbstractRefactoring;
24 import org.openide.util.Lookup;
25
26 /**
27  * Push Down Refactoring implementation class.
28  *
29  * @author Jan Becicka, Pavel Flaska
30  */

31 public class PushDownRefactoring extends AbstractRefactoring {
32     
33     private static final MemberInfo[] EMPTY_MEMBERS = new MemberInfo[0];
34     private MemberInfo[] members;
35     
36     /** Creates a new instance of PushDownRefactoring */
37     public PushDownRefactoring(Lookup sourceType) {
38         super(sourceType);
39     }
40     
41     
42     /** Returns descriptors of the members to pull up.
43      * @return Member descriptors.
44      */

45     public MemberInfo[] getMembers() {
46         // never return null
47
return members == null ? EMPTY_MEMBERS : members;
48     }
49
50     /** Sets members (using their descriptors) to pull up.
51      * @members Descriptors of members to be pulled up.
52      */

53     public void setMembers(MemberInfo[] members) {
54         this.members = members;
55     }
56     
57 // public JavaClass[] collectSubtypes() {
58
// if (subtypes == null) {
59
// if (sourceType != null) {
60
// Collection c = sourceType.findSubTypes(false);
61
// subtypes = (JavaClass[]) c.toArray(new JavaClass[c.size()]);
62
// } else {
63
// subtypes = new JavaClass[0];
64
// }
65
// }
66
// return subtypes;
67
// }
68

69     public TreePathHandle getSourceType() {
70         return getRefactoringSource().lookup(TreePathHandle.class);
71     }
72     
73     /** Class describing a member to be pushed down.
74      */

75     public static final class MemberInfo {
76         public final TreePathHandle member;
77         public final boolean makeAbstract;
78         
79         /** Creates a new instance of MemberInfo describing a method.
80          * @param method Method to be pulled up.
81          * @param makeAbstract Indicates whether the method should be made abstract
82          * in the supertype.
83          */

84         public MemberInfo(TreePathHandle method, boolean makeAbstract) {
85             this.member = method;
86             this.makeAbstract = makeAbstract;
87         }
88         
89         /** Creates a new instance of MemberInfo describing a field
90          * to be pulled up.
91          * @param field Field to be pulled up.
92          */

93         public MemberInfo(TreePathHandle innerClass) {
94             this(innerClass, false);
95         }
96         
97 // /** Creates a new instance of MemberInfo describing a field
98
// * to be pulled up.
99
// * @param field Field to be pulled up.
100
// */
101
// public MemberInfo(Field field) {
102
// this(field, false);
103
// }
104
//
105
// /** Creates a new instance of MemberInfo describing an interface name
106
// * from the implements clause that should be pulled up.
107
// * @param interfaceName Interface name to be pulled up.
108
// */
109
// public MemberInfo(MultipartId interfaceName) {
110
// this(interfaceName, false);
111
// }
112
}
113 }
114
Popular Tags