File: Class-SDMXFooterMessage.R

package info (click to toggle)
r-cran-rsdmx 1%3A0.6-5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,024 kB
  • sloc: sh: 14; makefile: 2
file content (53 lines) | stat: -rw-r--r-- 1,993 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#' @name SDMXFooterMessage
#' @docType class
#' @aliases SDMXFooterMessage-class
#' @title Class "SDMXFooterMessage"
#' @description A basic class to handle a footer message of a SDMX-ML document
#' 
#' @slot code Object of class "character" giving the status code
#' @slot severity Object of class "character" giving the severity of the message
#' @slot messages Object of class "list" giving the list of messages
#' 
#' @section Warning:
#' This class is not useful in itself, but all SDMX non-abstract classes will 
#' encapsulate it as slot, when parsing an SDMX-ML document
#' 
#' @note
#' This class is especially useful for SDMX 2.1 compliant documents. Footer 
#' messages are not supported in SDMX 2.0 standard format.
#' 
#' According to the SDMX 2.1 standard, the message severity takes one of the 
#' following values: "Error", "Warning",Information". Given the possible typos 
#' handled by data providers, rsdmx adopts a permissive strategy and does not 
#' validate the object according to such controlled terms.
#' 
#' @author Emmanuel Blondel, \email{emmanuel.blondel1@@gmail.com}
#'
setClass("SDMXFooterMessage",
         representation(
           code = "character",
           severity = "character",
           messages = "list"
         ),
         prototype = list(
           code = "413",
           severity = "Information",
           messages = list("msg1", "msg2")
         ),
         validity = function(object){
           
           #validation rules
           if(.rsdmx.options$validate){
             
             #severity
             if(!is.na(object@severity)){
               #SDMX standard severity types
               #Note: some data providers have typos for such messages
               severityTypes <- c("Error", "Warning", "Information")
               if(!(object@severity %in% severityTypes)) return(FALSE);
             }
             
           }
           return(TRUE);
         }
)