File: Class-SDMXCode.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 (64 lines) | stat: -rw-r--r-- 2,277 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#' @name SDMXCode
#' @docType class
#' @aliases SDMXCode-class
#' 
#' @title Class "SDMXCode"
#' @description A basic class to handle a SDMX Code
#' 
#' @slot id Object of class "character" giving the ID of the code (required). 
#'        In SDMX 2.0 documents, this slot will handle the 'value' attribute
#' @slot urn Object of class "character" giving the code urn
#' @slot parentCode Object of class "character" giving the parent code
#' @slot label Object of class "list" giving the code label (by language). In SDMX 2.0,
#' it takes the code 'Description' element vs. 'Name' element in SDMX 2.1. This property
#' deprecated and kept now for backward compatibility.
#' @slot name Object of class "list" giving the code name (by language).
#' @slot description Object of class "list" giving the code description (by language).
#'
#' @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 (Codelists, or 
#' DataStructureDefinition)
#' 
#' @author Emmanuel Blondel, \email{emmanuel.blondel1@@gmail.com}
#' 
setClass("SDMXCode",
         representation(
           #attributes
           id = "character", #required (equivalent to "value" in SDMX 2.0)
           urn = "character", #optional
           parentCode = "character", #optional
           
           #elements
           label = "list",
           name = "list",
           description = "list"
                          
         ),
         prototype = list(
           #attributes
           id = "CODE_ID",
           urn = as.character(NA),
           parentCode = as.character(NA),
           
           #elements
           name = list(
             en = "code name",
             fr = "nom du code"
           ),
           description = list(
             en = "code description",
             fr = "description du code"
           )
         ),
         validity = function(object){
           
           #eventual validation rules
           if(.rsdmx.options$validate){
            if(is.na(object@id)) return(FALSE)
            if(length(object@label) == 0) return(FALSE)
           }
           
           return(TRUE);
         }
)