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
Modifier and TypeFieldDescriptionstatic final Format
static final Format
static final Format
static final Format
static final String
static final Format
static final Format
static final Format
static final Format
static final Format
static final Format
static final Format
static final Format
static final Format
static final Format
static final Format
static final Format
static final Format
static final Format
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Format
angledList
(List<Format> elems) static Format
annotationGeneratedArguments
(String tool, String version, String date) static Format
annotationGeneratedArguments
(String tool, String version, String date, String... args) static Format
static String
apidoc2attValue
(String text) static Format
blockFormat
(Format statements) 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> }
static Format
constructorDefinition
(Format modifiers, Format typevars, Format name, List<Format> parameters, List<Format> exceptions, Format body) Generates<modifiers> <name>(<parameters>) [throws <exceptions>] { <body> }
static Format
declarationFormat
(Format type, Format item) static Format
declarationFormat
(Format modifiers, Format type, Format name, Format initializer) static Format
declarationFormat
(Format modifiers, Format type, String name) Generates[<modifiers> ]<type> <name>
static Format
declarationFormat
(Format modifiers, Format type, String name, Format initializer) Generates[<modifiers> ]<type> <name> = <expr>
static Format
definitionFormat
(Format header, Format body) Generates<header> { <body> }
static Format
definitionFormat
(Format header, Format body, boolean braces) static Format
enumConstant
(String name, List<Format> params, Format body) 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> }
static String
extractFirstSentence
(String text) static String
Extract the prefix from a Java doc text.static Format
generationComment
(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 Format
genericFormat
(List<Format> types) 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>] ; }
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> }
static Format
modifierFormat
(int modifiers) static Format
modifierFormat
(Format annotations, int modifiers) static Format
static Format
packageDecl
(Format annotations, String name) static Format
packageDecl
(String name) static Format
primeAssignment
(String target, Format value) Target of assignment is a variable name.static Format
static Format
statementFormat
(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
-