01: /*
02: * Copyright (C) 1999-2004 <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</a>
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18: package org.mandarax.kernel;
19:
20: import java.util.Collection;
21: import java.util.Properties;
22: import java.util.TreeSet;
23:
24: /**
25: * Abstract class providing a description of features of an object.
26: * Used to describe features of knowledge bases and inference engines.
27: * The most easiest way to use this class is to define an anonymous
28: * subclass, to override the constructor and to add a list of <code>support()</code>
29: * statements in the <code>initialize()</code> for the supported features.
30: * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
31: * @version 3.4 <7 March 05>
32: * @since 1.0
33: */
34: public abstract class FeatureDescriptions {
35: protected Collection supported = new TreeSet();
36: protected Properties descriptions = new Properties();
37:
38: /**
39: * Constructor.
40: */
41: public FeatureDescriptions() {
42: super ();
43: initialize();
44: }
45:
46: /**
47: * Get a description string of the respective feature.
48: * @return the description
49: * @param featureName the name of the feature
50: */
51: public String getFeatureDescription(String featureName) {
52: return descriptions.getProperty(featureName);
53: }
54:
55: /**
56: * Get a collection of all supported features.
57: * @return a collection of supported features
58: */
59: public Collection getSupportedFeatures() {
60: return supported;
61: }
62:
63: /**
64: * Initialize the object. Override this method and invoke this
65: * implementation using <code>super.initialize()</code> first.
66: */
67: protected void initialize() {
68: // nothing to do here
69: }
70:
71: /**
72: * Indicates whether the named feature is supported.
73: * @return true if the respective featurte is supported, false otherwise
74: * @param aFeatureName the name of the feature
75: */
76: public boolean isFeatureSupported(String aFeatureName) {
77: return supported.contains(aFeatureName);
78: }
79:
80: /**
81: * Register a feature to be supported.
82: * @param featureName the name of the feature
83: */
84: protected void support(String featureName) {
85: supported.add(featureName);
86: }
87: }
|