Class VariablePlugin

    • Field Detail

      • uses

        protected String[] uses
      • prefixLength

        protected int prefixLength
    • Constructor Detail

      • VariablePlugin

        public VariablePlugin​(String[] usesVariables,
                              String[] providesSuffixes)
        Instantiate a plugin
        Parameters:
        usesVariables - The IDs of the variables used to generate new values
        providesSuffixes - The suffixes of the generated variables. These will not form the actual variable IDs.
    • Method Detail

      • usesVariables

        public String[] usesVariables()
        Returns:
        The IDs of the variables which this plugin uses, in the order it needs them
      • providesVariables

        public String[] providesVariables()
        Returns:
        The IDs of the variables which this plugin provides
      • getValue

        public Number getValue​(String varId,
                               HorizontalPosition pos,
                               Number... values)
        Generates a value for the desired ID
        Parameters:
        varId - The ID of the variable to generate a value for
        pos - The HorizontalPosition at which the data is being generated. This may be relevant to how the plugin processes the values
        values - An array of Numbers representing the source values
        Returns:
        The derived value
      • doProcessVariableMetadata

        protected abstract VariableMetadata[] doProcessVariableMetadata​(VariableMetadata... metadata)
                                                                 throws EdalException
        Subclasses should override this method to modify the VariableMetadata tree, and return any new objects added to it. This allows subclasses to arbitrarily restructure the metadata tree by calling the VariableMetadata.setParent(VariableMetadata, String) methods. Note that the IDs in the newly-created VariableMetadata objects should be generated by calling getFullId(String) with the variable's suffix. If the plugin is designed to group several child variables, the first child will be used to automatically estimate the scale range of the parent. This is guaranteed to only be called once.
        Parameters:
        metadata - An array of VariableMetadata of the source variables in the order they were supplied to the constructor
        Returns:
        The derived VariableMetadata
        Throws:
        EdalException - If there is a problem generating new metadata
      • generateValue

        protected abstract Number generateValue​(String varSuffix,
                                                HorizontalPosition pos,
                                                Number... sourceValues)
        Subclasses should override this method to generate values based on source variable values
        Parameters:
        varSuffix - The suffix ID of the variable to generate VariableMetadata for. This will be one of the provided suffixes in the constructor, but not the actual variable ID (which subclasses do not need to worry about)
        pos - The HorizontalPosition at which the value is generated. This may affect the returned value
        sourceValues - An array of Numbers representing the source values in the order they were supplied to the constructor
        Returns:
        The derived value
      • combineIds

        protected String combineIds​(String... partsToUse)
        Provides a convenience method for mangling several IDs into one new one. This just concatenates them, but subclasses may wish to override this if they require a specific format for IDs. This is guaranteed to be called once upon construction.
        Parameters:
        partsToUse - The IDs to base this name on
      • getFullId

        protected final String getFullId​(String suffix)
        Returns an ID based on the combined ID of all used variables and the suffix of a provided variable. This should be used by subclasses to generate new VariableMetadata objects in doProcessVariableMetadata(VariableMetadata...) if required
        Parameters:
        suffix - The suffix used to identify the generated variable.
        Returns:
        The full ID