Class XmlLoader

All Implemented Interfaces:
Loader, ExtensionPoint, Comparable<Loader>

public class XmlLoader extends AbstractProgramLoader
  • Field Details

  • Constructor Details

    • XmlLoader

      public XmlLoader()
  • Method Details

    • getTier

      public LoaderTier getTier()
      Description copied from interface: Loader
      For ordering purposes; lower tier numbers are more important (and listed first).
      Returns:
      the tier of the loader
    • getTierPriority

      public int getTierPriority()
      Description copied from interface: Loader
      For ordering purposes; lower numbers are more important (and listed first, within its tier).
      Returns:
      the ordering of the loader within its tier
    • supportsLoadIntoProgram

      public boolean supportsLoadIntoProgram()
      Description copied from interface: Loader
      Checks to see if this Loader supports loading into an existing Program.

      The default behavior of this method is to return false.

      Returns:
      True if this Loader supports loading into an existing Program; otherwise, false.
    • findSupportedLoadSpecs

      public Collection<LoadSpec> findSupportedLoadSpecs(ByteProvider provider) throws IOException
      Description copied from interface: Loader
      If this Loader supports loading the given ByteProvider, this methods returns a Collection of all supported LoadSpecs that contain discovered load specification information that this Loader will need to load. If this Loader cannot support loading the given ByteProvider, an empty Collection is returned.
      Parameters:
      provider - The bytes being loaded.
      Returns:
      A Collection of LoadSpecs that this Loader supports loading, or an empty Collection if this Loader doesn't support loading the given ByteProvider.
      Throws:
      IOException - if there was an IO-related issue finding the LoadSpecs.
    • getPreferredFileName

      public String getPreferredFileName(ByteProvider provider)
      Description copied from interface: Loader
      The preferred file name to use when loading.

      The default behavior of this method is to return the (cleaned up) name of the given ByteProvider.

      NOTE: This method may get called frequently, so only parse the given ByteProvider if absolutely necessary.

      Parameters:
      provider - The bytes to load.
      Returns:
      The preferred file name to use when loading.
    • loadProgram

      protected List<AbstractProgramLoader.LoadedProgram> loadProgram(ByteProvider provider, String programName, DomainFolder programFolder, LoadSpec loadSpec, List<Option> options, MessageLog log, Object consumer, TaskMonitor monitor) throws IOException, CancelledException
      Description copied from class: AbstractProgramLoader
      Loads program bytes in a particular format as a new Program. Multiple Programs may end up getting created, depending on the nature of the format.
      Specified by:
      loadProgram in class AbstractProgramLoader
      Parameters:
      provider - The bytes to load.
      programName - The name of the Program that's being loaded.
      programFolder - The DomainFolder where the loaded thing should be saved. Could be null if the thing should not be pre-saved.
      loadSpec - The LoadSpec to use during load.
      options - The load options.
      log - The message log.
      consumer - A consumer object for Programs generated.
      monitor - A cancelable task monitor.
      Returns:
      A list of loaded programs (element 0 corresponds to primary loaded Program).
      Throws:
      IOException - if there was an IO-related problem loading.
      CancelledException - if the user cancelled the load.
    • loadProgramInto

      protected boolean loadProgramInto(ByteProvider provider, LoadSpec loadSpec, List<Option> options, MessageLog log, Program prog, TaskMonitor monitor) throws IOException, CancelledException
      Description copied from class: AbstractProgramLoader
      Loads program bytes into the specified Program. This method will not create any new Programs. It is only for adding to an existing Program.

      NOTE: The loading that occurs in this method will automatically be done in a transaction.

      Specified by:
      loadProgramInto in class AbstractProgramLoader
      Parameters:
      provider - The bytes to load into the Program.
      loadSpec - The LoadSpec to use during load.
      options - The load options.
      log - The message log.
      prog - The Program to load into.
      monitor - A cancelable task monitor.
      Returns:
      True if the file was successfully loaded; otherwise, false.
      Throws:
      IOException - if there was an IO-related problem loading.
      CancelledException - if the user cancelled the load.
    • getDefaultOptions

      public List<Option> getDefaultOptions(ByteProvider provider, LoadSpec loadSpec, DomainObject domainObject, boolean loadIntoProgram)
      Description copied from interface: Loader
      Gets the default Loader options.
      Specified by:
      getDefaultOptions in interface Loader
      Overrides:
      getDefaultOptions in class AbstractProgramLoader
      Parameters:
      provider - The bytes of the thing being loaded.
      loadSpec - The LoadSpec.
      domainObject - The DomainObject being loaded.
      loadIntoProgram - True if the load is adding to an existing DomainObject; otherwise, false.
      Returns:
      A list of the Loader's default options.
    • getName

      public String getName()
      Description copied from interface: Loader
      Gets the Loader's name, which is used both for display purposes, and to identify the Loader in the opinion files.
      Returns:
      The Loader's name.
    • validateOptions

      public String validateOptions(ByteProvider provider, LoadSpec loadSpec, List<Option> options, Program program)
      Description copied from interface: Loader
      Validates the Loader's options and returns null if all options are valid; otherwise, an error message describing the problem is returned.
      Specified by:
      validateOptions in interface Loader
      Overrides:
      validateOptions in class AbstractProgramLoader
      Parameters:
      provider - The bytes of the thing being loaded.
      loadSpec - The proposed LoadSpec.
      options - The list of Options to validate.
      program - existing program if the loader is adding to an existing program. If it is a fresh import, then this will be null.
      Returns:
      null if all Options are valid; otherwise, an error message describing the problem is returned.