001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.html; 014 015import org.apache.juneau.*; 016import org.apache.juneau.serializer.*; 017 018/** 019 * Serializes POJOs to HTTP responses as stripped HTML. 020 * 021 * <h5 class='topic'>Media types</h5> 022 * 023 * Handles <code>Accept</code> types: <code><b>text/html+stripped</b></code> 024 * <p> 025 * Produces <code>Content-Type</code> types: <code><b>text/html</b></code> 026 * 027 * <h5 class='topic'>Description</h5> 028 * 029 * Produces the same output as {@link HtmlDocSerializer}, but without the header and body tags and page title and 030 * description. 031 * Used primarily for JUnit testing the {@link HtmlDocSerializer} class. 032 */ 033public class HtmlStrippedDocSerializer extends HtmlSerializer { 034 035 /** 036 * Constructor. 037 * 038 * @param ps The property store containing all the settings for this object. 039 */ 040 public HtmlStrippedDocSerializer(PropertyStore ps) { 041 this(ps, "text/html", "text/html+stripped"); 042 } 043 044 /** 045 * Constructor. 046 * 047 * @param ps 048 * The property store containing all the settings for this object. 049 * @param produces 050 * The media type that this serializer produces. 051 * @param accept 052 * The accept media types that the serializer can handle. 053 * <p> 054 * Can contain meta-characters per the <code>media-type</code> specification of 055 * {@doc RFC2616.section14.1} 056 * <p> 057 * If empty, then assumes the only media type supported is <code>produces</code>. 058 * <p> 059 * For example, if this serializer produces <js>"application/json"</js> but should handle media types of 060 * <js>"application/json"</js> and <js>"text/json"</js>, then the arguments should be: 061 * <p class='bcode w800'> 062 * <jk>super</jk>(ps, <js>"application/json"</js>, <js>"application/json,text/json"</js>); 063 * </p> 064 * <br>...or... 065 * <p class='bcode w800'> 066 * <jk>super</jk>(ps, <js>"application/json"</js>, <js>"*​/json"</js>); 067 * </p> 068 * <p> 069 * The accept value can also contain q-values. 070 */ 071 public HtmlStrippedDocSerializer(PropertyStore ps, String produces, String accept) { 072 super(ps, produces, accept); 073 } 074 075 @Override /* Serializer */ 076 public WriterSerializerSession createSession(SerializerSessionArgs args) { 077 return new HtmlStrippedDocSerializerSession(this, args); 078 } 079}