Class XmlLoader

    • Constructor Detail

      • XmlLoader

        public XmlLoader()
    • Method Detail

      • 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 java.util.Collection<LoadSpec> findSupportedLoadSpecs​(ByteProvider provider)
                                                              throws java.io.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:
        java.io.IOException - if there was an IO-related issue finding the LoadSpecs.
      • getPreferredFileName

        public java.lang.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 java.util.List<Program> loadProgram​(ByteProvider provider,
                                                      java.lang.String programName,
                                                      DomainFolder programFolder,
                                                      LoadSpec loadSpec,
                                                      java.util.List<Option> options,
                                                      MessageLog log,
                                                      java.lang.Object consumer,
                                                      TaskMonitor monitor)
                                               throws java.io.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:
        java.io.IOException - if there was an IO-related problem loading.
        CancelledException - if the user cancelled the load.
      • loadProgramInto

        protected boolean loadProgramInto​(ByteProvider provider,
                                          LoadSpec loadSpec,
                                          java.util.List<Option> options,
                                          MessageLog log,
                                          Program prog,
                                          TaskMonitor monitor)
                                   throws java.io.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:
        java.io.IOException - if there was an IO-related problem loading.
        CancelledException - if the user cancelled the load.
      • getName

        public java.lang.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 java.lang.String validateOptions​(ByteProvider provider,
                                                LoadSpec loadSpec,
                                                java.util.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.