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;
26 * Represents a single configuration set of a single configuration client of the
29 * @author Erik Brakkee
31 public class SingleRouterConfig implements ExtendedRouterConfig {
33 public static final class DocumentConfig extends ConfigImpl<DocumentType> {
34 public DocumentConfig(Id<Config> aId) {
35 super(DocumentType.class, aId);
38 public DocumentConfig(DocumentConfig aConfig) {
43 public DocumentType wrap(DocumentType aT) {
44 return new RobustDocumentType(aT);
48 public static final class TransformationConfig extends
49 ConfigImpl<Transformation> {
50 public TransformationConfig(Id<Config> aId) {
51 super(Transformation.class, aId);
54 public TransformationConfig(TransformationConfig aConfig) {
59 public Transformation wrap(Transformation aTransformation) {
60 return new RobustTransformation(aTransformation);
64 public static final class FilterConfig extends ConfigImpl<Filter> {
65 public FilterConfig(Id<Config> aId) {
66 super(Filter.class, aId);
69 public FilterConfig(FilterConfig aConfig) {
74 public Filter wrap(Filter aFilter) {
75 return new RobustFilter("", aFilter);
79 private Id<RouterConfig> id;
81 private DocumentConfig documentTypes;
82 private TransformationConfig transformations;
83 private FilterConfig filters;
86 * Constructs a router configuration.
89 * Unique id for this configuration.
91 public SingleRouterConfig(Id<RouterConfig> aId) {
93 documentTypes = new DocumentConfig(new Id<Config>(aId.getId() +
95 transformations = new TransformationConfig(new Id<Config>(aId.getId() +
97 filters = new FilterConfig(new Id<Config>(aId.getId() + ".filters"));
100 public SingleRouterConfig(SingleRouterConfig aConfig) {
102 documentTypes = new DocumentConfig(aConfig.documentTypes);
103 transformations = new TransformationConfig(aConfig.transformations);
104 filters = new FilterConfig(aConfig.filters);
108 public Id<RouterConfig> getId() {
113 public Config<DocumentType> documentTypeConfig() {
114 return documentTypes;
118 public Config<Transformation> transformationConfig() {
119 return transformations;
123 public Config<Filter> filterConfig() {
128 public boolean equals(Object aObj) {
132 if (!(aObj instanceof SingleRouterConfig)) {
135 SingleRouterConfig obj = (SingleRouterConfig) aObj;
137 return documentTypes.equals(obj.documentTypes) &&
138 transformations.equals(obj.transformations) &&
139 filters.equals(obj.filters);
143 public int hashCode() {
144 return documentTypes.hashCode() + transformations.hashCode() +