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.
-
Nested Class Summary
Nested Classes -
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 PatternMatches one single "linefeed", "carriage return", or "horizontal tab" character.static 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, Formats.stringEscapeMode escapemode, boolean htmlMode, String[] args) Generates a Format which explains the tool application to generate 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 StringReplaces all occurences of "linefeed", "carriage return", or "horizontal tab" character by a space character.static Formatstatic FormatstatementFormat(Format format) Generates<statement>;static StringstringEscape(String data, Formats.stringEscapeMode mode) Escapes blank characters in the given datum according to the methods selected by the mode parameter:Formats.stringEscapeMode.NO_ESCAPE, no change,Formats.stringEscapeMode.ESCAPE_BLANKS_INDIVIDUALLY, escape each blank with an own backslash, orFormats.stringEscapeMode.ESCAPE_FRAME_WITH_DOUBLEQUOTES, frame whole string with double quotes and escape all internal double quotes with a backslash.
-
Field Details
-
semicolonFormat
-
packageFormat
-
openParenFormat
-
closeParenFormat
-
openBraceFormat
-
closeBraceFormat
-
ltFormat
-
gtFormat
-
commaFormat
-
enumFormat
-
implementsFormat
-
classFormat
-
extendsFormat
-
equalFormat
-
throwsFormat
-
importFormat
-
dotFormat
-
pattern_newlineAndTabs
Matches one single "linefeed", "carriage return", or "horizontal tab" character. -
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>] ; } -
stringEscape
Escapes blank characters in the given datum according to the methods selected by the mode parameter:-
Formats.stringEscapeMode.NO_ESCAPE, no change, -
Formats.stringEscapeMode.ESCAPE_BLANKS_INDIVIDUALLY, escape each blank with an own backslash, - or
Formats.stringEscapeMode.ESCAPE_FRAME_WITH_DOUBLEQUOTES, frame whole string with double quotes and escape all internal double quotes with a backslash.
- Parameters:
data- to transformmode- how to react to contained blanks- Returns:
- the transformed data
-
-
replaceNewlinesAndTabs
Replaces all occurences of "linefeed", "carriage return", or "horizontal tab" character by a space character.- Parameters:
s- to transform- Returns:
- the transformed data
-
generationComment
public static Format generationComment(String main_class, @Opt @Opt String descriptive_name, @Opt @Opt String clickable, @Opt @Opt String versionText, String dateAndTime, Formats.stringEscapeMode escapemode, boolean htmlMode, String[] args) Generates a Format which explains the tool application to generate a Java source file. This format can be used documents the command line call and its parameters and can be included as a doc-comment in the generated soruce.The format returned by this method is not a particular (programming language) comment format, but only its contents. It can be converted to a string (containing line breaks) by
result.toString(70), etc., as documented withFormat. or to a string (probably) not containing line breaks byresult.toString(1000).The result will look like
Created on [calendaric date and time] by [descriptive_name] (=[main_class]) (version [name_version])? command line: java [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 charactersclickable- target url which can be reached by clicking the program name. Relevant only withhtmlModeset.versionText- may be==null, omitting the "version ..." textdateAndTime- must be given,escapemode- how arg-strings which contain whitespace shall be encoded, seestringEscape(String,stringEscapeMode)htmlMode- whether to insert html line break commands and other markup.args- the array of arguments which reachedstatic void main()in the call of the tool application.- See Also:
-
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
-