X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fxmlrouter%2Fimpl%2FSingleRouterConfig.java;h=195f72da66295517bce3aec611c3fe05f3fd0cc8;hb=3b2c669b25bfcb5a3c3f06ff9180d85143bebb2a;hp=5e2fffe4829009b1d67cc26c8f66bc2808b776a7;hpb=e52385618670b54a5c6a4f2fbfab381bef43a905;p=xmlrouter diff --git a/impl/src/main/java/org/wamblee/xmlrouter/impl/SingleRouterConfig.java b/impl/src/main/java/org/wamblee/xmlrouter/impl/SingleRouterConfig.java index 5e2fffe..195f72d 100644 --- a/impl/src/main/java/org/wamblee/xmlrouter/impl/SingleRouterConfig.java +++ b/impl/src/main/java/org/wamblee/xmlrouter/impl/SingleRouterConfig.java @@ -16,10 +16,8 @@ package org.wamblee.xmlrouter.impl; import org.wamblee.xmlrouter.common.Id; -import org.wamblee.xmlrouter.config.Config; import org.wamblee.xmlrouter.config.DocumentType; import org.wamblee.xmlrouter.config.Filter; -import org.wamblee.xmlrouter.config.RouterConfig; import org.wamblee.xmlrouter.config.Transformation; /** @@ -29,45 +27,86 @@ import org.wamblee.xmlrouter.config.Transformation; * @author Erik Brakkee */ public class SingleRouterConfig implements ExtendedRouterConfig { - private Id id; - private ExtendedConfig documentTypes; - private ExtendedConfig transformations; - private ExtendedConfig filters; + + public static final class DocumentConfig extends ConfigImpl { + public DocumentConfig(String aId) { + super(DocumentType.class, aId); + } + + public DocumentConfig(DocumentConfig aConfig) { + super(aConfig); + } + + @Override + public DocumentType wrap(DocumentType aT) { + return new RobustDocumentType(aT); + } + } + + public static final class TransformationConfig extends + ConfigImpl { + public TransformationConfig(String aId) { + super(Transformation.class, aId); + } + + public TransformationConfig(TransformationConfig aConfig) { + super(aConfig); + } + + @Override + public Transformation wrap(Transformation aTransformation) { + return new RobustTransformation(aTransformation); + } + } + + public static final class FilterConfig extends ConfigImpl { + public FilterConfig(String aId) { + super(Filter.class, aId); + } + + public FilterConfig(FilterConfig aConfig) { + super(aConfig); + } + + @Override + public Filter wrap(Filter aFilter) { + return new RobustFilter("", aFilter); + } + } + + private String prefix; + + private DocumentConfig documentTypes; + private TransformationConfig transformations; + private FilterConfig filters; /** * Constructs a router configuration. * - * @param aSequenceNumberGenerator - * Sequence number generator to use. + * @param aPrefix + * Unique id for this configuration. */ - public SingleRouterConfig(Id aId) { - id = aId; - documentTypes = new ConfigImpl(new Id( - "documentTypes")) { - @Override - public DocumentType wrap(DocumentType aT) { - return new RobustDocumentType(aT); - } - }; - transformations = new ConfigImpl(new Id( - "transformations")) { - @Override - public Transformation wrap(Transformation aTransformation) { - return new RobustTransformation(aTransformation); - } - }; - filters = new ConfigImpl(new Id("filters")) { - @Override - public Filter wrap(Filter aFilter) { - return new RobustFilter(aFilter); - } - }; + public SingleRouterConfig(String aPrefix) { + prefix = aPrefix; + documentTypes = new DocumentConfig(aPrefix + ".documenttypes"); + transformations = new TransformationConfig(aPrefix + ".transformations"); + filters = new FilterConfig(aPrefix + ".filters"); + } + + public SingleRouterConfig(SingleRouterConfig aConfig) { + prefix = aConfig.prefix; + documentTypes = new DocumentConfig(aConfig.documentTypes); + transformations = new TransformationConfig(aConfig.transformations); + filters = new FilterConfig(aConfig.filters); } - // TODO test getId. @Override public Id getId() { - return id; + return new Id(prefix); + } + + public String getPrefix() { + return prefix; } @Override @@ -84,4 +123,25 @@ public class SingleRouterConfig implements ExtendedRouterConfig { public Config filterConfig() { return filters; } + + @Override + public boolean equals(Object aObj) { + if (aObj == null) { + return false; + } + if (!(aObj instanceof SingleRouterConfig)) { + return false; + } + SingleRouterConfig obj = (SingleRouterConfig) aObj; + + return documentTypes.equals(obj.documentTypes) && + transformations.equals(obj.transformations) && + filters.equals(obj.filters); + } + + @Override + public int hashCode() { + return documentTypes.hashCode() + transformations.hashCode() + + filters.hashCode(); + } }