The FRED Client domain model adheres to the Java Beans specification and contains logic for monitoring property changes via the PropertyChangeSupport class.

Developers can register instances of PropertyChangeListener with a given object and if a property changes they will be notified of the modification — see below for an example pertaining to how this is accomplished.

def queryBuilder = queryBuilderFactory.getInstance ()

def seriess = queryBuilder
    .category ()
    .series ()
        using (2001, Calendar.JANUARY, 20)
        using (2004, Calendar.MAY, 17)
    ).doGet (Seriess.class)

seriess.addPropertyChangeListener (
    new PropertyChangeListener () {
        public void propertyChange(PropertyChangeEvent event) {
            println "event: ${event}, source: ${event.source.realtimeStart}"
// Note that in Groovy the code below invokes a setter method.
seriess.offset = 1234

The complete example Groovy script which demonstrates how to acquire the GNPCA seriess using the FRED Client can be found on Bitbucket. There are two points to keep in mind with respect to this script:

  • Note that the xstreamMarshaller bean is set to This class allows the developer to easily switch between a standard PropertyChangeSupport (the default) and javax.swing.event.SwingPropertyChangeSupport for projects that run on the desktop and utilise the Java Swing API.
  • You will need your own API key from the Federal Reserve Bank of St. Louis in order to run this script. Refer to the apiKey constructor argument for the queryBuilderFactory bean in the XML configuration text.
  • Several notes appear at the top of the file and these are required steps in order to run execute the script successfully.

Leave a Reply

Close Menu
Close Panel