Package org.scictrl.mp.orbitcorrect
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
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
Reading input stream should be performed in following three steps:
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()
ParameterReader myreader= ...;Methods for opening and closing streams should not throw exceptions. Instead they return completion code.
// 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();
- Author:
- igor@scictrl.com
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close opened input stream.getList()
Returns list of instances of DataBush elements created byread()
method.getProperties.int
getSourceType.void
Opens input file.void
Opens input file.read()
Reads input and creates DataBush elements.Reads input and creates DataBush elements.setProperties
(Properties properties) setProperties.
-
Field Details
-
ST_FILE
static final int ST_FILEConstantST_FILE=1
- See Also:
-
ST_URL
static final int ST_URLConstantST_URL=2
- See Also:
-
-
Method Details
-
getProperties
Properties getProperties()getProperties.
- Returns:
- java.util.Properties
-
setProperties
setProperties.
- Parameters:
properties
- java.util.Properties- Returns:
- java.util.Properties
-
close
Close opened input stream. Input stream must be opened with one of openInStream method.- Throws:
DataBushException
- if any.
-
getList
ElementList<AbstractDataBushElement> getList()Returns list of instances of DataBush elements created byread()
method.- Returns:
ElementList
list of read elements
-
getSourceType
int getSourceType()getSourceType.
- Returns:
- int
-
open
Opens input file. Name of the file is specified byname
parameter. Parameterpath
is an array of file's paths. Path must end with '/'. ParameterusePath
tells to use path. Ifname
is fully qualified file name, usefalse
forusePath
flag. Close stream withcloseInStream()
method.- Parameters:
file
- aFile
object- Throws:
DataBushException
- if any.
-
open
Opens input file. Name of the file is specified byname
parameter. Parameterpath
is an array of file's paths. Path must end with '/'. ParameterusePath
tells to use path. Ifname
is fully qualified file name, usefalse
forusePath
flag. Close stream withcloseInStream()
method.- Parameters:
url
- aURL
object- Throws:
DataBushException
- if any.
-
read
Reads input and creates DataBush elements. Input must be opened with one ofParameterReader.openInStream
methods. Created elements are stored and returned inElementList
.- Returns:
ElementList
list of created elements- Throws:
DataBushException
- if any.
-
read
ElementList<AbstractDataBushElement> read(ElementList<AbstractDataBushElement> list) throws DataBushException Reads input and creates DataBush elements. Input must be opened with one ofParameterReader.openInStream
methods. Created elements are stored and returned inElementList
.- Parameters:
list
- aElementList
object- Returns:
ElementList
list of created elements- Throws:
DataBushException
- if any.
-