/** * Gets a component associated with the given parameter name. First search the component in * property table, then try to get component by name from the manager, then creates component with * default properties. * * @param name the parameter name * @return the component associated with the name * @throws edu.cmu.sphinx.util.props.PropertyException if the component does not exist or is of * the wrong type. */ public Configurable getComponent(String name) throws PropertyException { S4PropWrapper s4PropWrapper = getProperty(name, S4Component.class); Configurable configurable = null; S4Component s4Component = (S4Component) s4PropWrapper.getAnnotation(); Class<? extends Configurable> expectedType = s4Component.type(); Object propVal = propValues.get(name); if (propVal != null && propVal instanceof Configurable) { return (Configurable) propVal; } if (propVal != null && propVal instanceof String) { PropertySheet ps = cm.getPropertySheet(flattenProp(name)); if (ps != null) configurable = ps.getOwner(); else throw new InternalConfigurationException( getInstanceName(), name, "component '" + flattenProp(name) + "' is missing"); } if (configurable != null && !expectedType.isInstance(configurable)) throw new InternalConfigurationException( getInstanceName(), name, "mismatch between annotation and component type"); if (configurable != null) { propValues.put(name, configurable); return configurable; } configurable = getComponentFromAnnotation(name, s4Component); propValues.put(name, configurable); return configurable; }