-
Notifications
You must be signed in to change notification settings - Fork 0
Utilities Package
The util package in FlashLib provides a varying types of utilities, from array utils to java reflection, constant handling and more. The entire purpose is to simply assist developers and users of FlashLib in the execution of certain tasks. So far, we found it extremely usefull and we recommend using it.
FlashUtil
is the main utilities class. It contains a massive amount of static utiliy functions for a variety of tasks:
- Time utils:
- Getting time since the program has started
- Putting the current thread to sleep based on conditions
- etc
- Array utils:
- Copying array contents
- Finding an index of an element
- Checking the existance of an element
- Shifting elements in the array
- Resizing an array
- etc
- Reflection utils:
- Checking inheritence between class types
- Finding generic arguments of a class
- Creating an instance of a class by name
- etc
- Communiction utils
- Finding the local interface address
- etc
Those are just examples of what FlashUtil
provides to perform with ease.
FlashLib provides an abstract Log
class for logging runtime information. The log is rather simple and can be very usefull for runtime debugging of a robot software as well as post-run debugging.
Since the log is abstract, it is possible to implement it in any way wanted. But FlashLib provides 2 simple implmenetations:
-
SimpleStreamLog
: A simple log which keeps an open stream with 2 log files: error log and standard log. Since this implementation keeps an open stream, if the software crashes the data will be lost. Useful for simple softwares without any danger of crash issues or simple runtime debugging. -
SimpleBufferedLog
: A log which keeps a buffer and saves data to a file when the buffer is used or by a manual user call. Since this implementation does not keep an open stream, a software crash would not result in data loss. Useful for robotic softwares or when a chance for software crash is possible.
The beans package provide interfaces and implementations of JavaBeans and properties. The beans contained are used in several places throughout FlashLib and are very useful. The beans are seperated into primitive and generic interfaces and are then combined.
The beans hierarchy is divided in the following manner:
- Generic beans:
-
ValueSource
: Generic getter interface -
Property
: Generic getter and setter interface
-
- Type-specific beans (int, double, string, boolean):
- Source (
IntegerSource
,DoubleSource
,BooleanSource
,StringSource
): type-specific getter interface - Property (
IntegerProperty
,DoubleProperty
,BooleanProperty
,StringProperty
): type-specific getter and setter interface. Also extends the generic Property with the appropriate type argument.
- Source (
Each property type has an exisiting implementation which uses a variable to store data:
- Generic Property:
SimpleProperty
- IntegerProperty:
SimpleIntegerProperty
- DoubleProperty:
SimpleDoubleProperty
- BooleanProperty:
SimpleBooleanProperty
- StringProperty:
SimpleStringProperty
The beans.observable package provides interfaces and implementations of ObservableBeans. Observables allow listenening to value changes and even binding of 2 observables to each other. The observables hierarchy is divided in the following manner:
- Generic observables:
-
ObservableValue
: Generic observable which extends ValueSource -
ObservableProperty
: Generic observable which extends Property
-
- Type-specific observables (int, double, string, boolean):
- ObservableValue (
ObservableIntegerSource
,ObservableDoubleSource
,ObservableBooleanSource
,ObservableStringSource
): type-specific observable. extends both ObservableValue with the appropriate type arguments and the appropriate Source for the type - ObservableProperty (
ObservableIntegerProperty
,ObservableDoubleProperty
,ObservableBooleanProperty
,ObservableStringProperty
): type-specific observable. Also extends the generic Property with the appropriate type argument.
- ObservableValue (
Each property type has an exisiting implementation which uses a variable to store data:
- Generic ObservableProperty:
SimpleObservableProperty
- ObservableIntegerProperty:
SimpleObservableIntegerProperty
- ObservableDoubleProperty:
SimpleObservableDoubleProperty
- ObservableBooleanProperty:
SimpleObservableBooleanProperty
- ObservableStringProperty:
SimpleObservableStringProperty
The PropertyHandler
class contains maps which store properties from the beans package. The class allows users to save and organize properties by name and different data types. In addition, it is possible to save and load properties from XML files, allowing for data transfer between runs. There are 3 data types which can be stored:
- Boolean: using
BooleanProperty
from the beans package - Double: using
DoubleProperty
from the beans package - String: using
StringProperty
from the beans package