    001    // Copyright 2008, 2009, 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.internal.transform;
    016
    017    import java.util.List;
    018
    019    import org.apache.tapestry5.ComponentResources;
    020    import org.apache.tapestry5.annotations.MixinClasses;
    021    import org.apache.tapestry5.ioc.Messages;
    022    import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
    023    import org.apache.tapestry5.ioc.internal.util.InternalUtils;
    024    import org.apache.tapestry5.ioc.internal.util.MessagesImpl;
    025    import org.apache.tapestry5.plastic.PlasticField;
    026    import org.apache.tapestry5.services.TransformField;
    027
    028    public class TransformMessages
    029    {
    030        private static final Messages MESSAGES = MessagesImpl.forClass(TransformMessages.class);
    031
    032        public static String fieldInjectionError(String className, String fieldName, Throwable cause)
    033        {
    034            return MESSAGES.format("field-injection-error", className, fieldName, cause);
    035        }
    036
    037        public static String illegalNumberOfPageActivationContextHandlers(List<TransformField> fields)
    038        {
    039            List<String> names = CollectionFactory.newList();
    040
    041            for (TransformField field : fields)
    042            {
    043                names.add(field.getName());
    044            }
    045
    046            return MESSAGES.format("illegal-number-of-page-activation-context-handlers", InternalUtils.joinSorted(names));
    047        }
    048
    049            public static String illegalNumberOfPageActivationContextHandlers2(List<PlasticField> fields)
    050        {
    051            List<String> names = CollectionFactory.newList();
    052
    053            for (PlasticField field : fields)
    054            {
    055                names.add(field.getName());
    056            }
    057
    058            return MESSAGES.format("illegal-number-of-page-activation-context-handlers", InternalUtils.joinSorted(names));
    059        }
    060
    061        public static String badMixinConstraintLength(MixinClasses mixin, String fieldName)
    062        {
    063            return MESSAGES.format("bad-mixin-constraint-length", mixin.value().length, fieldName, mixin.order().length);
    064        }
    065
    066        /** @since 5.2.0 */
    067        public static String bindParameterOnlyOnMixin(String boundParameterName, ComponentResources resources)
    068        {
    069            return MESSAGES.format("bind-parameter-only-on-mixin", boundParameterName, resources.getComponentModel()
    070                    .getComponentClassName());
    071        }
    072
    073    }