I've copied this from SPL. AFAIK, there is no API method for this.