Initializing help system before first use

DefaultMessageListener

  • All Implemented Interfaces:
    XpressProblem.CallbackAPI.MessageCallback, XPRSmessageListener, java.util.EventListener

    public class DefaultMessageListener
    extends AbstractMessageListener
    implements XpressProblem.CallbackAPI.MessageCallback
    Implementation of AbstractMessageListener that directs all messages to streams or functors. The default constructor redirects all messages to the console. In addition there are constructors that redirect messages to specified streams or to Consumer<String> instances for maximum flexibility. The class also implements two static console functions. These functions print messages to the console and can be passed directly to XPRSprob.addMessageListener() and XpressProblem.callbacks.addMessageCallback. With this there are five ways to use this class:
     XPRSprob xprsProb = new XPRSprob("");
     // Print all messages to the console.
     xprsProb.addMessageListener(new DefaultMessageListener());
     // Print all messages to files.
     PrintStream infoStream = new PrintStream(new FileOutputStream("info.txt"));
     PrintStream warningStream = new PrintStream(new FileOutputStream("warning.txt"));
     PrintStream errorStream = new PrintStream(new FileOutputStream("error.txt"));
     xprsProb.addMessageListener(new DefaultMessageListener(infoStream, warningStream, errorStream));
     // Collect messages in lists.
     List
         
           infoList = new ArrayList
          
           ();
     List
           
             warningList = new ArrayList
            
             ();
     List
             
               errorList = new ArrayList
              
               (); xprsProb.addMessageListener(new DefaultMessageListener(info -> infoList.add(info), warningList -> warnings.add(warning)), errorList -> errors.add(error)); // Print to console. xprsProb.addMessageListener(DefaultMessageListener::console); 
              
             
            
           
          
         
    Similarly for the XpressProblem class:
     XpressProblem xpressProblem = new XpressProblem("", "");
     // Print all messages to the console.
     xpressProblem.callbacks.addMessageCallback(new DefaultMessageListener());
     // Print all messages to files.
     PrintStream infoStream = new PrintStream(new FileOutputStream("info.txt"));
     PrintStream warningStream = new PrintStream(new FileOutputStream("warning.txt"));
     PrintStream errorStream = new PrintStream(new FileOutputStream("error.txt"));
     xpressProblem.callbacks.addMessageCallback(new DefaultMessageListener(infoStream, warningStream, errorStream));
     // Collect messages in lists.
     List
         
           infoList = new ArrayList
          
           ();
     List
           
             warningList = new ArrayList
            
             ();
     List
             
               errorList = new ArrayList
              
               (); xpressProblem.callbacks.addMessageCallback(new DefaultMessageListener(info -> infoList.add(info), warningList -> warnings.add(warning)), errorList -> errors.add(error)); // Print to console. xpressProblem.callbacks.addMessageCallback(DefaultMessageListener::console); 
              
             
            
           
          
         
    • Constructor Detail

      • DefaultMessageListener

        public DefaultMessageListener()
        Create a message listener that prints to the console. Info and warning message will go to System.out, error messages will go to System.err.
      • DefaultMessageListener

        public DefaultMessageListener​(java.io.PrintStream infoStream,
                                      java.io.PrintStream warningStream,
                                      java.io.PrintStream errorStream)
        Create a message listener that directs messages to the specified streams. Any of the streams may be null in which case the respective messages will be swallowed.
        Parameters:
        infoStream - Output stream for info messages.
        warningStream - Output stream for warning messages.
        errorStream - Output stream for error messages.
      • DefaultMessageListener

        public DefaultMessageListener​(java.util.function.Consumer<java.lang.String> info,
                                      java.util.function.Consumer<java.lang.String> warning,
                                      java.util.function.Consumer<java.lang.String> error)
        Create a message listener that directs messages to the specified consumers. Any of the consumers may be null in which case the respective messages will be swallowed.
        Parameters:
        info - Consumer for info messages.
        warning - Consumer for warning messages.
        error - Consumer for error messages.
        Since:
        43.00

© 2001-2025 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.