Class UMod2java

java.lang.Object
eu.bandm.tools.umod.UMod2java

@PropertyDependency("eu.bandm.tools.umod.UMod2java.targetClassPath") public class UMod2java extends Object
  • Field Details

    • targetClassLoader

      public static final ClassLoader targetClassLoader
      Classloader for the resolution of EXT... declarations. (Is not used for the resolution of the default java.util.* classes.)
    • DOC_SEP

      public static final String DOC_SEP
      Html element to separate the sections of one Java api doc entry.
      See Also:
    • F_DOC_SEP

      public static final Format F_DOC_SEP
      Html element to separate the sections of one Java api doc entry.
    • docMissing_x

      public static final String docMissing_x
      Text for all model elements for which an explicit user doc by the model author is missing. (The trailing blank supports the recognition of the closing full-stop.)
      See Also:
    • docMissing

      public static final String docMissing
      First sentence of the default documentation text for classes and fields, when doc by the author is missing.
      See Also:
    • docDefault

      public static final String docDefault
      First sentence of default documentation text for generated entities which cannot have an explicit »DOC« entry in the umod syntax. Currently these are only the INTERFACE signatures defined in umod. (The trailing blank supports the recognition of the closing full-stop.)
      See Also:
    • FORMAT_null

      protected static final Format FORMAT_null
    • NAME_SAX_PARSER

      protected static final String NAME_SAX_PARSER
      See Also:
    • NAME_SAX_WRITER

      protected static final String NAME_SAX_WRITER
      See Also:
    • METHODNAME_GETFORMATHINT

      protected static final String METHODNAME_GETFORMATHINT
      See Also:
    • CLASSNAME_TREEGEN

      public static final String CLASSNAME_TREEGEN
      See Also:
    • MODIF_PACKAGE_ACCESSIBLE

      protected static final int MODIF_PACKAGE_ACCESSIBLE
      See Also:
    • MODIF_TOPCLASS

      protected static final int MODIF_TOPCLASS
      See Also:
    • MODIF_STATICCLASS

      protected static final int MODIF_STATICCLASS
      See Also:
    • MODIF_STATIC_CONST

      protected static final int MODIF_STATIC_CONST
      See Also:
    • MODIF_STATICFIELD

      protected static final int MODIF_STATICFIELD
      See Also:
    • MODIF_STATICFINALFIELD

      protected static final int MODIF_STATICFINALFIELD
      See Also:
    • MODIF_CALLABLE

      protected static final int MODIF_CALLABLE
      See Also:
    • MODIF_STATICCALLABLE

      protected static final int MODIF_STATICCALLABLE
      See Also:
    • suffix_srcDoc

      public static final String suffix_srcDoc
      See Also:
    • curforest

      protected UMod.Forest curforest
      Global variable for the resolution of identifiers (local or exernal)
    • floatNotDouble

      protected boolean floatNotDouble
      Whether to use Java float and not Java double for the realisation of the umod »float« type.
    • userDocLevel

      protected int userDocLevel
    • hasUserDoc

      protected boolean hasUserDoc
      Whether API doc will be inserted into the generated source. This depends from at least »DOC« entry appearing in the umod source text.
    • htmlDocText

      protected Types.HtmlDocText htmlDocText
      Visitor which delivers a HTML representation of a umod type. This includes navigation links for reference types, etc.
    • htmlPPfilename

      protected String htmlPPfilename
      The name of the pretty-printed and navigable source text. As part of the API-doc it is referred to ubiquituously.
    • msg

    • msgCounter

      protected MessageCounter msgCounter
    • log_phase

      protected String log_phase
    • annotationGeneratedArguments

      protected Format annotationGeneratedArguments
    • generationAnnotation

      protected GeneratedAnnotation generationAnnotation
    • doubleColonComment

      public static final Format doubleColonComment
    • CLASSNAME_TERM_PATTERNS

      public final String CLASSNAME_TERM_PATTERNS
      See Also:
    • NAMESTUB_PATTERN_TERM

      public final String NAMESTUB_PATTERN_TERM
      See Also:
    • NAMESTUB_PATTERN_CAST

      public final String NAMESTUB_PATTERN_CAST
      See Also:
    • class_term_patterns

      protected GeneratedClass class_term_patterns
    • METHODNAME_FORESTER_ENTRYPOINT

      public static final String METHODNAME_FORESTER_ENTRYPOINT
      See Also:
    • METHODNAME_TOSWINGTREE

      public static final String METHODNAME_TOSWINGTREE
      See Also:
    • WRAPPEDCLASS_SwingForester

      protected static final MetaClass WRAPPEDCLASS_SwingForester
    • WRAPPEDCLASS_SwingForester_LazyNode

      protected static final MetaClass WRAPPEDCLASS_SwingForester_LazyNode
    • WRAPPEDCLASS_swing_tree_TreeNode

      protected static final MetaClass WRAPPEDCLASS_swing_tree_TreeNode
    • dueToAlg

      protected static final Format dueToAlg
  • Constructor Details

    • UMod2java

      public UMod2java()
  • Method Details

    • findexternalclassforname

      @Opt protected static @Opt Class<?> findexternalclassforname(String n)
      Resolution of EXT... declarations. ATTENTION: Operates heuristically: replaces ».« by »$« to find inner classes. (Is not used for the resolution of the default java.util.* classes.)
      Parameters:
      n - the qualified name of the external calls to import.
      Returns:
      the found class, or null.
    • strictnessCheck

      protected static Format strictnessCheck(UMod.FieldDef fd)
      Return a format which reads the field value with a non-null check.
      Parameters:
      fd - the field to read
      Returns:
      a format which reads the field value with a non-null check.
    • fieldSetToString

      protected String fieldSetToString(Collection<UMod.FieldDef> coll, String sep)
    • fieldCollectionToConstant

      protected String fieldCollectionToConstant(Collection<UMod.FieldDef> coll, String sep)
    • addDocumentation

      protected void addDocumentation(GeneratedAnnotationTarget target, @Opt UMod.Item source, @Opt @Opt String genericAlternative, @Opt @Opt String concludingText)
    • addDocumentation

      protected void addDocumentation(GeneratedAnnotationTarget target, @Opt UMod.Item source, @Opt @Opt String prefixToUser, @Opt @Opt String genericAlternative, @Opt @Opt String concludingText)
      Adds metajava documentation objects to the generated metajava structure. Documentation is added if and only if umod runs in doc-mode, see hasUserDoc. Doc-mode is enabled iff there is at least one DOC entry in the umod source.

      The generated documentation consists of:

      • The explicit documentation text from the umod source connected to umod item source, if the item is !=null and there is such text. The documentation text is the concatenation of all DOC entries in the source, in source order. It shall adhere to the javadoc rules; esp. the first sentence should be self-contained and end with ". " = period and space. This text is included in <div class="bandmUser"> and prefixed by prefixToUser, if that is not ==null.
      • Otherwise the text in genericAlternative, if that is !=null.
      • Followed by the concludingText, if !=null.
      • Up to here only the prefixes of these texts are included, up to the start of the first javadoc "block tag".
      • Followed by a textual and linked source indication, if item != null.
      • Then follow the suffices of the selected texts, starting with the first javadoc "block tag".

      See this technical article.

      Parameters:
      target - the generated metajava object to be documented.
      source - the umod source which led to the generation, or null. FIXME DOCME wann ist das null ?
      prefixToUser - inserted before the author-defined doc text.
      genericAlternative - text which is used if there is no doc-text in the the umod source related to the item given by source; may be ==null.
      concludingText - to be put behind the author's or default text, anyhow.
    • addDocumentation

      protected void addDocumentation(GeneratedAnnotationTarget target, String text)
      Add comment text, but only iff we run in doc mode.
    • ERROR

      protected void ERROR(Locatable<XMLDocumentIdentifier> loc, String txt)
    • WARNING

      protected void WARNING(Locatable<XMLDocumentIdentifier> loc, String txt)
    • WARNING

      protected void WARNING(String txt)
    • logS

      protected void logS(String txt)
    • logE

      protected void logE(String txt)
    • logE

      protected void logE()
    • checkErrors

      protected void checkErrors()
      Terminate the execution if an error or a failure has been signalled. Sends a notifiying message and throws an exception.
      Throws:
      UMod2java.AbortExecution
    • translate

      public GeneratedPackage translate(UMod.Forest code, MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg0, String pkgname, Format generationDescription, String dateAndTime, boolean getterfunctions, boolean setterfunctions, boolean make_patterns, boolean saxgen, boolean swingtreegen, boolean visitordebug, boolean visitoroptimize, boolean visitorcompile, boolean allrewriterwarnings, boolean monolithic, boolean floatNotDouble, boolean constructorsPre20181214)
      Main class for translating a UMod model into Java source code. It is alled with an UMod.Forest object, which corresponds to some umod source file or has been constructed purely programmatically. It outputs a GeneratedPackage, which can be written to a source text file as usual.

      This main method calls additionally the main methods in separate classes UMod2visitors, UMod2Tsoap, UMod2format, etc.

      The sub-workes defined locally here are Visitors, namely UMod2java.ExtInstantier. UMod2java.V_compileVerbatimJava. UMod2java.V_importFieldTypes, UMod2java.V_compileFieldDefs, UMod2java.V__compileSwingTree, UMod2java.V_compileAlgebraic, UMod2java.V_compileOrdered, UMod2java.V_initFrom.
      Additionally, the class Types is used for type algebraics, and mapping UMod types to Java types.

    • resolveExternals

      protected void resolveExternals(UMod.Forest forest)
      <!ELEMENT extinstantiation (absoluteref, extinstantiation*) >
    • resolveOneExternal

      protected void resolveOneExternal(UMod.ExtDeclaration ext)
    • compileEnumDef

      protected void compileEnumDef(UMod.EnumDef td, GeneratedContext context)
      An UMod.EnumDef is a simple UMod expression which is translated to a java enumeration type. FIXME MISSING embedded java with enum or enum item currently not supported by input grammar.
    • compileIfaceDef

      protected void compileIfaceDef(UMod.IfaceDef td, GeneratedContext context)
      A UMod INTERFACE A | B || C expression is a lean notation which is translated into the definition of new java interfaces in the generated context (package or class). (Not to be mixed up with »IMPLEMENTS«.) FIXME currently documentation text is not supported.
    • compileTypeDef

      protected void compileTypeDef(UMod.TypeDef td, GeneratedContext context)
      FIXME assert that type expression is COMPLEX (not just T_reference or primitive!) Typedefs are CURRENTLY NOT YET USED NOR TESTED !
    • makeTConstructor

      protected void makeTConstructor(GeneratedClass gc, MetaType[] args)
    • addIfaceDeclarations

      protected void addIfaceDeclarations(UMod.Forest forest)
    • compilePatterns

      protected void compilePatterns(GeneratedContext context)
    • compilePatterns

      protected void compilePatterns(UMod.ClassDef cd)
    • makePrivate0aryConstructors

      protected void makePrivate0aryConstructors(boolean monolithicMode)
    • makeswingtree

      protected void makeswingtree(UMod.Forest forest, GeneratedClass modelclass, GeneratedContext context, GeneratedClass basematcher, boolean visitoroptimize)
      Generate a lazy Java swing representation for all models of this meta-model. The activation goes via the model class, as in
         util.ui.SwingBrowser.displayTree
            ([modelclass].toSwingTree([modelelement]) ;