11package org .fugerit .java .doc .base .facade ;
22
33import java .io .Serializable ;
4+ import java .util .Collection ;
45import java .util .HashMap ;
56import java .util .Map ;
67
78import org .fugerit .java .core .cfg .ConfigException ;
8- import org .fugerit .java .core .cfg . xml . FactoryCatalog ;
9+ import org .fugerit .java .core .util . collection . ListMapStringKey ;
910import org .fugerit .java .doc .base .config .DocInput ;
1011import org .fugerit .java .doc .base .config .DocOutput ;
1112import org .fugerit .java .doc .base .config .DocTypeHandler ;
@@ -34,15 +35,24 @@ public class DocHandlerFacade implements Serializable {
3435
3536 public static final boolean DEFAULT_ERROR_ON_DUPLICATE = false ;
3637
37- private Map <String , DocTypeHandler > mapHandlers ;
38+ private Map <String , DocTypeHandler > mapHandlers ; // map handlers registered by id
39+
40+ private Map <String , ListMapStringKey <DocTypeHandler >> mapTypeHandlers ; // map handlers registered by type
3841
3942 public DocHandlerFacade () {
4043 this .mapHandlers = new HashMap <>();
44+ this .mapTypeHandlers = new HashMap <>();
4145 }
4246
4347 private void doRegister ( DocTypeHandler handler , String id ) {
4448 logger .info ( "Registering handler with id {} : {}" , id , handler .getClass ().getName () );
45- this .mapHandlers .put ( id , handler );
49+ this .mapHandlers .put ( id , handler );
50+ ListMapStringKey <DocTypeHandler > list = this .mapTypeHandlers .get ( handler .getType () );
51+ if ( list == null ) {
52+ list = new ListMapStringKey <DocTypeHandler >();
53+ this .mapTypeHandlers .put ( handler .getType () , list );
54+ }
55+ list .add ( handler );
4656 }
4757
4858 public void registerHandler ( DocTypeHandler handler , boolean registerForType , boolean errorOnDuplicate ) throws Exception {
@@ -60,7 +70,7 @@ public void registerHandler( DocTypeHandler handler, boolean registerForType, bo
6070 doRegister (handler , type );
6171 }
6272 }
63-
73+
6474 public void registerHandler ( DocTypeHandler handler ) throws Exception {
6575 this .registerHandler ( handler , DEFAULT_REGISTER_FOR_TYPE , DEFAULT_ERROR_ON_DUPLICATE );
6676 }
@@ -79,12 +89,12 @@ public DocTypeHandler findHandler( String id ) {
7989 return this .mapHandlers .get ( id );
8090 }
8191
82- public void register ( String factoryCatalogPath ) {
83-
92+ public ListMapStringKey < DocTypeHandler > listHandlersForType ( String type ) {
93+ return this . mapTypeHandlers . get ( type );
8494 }
8595
86- public void register ( FactoryCatalog catalog ) {
87-
96+ public Collection < DocTypeHandler > handlers ( ) {
97+ return this . mapHandlers . values ();
8898 }
8999
90100}
0 commit comments