Class TemplateHelper
- java.lang.Object
-
- org.glassfish.jersey.server.mvc.internal.TemplateHelper
-
public final class TemplateHelper extends Object
Helper class to provide some common functionality related to MVC.- Author:
- Michal Gajdos
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgetAbsolutePath(Class<?> resourceClass, String path, char delim)Return an absolute path to the given class where segments are separated usingdelimcharacter andpathis appended to this path.static List<MediaType>getProducibleMediaTypes(ContainerRequest containerRequest, ExtendedUriInfo extendedUriInfo, org.glassfish.jersey.internal.util.collection.Ref<String> varyHeaderValue)Get media types for which theresolved viewablecould be produced.static TemplategetTemplateAnnotation(Annotation[] annotations)Extracttemplateannotation from given list.static StringgetTemplateName(Viewable viewable)Get template name from givenviewableor returnindexif the given viewable doesn't contain a valid template name.static CharsetgetTemplateOutputEncoding(Configuration configuration, String suffix)Get output encoding from configuration.
-
-
-
Method Detail
-
getAbsolutePath
public static String getAbsolutePath(Class<?> resourceClass, String path, char delim)
Return an absolute path to the given class where segments are separated usingdelimcharacter andpathis appended to this path.- Parameters:
resourceClass- class for which an absolute path should be obtained.path- segment to be appended to the resulting path.delim- character used for separating path segments.- Returns:
- an absolute path to the resource class.
-
getProducibleMediaTypes
public static List<MediaType> getProducibleMediaTypes(ContainerRequest containerRequest, ExtendedUriInfo extendedUriInfo, org.glassfish.jersey.internal.util.collection.Ref<String> varyHeaderValue)
Get media types for which theresolved viewablecould be produced.- Parameters:
containerRequest- request to obtain acceptable media types.extendedUriInfo- uri info to obtain resource method from and its producible media types.varyHeaderValue- Vary header reference.- Returns:
- list of producible media types.
-
getTemplateName
public static String getTemplateName(Viewable viewable)
Get template name from givenviewableor returnindexif the given viewable doesn't contain a valid template name.- Parameters:
viewable- viewable to obtain template name from.- Returns:
non-null,non-emptytemplate name.
-
getTemplateAnnotation
public static Template getTemplateAnnotation(Annotation[] annotations)
Extracttemplateannotation from given list.- Parameters:
annotations- list of annotations.- Returns:
templateannotation ornullif this annotation is not present.
-
getTemplateOutputEncoding
public static Charset getTemplateOutputEncoding(Configuration configuration, String suffix)
Get output encoding from configuration.- Parameters:
configuration- Configuration.suffix- Template processor suffix of the to configuration propertyMvcFeature.ENCODING.- Returns:
- Encoding read from configuration properties or a default encoding if no encoding is configured.
-
-