SourceForge.net Logo
AnyAtomicType.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2001, 2008,
3 * DecisionSoft Limited. All rights reserved.
4 * Copyright (c) 2004, 2015 Oracle and/or its affiliates. All rights reserved.
5 *
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20#ifndef _ANYATOMICTYPE_HPP
21#define _ANYATOMICTYPE_HPP
22
23#include <xqilla/framework/XQillaExport.hpp>
24#include <xqilla/items/Item.hpp>
25#include <xercesc/util/XercesDefs.hpp>
26
27class DynamicContext;
28class StaticContext;
29
30class XQILLA_API AnyAtomicType: public Item
31{
32
33public:
60
62
63 /* isAtomicValue from Item */
64 virtual bool isAtomicValue() const;
65
66 /* isNode from Item */
67 virtual bool isNode() const;
68
69 virtual bool isFunction() const;
70
71 /* is this type numeric? Return false by default */
72 virtual bool isNumericValue() const;
73
74 /* is this type date or time based? Return false by default */
75 virtual bool isDateOrTimeTypeValue() const;
76
77 /* Get the namespace uri of the primitive type (basic type) of this type */
78 virtual const XMLCh* getPrimitiveTypeURI() const;
79
80 /* Get the name of the primitive type (basic type) of this type (ie "decimal" for xs:decimal) */
81 virtual const XMLCh* getPrimitiveTypeName() const = 0;
82
83 /* Get the namespace URI for this type */
84 virtual const XMLCh* getTypeURI() const = 0;
85
86 /* Get the name of this type (ie "integer" for xs:integer) */
87 virtual const XMLCh* getTypeName() const = 0;
88
89 virtual void generateEvents(EventHandler *events, const DynamicContext *context,
90 bool preserveNS = true, bool preserveType = true) const;
91
92 /* If possible, cast this type to the target type -- no casting table lookup made */
93 AnyAtomicType::Ptr castAs(AtomicObjectType targetIndex, const DynamicContext* context) const;
94
95 /* If possible, cast this type to the target type -- no casting table lookup made */
96 AnyAtomicType::Ptr castAsNoCheck(AtomicObjectType targetIndex, const XMLCh* targetURI, const XMLCh* targetType,
97 const DynamicContext* context) const;
98
99 /* If possible, cast this type to the target type -- not virtual, this is the single entry point for casting */
100 AnyAtomicType::Ptr castAs(AtomicObjectType targetIndex, const XMLCh* targetURI, const XMLCh* targetType,
101 const DynamicContext* context) const;
102
103 /* Test if this type can be cast to the target type */
104 virtual bool castable(AtomicObjectType targetIndex, const XMLCh* targetURI, const XMLCh* targetType,
105 const DynamicContext* context) const;
106
107 /* returns the XMLCh* (canonical) representation of this type */
108 virtual const XMLCh* asString(const DynamicContext* context) const = 0;
109
110 /* returns true if the two objects are equal (whatever that means
111 * in the context of the datatype), false otherwise */
112 virtual bool equals(const AnyAtomicType::Ptr &target, const DynamicContext* context) const = 0;
113
114 /* Returns true if this typeName and uri match the given typeName and uri */
115 virtual bool isOfType(const XMLCh* targetURI, const XMLCh* targetType, const DynamicContext* context) const;
116
117 /* Returns true if this typeName and uri match the given typeName and uri,
118 * or if any of this type's parents match the given typeName and uri */
119 virtual bool isInstanceOfType(const XMLCh* targetURI, const XMLCh* targetType, const StaticContext* context) const;
120
121 virtual void typeToBuffer(DynamicContext *context, XERCES_CPP_NAMESPACE_QUALIFIER XMLBuffer &buffer) const;
122
135 bool castIsSupported(AtomicObjectType targetIndex, const DynamicContext* context) const;
136
138
139 static const XMLCh fgDT_ANYATOMICTYPE[];
140
141protected:
142 /* internal castAs method. This one is virtual and does the real work */
143 virtual AnyAtomicType::Ptr castAsInternal(AtomicObjectType targetIndex, const XMLCh* targetURI,
144 const XMLCh* targetType, const DynamicContext* context) const;
145
146private:
147
148 //friend class CastTable;
149 //template <class TYPE> friend class DatatypeFactoryTemplate;
150
151 // class that implements the Casting Table
152 class CastTable {
153 public:
154 CastTable();
155 bool getCell(AtomicObjectType source,
156 AtomicObjectType target) const;
157 private:
158 bool staticCastTable[NumAtomicObjectTypes][NumAtomicObjectTypes];
159 };
160
161
162 // reproduction of the XPath2 casting table: http://www.w3.org/TR/xquery-operators/#casting
163 static const CastTable staticCastTable;
164};
165
166#endif
Definition AnyAtomicType.hpp:31
virtual AnyAtomicType::Ptr castAsInternal(AtomicObjectType targetIndex, const XMLCh *targetURI, const XMLCh *targetType, const DynamicContext *context) const
virtual bool isFunction() const
virtual bool equals(const AnyAtomicType::Ptr &target, const DynamicContext *context) const =0
virtual AtomicObjectType getPrimitiveTypeIndex() const =0
AtomicObjectType
Definition AnyAtomicType.hpp:34
@ NOTATION
Definition AnyAtomicType.hpp:52
@ G_MONTH
Definition AnyAtomicType.hpp:47
@ G_YEAR_MONTH
Definition AnyAtomicType.hpp:50
@ DATE_TIME
Definition AnyAtomicType.hpp:40
@ ANY_SIMPLE_TYPE
Definition AnyAtomicType.hpp:35
@ DOUBLE
Definition AnyAtomicType.hpp:43
@ YEAR_MONTH_DURATION
Definition AnyAtomicType.hpp:57
@ BASE_64_BINARY
Definition AnyAtomicType.hpp:37
@ G_DAY
Definition AnyAtomicType.hpp:46
@ TIME
Definition AnyAtomicType.hpp:55
@ DECIMAL
Definition AnyAtomicType.hpp:42
@ HEX_BINARY
Definition AnyAtomicType.hpp:51
@ G_YEAR
Definition AnyAtomicType.hpp:49
@ BOOLEAN
Definition AnyAtomicType.hpp:38
@ QNAME
Definition AnyAtomicType.hpp:53
@ ANY_URI
Definition AnyAtomicType.hpp:36
@ G_MONTH_DAY
Definition AnyAtomicType.hpp:48
@ DURATION
Definition AnyAtomicType.hpp:44
@ NumAtomicObjectTypes
Definition AnyAtomicType.hpp:58
@ FLOAT
Definition AnyAtomicType.hpp:45
@ DATE
Definition AnyAtomicType.hpp:39
@ DAY_TIME_DURATION
Definition AnyAtomicType.hpp:41
@ STRING
Definition AnyAtomicType.hpp:54
@ UNTYPED_ATOMIC
Definition AnyAtomicType.hpp:56
RefCountPointer< const AnyAtomicType > Ptr
Definition AnyAtomicType.hpp:61
virtual bool isAtomicValue() const
AnyAtomicType::Ptr castAs(AtomicObjectType targetIndex, const XMLCh *targetURI, const XMLCh *targetType, const DynamicContext *context) const
virtual void generateEvents(EventHandler *events, const DynamicContext *context, bool preserveNS=true, bool preserveType=true) const
Generate events for this Item to the given EventHandler.
virtual const XMLCh * getTypeURI() const =0
virtual void typeToBuffer(DynamicContext *context, xercesc::XMLBuffer &buffer) const
Debug method to output the type of the item in SequenceType notation.
virtual bool isDateOrTimeTypeValue() const
virtual bool isNumericValue() const
AnyAtomicType::Ptr castAs(AtomicObjectType targetIndex, const DynamicContext *context) const
virtual const XMLCh * getPrimitiveTypeName() const =0
virtual const XMLCh * asString(const DynamicContext *context) const =0
virtual bool isInstanceOfType(const XMLCh *targetURI, const XMLCh *targetType, const StaticContext *context) const
virtual const XMLCh * getPrimitiveTypeURI() const
virtual bool castable(AtomicObjectType targetIndex, const XMLCh *targetURI, const XMLCh *targetType, const DynamicContext *context) const
virtual const XMLCh * getTypeName() const =0
virtual bool isOfType(const XMLCh *targetURI, const XMLCh *targetType, const DynamicContext *context) const
bool castIsSupported(AtomicObjectType targetIndex, const DynamicContext *context) const
Returns true if (a) both the input type and the target type are built-in schema types and cast is sup...
AnyAtomicType::Ptr castAsNoCheck(AtomicObjectType targetIndex, const XMLCh *targetURI, const XMLCh *targetType, const DynamicContext *context) const
virtual bool isNode() const
static const XMLCh fgDT_ANYATOMICTYPE[]
Definition AnyAtomicType.hpp:139
The execution time dynamic context interface.
Definition DynamicContext.hpp:39
Definition EventHandler.hpp:30
Item()
Definition Item.hpp:67
Super class of all the reference counted wrappers for Items.
Definition ReferenceCounted.hpp:62
The parse time static context interface.
Definition StaticContext.hpp:58