Package eu.bandm.tools.metajava
Class Formats
java.lang.Object
eu.bandm.tools.metajava.Formats
Container for fundamental static Format patterns, used by the
metajava source code generators.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Formatstatic final Formatstatic final Formatstatic final Formatstatic final Stringstatic final Formatstatic final Formatstatic final Formatstatic final Formatstatic final Formatstatic final Formatstatic final Formatstatic final Formatstatic final Formatstatic final Formatstatic final Formatstatic final Formatstatic final Formatstatic final Format -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FormatangledList(List<Format> elems) static FormatannotationGeneratedArguments(String tool, String version, String date) static FormatannotationGeneratedArguments(String tool, String version, String date, String... args) static Formatstatic Stringapidoc2attValue(String text) static FormatblockFormat(Format statements) static FormatclassDefinition(Format modifiers, Format name, Format typevars, Format superclass, List<Format> implementing, Format body) Generates<modifiers> class <name> <typevars> extends <superclass> [implements <interfaces>] { <body> }static FormatconstructorDefinition(Format modifiers, Format typevars, Format name, List<Format> parameters, List<Format> exceptions, Format body) Generates<modifiers> <name>(<parameters>) [throws <exceptions>] { <body> }static FormatdeclarationFormat(Format type, Format item) static FormatdeclarationFormat(Format modifiers, Format type, Format name, Format initializer) static FormatdeclarationFormat(Format modifiers, Format type, String name) Generates[<modifiers> ]<type> <name>static FormatdeclarationFormat(Format modifiers, Format type, String name, Format initializer) Generates[<modifiers> ]<type> <name> = <expr>static FormatdefinitionFormat(Format header, Format body) Generates<header> { <body> }static FormatdefinitionFormat(Format header, Format body, boolean braces) static FormatenumConstant(String name, List<Format> params, Format body) static FormatenumDefinition(Format modifiers, Format name, Format typevars, List<Format> implementing, List<Format> constants, Format body) Generates<modifiers> enum <name> <typevars> [implements <interfaces>] { [<consts>;] <body> }static StringextractFirstSentence(String text) static StringExtract the prefix from a Java doc text.static FormatgenerationComment(String main_class, @Opt String descriptive_name, @Opt String clickable, @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.static FormatgenericFormat(List<Format> types) static FormatmethodDefinition(Format modifiers, Format typevars, Format returntype, String name, List<Format> parameters, List<Format> exceptions) Generates<modifiers> <typevars> <type> <name>(<parameters>) [throws <exceptions>] ; }static FormatmethodDefinition(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> }static FormatmodifierFormat(int modifiers) static FormatmodifierFormat(Format annotations, int modifiers) static Formatstatic FormatpackageDecl(Format annotations, String name) static FormatpackageDecl(String name) static FormatprimeAssignment(String target, Format value) Target of assignment is a variable name.static Formatstatic FormatstatementFormat(Format format) Generates<statement>;
-
Field Details
-
semicolonFormat
-
packageFormat
-
openParenFormat
-
closeParenFormat
-
openBraceFormat
-
closeBraceFormat
-
ltFormat
-
gtFormat
-
commaFormat
-
enumFormat
-
implementsFormat
-
classFormat
-
extendsFormat
-
equalFormat
-
throwsFormat
-
importFormat
-
dotFormat
-
CREATED_ON
- See Also:
-
F_CREATED_ON
-
-
Constructor Details
-
Formats
public Formats()
-
-
Method Details
-
roundList
-
openList
-
angledList
-
genericFormat
-
statementFormat
Generates<statement>; -
modifierFormat
-
modifierFormat
-
packageDecl
-
packageDecl
-
declarationFormat
Generates[<modifiers> ]<type> <name> -
declarationFormat
-
declarationFormat
public static Format declarationFormat(Format modifiers, Format type, String name, Format initializer) Generates[<modifiers> ]<type> <name> = <expr> -
declarationFormat
-
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
Generates<header> { <body> } -
definitionFormat
-
enumConstant
-
blockFormat
-
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)orGeneratedAnnotationTarget.addComment(Format)
It can of course also be converted to a string (containing line breaks) byresult.toString(70), etc., as documented withFormat.
The result will look likeCreated 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 callingFilenameUtils.anonymiseLocalFile(String).- Parameters:
main_class- must be given,descriptive_name- is optional and may contain blanks and special charactersversionText- may be==null, omitting the "version ..." textdateAndTime- must be given,escapemode- how arg-strings which contain whitespace shall be encoded, seeFormats.stringescape(String,int)htmlMode- whether to insert html line break commands and other markup.args- the arguments which reachedstatic void main()
-
primeAssignment
Target of assignment is a variable name. -
annotationGeneratedArguments
-
annotationGeneratedArguments
-
annotationGeneratedArguments
-
extractFirstSentence_basic
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 "
&nbsp;" is allowed to escape a single dot in e.g. "Dr. Suess".
-
extractFirstSentence
-
apidoc2attValue
-