bes  Updated for version 3.20.6
ExplicitElement.cc
1 // This file is part of the "NcML Module" project, a BES module designed
3 // to allow NcML files to be used to be used as a wrapper to add
4 // AIS to existing datasets of any format.
5 //
6 // Copyright (c) 2009 OPeNDAP, Inc.
7 // Author: Michael Johnson <m.johnson@opendap.org>
8 //
9 // For more information, please also see the main website: http://opendap.org/
10 //
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU Lesser General Public
13 // License as published by the Free Software Foundation; either
14 // version 2.1 of the License, or (at your option) any later version.
15 //
16 // This library is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 // Lesser General Public License for more details.
20 //
21 // You should have received a copy of the GNU Lesser General Public
22 // License along with this library; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 //
25 // Please see the files COPYING and COPYRIGHT for more information on the GLPL.
26 //
27 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
29 #include "ExplicitElement.h"
30 #include "NCMLDebug.h"
31 #include "NCMLParser.h"
32 #include "NCMLUtil.h"
33 #include "NetcdfElement.h"
34 
35 namespace ncml_module {
36 
37 const string ExplicitElement::_sTypeName = "explicit";
38 const vector<string> ExplicitElement::_sValidAttributes = vector<string>(); // init to the empty vector... we should have none in here!
39 
40 ExplicitElement::ExplicitElement() :
41  NCMLElement(0)
42 {
43 }
44 
45 ExplicitElement::ExplicitElement(const ExplicitElement& /* proto */) :
46  RCObjectInterface(), NCMLElement(0)
47 {
48 }
49 
50 ExplicitElement::~ExplicitElement()
51 {
52 }
53 
54 const string&
55 ExplicitElement::getTypeName() const
56 {
57  return _sTypeName;
58 }
59 
61 ExplicitElement::clone() const
62 {
63  return new ExplicitElement(*this);
64 }
65 
66 void ExplicitElement::setAttributes(const XMLAttributeMap& attrs)
67 {
68  // make sure that none are specifed, basically. We'll list them out in here if we get any
69  // which is why this rather than check map size and throw.
70  validateAttributes(attrs, _sValidAttributes);
71 }
72 
73 void ExplicitElement::handleBegin()
74 {
75  NCMLParser& p = *_parser;
76  if (!p.isScopeNetcdf()) {
77  THROW_NCML_PARSE_ERROR(_parser->getParseLineNumber(), "Got <explicit/> while not a direct child of a <netcdf>");
78  }
79  // this applies to the current dataset
80  NetcdfElement* dataset = p.getCurrentDataset();
81  VALID_PTR(dataset);
82 
83  if (dataset->getProcessedMetadataDirective()) {
84  THROW_NCML_PARSE_ERROR(_parser->getParseLineNumber(),
85  "Got " + toString()
86  + " element but we already got a metadata directive for the current dataset! Only one may be specified.");
87  }
88 
89  dataset->setProcessedMetadataDirective();
90  VALID_PTR(dataset->getDDS());
91  p.clearAllAttrTables(dataset->getDDS());
92 }
93 
94 void ExplicitElement::handleContent(const string& content)
95 {
96  if (!NCMLUtil::isAllWhitespace(content)) {
97  THROW_NCML_PARSE_ERROR(_parser->getParseLineNumber(),
98  "Got non-whitespace for element content and didn't expect it. Element=" + toString() + " content=\""
99  + content + "\"");
100  }
101 }
102 
103 void ExplicitElement::handleEnd()
104 {
105 }
106 
107 string ExplicitElement::toString() const
108 {
109  return "<" + _sTypeName + ">";
110 }
111 }
ncml_module::NetcdfElement
Concrete class for NcML <netcdf> element.
Definition: NetcdfElement.h:62
ncml_module::NCMLParser
Definition: NCMLParser.h:158
ncml_module::XMLAttributeMap
Definition: XMLHelpers.h:93
ncml_module::ExplicitElement
Concrete class for NcML <explicit> element.
Definition: ExplicitElement.h:41
ncml_module
NcML Parser for adding/modifying/removing metadata (attributes) to existing local datasets using NcML...
Definition: AggregationElement.cc:72
ncml_module::NetcdfElement::getDDS
virtual const libdap::DDS * getDDS() const
Definition: NetcdfElement.cc:207