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(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(Transformation aTransformation) {
62 return new RobustTransformation(aTransformation);
66 public static final class FilterConfig extends ConfigImpl<Filter> {
67 public FilterConfig(Id<Config> aId) {
68 super(Filter.class, aId);
71 public FilterConfig(FilterConfig aConfig) {
76 public Filter wrap(Filter aFilter) {
77 return new RobustFilter("", aFilter);
81 private Id<RouterConfig> id;
83 private DocumentConfig documentTypes;
84 private TransformationConfig transformations;
85 private FilterConfig filters;
88 * Constructs a router configuration.
91 * Unique id for this configuration.
93 public SingleRouterConfig(Id<RouterConfig> aId) {
95 documentTypes = new DocumentConfig(new Id<Config>(aId.getId() +
97 transformations = new TransformationConfig(new Id<Config>(aId.getId() +
99 filters = new FilterConfig(new Id<Config>(aId.getId() + ".filters"));
102 public SingleRouterConfig(SingleRouterConfig aConfig) {
104 documentTypes = new DocumentConfig(aConfig.documentTypes);
105 transformations = new TransformationConfig(aConfig.transformations);
106 filters = new FilterConfig(aConfig.filters);
110 public Id<RouterConfig> getId() {
115 public Config<DocumentType> documentTypeConfig() {
116 return documentTypes;
120 public Config<Transformation> transformationConfig() {
121 return transformations;
125 public Config<Filter> filterConfig() {
130 public boolean equals(Object aObj) {
134 if (!(aObj instanceof SingleRouterConfig)) {
137 SingleRouterConfig obj = (SingleRouterConfig) aObj;
139 return documentTypes.equals(obj.documentTypes) &&
140 transformations.equals(obj.transformations) &&
141 filters.equals(obj.filters);
145 public int hashCode() {
146 return documentTypes.hashCode() + transformations.hashCode() +