Class OutletUtils


  • public final class OutletUtils
    extends Object
    Utility methods to retrieve information out of the source model or the configuration. The methods provide adequate logging and error handling.
    • Method Detail

      • getSourceElementAttribute

        public static String getSourceElementAttribute​(String elementName,
                                                       String attributeName,
                                                       ControllerState controllerState,
                                                       Class<?> clazz)
                                                throws GeneratorException
        Retrieves the value of a source element attribute. The source element must be found and the attribute must be set, otherwise an exception is thrown.
        Parameters:
        elementName - The name of the source element relative to the current source element; a dot (.) denotes the current element.
        attributeName - The name of the attribute of the element.
        controllerState - The controller state.
        clazz - the class in which the attribute should be retrieved; used only for logging.
        Returns:
        the value of the specified attribute, not null.
        Throws:
        GeneratorException - if the source element cannot be found or the specified attribute is not set.
      • getOption

        public static String getOption​(String optionName,
                                       ControllerState controllerState,
                                       Class<?> clazz)
                                throws GeneratorException
        Reads an option with a given name. The option must be set to a value different from null.
        Parameters:
        optionName - the name of the option to read, not null.
        controllerState - the current state of the controller, not null.
        clazz - the class from which this method is called, not null. Only used for logging purposes.
        Returns:
        the value of the option.
        Throws:
        GeneratorException - if the option is not set or set to null.
      • getFromDifferentPlaces

        public static String getFromDifferentPlaces​(String presetValue,
                                                    String optionName,
                                                    String variableName,
                                                    String sourceElementName,
                                                    String sourceElementAttribute,
                                                    ControllerState controllerState,
                                                    Class<?> clazz,
                                                    String expectedFieldNames)
                                             throws GeneratorException
        Retrieve a value from either a preset value, an option, a variable, or a source element attribute. Exactly one of these must be set to a value different from zero.
        Parameters:
        presetValue - the plain result, or null if the preset value should not be used.
        optionName - the name of the option to access, or null if no option value should be returned.
        variableName - the name of the variable to access, or null if no variable should be accessed.
        sourceElementName - the name of the source element relative to the current element which attribute should be read. Null if no source attribute value should be used.
        sourceElementAttribute - the name of the attribute of the above source element.
        controllerState - the current state of the controller, not null.
        clazz - the class from which this method is called, not null. Used only for logging purposes.
        expectedFieldNames - the field names in which the information is expected; for logging purposes only.
        Returns:
        the desired value, not null.
        Throws:
        GeneratorException - if the value is not set or more than one possibility to get the value exists.