Package com.igormaznitsa.jcp.containers
Class FileInfoContainer
- java.lang.Object
-
- com.igormaznitsa.jcp.containers.FileInfoContainer
-
public class FileInfoContainer extends java.lang.ObjectThe class is one from the main classes in the preprocessor because it describes a preprocessing file and contains business logic for the process
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringdestFileNameThe destination name for the fileprivate java.lang.StringdestFolderThe destination directory for the fileprivate static java.util.regex.PatternDIRECTIVE_HASH_PREFIXEDprivate static java.util.regex.PatternDIRECTIVE_SINGLE_DOLLAR_PREFIXEDprivate static java.util.regex.PatternDIRECTIVE_TAIL_REMOVERprivate static java.util.regex.PatternDIRECTIVE_TWO_DOLLARS_PREFIXEDprivate booleanexcludedFromPreprocessingThe flag shows that the file has been excluded from preprocessing and it will not be preprocessed and copiedprivate booleanforCopyOnlyThe flag shows that the file should be just copied into the destination place without any preprocessingprivate java.io.FilesourceFileThe source file for the container
-
Constructor Summary
Constructors Constructor Description FileInfoContainer(java.io.File srcFile, java.lang.String dstFileName, boolean copyOnly)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private booleancheckDirectiveArgumentRoughly(AbstractDirectiveHandler directive, java.lang.String rest)private java.lang.StringextractDoubleDollarPrefixedDirective(java.lang.String line, PreprocessorContext context)private java.lang.StringextractHashPrefixedDirective(java.lang.String line, PreprocessorContext context)private java.lang.StringextractSingleDollarPrefixedDirective(java.lang.String line, PreprocessorContext context)private static java.lang.StringfindTailRemover(java.lang.String str, PreprocessorContext context)java.lang.StringgetDestinationDir()java.lang.StringgetDestinationFilePath()java.lang.StringgetDestinationName()java.io.FilegetSourceFile()private booleanisDoubleDollarPrefixed(java.lang.String line, PreprocessorContext context)booleanisExcludedFromPreprocessing()booleanisForCopyOnly()private booleanisHashPrefixed(java.lang.String line, PreprocessorContext context)private booleanisSingleDollarPrefixed(java.lang.String line, PreprocessorContext context)PreprocessingStatepreprocessFile(PreprocessingState state, PreprocessorContext context)Preprocess file, NB! it doesn't clear local variables automatically for cloned contextsprotected AfterDirectiveProcessingBehaviourprocessDirective(PreprocessingState state, java.lang.String directiveString, PreprocessorContext context, boolean firstPass)java.util.List<PreprocessingState.ExcludeIfInfo>processGlobalDirectives(PreprocessingState state, PreprocessorContext context)voidsetDestinationDir(java.lang.String destDir)voidsetDestinationName(java.lang.String destName)voidsetExcluded(boolean flag)java.lang.StringtoString()
-
-
-
Field Detail
-
DIRECTIVE_HASH_PREFIXED
private static final java.util.regex.Pattern DIRECTIVE_HASH_PREFIXED
-
DIRECTIVE_TWO_DOLLARS_PREFIXED
private static final java.util.regex.Pattern DIRECTIVE_TWO_DOLLARS_PREFIXED
-
DIRECTIVE_SINGLE_DOLLAR_PREFIXED
private static final java.util.regex.Pattern DIRECTIVE_SINGLE_DOLLAR_PREFIXED
-
DIRECTIVE_TAIL_REMOVER
private static final java.util.regex.Pattern DIRECTIVE_TAIL_REMOVER
-
sourceFile
private final java.io.File sourceFile
The source file for the container
-
forCopyOnly
private final boolean forCopyOnly
The flag shows that the file should be just copied into the destination place without any preprocessing
-
excludedFromPreprocessing
private boolean excludedFromPreprocessing
The flag shows that the file has been excluded from preprocessing and it will not be preprocessed and copied
-
destFolder
private java.lang.String destFolder
The destination directory for the file
-
destFileName
private java.lang.String destFileName
The destination name for the file
-
-
Method Detail
-
getSourceFile
public java.io.File getSourceFile()
-
isExcludedFromPreprocessing
public boolean isExcludedFromPreprocessing()
-
isForCopyOnly
public boolean isForCopyOnly()
-
getDestinationDir
public java.lang.String getDestinationDir()
-
getDestinationName
public java.lang.String getDestinationName()
-
getDestinationFilePath
public java.lang.String getDestinationFilePath()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
processGlobalDirectives
@MustNotContainNull public java.util.List<PreprocessingState.ExcludeIfInfo> processGlobalDirectives(PreprocessingState state, PreprocessorContext context) throws java.io.IOException
- Throws:
java.io.IOException
-
isDoubleDollarPrefixed
private boolean isDoubleDollarPrefixed(java.lang.String line, PreprocessorContext context)
-
isSingleDollarPrefixed
private boolean isSingleDollarPrefixed(java.lang.String line, PreprocessorContext context)
-
isHashPrefixed
private boolean isHashPrefixed(java.lang.String line, PreprocessorContext context)
-
extractHashPrefixedDirective
private java.lang.String extractHashPrefixedDirective(java.lang.String line, PreprocessorContext context)
-
extractDoubleDollarPrefixedDirective
private java.lang.String extractDoubleDollarPrefixedDirective(java.lang.String line, PreprocessorContext context)
-
extractSingleDollarPrefixedDirective
private java.lang.String extractSingleDollarPrefixedDirective(java.lang.String line, PreprocessorContext context)
-
preprocessFile
public PreprocessingState preprocessFile(PreprocessingState state, PreprocessorContext context) throws java.io.IOException
Preprocess file, NB! it doesn't clear local variables automatically for cloned contexts- Parameters:
state- the start preprocessing state, can be nullcontext- the preprocessor context, must not be null- Returns:
- the state for the preprocessed file
- Throws:
java.io.IOException- it will be thrown for IO errorsPreprocessorException- it will be thrown for violation of preprocessing logic, like undefined variable
-
findTailRemover
private static java.lang.String findTailRemover(java.lang.String str, PreprocessorContext context)
-
checkDirectiveArgumentRoughly
private boolean checkDirectiveArgumentRoughly(AbstractDirectiveHandler directive, java.lang.String rest)
-
processDirective
protected AfterDirectiveProcessingBehaviour processDirective(PreprocessingState state, java.lang.String directiveString, PreprocessorContext context, boolean firstPass) throws java.io.IOException
- Throws:
java.io.IOException
-
setDestinationDir
public void setDestinationDir(java.lang.String destDir)
-
setDestinationName
public void setDestinationName(java.lang.String destName)
-
setExcluded
public void setExcluded(boolean flag)
-
-