Package eu.bandm.tools.util.files
Class SimpleFilePattern
java.lang.Object
eu.bandm.tools.util.files.SimpleFilePattern
Maps an input file name to an output file name according to a
very simple pattern rule inspired by "patsubst" from "make".
A SimpleFilePattern is constructed giving two(2) Strings which contain exactly
one(1) place holder character. Then it is applied to some input String, yielding
the output String.
As a variant, there is the case "multiple=false", in which neither of the Strings contains a place holder character. In this case the input must be identical with the first string to yield the second string.
patterns = inpre%inpost outpre%outpost inputname = XXXXinpreYYYYinpost (with inpre = latest occurrence in inpattern before inpost) outputname = XXXXoutpreYYYYoutpost stem = YYYYAll four components (inpre,inpost,outpre,outpost) may be empty.
As a variant, there is the case "multiple=false", in which neither of the Strings contains a place holder character. In this case the input must be identical with the first string to yield the second string.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
EvidentThe part of the input pattern after the placeholder-(package private) final int
Length of the part of the input pattern after the placeholder-The part of the input pattern before the placeholder-(package private) final int
Length of the part of the input pattern before the placeholder-(package private) final String
The complete input pattern, as given to the constructor call.final boolean
Whether in and out pattern contain a place holder character.The part of the output pattern after the placeholder-The part of the output pattern before the placeholder-(package private) final String
The complete output pattern, as given to the constructor call.final String
The place holder character as set by the constructor.The string matching the placeholder from the last executed call tomatch(String)
. -
Constructor Summary
ConstructorDescriptionSimpleFilePattern
(String in, String out) Construct a transformation with the given input and output pattern and thedefaultPlaceholder
.SimpleFilePattern
(String in, String out, String placeholder) Construct a transformation with the given input and output pattern and the given place holder. -
Method Summary
Modifier and TypeMethodDescriptiongetStem()
Return the stem which has been recognized by the most recent call tomatch(java.lang.String)
.Matches the input pattern and returns the derived output string.toString()
static boolean
validMultiple
(String in) Whether the string is a valid multiple input or output pattern with thedefaultPlaceholder
.static boolean
validMultiple
(String in, String placeholder) Whether the string is a valid multiple input or output pattern with the given placeholder.static boolean
validSingle
(String in) Whether the string is a valid single-solution input or output pattern with thedefaultPlaceholder
.static boolean
validSingle
(String in, String placeholder) Whether the string is a valid single-solution input or output pattern with the given placeholder.
-
Field Details
-
defaultPlaceholder
Evident- See Also:
-
placeholder
The place holder character as set by the constructor. -
multiple
public final boolean multipleWhether in and out pattern contain a place holder character. -
inPre
The part of the input pattern before the placeholder- -
inPost
The part of the input pattern after the placeholder- -
outPre
The part of the output pattern before the placeholder- -
outPost
The part of the output pattern after the placeholder- -
inPreLength
final int inPreLengthLength of the part of the input pattern before the placeholder- -
inPostLength
final int inPostLengthLength of the part of the input pattern after the placeholder- -
inText
The complete input pattern, as given to the constructor call. (Needs not contain a placeholder character.) -
outText
The complete output pattern, as given to the constructor call. (Needs not contain a placeholder character.) -
stem
The string matching the placeholder from the last executed call tomatch(String)
. Is != null in multiple mode.
-
-
Constructor Details
-
SimpleFilePattern
Construct a transformation with the given input and output pattern and thedefaultPlaceholder
. -
SimpleFilePattern
Construct a transformation with the given input and output pattern and the given place holder. Input and output pattern must contain the same number of placeholders, either zero or one.- Parameters:
placeholder
- must be a string of length==1.
-
-
Method Details
-
validMultiple
Whether the string is a valid multiple input or output pattern with thedefaultPlaceholder
. -
validMultiple
Whether the string is a valid multiple input or output pattern with the given placeholder. -
validSingle
Whether the string is a valid single-solution input or output pattern with thedefaultPlaceholder
. -
validSingle
Whether the string is a valid single-solution input or output pattern with the given placeholder. -
match
Matches the input pattern and returns the derived output string.Case not-multiple: The input string must be identical with the input pattern, and the output pattern is returned (no pattern contains a placeholder)
Case multiple: The output is calculated as follows (blanks to be ignored):
inpattern jjjj % lll stemstart p2 | p3 v v v in iiijjjjjj kkk lll outpattern ooo % ppp returned iiijj ooo kkk ppp stem kkk
-
getStem
Return the stem which has been recognized by the most recent call tomatch(java.lang.String)
. Must be called only if this call was in multiple mode. -
toString
-