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.enhance;
016
017 import org.apache.hivemind.Location;
018 import org.apache.tapestry.IBinding;
019 import org.apache.tapestry.IComponent;
020 import org.apache.tapestry.binding.BindingConstants;
021 import org.apache.tapestry.binding.BindingSource;
022
023 /**
024 * Encapsulates information needed to construct an initial value binding for a specified property
025 * (with an initial value).
026 *
027 * @author Howard M. Lewis Ship
028 * @since 4.0
029 */
030 public class InitialValueBindingCreator
031 {
032 private BindingSource _bindingSource;
033
034 private String _description;
035
036 private String _initialValue;
037
038 private Location _location;
039
040 /**
041 * This method is just implemented for testing purposes.
042 */
043
044 public boolean equals(Object obj)
045 {
046 InitialValueBindingCreator c = (InitialValueBindingCreator) obj;
047
048 return _bindingSource == c._bindingSource && _description.equals(c._description)
049 && _initialValue.equals(c._initialValue) && _location.equals(c._location);
050 }
051
052 public InitialValueBindingCreator(BindingSource bindingSource, String description,
053 String initialValue, Location location)
054 {
055 _bindingSource = bindingSource;
056 _description = description;
057 _initialValue = initialValue;
058 _location = location;
059 }
060
061 public IBinding createBinding(IComponent component)
062 {
063 return _bindingSource.createBinding(component, _description, _initialValue, BindingConstants.OGNL_PREFIX, _location);
064 }
065 }