File: Class-SDMXStructureType.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 (43 lines) | stat: -rw-r--r-- 1,583 bytes parent folder | download | duplicates (4)
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
#' @name SDMXStructureType
#' @docType class
#' @aliases SDMXStructureType-class
#' 
#' @title Class "SDMXStructureType"
#' @description A basic class to handle the type of a SDMX-ML Structure document
#' 
#' @section Warning:
#' This class is not useful in itself, but it will be used by \link{readSDMX} to
#' deal with SDMX-ML Structure documents.
#'    
#' @author Emmanuel Blondel, \email{emmanuel.blondel1@@gmail.com}
#'
setClassUnion("character_OR_NULL", c("character", "NULL"))
setClass("SDMXStructureType",
         contains = "SDMXType",
         representation(subtype = "character_OR_NULL"),
         prototype = list(),
         validity = function(object){
           
           #validation rules
           if(.rsdmx.options$validate){
             type <- getStructureType(object);
             #consider NULL type as valid in case of SDMXData with no structure embedded
             if(!is.null(type)){
               valid <- switch(type,
                               "DataflowsType" = TRUE,
                               "ConceptsType" = TRUE,
                               "CodelistsType" = TRUE,
                               "DataStructuresType" = TRUE,
                               "DataStructureDefinitionsType" = TRUE,
                               FALSE
               );
               if(valid == FALSE)
                 warning(paste0("Unknown SDMXStructureType '", type, "'"));
               
               return(valid);
             }
           }
           
           return(TRUE);
         }
)