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
21 * @version $Revision$ $Date$
23 abstract class AbstractBirthmarkExtractorService extends AbstractServiceProvider implements BirthmarkExtractorSpi{
25 * 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.
32 public String getDescription(Locale locale){
33 return LocalizedDescriptionManager.getInstance().getDescription(
34 locale, getType(), LocalizedDescriptionManager.ServiceCategory.extractor
39 * returns a localized description of the birthmark in default locale.
41 public String getDescription(){
42 return getDescription(Locale.getDefault());
45 public abstract String getExtractorClassName();
48 * 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){