1
2
3
4
5
6
7
8
9
10 package nl.tudelft.simulation.introspection;
11
12 import java.util.ArrayList;
13 import java.util.List;
14
15 /***
16 * The AbstractSupressIntrospector.
17 * <p>
18 * (c) copyright 2003-2004 <a href="http://www.simulation.tudelft.nl">Delft
19 * University of Technology </a>, the Netherlands. <br>
20 * See for project information <a
21 * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
22 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
23 * License (GPL) </a>, no warranty <br>
24 *
25 * @author <a
26 * href="http://web.eur.nl/fbk/dep/dep1/Introduction/Staff/People/Lang">Niels
27 * Lang </a><a
28 * href="http://www.tbm.tudelft.nl/webstaf/peterja/index.htm">Peter
29 * Jacobs </a>
30 * @version 1.1 Apr 15, 2004
31 * @since 1.4
32 */
33 public abstract class AbstractSuppressIntrospector implements Introspector
34 {
35 /*** the parent introspector */
36 protected Introspector parent;
37
38 /***
39 * Constructor for AbstractSuppressIntrospector.
40 *
41 * @param parent the parent introspector
42 */
43 public AbstractSuppressIntrospector(final Introspector parent)
44 {
45 super();
46 this.parent = parent;
47 }
48
49 /***
50 * @see nl.tudelft.simulation.introspection.Introspector#getProperties(Object)
51 */
52 public Property[] getProperties(final Object arg0)
53 {
54 Property[] original = this.parent.getProperties(arg0);
55 List result = new ArrayList();
56 for (int i = 0; i < original.length; i++)
57 {
58 if (!this.suppress(original[i].getType())
59 && !this.suppress(original[i].getName()))
60 {
61 result.add(original[i]);
62 }
63 }
64 return (Property[]) result.toArray(new Property[0]);
65 }
66
67 /***
68 * @see nl.tudelft.simulation.introspection.Introspector#getPropertyNames(Object)
69 */
70 public String[] getPropertyNames(final Object arg0)
71 {
72 Property[] properties = this.getProperties(arg0);
73 String[] result = new String[properties.length];
74 for (int i = 0; i < properties.length; i++)
75 {
76 result[i] = properties[i].getName();
77 }
78 return result;
79 }
80
81 /***
82 * @see nl.tudelft.simulation.introspection.Introspector#getProperty(Object,
83 * String)
84 */
85 public Property getProperty(final Object arg0, final String arg1)
86 {
87 Property[] properties = this.getProperties(arg0);
88 for (int i = 0; i < properties.length; i++)
89 {
90 if (properties[i].getName().equals(arg1))
91 {
92 return properties[i];
93 }
94 }
95 return null;
96 }
97
98 /***
99 * Method suppress.
100 *
101 * @param type the type of tyhe class
102 * @return boolean whether to supress
103 */
104 protected boolean suppress(final Class type)
105 {
106 if (type.equals(Class.class))
107 {
108 return true;
109 }
110 return false;
111 }
112
113 /***
114 * Method suppress.
115 *
116 * @param propertyName the propertyName
117 * @return whether to supress
118 */
119 protected abstract boolean suppress(final String propertyName);
120 }