    001    // Copyright 2010 The Apache Software Foundation
    002    //
    003    // Licensed under the Apache License, Version 2.0 (the "License");
    004    // you may not use this file except in compliance with the License.
    005    // You may obtain a copy of the License at
    006    //
    007    // http://www.apache.org/licenses/LICENSE-2.0
    008    //
    009    // Unless required by applicable law or agreed to in writing, software
    010    // distributed under the License is distributed on an "AS IS" BASIS,
    011    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    012    // See the License for the specific language governing permissions and
    013    // limitations under the License.
    014
    015    package org.apache.tapestry5;
    016
    017    import java.util.List;
    018
    019    /**
    020     * Wrapper around a {@link ValidationTracker} that delegates all methods to the wrapped instance.
    021     * Subclasses will often override specific methods.
    022     *
    023     * @since 5.2.0
    024     */
    025    public class ValidationTrackerWrapper implements ValidationTracker
    026    {
    027        private final ValidationTracker delegate;
    028
    029        public ValidationTrackerWrapper(ValidationTracker delegate)
    030        {
    031            this.delegate = delegate;
    032        }
    033
    034        public void clear()
    035        {
    036            delegate.clear();
    037        }
    038
    039        public String getError(Field field)
    040        {
    041            return delegate.getError(field);
    042        }
    043
    044        public List<String> getErrors()
    045        {
    046            return delegate.getErrors();
    047        }
    048
    049        public boolean getHasErrors()
    050        {
    051            return delegate.getHasErrors();
    052        }
    053
    054        public String getInput(Field field)
    055        {
    056            return delegate.getInput(field);
    057        }
    058
    059        public boolean inError(Field field)
    060        {
    061            return delegate.inError(field);
    062        }
    063
    064        public void recordError(Field field, String errorMessage)
    065        {
    066            delegate.recordError(field, errorMessage);
    067        }
    068
    069        public void recordError(String errorMessage)
    070        {
    071            delegate.recordError(errorMessage);
    072        }
    073
    074        public void recordInput(Field field, String input)
    075        {
    076            delegate.recordInput(field, input);
    077        }
    078
    079        /** Returns the instance to which methods are delegated. */
    080        protected ValidationTracker getDelegate()
    081        {
    082            return delegate;
    083        }
    084    }