public final class LineConvertors extends Object
LineConvertor
classes.Modifier and Type | Class and Description |
---|---|
static interface |
LineConvertors.FileLocator
Locates the file for the given path, file or part of the path.
|
Modifier and Type | Method and Description |
---|---|
static LineConvertor |
filePattern(LineConvertors.FileLocator fileLocator,
Pattern linePattern,
Pattern filePattern,
int fileGroup,
int lineGroup)
Returns the convertor searching for lines matching the patterns,
considering matched lines as being files.
|
static LineConvertor |
httpUrl()
Returns the convertor parsing the line and searching for
http or https URL. |
static LineConvertor |
proxy(LineConvertor... convertors)
Returns the convertor that will delegate to passed converters.
|
@NonNull public static LineConvertor proxy(@NonNull LineConvertor... convertors)
On call to LineConvertor.convert(java.lang.String)
converters
are asked one by one for conversion in the same order they were
passed to constructor. The first non null
value
is returned. If all coverters return null
for particular
line null
is returned.
Returned convertor is not thread safe.
convertors
- convertors that will be proxied; the same order
is used on LineConvertor.convert(java.lang.String)
invocation@NonNull public static LineConvertor filePattern(@NullAllowed LineConvertors.FileLocator fileLocator, @NonNull Pattern linePattern, @NullAllowed Pattern filePattern, int fileGroup, int lineGroup)
Convertor is trying to mach each line against the given
linePattern
. If the line matches the regexp group number
fileGroup
is supposed to be filename. This filename is then
checked whether it matches filePattern
(if any).
In next step converter tries to determine the line in file. The line
is parsed as lineGroup
regexp group. Line number begins
with 1
(first line of the file). If resulting value
representing line number can't be parsed or is less then or equal
to zero the OutputListener
associated with converted line
will use value 1
as a line number.
When the line does not match the linePattern
or
received filename does not match filePattern
null
is returned.
Resulting converted line contains the original text and a listener
that consults the fileLocator
(if any) when clicked
and displays the received file in the editor. If fileLocator
is null
output listener will try to find file simply by
new File(filename)
checking its existence by
isFile()
.
Returned convertor is not thread safe.
fileLocator
- locator that is consulted for real file; used in
listener for the converted line; may be null
linePattern
- pattern for matching the linefilePattern
- pattern for matching once received filenames;
may be null
fileGroup
- regexp group supposed to be the filename;
only nonnegative numbers allowedlineGroup
- regexp group supposed to be the line number;
if negative line number is not parsedFileOpenHandler
@NonNull public static LineConvertor httpUrl()
http
or https
URL.
Converted line returned from the processor consist from the original line and listener opening browser with recognized url on click.
If line is not recognized as http
or https
URL null
is returned.
Returned convertor is not thread safe.
http
or https
URLHttpOpenHandler