001: /*
002: * $Id: TempWrapperPropertyConfiguration.java 10256 2008-01-08 15:20:25Z dfeist $
003: * --------------------------------------------------------------------------------------
004: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
005: *
006: * The software in this package is published under the terms of the CPAL v1.0
007: * license, a copy of which has been included with this distribution in the
008: * LICENSE.txt file.
009: */
010:
011: package org.mule.config.spring.parsers.assembly.configuration;
012:
013: import java.util.Map;
014:
015: /**
016: * Wrap a PropertyConfiguration so that changes are kept in the wrapper
017: */
018: public class TempWrapperPropertyConfiguration implements
019: PropertyConfiguration {
020:
021: protected PropertyConfiguration delegate;
022: protected SimplePropertyConfiguration extra = new SimplePropertyConfiguration();
023: private boolean greedyIgnore;
024:
025: public TempWrapperPropertyConfiguration(
026: PropertyConfiguration delegate) {
027: this (delegate, true);
028: }
029:
030: public TempWrapperPropertyConfiguration(
031: PropertyConfiguration delegate, boolean greedyIgnore) {
032: this .delegate = delegate;
033: this .greedyIgnore = greedyIgnore;
034: }
035:
036: public void addReference(String propertyName) {
037: extra.addReference(propertyName);
038: }
039:
040: public void addMapping(String propertyName, Map mappings) {
041: extra.addMapping(propertyName, mappings);
042: }
043:
044: public void addMapping(String propertyName, String mappings) {
045: extra.addMapping(propertyName, mappings);
046: }
047:
048: public void addMapping(String propertyName, ValueMap mappings) {
049: extra.addMapping(propertyName, mappings);
050: }
051:
052: public void addAlias(String alias, String propertyName) {
053: extra.addAlias(alias, propertyName);
054: }
055:
056: public void addCollection(String propertyName) {
057: extra.addCollection(propertyName);
058: }
059:
060: public void addIgnored(String propertyName) {
061: extra.addIgnored(propertyName);
062: }
063:
064: public void removeIgnored(String propertyName) {
065: extra.removeIgnored(propertyName);
066: }
067:
068: public void setIgnoredDefault(boolean ignoreAll) {
069: extra.setIgnoredDefault(ignoreAll);
070: }
071:
072: public String getAttributeMapping(String alias) {
073: return extra.getAttributeMapping(alias, delegate
074: .getAttributeMapping(alias));
075: }
076:
077: public boolean isCollection(String propertyName) {
078: return extra.isCollection(propertyName)
079: || delegate.isCollection(propertyName);
080: }
081:
082: public boolean isIgnored(String propertyName) {
083: if (greedyIgnore) {
084: return extra.isIgnored(propertyName)
085: || delegate.isIgnored(propertyName);
086: } else {
087: return extra.isIgnored(propertyName)
088: && delegate.isIgnored(propertyName);
089: }
090: }
091:
092: public boolean isReference(String attributeName) {
093: return extra.isReference(attributeName)
094: || delegate.isReference(attributeName);
095: }
096:
097: public SingleProperty getSingleProperty(String propertyName) {
098: return new SinglePropertyWrapper(propertyName, this );
099: }
100:
101: public String translateName(String oldName) {
102: return extra.translateName(delegate.translateName(oldName));
103: }
104:
105: public Object translateValue(String name, String value) {
106: Object intermediate = delegate.translateValue(name, value);
107: if (intermediate.equals(value)) {
108: return extra.translateValue(name, value);
109: } else {
110: return intermediate;
111: }
112: }
113:
114: }
|