1 package jp.sourceforge.stigmata.birthmarks.extractors;
3 import java.lang.reflect.Constructor;
4 import java.lang.reflect.InvocationTargetException;
5 import java.util.Locale;
7 import jp.sourceforge.stigmata.BirthmarkExtractor;
8 import jp.sourceforge.stigmata.spi.AbstractServiceProvider;
9 import jp.sourceforge.stigmata.spi.BirthmarkExtractorSpi;
10 import jp.sourceforge.stigmata.spi.BirthmarkSpi;
11 import jp.sourceforge.stigmata.utils.LocalizedDescriptionManager;
14 * Birthmark Service Provider Interface.
16 * @author Haruaki TAMADA
18 public abstract class AbstractBirthmarkExtractorService extends AbstractServiceProvider implements BirthmarkExtractorSpi{
20 * returns a type of the birthmark this service provides.
23 public abstract String getType();
26 * returns a localized description of the birthmark this service provides.
29 public String getDescription(Locale locale){
30 return LocalizedDescriptionManager.getInstance().getDescription(
31 locale, getType(), LocalizedDescriptionManager.ServiceCategory.extractor
36 * returns a localized description of the birthmark in default locale.
39 public String getDescription(){
40 return getDescription(Locale.getDefault());
44 public abstract String getExtractorClassName();
47 * returns a extractor for the birthmark of this service.
50 public BirthmarkExtractor getExtractor(BirthmarkSpi service){
52 Class<?> c = Class.forName(getExtractorClassName());
53 Class<? extends BirthmarkExtractor> clazz = c.asSubclass(BirthmarkExtractor.class);
54 Constructor<? extends BirthmarkExtractor> constructor = clazz.getConstructor(BirthmarkSpi.class);
55 return constructor.newInstance(service);
56 } catch(NoSuchMethodException e){
57 } catch(InstantiationException e){
58 } catch(InvocationTargetException e){
59 } catch(ClassNotFoundException e){
60 } catch(IllegalAccessException e){