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.annotation; 014 015import static java.lang.annotation.ElementType.*; 016import static java.lang.annotation.RetentionPolicy.*; 017 018import java.lang.annotation.*; 019 020import org.apache.juneau.html.*; 021 022/** 023 * Annotation that can be applied to classes, fields, and methods to tweak how they are handled by {@link HtmlSerializer}. 024 * 025 * <ul class='seealso'> 026 * <li class='link'>{@doc juneau-marshall.HtmlDetails.HtmlAnnotation} 027 * </ul> 028 */ 029@Documented 030@Target({TYPE,FIELD,METHOD}) 031@Retention(RUNTIME) 032@Inherited 033public @interface Html { 034 035 /** 036 * Use the specified anchor text when serializing a URI. 037 * 038 * <p> 039 * The text can contain any bean property values resolved through variables of the form <js>"{property-name}"</js>. 040 * 041 * <h5 class='figure'>Example:</h5> 042 * <p class='bcode w800'> 043 * <jc>// Produces <a href='...'>drive</a> when serialized to HTML.</jc> 044 * <ja>@Html</ja>(anchorText=<js>"drive"</js>) 045 * <ja>@URI</ja> <jc>// Treat property as a URL</jc> 046 * <jk>public</jk> String getDrive() {...} 047 * </p> 048 * 049 * This overrides the behavior specified by {@link HtmlSerializer#HTML_uriAnchorText}. 050 */ 051 String anchorText() default ""; 052 053 /** 054 * Specifies what format to use for the HTML element. 055 */ 056 HtmlFormat format() default HtmlFormat.HTML; 057 058 /** 059 * Adds a hyperlink to a bean property when rendered as HTML. 060 * 061 * <p> 062 * The text can contain any bean property values resolved through variables of the form <js>"{property-name}"</js>. 063 * 064 * <p> 065 * The URLs can be any of the following forms: 066 * <ul> 067 * <li>Absolute - e.g. <js>"http://host:123/myContext/myServlet/myPath"</js> 068 * <li>Context-root-relative - e.g. <js>"/myContext/myServlet/myPath"</js> 069 * <li>Context-relative - e.g. <js>"context:/myServlet/myPath"</js> 070 * <li>Servlet-relative - e.g. <js>"servlet:/myPath"</js> 071 * <li>Path-info-relative - e.g. <js>"myPath"</js> 072 * </ul> 073 * 074 * <h5 class='figure'>Example:</h5> 075 * <p class='bcode w800'> 076 * <jk>public class</jk> FileSpace { 077 * 078 * <ja>@Html</ja>(link=<js>"servlet:/drive/{drive}"</js>) 079 * <jk>public</jk> String getDrive() { 080 * ...; 081 * } 082 * } 083 * </p> 084 */ 085 String link() default ""; 086 087 /** 088 * When <jk>true</jk>, don't add headers to tables. 089 * 090 * <ul class='seealso'> 091 * <li class='jf'>{@link HtmlSerializer#HTML_addKeyValueTableHeaders} 092 * </ul> 093 */ 094 boolean noTableHeaders() default false; 095 096 /** 097 * When <jk>true</jk>, collections of beans should be rendered as trees instead of tables. 098 * 099 * <p> 100 * Default is <jk>false</jk>. 101 */ 102 boolean noTables() default false; 103 104 /** 105 * Associates an {@link HtmlRender} with a bean property for custom HTML rendering of the property. 106 * 107 * <p> 108 * This annotation applies to bean properties and classes. 109 */ 110 @SuppressWarnings("rawtypes") 111 Class<? extends HtmlRender> render() default HtmlRender.class; 112}