001/*
002 * (C) Copyright 2019 Qastia (http://www.qastia.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Benjamin JALON
018 *
019 */
020
021package org.nuxeo.template.serializer.executors;
022
023import java.util.List;
024
025import org.nuxeo.ecm.core.api.DocumentModel;
026import org.nuxeo.template.api.TemplateInput;
027import org.nuxeo.template.serializer.service.TemplateSerializerService;
028
029/**
030 * This class contains the Serialization/Deserialization logic.
031 * <p>
032 * {@link TemplateInput} parameters are stored in the {@link DocumentModel} as a single String Property via XML
033 * Serialization.
034 *
035 * @author Tiry (tdelprat@nuxeo.com)
036 * @author bjalon (bjalon@qastia.com)
037 * @since 11.1
038 */
039public interface TemplateSerializer {
040
041    /**
042     * Transform String to a List of TemplateInput. TemplateInput represent a field that will be finally added into the
043     * context of the file rendition. Please for more information look the documentation of
044     * {@link TemplateSerializerService}
045     *
046     * @param content String containing a list of fields' description serialized
047     * @return the serialized content
048     */
049    List<TemplateInput> deserialize(String content);
050
051    /**
052     * Transform the List of TemplateInput to String. Used to store a rendition context in the Document TemplateBased.
053     * Please for more information look the documentation of {@link TemplateSerializerService}
054     */
055    String serialize(List<TemplateInput> params);
056}