001/*
002 *  Copyright 2017 Anyware Services
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 */
016package org.ametys.plugins.extraction.component;
017
018import java.util.List;
019import java.util.Map;
020import java.util.Set;
021
022import org.xml.sax.ContentHandler;
023
024import org.ametys.plugins.extraction.execution.ExtractionExecutionContext;
025
026/**
027 * This interface represents a component of the extraction module
028 */
029public interface ExtractionComponent
030{
031    /**
032     * Prepare the execution of the component
033     * @param context context of the extraction component
034     * @throws Exception if an error occurs
035     */
036    public void prepareComponentExecution(ExtractionExecutionContext context) throws Exception;
037    
038    /**
039     * Execute the extraction of the component
040     * @param contentHandler result document
041     * @param context context of the extraction component
042     * @throws Exception if an error occurs
043     */
044    public void execute(ContentHandler contentHandler, ExtractionExecutionContext context) throws Exception;
045    
046    /**
047     * Add sub component
048     * @param subComponent the sub components to add
049     */
050    public void addSubComponent(ExtractionComponent subComponent);
051    
052    /**
053     * Retrieves sub components of the component
054     * @return a list of sub components
055     */
056    public List<ExtractionComponent> getSubComponents();
057    
058    /**
059     * Retrieves the list of content types defined for this component
060     * @return a list of content types id
061     */
062    public Set<String> getContentTypes();
063    
064    /**
065     * Retrieves the details of the component for tree
066     * @return a <code>Map</code> containing component details
067     */
068    public Map<String, Object> getComponentDetailsForTree();
069}