2 * Copyright 2005-2011 the original author or authors.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.wamblee.xmlrouter.impl;
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;
25 // TODO implement copying of routerconfig.
28 * Represents a single configuration set of a single configuration client of the
31 * @author Erik Brakkee
33 public class SingleRouterConfig implements ExtendedRouterConfig {
35 public static final class DocumentConfig extends ConfigImpl<DocumentType> {
36 public DocumentConfig(Id<Config> aId) {
37 super(DocumentType.class, aId);
40 public DocumentConfig(DocumentConfig aConfig) {
45 public DocumentType wrap(String aPrefix, DocumentType aT) {
46 return new RobustDocumentType("", aT);
50 public static final class TransformationConfig extends
51 ConfigImpl<Transformation> {
52 public TransformationConfig(Id<Config> aId) {
53 super(Transformation.class, aId);
56 public TransformationConfig(TransformationConfig aConfig) {
61 public Transformation wrap(String aPrefix,
62 Transformation aTransformation) {
63 return new RobustTransformation("", aTransformation);
67 public static final class FilterConfig extends ConfigImpl<Filter> {
68 public FilterConfig(Id<Config> aId) {
69 super(Filter.class, aId);
72 public FilterConfig(FilterConfig aConfig) {
77 public Filter wrap(String aPrefix, Filter aFilter) {
78 return new RobustFilter("", aFilter);
82 private Id<RouterConfig> id;
84 private DocumentConfig documentTypes;
85 private TransformationConfig transformations;
86 private FilterConfig filters;
89 * Constructs a router configuration.
92 * Unique id for this configuration.
94 public SingleRouterConfig(Id<RouterConfig> aId) {
96 documentTypes = new DocumentConfig(new Id<Config>(aId.getId() +
98 transformations = new TransformationConfig(new Id<Config>(aId.getId() +
100 filters = new FilterConfig(new Id<Config>(aId.getId() + ".filters"));
103 public SingleRouterConfig(SingleRouterConfig aConfig) {
105 documentTypes = new DocumentConfig(aConfig.documentTypes);
106 transformations = new TransformationConfig(aConfig.transformations);
107 filters = new FilterConfig(aConfig.filters);
111 public Id<RouterConfig> getId() {
116 public Config<DocumentType> documentTypeConfig() {
117 return documentTypes;
121 public Config<Transformation> transformationConfig() {
122 return transformations;
126 public Config<Filter> filterConfig() {
131 public boolean equals(Object aObj) {
135 if (!(aObj instanceof SingleRouterConfig)) {
138 SingleRouterConfig obj = (SingleRouterConfig) aObj;
140 return documentTypes.equals(obj.documentTypes) &&
141 transformations.equals(obj.transformations) &&
142 filters.equals(obj.filters);
146 public int hashCode() {
147 return documentTypes.hashCode() + transformations.hashCode() +