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.internal.*;
017import org.apache.juneau.serializer.*;
018
019/**
020 * Serializes POJOs to HTTP responses as stripped HTML.
021 *
022 * <h5 class='topic'>Media types</h5>
023 *
024 * Handles <code>Accept</code> types:  <code><b>text/html+stripped</b></code>
025 * <p>
026 * Produces <code>Content-Type</code> types:  <code><b>text/html</b></code>
027 *
028 * <h5 class='topic'>Description</h5>
029 *
030 * Produces the same output as {@link HtmlDocSerializer}, but without the header and body tags and page title and
031 * description.
032 * Used primarily for JUnit testing the {@link HtmlDocSerializer} class.
033 */
034public class HtmlStrippedDocSerializer extends HtmlSerializer {
035
036   /**
037    * Constructor.
038    *
039    * @param ps The property store containing all the settings for this object.
040    */
041   public HtmlStrippedDocSerializer(PropertyStore ps) {
042      this(ps, "text/html", "text/html+stripped");
043   }
044
045   /**
046    * Constructor.
047    *
048    * @param ps
049    *    The property store containing all the settings for this object.
050    * @param produces
051    *    The media type that this serializer produces.
052    * @param accept
053    *    The accept media types that the serializer can handle.
054    *    <p>
055    *    Can contain meta-characters per the <code>media-type</code> specification of
056    *    {@doc RFC2616.section14.1}
057    *    <p>
058    *    If empty, then assumes the only media type supported is <code>produces</code>.
059    *    <p>
060    *    For example, if this serializer produces <js>"application/json"</js> but should handle media types of
061    *    <js>"application/json"</js> and <js>"text/json"</js>, then the arguments should be:
062    *    <p class='bcode w800'>
063    *    <jk>super</jk>(ps, <js>"application/json"</js>, <js>"application/json,text/json"</js>);
064    *    </p>
065    *    <br>...or...
066    *    <p class='bcode w800'>
067    *    <jk>super</jk>(ps, <js>"application/json"</js>, <js>"*&#8203;/json"</js>);
068    *    </p>
069    * <p>
070    * The accept value can also contain q-values.
071    */
072   public HtmlStrippedDocSerializer(PropertyStore ps, String produces, String accept) {
073      super(ps, produces, accept);
074   }
075
076   @Override /* Serializer */
077   public WriterSerializerSession createSession(SerializerSessionArgs args) {
078      return new HtmlStrippedDocSerializerSession(this, args);
079   }
080
081   /**
082    * @deprecated Use {@link #HtmlStrippedDocSerializer(PropertyStore, String, String)}
083    */
084   @SuppressWarnings("javadoc")
085   @Deprecated
086   public HtmlStrippedDocSerializer(PropertyStore ps, String produces, String...accept) {
087      this(ps, produces, StringUtils.join(accept, ','));
088   }
089}