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.annotation.*; 021import org.apache.juneau.html.*; 022import org.apache.juneau.serializer.*; 023 024/** 025 * Annotation for specifying config properties defined in {@link HtmlSerializer}, {@link HtmlParser}, and {@link HtmlDocSerializer}. 026 * 027 * <p> 028 * Used primarily for specifying bean configuration properties on REST classes and methods. 029 */ 030@Documented 031@Target({TYPE,METHOD}) 032@Retention(RUNTIME) 033@Inherited 034@PropertyStoreApply(HtmlConfigApply.class) 035public @interface HtmlConfig { 036 037 //------------------------------------------------------------------------------------------------------------------- 038 // HtmlSerializer 039 //------------------------------------------------------------------------------------------------------------------- 040 041 /** 042 * Configuration property: Add <js>"_type"</js> properties when needed. 043 * 044 * <p> 045 * If <jk>true</jk>, then <js>"_type"</js> properties will be added to beans if their type cannot be inferred 046 * through reflection. 047 * 048 * <p> 049 * When present, this value overrides the {@link Serializer#SERIALIZER_addBeanTypes} setting and is 050 * provided to customize the behavior of specific serializers in a {@link SerializerGroup}. 051 * 052 * <ul class='notes'> 053 * <li> 054 * Possible values: 055 * <ul> 056 * <li><js>"true"</js> 057 * <li><js>"false"</js> (default) 058 * </ul> 059 * <li> 060 * Supports {@doc DefaultSvlVariables} (e.g. <js>"$C{myConfigVar}"</js>). 061 * <li> 062 * A default global value can be set via the system property <js>"HtmlSerializer.addBeanTypes.b"</js>. 063 * </ul> 064 * 065 * <ul class='seealso'> 066 * <li class='jf'>{@link HtmlSerializer#HTML_addBeanTypes} 067 * </ul> 068 */ 069 String addBeanTypes() default ""; 070 071 /** 072 * Configuration property: Add key/value headers on bean/map tables. 073 * 074 * <p> 075 * When enabled, <bc>key</bc> and <bc>value</bc> column headers are added to tables. 076 * 077 * <p> 078 * The following shows the difference between the two generated outputs: 079 * 080 * <table class='styled'> 081 * <tr> 082 * <th><c>withoutHeaders</c></th> 083 * <th><c>withHeaders</c></th> 084 * </tr> 085 * <tr> 086 * <td> 087 * <table class='unstyled'> 088 * <tr><td>f1</td><td>foo</td></tr> 089 * <tr><td>f2</td><td>bar</td></tr> 090 * </table> 091 * </td> 092 * <td> 093 * <table class='unstyled'> 094 * <tr><th>key</th><th>value</th></tr> 095 * <tr><td>f1</td><td>foo</td></tr> 096 * <tr><td>f2</td><td>bar</td></tr> 097 * </table> 098 * </td> 099 * </tr> 100 * </table> 101 * 102 * <ul class='notes'> 103 * <li> 104 * Possible values: 105 * <ul> 106 * <li><js>"true"</js> 107 * <li><js>"false"</js> (default) 108 * </ul> 109 * <li> 110 * Supports {@doc DefaultSvlVariables} (e.g. <js>"$C{myConfigVar}"</js>). 111 * <li> 112 * A default global value can be set via the system property <js>"HtmlSerializer.addKeyValueTableHeaders.b"</js>. 113 * </ul> 114 * 115 * <ul class='seealso'> 116 * <li class='jf'>{@link HtmlSerializer#HTML_addKeyValueTableHeaders} 117 * </ul> 118 */ 119 String addKeyValueTableHeaders() default ""; 120 121 /** 122 * Configuration property: Look for URLs in {@link String Strings}. 123 * 124 * <p> 125 * If a string looks like a URL (i.e. starts with <js>"http://"</js> or <js>"https://"</js>, then treat it like a URL 126 * and make it into a hyperlink based on the rules specified by {@link HtmlSerializer#HTML_uriAnchorText}. 127 * 128 * <p> 129 * The following shows the difference between the two generated outputs: 130 * 131 * <table class='styled'> 132 * <tr> 133 * <th><c>withLinks</c></th> 134 * <th><c>withoutLinks</c></th> 135 * </tr> 136 * <tr> 137 * <td> 138 * <table class='unstyled'> 139 * <tr><th>key</th><th>value</th></tr> 140 * <tr><td>f1</td><td><a href='http://www.apache.org'>http://www.apache.org</a></td></tr> 141 * </table> 142 * </td> 143 * <td> 144 * <table class='unstyled'> 145 * <tr><th>key</th><th>value</th></tr> 146 * <tr><td>f1</td><td>http://www.apache.org</td></tr> 147 * </table> 148 * </td> 149 * </tr> 150 * </table> 151 * 152 * <ul class='notes'> 153 * <li> 154 * Possible values: 155 * <ul> 156 * <li><js>"true"</js> (default) 157 * <li><js>"false"</js> 158 * </ul> 159 * <li> 160 * Supports {@doc DefaultSvlVariables} (e.g. <js>"$C{myConfigVar}"</js>). 161 * <li> 162 * A default global value can be set via the system property <js>"HtmlSerializer.detectLinksInStrings.b"</js>. 163 * </ul> 164 * 165 * <ul class='seealso'> 166 * <li class='jf'>{@link HtmlSerializer#HTML_detectLinksInStrings} 167 * </ul> 168 */ 169 String detectLinksInStrings() default ""; 170 171 /** 172 * Configuration property: Link label parameter name. 173 * 174 * <p> 175 * The parameter name to look for when resolving link labels via {@link HtmlSerializer#HTML_detectLabelParameters}. 176 * 177 * <ul class='notes'> 178 * <li> 179 * Default value: <js>"label"</js> 180 * <li> 181 * Supports {@doc DefaultSvlVariables} (e.g. <js>"$C{myConfigVar}"</js>). 182 * <li> 183 * A default global value can be set via the system property <js>"HtmlSerializer.labelParameter.s"</js>. 184 * </ul> 185 * 186 * <ul class='seealso'> 187 * <li class='jf'>{@link HtmlSerializer#HTML_labelParameter} 188 * </ul> 189 */ 190 String labelParameter() default ""; 191 192 /** 193 * Configuration property: Look for link labels in URIs. 194 * 195 * <p> 196 * If the URL has a label parameter (e.g. <js>"?label=foobar"</js>), then use that as the anchor text of the link. 197 * 198 * <p> 199 * The parameter name can be changed via the {@link HtmlSerializer#HTML_labelParameter} property. 200 * 201 * <p> 202 * The following shows the difference between the two generated outputs. 203 * <br>Note that they're both hyperlinks, but the anchor text differs: 204 * 205 * <table class='styled'> 206 * <tr> 207 * <th><c>withLabels</c></th> 208 * <th><c>withoutLabels</c></th> 209 * </tr> 210 * <tr> 211 * <td> 212 * <table class='unstyled'> 213 * <tr><th>key</th><th>value</th></tr> 214 * <tr><td>f1</td><td><a href='http://www.apache.org?label=Apache%20Foundation'>Apache Foundation</a></td></tr> 215 * </table> 216 * </td> 217 * <td> 218 * <table class='unstyled'> 219 * <tr><th>key</th><th>value</th></tr> 220 * <tr><td>f1</td><td><a href='http://www.apache.org?label=Apache%20Foundation'>http://www.apache.org?label=Apache%20Foundation</a></td></tr> 221 * </table> 222 * </td> 223 * </tr> 224 * </table> 225 * 226 * <ul class='notes'> 227 * <li> 228 * Possible values: 229 * <ul> 230 * <li><js>"true"</js> (default) 231 * <li><js>"false"</js> 232 * </ul> 233 * <li> 234 * Supports {@doc DefaultSvlVariables} (e.g. <js>"$C{myConfigVar}"</js>). 235 * <li> 236 * A default global value can be set via the system property <js>"HtmlSerializer.detectLabelParameters.b"</js>. 237 * </ul> 238 * 239 * <ul class='seealso'> 240 * <li class='jf'>{@link HtmlSerializer#HTML_detectLabelParameters} 241 * </ul> 242 */ 243 String detectLabelParameters() default ""; 244 245 /** 246 * Configuration property: Anchor text source. 247 * 248 * <p> 249 * When creating anchor tags (e.g. <code><xt><a</xt> <xa>href</xa>=<xs>'...'</xs> 250 * <xt>></xt>text<xt></a></xt></code>) in HTML, this setting defines what to set the inner text to. 251 * 252 * <ul class='notes'> 253 * <li> 254 * Possible values: 255 * <ul> 256 * <li><js>"TO_STRING"</js> - Set to whatever is returned by {@link #toString()} on the object. 257 * <li><js>"PROPERTY_NAME"</js> - Set to the bean property name. 258 * <li><js>"URI"</js> - Set to the URI value. 259 * <li><js>"LAST_TOKEN"</js> - Set to the last token of the URI value. 260 * <li><js>"URI_ANCHOR"</js> - Set to the anchor of the URL. 261 * <li><js>"CONTEXT_RELATIVE"</js> - Same as <js>"TO_STRING"</js> but assumes it's a context-relative path. 262 * <li><js>"SERVLET_RELATIVE"</js> - Same as <js>"TO_STRING"</js> but assumes it's a servlet-relative path. 263 * <li><js>"PATH_RELATIVE"</js> - Same as <js>"TO_STRING"</js> but assumes it's a path-relative path. 264 * </ul> 265 * <li> 266 * Supports {@doc DefaultSvlVariables} (e.g. <js>"$C{myConfigVar}"</js>). 267 * <li> 268 * A default global value can be set via the system property <js>"HtmlSerializer.uriAnchorText.s"</js>. 269 * </ul> 270 * 271 * <ul class='seealso'> 272 * <li class='jf'>{@link HtmlSerializer#HTML_uriAnchorText} 273 * </ul> 274 */ 275 String uriAnchorText() default ""; 276}