org.apache.juneau.html.annotation.Html Maven / Gradle / Ivy
// ***************************************************************************************************************************
// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
// * with the License. You may obtain a copy of the License at *
// * *
// * http://www.apache.org/licenses/LICENSE-2.0 *
// * *
// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
package org.apache.juneau.html.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
import org.apache.juneau.html.*;
/**
* Annotation that can be applied to classes, fields, and methods to tweak how they are handled by {@link HtmlSerializer}.
*
* See Also:
*
* - {@doc juneau-marshall.HtmlDetails.HtmlAnnotation}
*
*/
@Documented
@Target({TYPE,FIELD,METHOD})
@Retention(RUNTIME)
@Inherited
public @interface Html {
/**
* Use the specified anchor text when serializing a URI.
*
*
* The text can contain any bean property values resolved through variables of the form "{property-name}" .
*
*
Example:
*
* // Produces <a href='...'>drive</a> when serialized to HTML.
* @Html (anchorText="drive" )
* @URI // Treat property as a URL
* public String getDrive() {...}
*
*
* This overrides the behavior specified by {@link HtmlSerializer#HTML_uriAnchorText}.
*/
String anchorText() default "";
/**
* Specifies what format to use for the HTML element.
*/
HtmlFormat format() default HtmlFormat.HTML;
/**
* Adds a hyperlink to a bean property when rendered as HTML.
*
*
* The text can contain any bean property values resolved through variables of the form "{property-name}" .
*
*
* The URLs can be any of the following forms:
*
* - Absolute - e.g.
"http://host:123/myContext/myServlet/myPath"
* - Context-root-relative - e.g.
"/myContext/myServlet/myPath"
* - Context-relative - e.g.
"context:/myServlet/myPath"
* - Servlet-relative - e.g.
"servlet:/myPath"
* - Path-info-relative - e.g.
"myPath"
*
*
* Example:
*
* public class FileSpace {
*
* @Html (link="servlet:/drive/{drive}" )
* public String getDrive() {
* ...;
* }
* }
*
*/
String link() default "";
/**
* When true , don't add headers to tables.
*
* See Also:
*
* - {@link HtmlSerializer#HTML_addKeyValueTableHeaders}
*
*/
boolean noTableHeaders() default false;
/**
* When true , collections of beans should be rendered as trees instead of tables.
*
*
* Default is false .
*/
boolean noTables() default false;
/**
* Associates an {@link HtmlRender} with a bean property for custom HTML rendering of the property.
*
*
* This annotation applies to bean properties and classes.
*/
@SuppressWarnings("rawtypes")
Class extends HtmlRender> render() default HtmlRender.class;
}