Package eu.bandm.tools.format.java
Class CommentFormats
java.lang.Object
eu.bandm.tools.format.java.CommentFormats
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
anonymiseLocalFile
(String path) Heuristics which removes "/home/max/metatools/" by "$(HOME)/metatools".
FIXME only implemented for UNIX.static Format
static String
Returns the given date in the format defined byformat_dateAndTime
.static String
Returns the current state of the calendaric clock in the format defined byformat_dateAndTime
.static Format
generationComment
(String name_program, @Opt String name_version, int escapemode, boolean html_breaks, String[] args) Generates a Format which can be used to document the command line call.static Format
generationComment
(String name_program, @Opt String name_version, String dateAndTime, int escapemode, boolean html_breaks, String[] args) Generates a Format which can be used to document the command line call, which initiated the generation of a certain java source file.static String
generationText
(String prefix, String[] args, int blankEscapeMode, String argSeparator, String lineSeparator, int maxWidth) Generate a primitive string which explains the parameters of a tool application.static Format
static String
static Format
singleLine
(Format format) static String
stringescape
(String data, int mode) Escapes blank characters in the given datum according to the methods selected byno_escape
, no change,escape_blanks_individually
, escape each blank with an own backslash, orescape_frame_with_doublequotes
, frame whole string with double quotes and escape all internal double quotes with a backslash.
-
Field Details
-
no_escape
public static final int no_escape- See Also:
-
escape_frame_with_doublequotes
public static final int escape_frame_with_doublequotes- See Also:
-
escape_blanks_individually
public static final int escape_blanks_individually- See Also:
-
pattern_newlineAndTabs
-
format_dateAndTime
String formatting template for date and time. This string is applied to {@link java.lang.String.format(String,Object...)} with someGregorianCalendar
as second argument. Date and Time format is set to the same format as the shell function "makedate" in "etc/calltools.mk", (beside that the latter does currently not include seconds.)
The result looks like
2009-07-21_01h09m07s
Please note that the day-part is defined by the java string formatting standard code "%tF", which directly corresponds to "%tY-%tm-%td", and thus verbatim to ISO 8601
The time-of-day part closely follows the "extended format" of ISO 8601 cf. ISO 8601/en and ISO 8601/de
BUT the separation character "." had to be replaced by "h" and "m", to make the string usable as a file name/time stamp! (windoof does not allow colon in file names, and you shouldn't try with unix.)
Alternatives would have been ...- better readable "
%tF %tHh%tMm%tS
" - older version "
%tF %tT
" - completely consistent with "extended" format from
ISO8601 is "
%tFT%tT
"
- See Also:
- better readable "
-
-
Constructor Details
-
CommentFormats
public CommentFormats()
-
-
Method Details
-
singleLine
-
apiDoc
-
multiLine
-
stringescape
Escapes blank characters in the given datum according to the methods selected by-
no_escape
, no change, -
escape_blanks_individually
, escape each blank with an own backslash, - or
escape_frame_with_doublequotes
, frame whole string with double quotes and escape all internal double quotes with a backslash.
-
-
replaceNewlinesAndTabs
-
dateNow_standardFormat
Returns the current state of the calendaric clock in the format defined byformat_dateAndTime
. -
date_standardFormat
Returns the given date in the format defined byformat_dateAndTime
. -
anonymiseLocalFile
Heuristics which removes "/home/max/metatools/" by "$(HOME)/metatools".
FIXME only implemented for UNIX. Other operating systems still missing. -
generationText
public static String generationText(String prefix, String[] args, int blankEscapeMode, String argSeparator, String lineSeparator, int maxWidth) Generate a primitive string which explains the parameters of a tool application. Concatenates the prefix and the sequence of args, after blank escaping. It joins the args by argSeparator, or by lineSeparator whenever the line length reaches maxWidth.
All strings are considered as potential file paths and HEURISTICALLY anonymized: "$(HOME)" is inserted for anything which looks like a home directory. -
generationComment
public static Format generationComment(String name_program, @Opt @Opt String name_version, String dateAndTime, int escapemode, boolean html_breaks, String[] args) Generates a Format which can be used to document the command line call, which initiated the generation of a certain java source file.
The format returned by this method can be attached to the generated structure by callingGeneratedAnnotationTarget.addComment(Format)
orGeneratedAnnotationTarget.addComment(Format)
It can of course also be converted to a string (containing line breaks) by result.toString(70), etc., as documented withFormat
.
The result will look likeCreated on
All strings args are considered as potential file paths and HEURISTICALLY anonymized: "$(HOME)" is inserted for anything which looks like a home directory.by (version )? command line: - Parameters:
name_program
- must be given,name_version
- may be==null
, omitting the "version ..." textdateAndTime
- must be given,escapemode
- how arg-strings which contain whitespace shall be encodedhtml_breaks
- whether to insert html break commands.args
- the arguments which reachedstatic void main()
-
generationComment
public static Format generationComment(String name_program, @Opt @Opt String name_version, int escapemode, boolean html_breaks, String[] args) Generates a Format which can be used to document the command line call. Acts asgenerationComment(String,String,String,int,boolean,String[])
, but usesdateNow_standardFormat()
for date and time.- Parameters:
name_program
- must be given,name_version
- may be==null
, omitting the "version ..." textescapemode
- how arg-strings which contain whitespace shall be encodedhtml_breaks
- whether to insert html break commands.args
- the arguments which reachedstatic void main()
-