001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.marshall.html; 018 019import static java.lang.annotation.ElementType.*; 020import static java.lang.annotation.RetentionPolicy.*; 021 022import java.lang.annotation.*; 023 024import org.apache.juneau.marshall.*; 025import org.apache.juneau.marshall.serializer.*; 026 027/** 028 * Annotation for specifying config properties defined in {@link HtmlSerializer}, {@link HtmlParser}, and {@link HtmlDocSerializer}. 029 * 030 * <p> 031 * Used primarily for specifying bean configuration properties on REST classes and methods. 032 * 033 * <h5 class='section'>See Also:</h5><ul> 034 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/HtmlSupport">HTML</a> 035 * </ul> 036 */ 037@Target({ TYPE, METHOD }) 038@Retention(RUNTIME) 039@Inherited 040@ContextApply({ HtmlConfigAnnotation.SerializerApply.class, HtmlConfigAnnotation.ParserApply.class }) 041public @interface HtmlConfig { 042 043 /** 044 * Add <js>"_type"</js> properties when needed. 045 * 046 * <p> 047 * If <jk>true</jk>, then <js>"_type"</js> properties will be added to beans if their type cannot be inferred 048 * through reflection. 049 * 050 * <p> 051 * When present, this value overrides the {@link org.apache.juneau.marshall.serializer.Serializer.Builder#addBeanTypes() Serializer.Builder#addBeanTypes()} setting and is 052 * provided to customize the behavior of specific serializers in a {@link SerializerSet}. 053 * 054 * <ul class='values'> 055 * <li><js>"true"</js> 056 * <li><js>"false"</js> (default) 057 * </ul> 058 * 059 * <h5 class='section'>Notes:</h5><ul> 060 * <li class='note'> 061 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 062 * </ul> 063 * 064 * <h5 class='section'>See Also:</h5><ul> 065 * <li class='jm'>{@link HtmlSerializer.Builder#addBeanTypesHtml()} 066 * </ul> 067 * 068 * @return The annotation value. 069 */ 070 String addBeanTypes() default ""; 071 072 /** 073 * Add key/value headers on bean/map tables. 074 * 075 * <p> 076 * When enabled, <bc>key</bc> and <bc>value</bc> column headers are added to tables. 077 * 078 * <p> 079 * The following shows the difference between the two generated outputs: 080 * 081 * <table class='styled'> 082 * <tr> 083 * <th><c>withoutHeaders</c></th> 084 * <th><c>withHeaders</c></th> 085 * </tr> 086 * <tr> 087 * <td> 088 * <table class='unstyled'> 089 * <tr><td>f1</td><td>foo</td></tr> 090 * <tr><td>f2</td><td>bar</td></tr> 091 * </table> 092 * </td> 093 * <td> 094 * <table class='unstyled'> 095 * <tr><th>key</th><th>value</th></tr> 096 * <tr><td>f1</td><td>foo</td></tr> 097 * <tr><td>f2</td><td>bar</td></tr> 098 * </table> 099 * </td> 100 * </tr> 101 * </table> 102 * 103 * <ul class='values'> 104 * <li><js>"true"</js> 105 * <li><js>"false"</js> (default) 106 * </ul> 107 * 108 * <h5 class='section'>Notes:</h5><ul> 109 * <li class='note'> 110 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 111 * </ul> 112 * 113 * <h5 class='section'>See Also:</h5><ul> 114 * <li class='jm'>{@link HtmlSerializer.Builder#addKeyValueTableHeaders()} 115 * </ul> 116 * 117 * @return The annotation value. 118 */ 119 String addKeyValueTableHeaders() default ""; 120 121 /** 122 * Don't look for link labels in URIs. 123 * 124 * <p> 125 * Disables the feature where if the URL has a label parameter (e.g. <js>"?label=foobar"</js>), then use that as the anchor text of the link. 126 * 127 * <p> 128 * The parameter name can be changed via the {@link HtmlSerializer.Builder#labelParameter(String)} property. 129 * 130 * <p> 131 * The following shows the difference between the two generated outputs. 132 * <br>Note that they're both hyperlinks, but the anchor text differs: 133 * 134 * <table class='styled'> 135 * <tr> 136 * <th><c>withLabels</c></th> 137 * <th><c>withoutLabels</c></th> 138 * </tr> 139 * <tr> 140 * <td> 141 * <table class='unstyled'> 142 * <tr><th>key</th><th>value</th></tr> 143 * <tr><td>f1</td><td><a href='http://www.apache.org?label=Apache%20Foundation'>Apache Foundation</a></td></tr> 144 * </table> 145 * </td> 146 * <td> 147 * <table class='unstyled'> 148 * <tr><th>key</th><th>value</th></tr> 149 * <tr><td>f1</td><td><a href='http://www.apache.org?label=Apache%20Foundation'>http://www.apache.org?label=Apache%20Foundation</a></td></tr> 150 * </table> 151 * </td> 152 * </tr> 153 * </table> 154 * 155 * <ul class='values'> 156 * <li><js>"true"</js> 157 * <li><js>"false"</js> (default) 158 * </ul> 159 * 160 * <h5 class='section'>Notes:</h5><ul> 161 * <li class='note'> 162 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 163 * </ul> 164 * 165 * <h5 class='section'>See Also:</h5><ul> 166 * <li class='jm'>{@link HtmlSerializer.Builder#disableDetectLabelParameters()} 167 * </ul> 168 * 169 * @return The annotation value. 170 */ 171 String disableDetectLabelParameters() default ""; 172 173 /** 174 * Don't look for URLs in {@link String Strings}. 175 * 176 * <p> 177 * Disables the feature where if a string looks like a URL (i.e. starts with <js>"http://"</js> or <js>"https://"</js>, then treat it like a URL 178 * and make it into a hyperlink based on the rules specified by {@link HtmlSerializer.Builder#uriAnchorText(AnchorText)}. 179 * 180 * <p> 181 * The following shows the difference between the two generated outputs: 182 * 183 * <table class='styled'> 184 * <tr> 185 * <th><c>withLinks</c></th> 186 * <th><c>withoutLinks</c></th> 187 * </tr> 188 * <tr> 189 * <td> 190 * <table class='unstyled'> 191 * <tr><th>key</th><th>value</th></tr> 192 * <tr><td>f1</td><td><a href='http://www.apache.org'>http://www.apache.org</a></td></tr> 193 * </table> 194 * </td> 195 * <td> 196 * <table class='unstyled'> 197 * <tr><th>key</th><th>value</th></tr> 198 * <tr><td>f1</td><td>http://www.apache.org</td></tr> 199 * </table> 200 * </td> 201 * </tr> 202 * </table> 203 * 204 * <ul class='values'> 205 * <li><js>"true"</js> 206 * <li><js>"false"</js> (default) 207 * </ul> 208 * 209 * <h5 class='section'>Notes:</h5><ul> 210 * <li class='note'> 211 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 212 * </ul> 213 * 214 * <h5 class='section'>See Also:</h5><ul> 215 * <li class='jm'>{@link HtmlSerializer.Builder#disableDetectLinksInStrings()} 216 * </ul> 217 * 218 * @return The annotation value. 219 */ 220 String disableDetectLinksInStrings() default ""; 221 222 /** 223 * Link label parameter name. 224 * 225 * <p> 226 * The parameter name to look for when resolving link labels. 227 * 228 * <h5 class='section'>Notes:</h5><ul> 229 * <li class='note'> 230 * Default value: <js>"label"</js> 231 * <li class='note'> 232 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 233 * </ul> 234 * 235 * <h5 class='section'>See Also:</h5><ul> 236 * <li class='jm'>{@link HtmlSerializer.Builder#labelParameter(String)} 237 * </ul> 238 * 239 * @return The annotation value. 240 */ 241 String labelParameter() default ""; 242 243 /** 244 * Optional rank for this config. 245 * 246 * <p> 247 * Can be used to override default ordering and application of config annotations. 248 * 249 * @return The annotation value. 250 */ 251 int rank() default 0; 252 253 /** 254 * Anchor text source. 255 * 256 * <p> 257 * When creating anchor tags (e.g. <code><xt><a</xt> <xa>href</xa>=<xs>'...'</xs> 258 * <xt>></xt>text<xt></a></xt></code>) in HTML, this setting defines what to set the inner text to. 259 * 260 * <ul class='values'> 261 * <li><js>"TO_STRING"</js> - Set to whatever is returned by {@link #toString()} on the object. 262 * <li><js>"PROPERTY_NAME"</js> - Set to the bean property name. 263 * <li><js>"URI"</js> - Set to the URI value. 264 * <li><js>"LAST_TOKEN"</js> - Set to the last token of the URI value. 265 * <li><js>"URI_ANCHOR"</js> - Set to the anchor of the URL. 266 * <li><js>"CONTEXT_RELATIVE"</js> - Same as <js>"TO_STRING"</js> but assumes it's a context-relative path. 267 * <li><js>"SERVLET_RELATIVE"</js> - Same as <js>"TO_STRING"</js> but assumes it's a servlet-relative path. 268 * <li><js>"PATH_RELATIVE"</js> - Same as <js>"TO_STRING"</js> but assumes it's a path-relative path. 269 * </ul> 270 * 271 * <h5 class='section'>Notes:</h5><ul> 272 * <li class='note'> 273 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>). 274 * </ul> 275 * 276 * <h5 class='section'>See Also:</h5><ul> 277 * <li class='jm'>{@link HtmlSerializer.Builder#uriAnchorText(AnchorText)} 278 * </ul> 279 * 280 * @return The annotation value. 281 */ 282 String uriAnchorText() default ""; 283}