Class Main

java.lang.Object
eu.bandm.tools.d2d2.base.Main

public class Main extends Object
D2d comand line tool, by static method main(java.lang.String[]).

Most executives for the different tasks of d2d are dislocated as public static methods into Tasks, since they are also called by programs. See there for complete use case information flow diagrams.

Some transformations are implemeted in these both classes directly; others are implemented de-centrally. E.g. the reading of DTDs and .umod files as ddf-s is done by the ModuleRegistry "under the hood", when looking for text format definitions.

  • Field Details

    • msg_counter

      protected MessageCounter msg_counter
      Used for ending program execution early.
    • debuglevel

      protected int debuglevel
      Set by the command line options. Smaller than one suppresses all logging messages. Error messages are never suppressed.
    • msg

      Evident
    • prototypeGui

      public static final OptionsGui prototypeGui
      Service access point: prototype for gui-based client software.
  • Constructor Details

    • Main

      public Main()
  • Method Details

    • error

      protected void error(String s, Object... args)
      Evident
    • error

      protected void error(Exception ex, String s, Object... args)
      Evident
    • warning

      protected void warning(String s, Object... args)
      Evident
    • log

      protected void log(String s, Object... args)
      Evident
    • logStart

      protected void logStart(String s, Object... args)
      Evident
    • logEnd

      protected void logEnd(String s, Object... args)
      Evident
    • printErrorCounter

      protected void printErrorCounter()
      Print all non-zero message numbers, per category and over all.
    • terminateApplicationOnErrors_printUsage

      protected void terminateApplicationOnErrors_printUsage()
      Evident
    • terminateApplicationOnErrors

      protected void terminateApplicationOnErrors()
      Evident
    • modeText

      protected String modeText(Options options)
      Synthesize text for use in messages which indicates the selected "mode"
    • get2names

      @Opt protected @Opt String[] get2names(Options options, String sourceRole)
      Extract an input module name and an output file from the options (option --module and --outputfile). Raise error if not possible.
    • check_noKey

      protected void check_noKey(Options options)
      Ensure that no key or keys option is given.
    • splitAndCheckKey

      @Opt public static @Opt String[] splitAndCheckKey(MessageReceiver<SimpleMessage<@Opt XMLDocumentIdentifier>> msg, String s)
      Split one string according to the syntax [modulePath] (":"[ElementTag])?. Return one or two strings, or null in case of error. The first is always a definition module (mostly a dtd!). The second is the top-level element, used for identifying the "set of reachables".
    • getKey_split

      @Opt protected @Opt String[] getKey_split(Options options)
      Split the command line option "-k/--key" with splitAndCheckKey(MessageReceiver,String). Currently only used for ddf2xslt-mode.
      Returns:
      an array of one or two strings, holding the target module and maybe the target top tag
    • checkKeyIsSet

      protected void checkKeyIsSet(Options options, String txt)
      Check for option "-k/--key".
    • initModuleReg

      public static ModuleRegistry initModuleReg(MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg, int tracelevel, Stream<String> libpath)
      Construct a module registry according to the command line options.
    • initModuleReg

      protected ModuleRegistry initModuleReg(Options options)
      Construct a module registry according to the command line options.
    • initErrorStrategy

      public static Text2Udom.ErrorStrategy initErrorStrategy(int interactive, boolean partialDocs)
      Construct an eror strategy according to the command line options.
    • initErrorStrategy

      protected Text2Udom.ErrorStrategy initErrorStrategy(Options options)
      Construct an eror strategy according to the command line options.
    • interpretCommandline

      public static void interpretCommandline(MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg, String cli_text)
      Service access point: execute the value as if it were a command line suffix.
    • nonStatic_interpretCommandline

      public void nonStatic_interpretCommandline(MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg, String cli_text)
      Simulate CLI input fFor programmatic use. Esp. for tests. Does NOT decode the "--version" option, etc.
    • main

      public static void main(String[] args)
      Create one instance, for messaging and option decoding, and call nonStatic_main(String[]).
    • nonStatic_main

      protected void nonStatic_main(String[] args)
      Tool implementation: Decodes and checks the commandline options,
    • execute

      public void execute(Options options, MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg)
      Execute an Option model (mostly GUI-generated).
    • execute

      public boolean execute(Options options, String genString)
      Execute the CLI-parsed or GUI-generated Option model. Sets up some global parameters, and calls the different worker methods. These are mostly in Tasks, for programmatic invokation.
      Returns:
      whether the kind of error proposes to any cli-based caller to present the "usage()" in case of errors