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
015package org.apache.tapestry.form.validator;
016
017import org.apache.hivemind.util.PropertyUtils;
018import org.apache.tapestry.IMarkupWriter;
019import org.apache.tapestry.IRequestCycle;
020import org.apache.tapestry.form.FormComponentContributorContext;
021import org.apache.tapestry.form.IFormComponent;
022
023/**
024 * Abstract implementation of {@link org.apache.tapestry.form.validator.Validator}.
025 * 
026 * @author Howard Lewis Ship
027 * @since 4.0
028 */
029
030public abstract class BaseValidator implements Validator
031{
032    private String _message;
033
034    public String getMessage()
035    {
036        return _message;
037    }
038
039    public void setMessage(String message)
040    {
041        _message = message;
042    }
043
044    public BaseValidator()
045    {
046    }
047
048    public BaseValidator(String initializer)
049    {
050        PropertyUtils.configureProperties(this, initializer);
051    }
052
053    /**
054     * Returns false.
055     */
056
057    public boolean getAcceptsNull()
058    {
059        return false;
060    }
061
062    /**
063     * Does nothing.
064     */
065
066    public void renderContribution(IMarkupWriter writer, IRequestCycle cycle,
067            FormComponentContributorContext context, IFormComponent field)
068    {
069    }
070
071    /**
072     * Returns false. Subclasses may override.
073     */
074
075    public boolean isRequired()
076    {
077        return false;
078    }
079}