/** * Checks if the parsed language is included in the configuration * @param language the language * @return the state */ public boolean isLanguage(String language){ return getLanguageState(language).state; } /**
/** * Resets the configuration to the default (as parsed in the constructor) */ public void setDefault() { try { parseConfiguration(defaultConfig); } catch (ConfigurationException e) { // can not happen else the default config is already validated // within the constructor } } /**
@Override public int canEnhance(ContentItem ci) throws EngineException { return getAnalysedText(this, ci, false) != null ? ENHANCE_ASYNC : CANNOT_ENHANCE; }
@Override public int canEnhance(ContentItem ci) throws EngineException { String language = getLanguage(this, ci,false); if(language == null){ return CANNOT_ENHANCE; } if(!isLangaugeConfigured(this,languageConfig,language,false)){ return CANNOT_ENHANCE; } if(getAnalysedText(this,ci,false) == null) { return CANNOT_ENHANCE; } // default enhancement is synchronous enhancement return ENHANCE_ASYNC; }
@Override public int canEnhance(ContentItem ci) throws EngineException { return NlpEngineHelper.getAnalysedText(this, ci, false) != null && NlpEngineHelper.getLanguage(this, ci, false) != null ? ENHANCE_ASYNC : CANNOT_ENHANCE; }
@Deactivate protected void deactivate(ComponentContext ctx){ languageConfig.setDefault(); }
@Activate protected void activate(ComponentContext ctx) throws ConfigurationException { languageConfig.setConfiguration(ctx.getProperties()); } @Deactivate
/** * Reads the configuration for the configured {@link #getProperty()} from * the properties of the parsed {@link ServiceReference}.<p> * This implementation supports * <code>null</code> (sets the default), <code>String[]</code>, * <code>Collections<?></code> (Object{@link #toString() toString()} is called * on members) and comma separated {@link String}. * @param ref the SerivceRefernece * @throws ConfigurationException */ public void setConfiguration(ServiceReference ref) throws ConfigurationException { processConfiguration(ref.getProperty(property)); }
@Deactivate protected void deactivate(ComponentContext ctx){ resourceLoader = null; charFilterFactory = null; tokenizerFactory = null; filterFactories.clear(); langConf.setDefault(); }
@Override public int canEnhance(ContentItem ci) throws EngineException { return getAnalysedText(this, ci, false) != null ? ENHANCE_ASYNC : CANNOT_ENHANCE; }
/** * Checks if the parsed language is included in the configuration * @param language the language * @return the state */ public boolean isLanguage(String language){ return getLanguageState(language).state; } /**
/** * Reads the config for the configured {@link #getProperty() property} * from the parsed configuration. <p> * This implementation supports * <code>null</code> (sets the default), <code>String[]</code>, * <code>Collections<?></code> (Object{@link #toString() toString()} is called * on members) and comma separated {@link String}. * @param configuration the configuration */ public void setConfiguration(Dictionary<?,?> configuration) throws ConfigurationException { processConfiguration(configuration.get(property)); } /**
/** * Resets the configuration to the default (as parsed in the constructor) */ public void setDefault() { try { parseConfiguration(defaultConfig); } catch (ConfigurationException e) { // can not happen else the default config is already validated // within the constructor } } /**
@Deactivate protected void deactivate(ComponentContext ctx){ resourceLoader = null; charFilterFactory = null; tokenizerFactory = null; filterFactories.clear(); langConf.setDefault(); }
/** * Getter for the language specific parameters. This does NOT include * default parameters. * @param language the language * @return the language specific parameters or <code>null</code> if no * parameters are configured. */ public Map<String,String> getLanguageParams(String parsedLang){ LangState ls = getLanguageState(parsedLang); return ls.state ? configuredLanguages.get(ls.lang) : null; } /**
/** * Reads the config for the configured {@link #getProperty() property} * from the parsed configuration. <p> * This implementation supports * <code>null</code> (sets the default), <code>String[]</code>, * <code>Collections<?></code> (Object{@link #toString() toString()} is called * on members) and comma separated {@link String}. * @param configuration the configuration */ public void setConfiguration(Dictionary<?,?> configuration) throws ConfigurationException { processConfiguration(configuration.get(property)); } /**
@Override @Deactivate protected void deactivate(ComponentContext ce) { languageConfig.setDefault(); super.deactivate(ce); }
/** * Getter for the language specific parameters. This does NOT include * default parameters. * @param language the language * @return the language specific parameters or <code>null</code> if no * parameters are configured. */ public Map<String,String> getLanguageParams(String parsedLang){ LangState ls = getLanguageState(parsedLang); return ls.state ? configuredLanguages.get(ls.lang) : null; } /**
/** * Reads the configuration for the configured {@link #getProperty()} from * the properties of the parsed {@link ServiceReference}.<p> * This implementation supports * <code>null</code> (sets the default), <code>String[]</code>, * <code>Collections<?></code> (Object{@link #toString() toString()} is called * on members) and comma separated {@link String}. * @param ref the SerivceRefernece * @throws ConfigurationException */ public void setConfiguration(ServiceReference ref) throws ConfigurationException { processConfiguration(ref.getProperty(property)); }
@Deactivate protected void deactivate(ComponentContext context) { languageConfig.setDefault(); super.deactivate(context); }