Class CommentFormats

java.lang.Object
eu.bandm.tools.format.java.CommentFormats

public class CommentFormats extends Object
  • 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

      public static final Pattern pattern_newlineAndTabs
    • format_dateAndTime

      public static final String format_dateAndTime
      String formatting template for date and time. This string is applied to {@link java.lang.String.format(String,Object...)} with some GregorianCalendar 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 ...
      1. better readable "%tF %tHh%tMm%tS"
      2. older version "%tF %tT"
      3. completely consistent with "extended" format from ISO8601 is "%tFT%tT"
      But the latter two both work like "%tH:%tM:%tS", thus inserting ":" colon chars. So these can not be used as file names !
      See Also:
  • Constructor Details

    • CommentFormats

      public CommentFormats()
  • Method Details

    • singleLine

      public static Format singleLine(Format format)
    • apiDoc

      public static Format apiDoc(List<Format> formats)
    • multiLine

      public static Format multiLine(Format format)
    • stringescape

      public static String stringescape(String data, int mode)
      Escapes blank characters in the given datum according to the methods selected by
    • replaceNewlinesAndTabs

      public static String replaceNewlinesAndTabs(String s)
    • dateNow_standardFormat

      public static String dateNow_standardFormat()
      Returns the current state of the calendaric clock in the format defined by format_dateAndTime.
    • date_standardFormat

      public static String date_standardFormat(GregorianCalendar now)
      Returns the given date in the format defined by format_dateAndTime.
    • anonymiseLocalFile

      public static String anonymiseLocalFile(String path)
      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 calling GeneratedAnnotationTarget.addComment(Format) or GeneratedAnnotationTarget.addComment(Format)
      It can of course also be converted to a string (containing line breaks) by result.toString(70), etc., as documented with Format.
      The result will look like
       Created on  
       by    (version )?
       command line:
           
      
      All strings args are considered as potential file paths and HEURISTICALLY anonymized: "$(HOME)" is inserted for anything which looks like a home directory.
      Parameters:
      name_program - must be given,
      name_version - may be ==null, omitting the "version ..." text
      dateAndTime - must be given,
      escapemode - how arg-strings which contain whitespace shall be encoded
      html_breaks - whether to insert html break commands.
      args - the arguments which reached static 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 as generationComment(String,String,String,int,boolean,String[]), but uses dateNow_standardFormat() for date and time.
      Parameters:
      name_program - must be given,
      name_version - may be ==null, omitting the "version ..." text
      escapemode - how arg-strings which contain whitespace shall be encoded
      html_breaks - whether to insert html break commands.
      args - the arguments which reached static void main()