"Fossies" - the Fresh Open Source Software Archive

Member "apidocs/src-html/org/apache/tapestry5/internal/services/LiteralPropertyConduit.html" (9 Sep 2020, 7754 Bytes) of package /linux/www/apache-tapestry-5.6.1-apidocs.zip:


Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the project site itself.

001// Copyright 2008, 2011 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.tapestry5.internal.services;
016
017import java.lang.annotation.Annotation;
018import java.lang.reflect.Type;
019
020import org.apache.tapestry5.internal.InternalPropertyConduit;
021import org.apache.tapestry5.ioc.AnnotationProvider;
022import org.apache.tapestry5.ioc.services.TypeCoercer;
023
024/**
025 * A PropertyConduit for a literal value in an expression, such as a number, or "true", "false" or "null".
026 */
027public class LiteralPropertyConduit extends PropertyConduitDelegate implements InternalPropertyConduit
028{
029    private final Class propertyType;
030
031    private final AnnotationProvider annotationProvider;
032
033    private final String description;
034
035    private final Object value;
036
037    public LiteralPropertyConduit(TypeCoercer typeCoercer, Class propertyType, AnnotationProvider annotationProvider,
038            String description, Object value)
039    {
040        super(typeCoercer);
041
042        this.propertyType = propertyType;
043        this.annotationProvider = annotationProvider;
044        this.description = description;
045
046        this.value = value;
047    }
048
049    public Object get(Object instance)
050    {
051        return value;
052    }
053
054    public void set(Object instance, Object value)
055    {
056        throw new RuntimeException("Literal values are not updateable.");
057    }
058
059    public Class getPropertyType()
060    {
061        return propertyType;
062    }
063    
064    public Type getPropertyGenericType()
065    {
066        return propertyType;
067    }
068
069    public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
070    {
071        return annotationProvider.getAnnotation(annotationClass);
072    }
073
074    public String getPropertyName()
075    {
076        return null;
077    }
078
079    @Override
080    public String toString()
081    {
082        return description;
083    }
084
085}