001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. 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 distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.html; 014 015import org.apache.juneau.html.annotation.*; 016import org.apache.juneau.serializer.*; 017 018/** 019 * Allows custom rendering of bean property values when serialized as HTML. 020 * 021 * <p> 022 * Associated with bean properties using the {@link Html#render() @Html(render)} annotation. 023 * 024 * <p> 025 * Using this class, you can alter the CSS style and HTML content of the bean property. 026 * 027 * <h5 class='section'>See Also:</h5><ul> 028 * <li class='link'><a class="doclink" href="../../../../index.html#jm.HtmlRenderAnnotation">@Html(render) Annotation</a> 029 * <li class='link'><a class="doclink" href="../../../../index.html#jm.HtmlDetails">HTML Details</a> 030 * </ul> 031 * 032 * @param <T> The bean property type. 033 */ 034public abstract class HtmlRender<T> { 035 036 /** 037 * Returns the CSS style of the element containing the bean property value. 038 * 039 * @param session 040 * The current serializer session. 041 * Can be used to retrieve properties and session-level information. 042 * @param value The bean property value. 043 * @return The CSS style string, or <jk>null</jk> if no style should be added. 044 */ 045 public String getStyle(SerializerSession session, T value) { 046 return null; 047 } 048 049 /** 050 * Returns the delegate value for the specified bean property value. 051 * 052 * <p> 053 * The default implementation simply returns the same value. 054 * A typical use is to return an HTML element using one of the HTML5 DOM beans. 055 * 056 * @param session 057 * The current serializer session. 058 * Can be used to retrieve properties and session-level information. 059 * @param value The bean property value. 060 * @return The new bean property value. 061 */ 062 public Object getContent(SerializerSession session, T value) { 063 return value; 064 } 065}