This package provides all kinds of utility classes, which are too small to have their own projects.
package goedegep.util
This package contains utility classes which don’t have their own sub package.
class goedegep.util.PgUtilities
This class contains methods for which I don’t know a better place.
It currently contains an equals method, where one or both arguments may be null.
class goedegep.util.TimeStampedObject
This class provides a time-stamped object.
It contains an object of type T and a LocalDataTime time-stamp.
The time-stamp can be used for sorting, for which a Comparator is available via the method getTimeStampComparator().
class goedegep.util.Triplet
This class stores three values (objects), of types T, U and V respectively.
The main use is for methods that actually return 3 values, which isn’t possible in Java. So the values are stored in this triplet.
class goedegep.util.Tuplet
This class stores two values (objects), of types T and U respectively.
The main use is for methods that actually return 2 values, which isn’t possible in Java. So the values are stored in this tuplet.
package goedegep.util.bitsequence
This package contains a class for a sequence of bits.
class goedegep.util.bitsequence.BitSequence
This class represents a sequence of bits. You can set/clear individual bits or read/write integers with a specific number of bits.
length
The current logical length of the bit sequence (i.e. the number of bits).
position
The next read/write location. This applies to specific methods.
Creating a bit sequence
The is a constructor for a new empty bit sequence and a constructor to construct a bit sequence from an array of bytes. You can also read a bit sequence from a file.
Setting/clearing bits
You can set or clear bits, where you specify the bit index. These are the most basic operations (most other functionality is implemented on top of these methods).
Reading from and writing to the current position
You can read one bit at the time from the current position and you can read and write fixed size integers from/to the position.
Bulk operations
You can add bytes, or a bit sequence to the bit sequence and you can get the bit sequence as an array of bytes.
File operations
There are methods to write a bit sequence to a file and to read a bit sequence from a file.
package goedegep.util.bytearray
This package provides a utility class for byte arrays.
class goedegep.util.bytearray.ByteArrayUtils
This is a utility class, with utility methods related to bytes and byte arrays. It provides methods to represent bytes and byte arrays as strings.
package goedegep.util.chart
This package provides a utility class for charts.
class goedegep.util.chart.ChartUtil
This is a utility class, with utility methods related to charts. It provides methods to generate labels (tickmarks) for along the axis of a chart.
package goedegep.util.clazz
This package provides a utility class for classes.
class goedegep.util.clazz.ClassUtil
This is a utility class, with utility methods related to classes. It provides a method to get a string representation of the fields of a class.
package goedegep.util.collections
This package provides a utility class for collections.
class goedegep.util.collections.ListUtil
This is a utility class, with utility methods related to lists. It provides a method to check which items in one list are not in another list.
package goedegep.util.csvfileaccess
This package provides a class to read CSV files.
class goedegep.util.csvfileaccess.CSVFileReader
This class can be used for reading CSV (Comma Separated Values) files.
package goedegep.util.datetime
This package offers functionality related to dates and times.
It provides:
-
- A
DateUtil
class with utility methods for dates and times. - A
DurationFormat
, which is aFormat
for thejava.time.Duration
class. - A
FlexDate
and the accompanying formatterFlexDateFormat
.
Often not all information of a date is known. This type can hold a year, a month within a year, or a complete date. - A
Quarter
of a year and the accompanying formatterQuarterFormat
. - A utility class
YearMonthAsLong
to convert a month within a year to a long and vice versa.
This class is e.g. useful for drawing charts.
- A
package goedegep.util.dir
This package provides functionality related to directories.
class goedegep.util.dir.DirectoryUtils
This class provides utility methods that apply to directories.
Note: this class is currently not used within this project. (ToDo)
class goedegep.util.dir.DirectoryCheckOptions
This class provides options for methods in DirectoryUtils.
package goedegep.util.douglaspeuckerreducer
This package provides a method to reduce the number of points in a shape using the Douglas-Peucker algorithm.
class goedegep.util.douglaspeuckerreducer.DouglasPeuckerReducer
This class provides a method to reduce the number of points in a shape using the Douglas-Peucker algorithm.
It is based on https://github.com/spyhunter99/kml-reducer/blob/master/src/main/java/org/miloss/kmlreducer/Main.java.
package goedegep.util.emf
This package provides functionality related to the Eclipse Modeling Framework (EMF).
interface goedegep.util.emf.EMFNotificationListener
This functional interface indicates that an implementing class can react to EMF Notifications. On an EMFResource you can register these listeners.
interface goedegep.util.emf.EmfObjectCreator
This functional interface defines a method for creating an EObject (subtype).
class goedegep.util.emf.EmfPackageHelper
This class provides some useful functionality for an EMF package.
- Get all subtypes of an EClass within the package
- Get the EClass for a qualified name
- Get the EEnum for a qualified name
class goedegep.util.emf.EMFResource
This class handles an EMF Resource
.
The class uses the ResourceSet
singleton provided by EMFResourceSet.getResourceSet
.
Typical ways of using this class:
- Open, edit and save a resource
- Open the resource by calling
load(resourceFileName)
This returns the object, which can be shown to the user and edited. And sets ‘resourceFileName’ as the ‘current file’. - Edit the object outside of this class.
- Save the object by calling save().
This saves the object to the ‘current file’. In this case overwriting the file which is was loaded from.
The object can also be saved to a different file by calling save(resourceFileName).
- Open the resource by calling
- Create a new object and save it.
- Create the object by calling
newEObject
and edit it outside of this class. - Save the object by calling
save(resourceFileName)
.
This also sets ‘resourceFileName’ as the ‘current file’.So after further editing the object can be saved by callingsave()
.
- Create the object by calling
- Or in terms of a standard ‘File menu’.
- New
Obtain the new object by callingnewEObject()
. - Open …
The file name has to be determined by the application, typically via a FileChooser. Load the object from the fileby callingload(resourceFileName)
. - Save
If there is a ‘current file’, which can be checked by callinggetFileName()
, save the object by callingsave()
.
Else, the application has to determine a file name, typically via a FileChooser, and then callsave(String resourceFileName)
. - Save as …
The application has to determine a file name, typically via a FileChooser, and then callsave(String resourceFileName)
.
- New
If an application has to react to changes in the object, it can register an EMFNotificationListener (instead of creating its own Adapter and adding that to the object).
The following Properties are provided:
- dirty
If true, there are unsaved changes in the object. - resourceFileName
The name of the current file.
Note: When an xml file is loaded using a model generated from the related xsd file, you first have to register the EPackage.
E.g. EPackage.Registry.INSTANCE.put(GPXPackage.eNS_URI, GPXPackage.eINSTANCE)
;
Type Parameters:
- <E> The data type handled by this resource.
class goedegep.util.emf.EMFResourceSet
This class provides an EMF ResourceSet
singleton.
All EMF resources within an application can be related. So they should, or at least can, all be handled by a single ResourceSet. This ResourceSet is provided by this class.
The default resource factory (EcoreResourceFactoryImpl()
) is already registered for any extension (‘*’).
Any other required resource factory has to be added by a user of this resource set.
class goedegep.util.emf.EmfUtil
This is a utility class, with many EMF utility methods.
package goedegep.util.logging
goedegep.util.logging.MyLoggingFormatter
This class extends java.util.logging.SimpleFormatter
. It’s meant to be used as a Formatter
for java.util.logging.ConsoleHandler
within Eclipse. Log output looks as follows:
SomeClass.initMethod: Illegal argument (SomeClass.java:38)