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.marshall;
014
015import org.apache.juneau.plaintext.*;
016
017/**
018 * A pairing of a {@link PlainTextSerializer} and {@link PlainTextParser} into a single class with convenience read/write methods.
019 *
020 * <p>
021 *    The general idea is to combine a single serializer and parser inside a simplified API for reading and writing POJOs.
022 *
023 * <h5 class='figure'>Examples:</h5>
024 * <p class='bcode w800'>
025 *    <jc>// Using instance.</jc>
026 *    PlainText plainText = <jk>new</jk> PlainText();
027 *    MyPojo myPojo = plainText.read(string, MyPojo.<jk>class</jk>);
028 *    String string = plainText.write(myPojo);
029 * </p>
030 * <p class='bcode w800'>
031 * <jc>// Using DEFAULT instance.</jc>
032 *    MyPojo myPojo = PlainText.<jsf>DEFAULT</jsf>.read(string, MyPojo.<jk>class</jk>);
033 *    String string = PlainText.<jsf>DEFAULT</jsf>.write(myPojo);
034 * </p>
035 *
036 * <h5 class='section'>See Also:</h5>
037 * <ul>
038 *    <li class='link'>{@doc juneau-marshall.Marshalls}
039 * </ul>
040 *
041 * <h5 class='section'>See Also:</h5>
042 * <ul>
043 *    <li class='link'>{@doc juneau-marshall.Marshalls}
044 * </ul>
045 */
046public class PlainText extends CharMarshall {
047
048   /**
049    * Default reusable instance.
050    */
051   public static final PlainText DEFAULT = new PlainText();
052
053   /**
054    * Constructor.
055    *
056    * @param s
057    *    The serializer to use for serializing output.
058    *    <br>Must not be <jk>null</jk>.
059    * @param p
060    *    The parser to use for parsing input.
061    *    <br>Must not be <jk>null</jk>.
062    */
063   public PlainText(PlainTextSerializer s, PlainTextParser p) {
064      super(s, p);
065   }
066
067   /**
068    * Constructor.
069    *
070    * <p>
071    * Uses {@link PlainTextSerializer#DEFAULT} and {@link PlainTextParser#DEFAULT}.
072    */
073   public PlainText() {
074      this(PlainTextSerializer.DEFAULT, PlainTextParser.DEFAULT);
075   }
076}