1 /* 2 * #%L 3 * EUGene :: EUGene 4 * %% 5 * Copyright (C) 2004 - 2010 CodeLutin 6 * %% 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU Lesser General Public License as 9 * published by the Free Software Foundation, either version 3 of the 10 * License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Lesser Public License for more details. 16 * 17 * You should have received a copy of the GNU General Lesser Public 18 * License along with this program. If not, see 19 * <http://www.gnu.org/licenses/lgpl-3.0.html>. 20 * #L% 21 */ 22 23 package org.nuiton.eugene.writer; 24 25 import java.io.IOException; 26 import java.util.List; 27 import java.util.Map; 28 import java.util.Set; 29 30 /** 31 * Contract of the chained writer engine. 32 * 33 * You can register inputs via the method {@link #registerInclude(String)}. 34 * 35 * And later obtain of the selected writers for your inputs via the method 36 * {@link #getSelectedWriters()}. 37 * 38 * Created: 17 déc. 2009 39 * 40 * @author Tony Chemit - chemit@codelutin.com 41 * @since 2.0.0 42 */ 43 public interface ChainedWriterEngine { 44 45 void init(ChainedFileWriterConfiguration configuration); 46 47 /** 48 * Register in engine a new input source. 49 * 50 * this method will detects writers to register and chain them if necessary. 51 * 52 * @param include the new include to digest 53 */ 54 void registerInclude(String include); 55 56 57 /** @return the set of all available writers discovered at runtime */ 58 Set<ChainedFileWriter> getAvailableWriters(); 59 60 /** @return the list of selected writers after having registred some inputs. */ 61 List<ChainedFileWriter> getSelectedWriters(); 62 63 /** 64 * Tests if there is a selected writer using the given input protocol. 65 * 66 * @param inputProtocol the inputProtocol to test 67 * @return {@code true} if there is a selected writer using this input protocol 68 * @see ChainedFileWriter#getInputProtocol() 69 * @see #getSelectedWriters() 70 */ 71 boolean containsWriter(String inputProtocol); 72 73 /** 74 * Filter the given {@code universe} of writers which accept the given {@code modelType}. 75 * 76 * @param universe the list of writers to filter 77 * @param modelType the accepted model type 78 * @return the set of filtered writers 79 * @see ChainedFileWriter#acceptModel(String) 80 */ 81 Set<ChainedFileWriter> filterWriterForModelType( 82 Map<String, ChainedFileWriter> universe, 83 String modelType); 84 85 /** 86 * Filter the given {@code universe} of writers which accept the given 87 * {@code modelType} and {@code inputProtocol}. 88 * 89 * @param universe the list of writers to filter 90 * @param inputProtocol the accepted input protocol 91 * @param modelType the accepted model type 92 * @return the set of filtered writers 93 * @see ChainedFileWriter#acceptModel(String) 94 * @see ChainedFileWriter#getInputProtocol() 95 * @see ChainedFileWriter#getInputProtocol(String) 96 */ 97 ChainedFileWriter getWriterForInputProtocol( 98 Set<ChainedFileWriter> universe, 99 String inputProtocol, 100 String modelType); 101 102 /** 103 * Filter the given {@code universe} of writers which accept the given 104 * {@code modelType} and {@code include}. 105 * 106 * The include can have several forms : <ul> <li></li> <li></li> </ul> 107 * 108 * @param universe the list of writers to filter 109 * @param include the include configuration 110 * @param modelType the accepted model type 111 * @return the set of filtered writers 112 * @see ChainedFileWriter#acceptModel(String) 113 * @see ChainedFileWriter#getInputProtocol() 114 * @see ChainedFileWriter#getInputProtocol(String) 115 */ 116 ChainedFileWriter getWriterForInclude( 117 Set<ChainedFileWriter> universe, 118 String include, 119 String modelType); 120 121 /** 122 * Obtain the universe of files to react by the given {@code writer} 123 * associated with each (distinct). 124 * 125 * <b>Note:</b> If some files are in class-path (using the classpath: 126 * prefix) then they will be extracted to the 127 * {@link ChainedFileWriterConfiguration#getExtractDirectory()}. 128 * 129 * @param writer the writer to inspect 130 * @return the universe of files to react for the given writer 131 * @throws IOException for any IO pb 132 * @since 2.1.3 133 */ 134 ChainedFileWriterData getData(ChainedFileWriter writer) throws IOException; 135 136 /** clean all internal states */ 137 void clear(); 138 139 }