Package org.daisy.cli

Class AbstractUI

java.lang.Object
org.daisy.cli.AbstractUI
Direct Known Subclasses:
BasicUI

public abstract class AbstractUI extends Object
Provides an abstract base for command line UI's.
Author:
Joel HÃ¥kansson
  • Field Details

    • ARG_PREFIX

      public static final String ARG_PREFIX
      Prefix used for required arguments in the arguments map
      See Also:
  • Constructor Details

    • AbstractUI

      public AbstractUI()
      Creates a new AbstractUI using the default key/value delimiter '=' and the default optional argument prefix '-'
  • Method Details

    • expandShortForm

      public void expandShortForm(Map<String,String> map, String key, ShortFormResolver resolver)
      Expands the short form of the value with the given key in the provided map using the specified resolver.
      Parameters:
      map -
      key -
      resolver -
    • getDefinitionList

      public List<AbstractUI.Definition> getDefinitionList(FactoryCatalog<? extends Factory> catalog, ShortFormResolver resolver)
      Creates a list of definitions based on the contents of the supplied FactoryCatalog.
      Parameters:
      catalog - the catalog to create definitions for
      resolver -
      Returns:
      returns a list of definitions
    • setKeyValueDelimiter

      public void setKeyValueDelimiter(String value)
      Sets the delimiter to use between key and value in the argument strings passed to the UI.
      Parameters:
      value - the delimiter to use
    • setOptionalArgumentPrefix

      public void setOptionalArgumentPrefix(String value)
      Sets the optional argument prefix to use in argument strings passed to the UI.
      Parameters:
      value - the prefix to use
    • getName

      public abstract String getName()
      Gets the name for the UI
      Returns:
      returns the UI name
    • getRequiredArguments

      public abstract List<AbstractUI.Argument> getRequiredArguments()
      Gets required arguments
      Returns:
      returns a list of required arguments that can be passed to the UI on startup
    • getOptionalArguments

      public abstract List<AbstractUI.OptionalArgument> getOptionalArguments()
      Gets optional arguments
      Returns:
      returns a list of optional arguments that can be passed to the UI on startup
    • toMap

      public Map<String,String> toMap(String[] args)
      Converts a string based definition of UI arguments, typically passed by the main method, into a key-value map as described by displayHelp
      Parameters:
      args - the arguments passed to the application
      Returns:
      returns a map of application arguments
    • getOptional

      public Map<String,String> getOptional(String[] args)
    • getRequired

      public List<String> getRequired(String[] args)
    • exitWithCode

      public static void exitWithCode(AbstractUI.ExitCode e)
    • exitWithCode

      public static void exitWithCode(AbstractUI.ExitCode e, String message)
    • displayHelp

      public void displayHelp(PrintStream ps)
      Displays a help text for the UI based on the implementation of the methods getName, getOptionalArguments and getRequiredArguments.
      Parameters:
      ps - The print stream to use, typically System.out