Class specLoader

java.lang.Object
name.moore.kevin.ze.XMLdata.specs.specLoader

public class specLoader extends Object
Class that loads all specifications held in XML into java objects.

Once loaded they can be converted into entities and their components

Author:
Kevin Moore <dev@kevin.moore.name>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    All the collected spec objects.
    private static org.slf4j.Logger
     
    static com.thoughtworks.xstream.XStream
    XStream object to process XML files into java objects.
  • Constructor Summary

    Constructors
    Constructor
    Description
    specLoader​(com.thoughtworks.xstream.XStream x)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    load​(File s)
    Load specifications from disk which we will only need to do once.
    private void
    Load the specific XML specifications file.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • xstream

      public static com.thoughtworks.xstream.XStream xstream
      XStream object to process XML files into java objects.
    • allspecs

      public List<XMLbase> allspecs
      All the collected spec objects. These can be processed elsewhere.
  • Constructor Details

    • specLoader

      public specLoader(com.thoughtworks.xstream.XStream x)
  • Method Details

    • load

      public void load(File s) throws FileNotFoundException, com.thoughtworks.xstream.XStreamException
      Load specifications from disk which we will only need to do once.

      Store the loaded objects for later access. If the parameter is a directory then all XML files in that directory will be treated as a spec and loaded. Alternatively a single XML spec file can be passed for loading. Can be called repeatedly and will append to the already collected specs.

      This loader also sets the required security so we only allow XStream abilities from this package.

      Parameters:
      s - path to the directory from which to load specs from or to specific single file.
      Throws:
      FileNotFoundException
      com.thoughtworks.xstream.XStreamException
    • loadSingleSpec

      private void loadSingleSpec(File fxml) throws FileNotFoundException, com.thoughtworks.xstream.XStreamException
      Load the specific XML specifications file. The file expects a <list>...</list> XML element wrapper containing one or more specs (of the same type).
      Parameters:
      fxml - full path to the file to load
      Throws:
      FileNotFoundException - XStreamException
      com.thoughtworks.xstream.XStreamException