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