001    // Copyright 2005 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.tapestry.valid;
016    
017    import org.apache.tapestry.IMarkupWriter;
018    import org.apache.tapestry.IRequestCycle;
019    import org.apache.tapestry.form.IFormComponent;
020    
021    /**
022     * Mock implementation of {@link org.apache.tapestry.valid.IValidationDelegate}used to test
023     * decoration.
024     * 
025     * @author Howard M. Lewis Ship
026     * @since 4.0
027     */
028    public class MockDelegate extends ValidationDelegate
029    {
030        private static final long serialVersionUID = -9197298078385854706L;
031    
032            public void writeLabelPrefix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle)
033        {
034            writer.print("{LABEL-PREFIX}");
035        }
036    
037        public void writeAttributes(IMarkupWriter writer, IRequestCycle cycle,
038                IFormComponent component, IValidator validator)
039        {
040            writer.attribute("class", "mock-delegate");
041        }
042    
043        public void writeLabelSuffix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle)
044        {
045            writer.print("{LABEL-SUFFIX}");
046        }
047    
048        public void writePrefix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component,
049                IValidator validator)
050        {
051            writer.print("{PREFIX}");
052        }
053    
054        public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component,
055                IValidator validator)
056        {
057            writer.print("{SUFFIX}");
058        }
059        
060        /**
061         * {@inheritDoc}
062         */
063        public void beforeLabelText(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component)
064        {
065            writer.print("{BEFORE-TEXT}");
066        }
067        
068        /**
069         * {@inheritDoc}
070         */
071        public void afterLabelText(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component)
072        {
073            writer.print("{AFTER-TEXT}");
074        }
075    }