Class Formats

java.lang.Object
eu.bandm.tools.metajava.Formats

public abstract class Formats extends Object
Container for fundamental static Format patterns, used by the metajava source code generators.
  • Field Details

    • semicolonFormat

      public static final Format semicolonFormat
    • packageFormat

      public static final Format packageFormat
    • openParenFormat

      public static final Format openParenFormat
    • closeParenFormat

      public static final Format closeParenFormat
    • openBraceFormat

      public static final Format openBraceFormat
    • closeBraceFormat

      public static final Format closeBraceFormat
    • ltFormat

      public static final Format ltFormat
    • gtFormat

      public static final Format gtFormat
    • commaFormat

      public static final Format commaFormat
    • enumFormat

      public static final Format enumFormat
    • implementsFormat

      public static final Format implementsFormat
    • classFormat

      public static final Format classFormat
    • extendsFormat

      public static final Format extendsFormat
    • equalFormat

      public static final Format equalFormat
    • throwsFormat

      public static final Format throwsFormat
    • importFormat

      public static final Format importFormat
    • dotFormat

      public static final Format dotFormat
    • CREATED_ON

      public static final String CREATED_ON
      See Also:
    • F_CREATED_ON

      public static final Format F_CREATED_ON
  • Constructor Details

    • Formats

      public Formats()
  • Method Details

    • roundList

      public static Format roundList(List<Format> elems)
    • openList

      public static Format openList(List<Format> elems)
    • angledList

      public static Format angledList(List<Format> elems)
    • genericFormat

      public static Format genericFormat(List<Format> types)
    • statementFormat

      public static Format statementFormat(Format format)
      Generates <statement>;
    • modifierFormat

      public static Format modifierFormat(Format annotations, int modifiers)
    • modifierFormat

      public static Format modifierFormat(int modifiers)
    • packageDecl

      public static Format packageDecl(String name)
    • packageDecl

      public static Format packageDecl(Format annotations, String name)
    • declarationFormat

      public static Format declarationFormat(Format modifiers, Format type, String name)
      Generates [<modifiers> ]<type> <name>
    • declarationFormat

      public static Format declarationFormat(Format type, Format item)
    • declarationFormat

      public static Format declarationFormat(Format modifiers, Format type, String name, Format initializer)
      Generates [<modifiers> ]<type> <name> = <expr>
    • declarationFormat

      public static Format declarationFormat(Format modifiers, Format type, Format name, Format initializer)
    • classDefinition

      public static Format classDefinition(Format modifiers, Format name, Format typevars, Format superclass, List<Format> implementing, Format body)
      Generates <modifiers> class <name> <typevars> extends <superclass> [implements <interfaces>] { <body> }
    • enumDefinition

      public static Format enumDefinition(Format modifiers, Format name, Format typevars, List<Format> implementing, List<Format> constants, Format body)
      Generates <modifiers> enum <name> <typevars> [implements <interfaces>] { [<consts>;] <body> }
    • definitionFormat

      public static Format definitionFormat(Format header, Format body)
      Generates <header> { <body> }
    • definitionFormat

      public static Format definitionFormat(Format header, Format body, boolean braces)
    • enumConstant

      public static Format enumConstant(String name, List<Format> params, Format body)
    • blockFormat

      public static Format blockFormat(Format statements)
    • constructorDefinition

      public static Format constructorDefinition(Format modifiers, Format typevars, Format name, List<Format> parameters, List<Format> exceptions, Format body)
      Generates <modifiers> <name>(<parameters>) [throws <exceptions>] { <body> }
    • methodDefinition

      public static Format methodDefinition(Format modifiers, Format typevars, Format returntype, String name, List<Format> parameters, List<Format> exceptions, Format body)
      Generates <modifiers> <typevars> <type> <name>(<parameters>) [throws <exceptions>] { <body> }
    • methodDefinition

      public static Format methodDefinition(Format modifiers, Format typevars, Format returntype, String name, List<Format> parameters, List<Format> exceptions)
      Generates <modifiers> <typevars> <type> <name>(<parameters>) [throws <exceptions>] ; }
    • generationComment

      public static Format generationComment(String main_class, @Opt @Opt String descriptive_name, @Opt @Opt String clickable, @Opt @Opt String versionText, String dateAndTime, int escapemode, boolean htmlMode, String[] args)
      Generates a Format which can be used as a doc-comment to document the command line call which initiated the generation of a 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  [calendaric date and time]
       by [descriptive_name] (=[main_class])   (version [name_version])?
       command line:
       [main_class] [arg1] [arg2]
      
      All strings in the "args" array are considered as potential file paths and thus (heuristically) anonymized by calling FilenameUtils.anonymiseLocalFile(String).
      Parameters:
      main_class - must be given,
      descriptive_name - is optional and may contain blanks and special characters
      versionText - may be ==null, omitting the "version ..." text
      dateAndTime - must be given,
      escapemode - how arg-strings which contain whitespace shall be encoded, see Formats.stringescape(String,int)
      htmlMode - whether to insert html line break commands and other markup.
      args - the arguments which reached static void main()
    • primeAssignment

      public static Format primeAssignment(String target, Format value)
      Target of assignment is a variable name.
    • annotationGeneratedArguments

      public static Format annotationGeneratedArguments(String tool, String version, String date, String... args)
    • annotationGeneratedArguments

      public static Format annotationGeneratedArguments(String tool, String version, String date)
    • annotationGeneratedArguments

      public static Format annotationGeneratedArguments(String tool, String version, String date, @Opt @Opt List<String> args)
    • extractFirstSentence_basic

      public static String extractFirstSentence_basic(String text)
      Extract the prefix from a Java doc text. The rules applied by JavaDoc are quite complex and pluggable; see the e.g. "-breakiterator" in the java tool reference.

      See also the source of "module jdk.compiler / package com.sun.source.doctree / interface DocCommentTree", method "getFirstSentence()".

      This very primitive version requires:

      • Any HTML markup or javadoc inline tag delimits the first sentence.
      • Otherwise a dot followed by a whitespace ends the first sentence.
      • But HTML "&amp;nbsp;" is allowed to escape a single dot in e.g. "Dr. Suess".
    • extractFirstSentence

      public static String extractFirstSentence(String text)
    • apidoc2attValue

      public static String apidoc2attValue(String text)