Class FileSourceProvider
- java.lang.Object
-
- org.apache.torque.generator.source.SourceProvider
-
- org.apache.torque.generator.source.stream.FileSourceProvider
-
public class FileSourceProvider extends SourceProvider
Contains sources which are read from files in the file system. $Id: FileSourceProvider.java 1839288 2018-08-27 09:48:33Z tv $
-
-
Constructor Summary
Constructors Constructor Description FileSourceProvider(StreamSourceFormat sourceFormat, Fileset sourceFileset, Boolean combineFiles)
Constructor.
-
Method Summary
Modifier and Type Method Description SourceProvider
copy()
Returns a copy of this source provider in its initial state.void
copyNotSetSettingsFrom(SourceProvider sourceProvider)
Copies settings which are not set in this source provider from another source provider.Boolean
getCombineFiles()
Returns whether source files are combined into one source tree.List<File>
getPaths()
Returns all paths in the source Fileset.Fileset
getSourceFileset()
Returns the fileset which determines the source files to read.StreamSourceFormat
getSourceFormat()
Returns the source format for this provider.boolean
hasNext()
protected void
initInternal(ConfigurationHandlers configurationHandlers, ControllerState controllerState)
Determines the files which match the source fileset.Source
next()
void
remove()
void
resetInternal(ConfigurationHandlers configurationHandlers, ControllerState controllerState)
Resets the sources provided by this SourceProvider.void
setSourceFileset(Fileset sourceFileset)
Sets the fileset which determines the source files to read.String
toString()
-
Methods inherited from class org.apache.torque.generator.source.SourceProvider
init, isInit, reset
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Constructor Detail
-
FileSourceProvider
public FileSourceProvider(StreamSourceFormat sourceFormat, Fileset sourceFileset, Boolean combineFiles) throws ConfigurationException
Constructor.- Parameters:
sourceFormat
- the source format, or null if the source format should be determined from the file extension.sourceFileset
- the fileset defining the source files, not null.combineFiles
- whether all files should be combined into one source tree.- Throws:
IllegalArgumentException
- if the source type is unknown.NullPointerException
- if path is null.ConfigurationException
- if the source filter cannot be instantiated.
-
-
Method Detail
-
initInternal
protected void initInternal(ConfigurationHandlers configurationHandlers, ControllerState controllerState) throws ConfigurationException
Determines the files which match the source fileset.- Specified by:
initInternal
in classSourceProvider
- Parameters:
configurationHandlers
- the configuration handlers, not null.controllerState
- the current controller state, not null.- Throws:
ConfigurationException
- if the sourceFileset has no basedir or if the files cannot be determined.
-
resetInternal
public void resetInternal(ConfigurationHandlers configurationHandlers, ControllerState controllerState)
Description copied from class:SourceProvider
Resets the sources provided by this SourceProvider.- Specified by:
resetInternal
in classSourceProvider
- Parameters:
configurationHandlers
- the configuration handlers, not null.controllerState
- the current controller state, not null.
-
hasNext
public boolean hasNext()
-
next
public Source next()
-
remove
public void remove()
-
getSourceFormat
public StreamSourceFormat getSourceFormat()
Returns the source format for this provider.- Returns:
- the source format, or null if the format is determined from file extensions.
-
getSourceFileset
public Fileset getSourceFileset()
Returns the fileset which determines the source files to read.- Returns:
- the fileset which determines the source files to read.
-
setSourceFileset
public void setSourceFileset(Fileset sourceFileset)
Sets the fileset which determines the source files to read.- Parameters:
sourceFileset
- the new source fileset, not null.- Throws:
NullPointerException
- if sourceFileset is null.IllegalStateException
- if init() was called before.
-
getPaths
public List<File> getPaths()
Returns all paths in the source Fileset. The method init() must be called beforehand.- Returns:
- all Paths in the source fileset, not null.
- Throws:
IllegalStateException
- if the init method was not yet called.
-
getCombineFiles
public Boolean getCombineFiles()
Returns whether source files are combined into one source tree.- Returns:
- true if the source files are combined into one source tree, false otherwise, null to allow overriding this property (but will count as false if not overridden).
-
copy
public SourceProvider copy() throws ConfigurationException
Returns a copy of this source provider in its initial state. This means theSourceProvider.init(ConfigurationHandlers, ControllerState)
method of the new source provider must be called before it can be used.- Specified by:
copy
in classSourceProvider
- Returns:
- the SourceProvider
- Throws:
ConfigurationException
- if the new SourceProvider cannot be initialized.
-
copyNotSetSettingsFrom
public void copyNotSetSettingsFrom(SourceProvider sourceProvider)
Copies settings which are not set in this source provider from another source provider. This only works if the type of the other source provider is known to this source provider. Only a subset of all properties are typically used for overwriting. No Properties which are already set are overwritten.- Specified by:
copyNotSetSettingsFrom
in classSourceProvider
- Parameters:
sourceProvider
- the source provoder to copy the settings from.
-
-