1 package jp.sourceforge.stigmata.birthmarks.extractors;
7 import java.lang.reflect.Constructor;
8 import java.lang.reflect.InvocationTargetException;
9 import java.util.Locale;
11 import jp.sourceforge.stigmata.BirthmarkExtractor;
12 import jp.sourceforge.stigmata.spi.AbstractServiceProvider;
13 import jp.sourceforge.stigmata.spi.BirthmarkExtractorSpi;
14 import jp.sourceforge.stigmata.spi.BirthmarkSpi;
15 import jp.sourceforge.stigmata.utils.LocalizedDescriptionManager;
18 * Birthmark Service Provider Interface.
20 * @author Haruaki TAMADA
22 public abstract class AbstractBirthmarkExtractorService extends AbstractServiceProvider implements BirthmarkExtractorSpi{
24 * returns a type of the birthmark this service provides.
27 public abstract String getType();
30 * returns a localized description of the birthmark this service provides.
33 public String getDescription(Locale locale){
34 return LocalizedDescriptionManager.getInstance().getDescription(
35 locale, getType(), LocalizedDescriptionManager.ServiceCategory.extractor
40 * returns a localized description of the birthmark in default locale.
43 public String getDescription(){
44 return getDescription(Locale.getDefault());
48 public abstract String getExtractorClassName();
51 * returns a extractor for the birthmark of this service.
54 public BirthmarkExtractor getExtractor(BirthmarkSpi service){
56 Class<?> c = Class.forName(getExtractorClassName());
57 Class<? extends BirthmarkExtractor> clazz = c.asSubclass(BirthmarkExtractor.class);
58 Constructor<? extends BirthmarkExtractor> constructor = clazz.getConstructor(BirthmarkSpi.class);
59 return constructor.newInstance(service);
60 } catch(NoSuchMethodException e){
61 } catch(InstantiationException e){
62 } catch(InvocationTargetException e){
63 } catch(ClassNotFoundException e){
64 } catch(IllegalAccessException e){