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.hivemind.Location;
018 import org.apache.hivemind.util.Defense;
019 import org.apache.tapestry.binding.AbstractBinding;
020 import org.apache.tapestry.coerce.ValueConverter;
021
022 /**
023 * Implementation of {@link IBinding} that provides
024 * {@link org.apache.tapestry.valid.IValidator} instances based on a
025 * validator bean descriptor. The descriptor is of the form "type[,properties]".
026 * The types are values such as "string", "date" or "number" defined in the
027 * tapestry.valid.Validators configuration point. The properties are a
028 * properties initialization string.
029 *
030 * @author Howard M. Lewis Ship
031 * @since 4.0
032 * @see org.apache.hivemind.util.PropertyUtils#configureProperties(java.lang.Object,
033 * java.lang.String)
034 */
035 public class ValidatorBinding extends AbstractBinding
036 {
037
038 private final IValidator _validator;
039
040 public ValidatorBinding(String description, ValueConverter valueConverter,
041 Location location, IValidator validator)
042 {
043 super(description, valueConverter, location);
044
045 Defense.notNull(validator, "validator");
046
047 _validator = validator;
048 }
049
050 public Object getObject()
051 {
052 return _validator;
053 }
054
055 }