cc778fe7c707928fc10ef6673390d8a30c1cbff4
[xmlrouter] / impl / src / main / java / org / wamblee / xmlrouter / impl / SingleRouterConfig.java
1 /*
2  * Copyright 2005-2011 the original author or authors.
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * 
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  * 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.wamblee.xmlrouter.impl;
17
18 import org.wamblee.xmlrouter.common.Id;
19 import org.wamblee.xmlrouter.config.Config;
20 import org.wamblee.xmlrouter.config.DocumentType;
21 import org.wamblee.xmlrouter.config.Filter;
22 import org.wamblee.xmlrouter.config.RouterConfig;
23 import org.wamblee.xmlrouter.config.Transformation;
24
25 // TODO implement equality based on ids for the single routerconfig. 
26 // TODO add clear method to the routerconfig
27 // TODO implement copying of routerconfig. 
28
29 /**
30  * Represents a single configuration set of a single configuration client of the
31  * XML router.
32  * 
33  * @author Erik Brakkee
34  */
35 public class SingleRouterConfig implements ExtendedRouterConfig {
36     private Id<RouterConfig> id;
37     private ExtendedConfig<DocumentType> documentTypes;
38     private ExtendedConfig<Transformation> transformations;
39     private ExtendedConfig<Filter> filters;
40
41     /**
42      * Constructs a router configuration.
43      * 
44      * @param aSequenceNumberGenerator
45      *            Sequence number generator to use.
46      */
47     public SingleRouterConfig(Id<RouterConfig> aId) {
48         id = aId;
49         documentTypes = new ConfigImpl<DocumentType>(new Id<Config>(
50             "documentTypes")) {
51             @Override
52             public DocumentType wrap(String aPrefix, DocumentType aT) {
53                 return new RobustDocumentType(aPrefix, aT);
54             }
55         };
56         transformations = new ConfigImpl<Transformation>(new Id<Config>(
57             "transformations")) {
58             @Override
59             public Transformation wrap(String aPrefix,
60                 Transformation aTransformation) {
61                 return new RobustTransformation(aPrefix, aTransformation);
62             }
63         };
64         filters = new ConfigImpl<Filter>(new Id<Config>("filters")) {
65             @Override
66             public Filter wrap(String aPrefix, Filter aFilter) {
67                 return new RobustFilter(aPrefix, aFilter);
68             }
69         };
70     }
71
72     // TODO test getId.
73     @Override
74     public Id<RouterConfig> getId() {
75         return id;
76     }
77
78     @Override
79     public Config<DocumentType> documentTypeConfig() {
80         return documentTypes;
81     }
82
83     @Override
84     public Config<Transformation> transformationConfig() {
85         return transformations;
86     }
87
88     @Override
89     public Config<Filter> filterConfig() {
90         return filters;
91     }
92 }