00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef _ANYATOMICTYPE_HPP
00015 #define _ANYATOMICTYPE_HPP
00016
00017 #include <xqilla/framework/XQillaExport.hpp>
00018 #include <xqilla/items/Item.hpp>
00019 #include <xercesc/util/XercesDefs.hpp>
00020
00021 class DynamicContext;
00022 class StaticContext;
00023
00024 class XQILLA_API AnyAtomicType: public Item
00025 {
00026
00027 public:
00028 typedef RefCountPointer<const AnyAtomicType> Ptr;
00029
00030
00031 virtual bool isAtomicValue() const;
00032
00033
00034 virtual bool isNode() const;
00035
00036
00037 virtual bool isNumericValue() const;
00038
00039
00040 virtual bool isDateOrTimeTypeValue() const;
00041
00042
00043 virtual const XMLCh* getPrimitiveTypeURI() const;
00044
00045
00046 virtual const XMLCh* getPrimitiveTypeName() const = 0;
00047
00048
00049 virtual const XMLCh* getTypeURI() const = 0;
00050
00051
00052 virtual const XMLCh* getTypeName() const = 0;
00053
00054
00055 AnyAtomicType::Ptr castAs(const XMLCh* targetURI, const XMLCh* targetType, const DynamicContext* context) const;
00056
00057
00058 virtual bool castable(const XMLCh* targetURI, const XMLCh* targetType, const DynamicContext* context) const;
00059
00060
00061 virtual const XMLCh* asString(const DynamicContext* context) const = 0;
00062
00063
00064
00065 virtual bool equals(const AnyAtomicType::Ptr &target, const DynamicContext* context) const = 0;
00066
00067
00068 virtual bool isOfType(const XMLCh* targetURI, const XMLCh* targetType, const DynamicContext* context) const;
00069
00070
00071
00072 virtual bool isInstanceOfType(const XMLCh* targetURI, const XMLCh* targetType, const StaticContext* context) const;
00073
00074 enum AtomicObjectType {
00075 ANY_SIMPLE_TYPE = 0,
00076 ANY_URI = 1,
00077 BASE_64_BINARY = 2,
00078 BOOLEAN = 3,
00079 DATE = 4,
00080 DATE_TIME = 5,
00081 DAY_TIME_DURATION = 6,
00082 DECIMAL = 7,
00083 DOUBLE = 8,
00084 DURATION = 9,
00085 FLOAT = 10,
00086 G_DAY = 11,
00087 G_MONTH = 12,
00088 G_MONTH_DAY = 13,
00089 G_YEAR = 14,
00090 G_YEAR_MONTH = 15,
00091 HEX_BINARY = 16,
00092 NOTATION = 17,
00093 QNAME = 18,
00094 STRING = 19,
00095 TIME = 20,
00096 UNTYPED_ATOMIC = 21,
00097 YEAR_MONTH_DURATION= 22,
00098 NumAtomicObjectTypes= 23
00099 };
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00141 bool castIsSupported(AtomicObjectType targetIndex, const DynamicContext* context) const;
00142
00143 virtual AtomicObjectType getPrimitiveTypeIndex() const = 0;
00144
00145 static const XMLCh fgDT_ANYATOMICTYPE[];
00146 static const XMLCh fgDT_ANYATOMICTYPE_XERCESHASH[];
00147
00148 protected:
00149
00150 virtual AnyAtomicType::Ptr castAsInternal(AtomicObjectType targetIndex, const XMLCh* targetURI,
00151 const XMLCh* targetType, const DynamicContext* context) const;
00152
00153 private:
00154
00155
00156
00157
00158
00159 class CastTable {
00160 public:
00161 CastTable();
00162 bool getCell(AtomicObjectType source,
00163 AtomicObjectType target) const;
00164 private:
00165 bool staticCastTable[NumAtomicObjectTypes][NumAtomicObjectTypes];
00166 };
00167
00168
00169
00170 static const CastTable staticCastTable;
00171 };
00172
00173 #endif // _ANYATOMICTYPE_HPP