View Javadoc

1   /*
2    * Copyright (c) 2003-2008 by Cosylab d. d.
3    *
4    * This file is part of Java-Common.
5    *
6    * Java-Common is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU General Public License as published by
8    * the Free Software Foundation, either version 3 of the License, or
9    * (at your option) any later version.
10   *
11   * Java-Common is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details.
15   *
16   * You should have received a copy of the GNU General Public License
17   * along with Java-Common.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  
20  package com.cosylab.introspection;
21  
22  import java.lang.reflect.Member;
23  /**
24   * This class serves as a filter for selecting members in
25   * a <code>Class</code> or from an array.
26   * 
27   * @author Miha Kadunc (miha.kadunc@cosylab.com)
28   * @version @@VERSION@@
29   */
30  public interface MemberFilter {
31  	/**
32     * Should return true iff the filter allows
33     * constructors to be contained in the output.
34     * Should only some of the constructors be filtered,
35     * this method should return true and specify a
36     * custom filter in the <code>isAllowed(Member)</code> method.
37     * 
38  	 * @return boolean
39  	 */
40  	public boolean areConstructorsAllowed();
41    
42  	/**
43     * If filter is used to retrieve members from a class,
44     * this method should return true iff only members
45     * that are declared in the given class are to be
46     * returned, discarding members that are declared in
47     * superclasses or superinterfaces.
48     * 
49  	 * @return boolean
50  	 */
51  	public boolean areDeclaredOnly();
52    
53  	/**
54     * Should return true iff the filter allows fields.
55     * 
56  	 * @return boolean
57  	 */
58  	public boolean areFieldsAllowed();
59    
60  	/**
61     * Should return true iff the filter allows methods.
62     * 
63  	 * @return boolean
64  	 */
65  	public boolean areMethodsAllowed();
66    
67  	/**
68     * Should return true iff the filter discards all
69     * the non-public members.
70     * 
71  	 * @return boolean
72  	 */
73  	public boolean arePublicOnly();
74    
75  	/**
76     * When other methods in this class are not sufficient for
77     * the filter implementation, this method should be used.
78     * Members, that comply with all other requirements by this
79     * class's methods, will be passed as a parameter to this method,
80     * which decides whether a given member should be contained in the
81     * output or not.
82     * 
83  	 * @param member Member
84  	 * @return boolean
85  	 */
86  	public boolean isAllowed(Member member);
87  }