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.DocumentType;
20 import org.wamblee.xmlrouter.config.Filter;
21 import org.wamblee.xmlrouter.config.Transformation;
24 * Represents a single configuration set of a single configuration client of the
27 * @author Erik Brakkee
29 public class SingleRouterConfig implements ExtendedRouterConfig {
31 public static final class DocumentConfig extends ConfigImpl<DocumentType> {
32 public DocumentConfig(String aId) {
33 super(DocumentType.class, aId);
36 public DocumentConfig(DocumentConfig aConfig) {
41 public DocumentType wrap(DocumentType aT) {
42 return new RobustDocumentType(aT);
46 public static final class TransformationConfig extends
47 ConfigImpl<Transformation> {
48 public TransformationConfig(String aId) {
49 super(Transformation.class, aId);
52 public TransformationConfig(TransformationConfig aConfig) {
57 public Transformation wrap(Transformation aTransformation) {
58 return new RobustTransformation(aTransformation);
62 public static final class FilterConfig extends ConfigImpl<Filter> {
63 public FilterConfig(String aId) {
64 super(Filter.class, aId);
67 public FilterConfig(FilterConfig aConfig) {
72 public Filter wrap(Filter aFilter) {
73 return new RobustFilter("", aFilter);
77 private String prefix;
79 private DocumentConfig documentTypes;
80 private TransformationConfig transformations;
81 private FilterConfig filters;
84 * Constructs a router configuration.
87 * Unique id for this configuration.
89 public SingleRouterConfig(String aPrefix) {
91 documentTypes = new DocumentConfig(aPrefix + ".documenttypes");
92 transformations = new TransformationConfig(aPrefix + ".transformations");
93 filters = new FilterConfig(aPrefix + ".filters");
96 public SingleRouterConfig(SingleRouterConfig aConfig) {
97 prefix = aConfig.prefix;
98 documentTypes = new DocumentConfig(aConfig.documentTypes);
99 transformations = new TransformationConfig(aConfig.transformations);
100 filters = new FilterConfig(aConfig.filters);
104 public Id<RouterConfig> getId() {
105 return new Id<RouterConfig>(prefix);
108 public String getPrefix() {
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() +