Package org.nuiton.eugene.writer
Class AbstractChainedFileWriter
- java.lang.Object
-
- org.nuiton.eugene.writer.AbstractChainedFileWriter
-
- All Implemented Interfaces:
ChainedFileWriter
public abstract class AbstractChainedFileWriter extends Object implements ChainedFileWriter
Abstract implementation of theChainedFileWriter
.- Since:
- 2.0.0
- Author:
- Tony Chemit - chemit@codelutin.com
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,String>
authorizedPropertyDescriptions
universe of authorized properties (keys are property names, values are property descriptions).protected List<ChainedFileWriterEntry>
entries
entries to treate with this writerprotected ChainedFileWriter
nextWriter
next writer (can be null)protected ChainedFileWriter
previousWriter
previous writer (can be null)protected Map<String,Object>
properties
real properties obtained fro a configuration ininitWriter(ChainedFileWriterConfiguration)
method
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractChainedFileWriter(String... propertyNameAndDescriptions)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addEntry(ChainedFileWriterEntry entry)
Add an entry to treate.void
clear()
Clear all internal statesprotected abstract void
generate(ChainedFileWriterConfiguration configuration, File outputDir, Map<File,List<File>> filesByRoot, Map<File,List<File>> resourcesByFile)
Generates for all given files (filesByRoot
and then copy resources given for his file reacted in theresourcesByFile
dictionnary.void
generate(ChainedFileWriterConfiguration configuration, ChainedFileWriterData data)
Launch the generation for this writer with all pre-computed data to treate and resources to copy.Map<String,String>
getAuthorizedPropertyDescriptions()
String[]
getAuthorizedPropertyNames()
List<ChainedFileWriterEntry>
getEntries()
File
getExtractDirectory(File outputBasedir, boolean testPhase)
Obtain the real directory where to extract files (when using resources from class-path).String
getInputProtocol(String modelType)
Obtain the input protocol of this writer given the passedmodelType
.protected ChainedFileWriter
getNextWriter()
File
getOutputDirectory(File outputBasedir, boolean testPhase)
Obtain the real directory where to write files.protected ChainedFileWriter
getPreviousWriter()
<T> T
getProperty(String key, Class<T> type)
Obtain a writer extra property.WriterReport
getWriterReport()
protected void
initWriter(ChainedFileWriterConfiguration configuration)
Initialize the writer before the generation.protected void
setNextWriter(ChainedFileWriter nextWriter)
void
setWriterReport(WriterReport writerReport)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuiton.eugene.writer.ChainedFileWriter
acceptInclude, acceptModel, getDefaultIncludes, getDefaultInputDirectory, getDefaultOutputDirectory, getDefaultTestInputDirectory, getDefaultTestOutputDirectory, getInputProtocol, getOutputProtocol
-
-
-
-
Field Detail
-
entries
protected List<ChainedFileWriterEntry> entries
entries to treate with this writer
-
previousWriter
protected ChainedFileWriter previousWriter
previous writer (can be null)
-
nextWriter
protected ChainedFileWriter nextWriter
next writer (can be null)
-
authorizedPropertyDescriptions
protected final Map<String,String> authorizedPropertyDescriptions
universe of authorized properties (keys are property names, values are property descriptions).
-
properties
protected Map<String,Object> properties
real properties obtained fro a configuration ininitWriter(ChainedFileWriterConfiguration)
method
-
-
Constructor Detail
-
AbstractChainedFileWriter
protected AbstractChainedFileWriter(String... propertyNameAndDescriptions)
-
-
Method Detail
-
generate
protected abstract void generate(ChainedFileWriterConfiguration configuration, File outputDir, Map<File,List<File>> filesByRoot, Map<File,List<File>> resourcesByFile) throws IOException
Generates for all given files (filesByRoot
and then copy resources given for his file reacted in theresourcesByFile
dictionnary.- Parameters:
configuration
- the shared configuration for all writersoutputDir
- where to generate filesfilesByRoot
- all files to treateresourcesByFile
- resources associated to files to treate- Throws:
IOException
- for any IO pb.- Since:
- 2.1.3
-
getAuthorizedPropertyDescriptions
public Map<String,String> getAuthorizedPropertyDescriptions()
- Specified by:
getAuthorizedPropertyDescriptions
in interfaceChainedFileWriter
- Returns:
- the dictionnary of authorized property descriptions (keys are property names and values are descriptions).
-
getAuthorizedPropertyNames
public String[] getAuthorizedPropertyNames()
- Specified by:
getAuthorizedPropertyNames
in interfaceChainedFileWriter
- Returns:
- the array of properties names authorized for the chained writer.
-
clear
public void clear()
Description copied from interface:ChainedFileWriter
Clear all internal states- Specified by:
clear
in interfaceChainedFileWriter
-
addEntry
public void addEntry(ChainedFileWriterEntry entry)
Description copied from interface:ChainedFileWriter
Add an entry to treate.- Specified by:
addEntry
in interfaceChainedFileWriter
- Parameters:
entry
- the entry to add to writer
-
getProperty
public <T> T getProperty(String key, Class<T> type)
Description copied from interface:ChainedFileWriter
Obtain a writer extra property.- Specified by:
getProperty
in interfaceChainedFileWriter
- Type Parameters:
T
- the type of property- Parameters:
key
- the key of required propertytype
- the type of property- Returns:
- the property found or
null
if not found.
-
generate
public void generate(ChainedFileWriterConfiguration configuration, ChainedFileWriterData data) throws IOException
Description copied from interface:ChainedFileWriter
Launch the generation for this writer with all pre-computed data to treate and resources to copy.- Specified by:
generate
in interfaceChainedFileWriter
- Parameters:
configuration
- the share configuration of all writers.data
- data to treate (files to react + resources to copy)- Throws:
IOException
- if any io pb.
-
getInputProtocol
public String getInputProtocol(String modelType)
Description copied from interface:ChainedFileWriter
Obtain the input protocol of this writer given the passedmodelType
.- Specified by:
getInputProtocol
in interfaceChainedFileWriter
- Parameters:
modelType
- the type of model used- Returns:
- the input protocol or
null
if this writer does not accept the type of model
-
getOutputDirectory
public File getOutputDirectory(File outputBasedir, boolean testPhase)
Description copied from interface:ChainedFileWriter
Obtain the real directory where to write files. //FIXME-TC20091126 make this configurable (via the properties)- Specified by:
getOutputDirectory
in interfaceChainedFileWriter
- Parameters:
outputBasedir
- the output base directorytestPhase
-true
if writer is used in a test phase- Returns:
- the real output directory where to generate for this particular writer
-
getExtractDirectory
public File getExtractDirectory(File outputBasedir, boolean testPhase)
Description copied from interface:ChainedFileWriter
Obtain the real directory where to extract files (when using resources from class-path).- Specified by:
getExtractDirectory
in interfaceChainedFileWriter
- Parameters:
outputBasedir
- the output base directorytestPhase
-true
if writer is used in a test phase- Returns:
- the real output directory where to extract for this particular writer
-
getEntries
public List<ChainedFileWriterEntry> getEntries()
- Specified by:
getEntries
in interfaceChainedFileWriter
- Returns:
- the list of all entries registered
-
getWriterReport
public WriterReport getWriterReport()
- Specified by:
getWriterReport
in interfaceChainedFileWriter
- Returns:
- the writer report (to save generated file to later report)
-
setWriterReport
public void setWriterReport(WriterReport writerReport)
- Specified by:
setWriterReport
in interfaceChainedFileWriter
-
getNextWriter
protected ChainedFileWriter getNextWriter()
-
getPreviousWriter
protected ChainedFileWriter getPreviousWriter()
-
setNextWriter
protected void setNextWriter(ChainedFileWriter nextWriter)
-
initWriter
protected void initWriter(ChainedFileWriterConfiguration configuration)
Initialize the writer before the generation.- Parameters:
configuration
- the configuration to use for int
-
-