Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef OPENMS_FORMAT_VALIDATORS_SEMANTICVALIDATOR_H
00036 #define OPENMS_FORMAT_VALIDATORS_SEMANTICVALIDATOR_H
00037
00038 #include <OpenMS/FORMAT/XMLFile.h>
00039 #include <OpenMS/FORMAT/HANDLERS/XMLHandler.h>
00040 #include <OpenMS/DATASTRUCTURES/Map.h>
00041 #include <OpenMS/DATASTRUCTURES/CVMappings.h>
00042
00043
00044 namespace OpenMS
00045 {
00046 class ControlledVocabulary;
00047 namespace Internal
00048 {
00049
00056 class OPENMS_DLLAPI SemanticValidator :
00057 protected Internal::XMLHandler,
00058 public Internal::XMLFile
00059 {
00060 public:
00067 SemanticValidator(const CVMappings & mapping, const ControlledVocabulary & cv);
00068
00070 virtual ~SemanticValidator();
00071
00073 struct CVTerm
00074 {
00075 String accession;
00076 String name;
00077 String value;
00078 bool has_value;
00079 String unit_accession;
00080 bool has_unit_accession;
00081 String unit_name;
00082 bool has_unit_name;
00083 };
00084
00096 bool validate(const String & filename, StringList & errors, StringList & warnings);
00097
00099 bool locateTerm(const String & path, const CVTerm & parsed_term) const;
00100
00102 void setTag(const String & tag);
00103
00105 void setAccessionAttribute(const String & accession);
00106
00108 void setNameAttribute(const String & name);
00109
00111 void setValueAttribute(const String & value);
00112
00121 void setCheckTermValueTypes(bool check);
00122
00130 void setCheckUnits(bool check);
00131
00133 void setUnitAccessionAttribute(const String & accession);
00134
00136 void setUnitNameAttribute(const String & name);
00137
00138 protected:
00139
00140
00141 void startElement(const XMLCh * const , const XMLCh * const , const XMLCh * const qname, const xercesc::Attributes & attributes);
00142
00143
00144 void endElement(const XMLCh * const , const XMLCh * const , const XMLCh * const qname);
00145
00146
00147 void characters(const XMLCh * const chars, const XMLSize_t );
00148
00150 virtual String getPath_(UInt remove_from_end = 0) const;
00151
00153 virtual void getCVTerm_(const xercesc::Attributes & attributes, CVTerm & parsed_term);
00154
00155
00156
00157
00158
00160 virtual void handleTerm_(const String & path, const CVTerm & parsed_term);
00161
00163 const CVMappings & mapping_;
00164
00166 const ControlledVocabulary & cv_;
00167
00169 StringList errors_;
00170
00172 StringList warnings_;
00173
00175 StringList open_tags_;
00176
00178 Map<String, std::vector<CVMappingRule> > rules_;
00179
00183 Map<String, Map<String, Map<String, UInt> > > fulfilled_;
00184
00185
00187
00188 String cv_tag_;
00189 String accession_att_;
00190 String name_att_;
00191 String value_att_;
00192 String unit_accession_att_;
00193 String unit_name_att_;
00194 bool check_term_value_types_;
00195 bool check_units_;
00197
00198 private:
00199
00201 SemanticValidator();
00202
00204 SemanticValidator(const SemanticValidator & rhs);
00205
00207 SemanticValidator & operator=(const SemanticValidator & rhs);
00208
00209 };
00210
00211 }
00212
00213 }
00214
00215 #endif // OPENMS_FORMAT_VSLIDATORS_SEMANTICVALIDATOR_H