1
1
package org .fugerit .java .doc .base .facade ;
2
2
3
3
import java .io .Serializable ;
4
+ import java .util .Collection ;
4
5
import java .util .HashMap ;
5
6
import java .util .Map ;
6
7
7
8
import org .fugerit .java .core .cfg .ConfigException ;
8
- import org .fugerit .java .core .cfg . xml . FactoryCatalog ;
9
+ import org .fugerit .java .core .util . collection . ListMapStringKey ;
9
10
import org .fugerit .java .doc .base .config .DocInput ;
10
11
import org .fugerit .java .doc .base .config .DocOutput ;
11
12
import org .fugerit .java .doc .base .config .DocTypeHandler ;
@@ -34,15 +35,24 @@ public class DocHandlerFacade implements Serializable {
34
35
35
36
public static final boolean DEFAULT_ERROR_ON_DUPLICATE = false ;
36
37
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
38
41
39
42
public DocHandlerFacade () {
40
43
this .mapHandlers = new HashMap <>();
44
+ this .mapTypeHandlers = new HashMap <>();
41
45
}
42
46
43
47
private void doRegister ( DocTypeHandler handler , String id ) {
44
48
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 );
46
56
}
47
57
48
58
public void registerHandler ( DocTypeHandler handler , boolean registerForType , boolean errorOnDuplicate ) throws Exception {
@@ -60,7 +70,7 @@ public void registerHandler( DocTypeHandler handler, boolean registerForType, bo
60
70
doRegister (handler , type );
61
71
}
62
72
}
63
-
73
+
64
74
public void registerHandler ( DocTypeHandler handler ) throws Exception {
65
75
this .registerHandler ( handler , DEFAULT_REGISTER_FOR_TYPE , DEFAULT_ERROR_ON_DUPLICATE );
66
76
}
@@ -79,12 +89,12 @@ public DocTypeHandler findHandler( String id ) {
79
89
return this .mapHandlers .get ( id );
80
90
}
81
91
82
- public void register ( String factoryCatalogPath ) {
83
-
92
+ public ListMapStringKey < DocTypeHandler > listHandlersForType ( String type ) {
93
+ return this . mapTypeHandlers . get ( type );
84
94
}
85
95
86
- public void register ( FactoryCatalog catalog ) {
87
-
96
+ public Collection < DocTypeHandler > handlers ( ) {
97
+ return this . mapHandlers . values ();
88
98
}
89
99
90
100
}
0 commit comments