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