Interface IDataBushReader

All Known Implementing Classes:
DefaultDBReader, MADInterpreter, PropertiesReader

public interface IDataBushReader
This is interface for DataBush structure readers. DataBush reader should store elements in ElementList. This list is used to initialized DataBush.

about DataBush
DataBush gives physical view to accelerator. Accelerator devices or elements, as power supplies, magnets..., are represented as individual instances of JAVA objects. These are called DataBush elements. DataBush does not provides only organized access to DataBush elements, it also bind them together and with accelerator devices and perform some linear optics calculations. Before use of DataBush, elements must be introduced to DataBush with initialization process. DataBush does not know, how elements are obtained, this is task ob IDataBushReader. IDataBushReader gets description, what kind of elements to instantiate from input file.

about ElementList
ElementList is simple collection for holding DataBush elements. It can hold only elements with unique names. Elements can be accessed through their names or position in list.

about elements
Under name "element" could be understood at least three things. One is accelerator device. Other is DataBush element, or instance of JAVA object, that can connect itself to accelerator devices and perform operations. Third is description of accelerator element in input file.
DataBush can operate only with its DataBush elements. Each DataBush element represents individual accelerator device.
Input file hold elements, that are no more than lines of formatted text. Since they represents accelerator devices, they can be transformed by IDataBushReader into DataBush elements.
So line in input file is not really an element in our sense, just description of one. When we say element or DataBush element, we mean instance of JAVA object in DataBush, representing accelerator device.
To read an element in IDataBushReader means to read line of description an instantiate an DataBush element with read parameters. This interface is used as basic interface for all elements in package util that must read from file or any other kind of input stream. This interface introduces some basic behaviour of reading input stream.

Reading input stream should be performed in following three steps:
  • open input stream with openInStream. There are provided three different ways of opening input stream
  • read input stream and initialize reader with init()
  • close input stream with closeInStream()
EXAMPLE
 ParameterReader myreader= ...;
 
// prepare input and open input // case #1, from file String[] path= {"C:\my folder\","D:\my other folder\"} String file= "my file.txt"; boolean usePath= true;
myreader.openInStream(path,file,usePath);
// or case #2, from generic input stream java.io.Reader inputStream= ...;
myreader.onpenInputStream(inputStream);
//or case #3, from text java.lang.String inputString= "This text is to be read";
myreader.onpenInputStream(inputString);
// ParameterReader is intended to be used only with one of this three methods.
// Read stream and initialize internal structure
myreader.init();
//close input stream myreader.closeInStream();
Methods for opening and closing streams should not throw exceptions. Instead they return completion code.
Author:
igor@scictrl.com
  • Field Details

  • Method Details

    • getProperties

      Properties getProperties()

      getProperties.

      Returns:
      java.util.Properties
    • setProperties

      Properties setProperties(Properties properties)

      setProperties.

      Parameters:
      properties - java.util.Properties
      Returns:
      java.util.Properties
    • close

      void close() throws DataBushException
      Close opened input stream. Input stream must be opened with one of openInStream method.
      Throws:
      DataBushException - if any.
    • getList

      Returns list of instances of DataBush elements created by read() method.
      Returns:
      ElementList list of read elements
    • getSourceType

      int getSourceType()

      getSourceType.

      Returns:
      int
    • open

      void open(File file) throws DataBushException
      Opens input file. Name of the file is specified by name parameter. Parameter path is an array of file's paths. Path must end with '/'. Parameter usePath tells to use path. If name is fully qualified file name, use false for usePath flag. Close stream with closeInStream() method.
      Parameters:
      file - a File object
      Throws:
      DataBushException - if any.
    • open

      void open(URL url) throws DataBushException
      Opens input file. Name of the file is specified by name parameter. Parameter path is an array of file's paths. Path must end with '/'. Parameter usePath tells to use path. If name is fully qualified file name, use false for usePath flag. Close stream with closeInStream() method.
      Parameters:
      url - a URL object
      Throws:
      DataBushException - if any.
    • read

      Reads input and creates DataBush elements. Input must be opened with one of ParameterReader.openInStream methods. Created elements are stored and returned in ElementList.
      Returns:
      ElementList list of created elements
      Throws:
      DataBushException - if any.
    • read

      Reads input and creates DataBush elements. Input must be opened with one of ParameterReader.openInStream methods. Created elements are stored and returned in ElementList.
      Parameters:
      list - a ElementList object
      Returns:
      ElementList list of created elements
      Throws:
      DataBushException - if any.