OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
ReadMetadataElement.cc
Go to the documentation of this file.
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 "ReadMetadataElement.h"
30 #include "NetcdfElement.h"
31 #include "NCMLDebug.h"
32 #include "NCMLParser.h"
33 #include "NCMLUtil.h"
34 
35 namespace ncml_module
36 {
37 
38  const string ReadMetadataElement::_sTypeName = "readMetadata";
39  const vector<string> ReadMetadataElement::_sValidAttributes = vector<string>();
40 
42  : RCObjectInterface()
43  , NCMLElement(0)
44  {
45  }
46 
48  : RCObjectInterface()
49  , NCMLElement(proto)
50  {
51  }
52 
54  {
55  }
56 
57  const string&
59  {
60  return _sTypeName;
61  }
62 
65  {
66  return new ReadMetadataElement(*this);
67  }
68 
69  void
71  {
72  // make sure that none are specifed, basically. We'll list them out in here if we get any
73  // which is why this rather than check map size and throw.
75  }
76 
77  void
79  {
80  if (!_parser->isScopeNetcdf())
81  {
83  "Got <readMetadata/> while not within <netcdf>");
84  }
85  NetcdfElement* dataset = _parser->getCurrentDataset();
86  VALID_PTR(dataset);
87 
88  // Like Highlander, there can be only one!
89  if (dataset->getProcessedMetadataDirective())
90  {
92  "Got " + toString() +
93  " element but we already got a metadata directive"
94  " for the current dataset! Only one may be specified.");
95  }
97  }
98 
99  void
100  ReadMetadataElement::handleContent(const string& content)
101  {
102  if (!NCMLUtil::isAllWhitespace(content))
103  {
105  "Got non-whitespace for element content and didn't expect it."
106  " Element=" + toString() + " content=\"" +
107  content + "\"");
108  }
109  }
110 
111  void
113  {
114  }
115 
116  string
118  {
119  return "<" + _sTypeName + ">";
120  }
121 }
virtual bool validateAttributes(const XMLAttributeMap &attrs, const vector< string > &validAttrs, vector< string > *pInvalidAttrs=0, bool printInvalid=true, bool throwOnError=true)
Check that the given attributes are all in the valid set, otherwise fill in *pInvalidAttrs with the p...
Definition: NCMLElement.cc:191
virtual void handleBegin()
Handle a begin on this element.
Concrete class for NcML element.
virtual const string & getTypeName() const
Return the type of the element, which should be: the same as ConcreteClassName::getTypeName() ...
virtual void setAttributes(const XMLAttributeMap &attrs)
Set the attributes of this from the map.
virtual void handleEnd()
Handle the closing of this element.
An abstract superclass for NCMLArray that handles the non-parameterized functionality and allows u...
static bool isAllWhitespace(const std::string &str)
Is all the string whitespace as defined by chars in WHITESPACE ?
Definition: NCMLUtil.cc:110
Concrete class for NcML element.
Definition: NetcdfElement.h:63
virtual string toString() const
Return a string describing the element.
virtual ReadMetadataElement * clone() const
Make and return a copy of this.
int getParseLineNumber() const
Get the line of the NCML file the parser is currently parsing.
Definition: NCMLParser.cc:222
bool getProcessedMetadataDirective() const
#define THROW_NCML_PARSE_ERROR(parseLine, msg)
Definition: NCMLDebug.h:69
virtual void handleContent(const string &content)
Handle the characters content for the element.
Base class for NcML element concrete classes.
Definition: NCMLElement.h:64
static const vector< string > _sValidAttributes
#define VALID_PTR(ptr)
Definition: NCMLDebug.h:88