If you are already accustomed to the text interface to Magpie, the structure of the library and the names of operations are might be eerily familiar. If not, you might want to check out the examples scripts to get an idea about what Dataset and Model objects are and how they are used.
Most operations that one performs on a variable in the text interface directly map to an operation in Java. For instance, the command submodel set <index> $leaf
on a model corresponds to the setModel(int index, BaseModel model)
function of a class that implements the SplitModel interface.
The key exception to the "for any text command, there is a Java function" rule are text commands that involve a "method" parameter. In these cases, Magpie first searches for a class whose name matches the "method" parameter, creates an instance of that variable (with the options you specified), and then uses that variable to do something. For example, calling "data modify NonZeroClassModifier
" creates an instance of the NonZeroClassModifier and calls the modifyDataset(Dataset data)
operation of NonZeroClassModifier to make changes to data
. Moral of the story: For commands that involve a "method" parameter, look for an class that performs the task you are looking to do.
As alluded to in the previous section, Magpie is built using many independent classes that each perform a specific task. These classes are all unique versions of several main archetypes, which are referred to as "BaseClasses". If you look in the list of classes in the Javadoc, you may notice many classes whose names start with "Base". Each of these classes are not actually usable as written, but instead serve to provide a starting point for all classes designed to perform a specific kind of operation. For instance, all classes that are used to filter a Dataset are extensions of BaseDatasetFilter. While you can access a complete list of variable types in the Javadoc, here are a few of the ones that are the most useful: