/src/xerces-c/src/xercesc/dom/DOMAttr.hpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
3 | | * contributor license agreements. See the NOTICE file distributed with |
4 | | * this work for additional information regarding copyright ownership. |
5 | | * The ASF licenses this file to You under the Apache License, Version 2.0 |
6 | | * (the "License"); you may not use this file except in compliance with |
7 | | * the License. You may obtain a copy of the License at |
8 | | * |
9 | | * http://www.apache.org/licenses/LICENSE-2.0 |
10 | | * |
11 | | * Unless required by applicable law or agreed to in writing, software |
12 | | * distributed under the License is distributed on an "AS IS" BASIS, |
13 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | | * See the License for the specific language governing permissions and |
15 | | * limitations under the License. |
16 | | */ |
17 | | |
18 | | /* |
19 | | * $Id: DOMAttr.hpp 527149 2007-04-10 14:56:39Z amassari $ |
20 | | */ |
21 | | |
22 | | #if !defined(XERCESC_INCLUDE_GUARD_DOMATTR_HPP) |
23 | | #define XERCESC_INCLUDE_GUARD_DOMATTR_HPP |
24 | | |
25 | | #include <xercesc/util/XercesDefs.hpp> |
26 | | #include <xercesc/dom/DOMNode.hpp> |
27 | | |
28 | | XERCES_CPP_NAMESPACE_BEGIN |
29 | | |
30 | | class DOMElement; |
31 | | class DOMTypeInfo; |
32 | | |
33 | | /** |
34 | | * The <code>DOMAttr</code> class refers to an attribute of an XML element. |
35 | | * |
36 | | * Typically the allowable values for the |
37 | | * attribute are defined in a documenttype definition. |
38 | | * <p><code>DOMAttr</code> objects inherit the <code>DOMNode</code> interface, but |
39 | | * since attributes are not actually child nodes of the elements they are associated with, the |
40 | | * DOM does not consider them part of the document tree. Thus, the |
41 | | * <code>DOMNode</code> attributes <code>parentNode</code>, |
42 | | * <code>previousSibling</code>, and <code>nextSibling</code> have a null |
43 | | * value for <code>DOMAttr</code> objects. The DOM takes the view that |
44 | | * attributes are properties of elements rather than having a separate |
45 | | * identity from the elements they are associated with; this should make it |
46 | | * more efficient to implement such features as default attributes associated |
47 | | * with all elements of a given type. Furthermore, attribute nodes |
48 | | * may not be immediate children of a <code>DOMDocumentFragment</code>. However, |
49 | | * they can be associated with <code>DOMElement</code> nodes contained within a |
50 | | * <code>DOMDocumentFragment</code>. In short, users of the DOM |
51 | | * need to be aware that <code>DOMAttr</code> nodes have some things in common |
52 | | * with other objects inheriting the <code>DOMNode</code> interface, but they |
53 | | * also are quite distinct. |
54 | | * |
55 | | * @since DOM Level 1 |
56 | | */ |
57 | | class CDOM_EXPORT DOMAttr: public DOMNode { |
58 | | protected: |
59 | | // ----------------------------------------------------------------------- |
60 | | // Hidden constructors |
61 | | // ----------------------------------------------------------------------- |
62 | | /** @name Hidden constructors */ |
63 | | //@{ |
64 | 0 | DOMAttr() {} |
65 | 0 | DOMAttr(const DOMAttr &other) : DOMNode(other) {} |
66 | | //@} |
67 | | |
68 | | private: |
69 | | // ----------------------------------------------------------------------- |
70 | | // Unimplemented constructors and operators |
71 | | // ----------------------------------------------------------------------- |
72 | | /** @name Unimplemented operators */ |
73 | | //@{ |
74 | | DOMAttr & operator = (const DOMAttr &); |
75 | | //@} |
76 | | |
77 | | public: |
78 | | // ----------------------------------------------------------------------- |
79 | | // All constructors are hidden, just the destructor is available |
80 | | // ----------------------------------------------------------------------- |
81 | | /** @name Destructor */ |
82 | | //@{ |
83 | | /** |
84 | | * Destructor |
85 | | * |
86 | | */ |
87 | 0 | virtual ~DOMAttr() {}; |
88 | | //@} |
89 | | |
90 | | // ----------------------------------------------------------------------- |
91 | | // Virtual DOMAttr interface |
92 | | // ----------------------------------------------------------------------- |
93 | | /** @name Functions introduced in DOM Level 1 */ |
94 | | //@{ |
95 | | // ----------------------------------------------------------------------- |
96 | | // Getter methods |
97 | | // ----------------------------------------------------------------------- |
98 | | /** |
99 | | * Returns the name of this attribute. |
100 | | * @since DOM Level 1 |
101 | | */ |
102 | | virtual const XMLCh * getName() const = 0; |
103 | | |
104 | | /** |
105 | | * |
106 | | * Returns true if the attribute received its value explicitly in the |
107 | | * XML document, or if a value was assigned programatically with |
108 | | * the setValue function. Returns false if the attribute value |
109 | | * came from the default value declared in the document's DTD. |
110 | | * @since DOM Level 1 |
111 | | */ |
112 | | virtual bool getSpecified() const = 0; |
113 | | |
114 | | /** |
115 | | * Returns the value of the attribute. |
116 | | * |
117 | | * The value of the attribute is returned as a string. |
118 | | * Character and general entity references are replaced with their values. |
119 | | * @since DOM Level 1 |
120 | | */ |
121 | | virtual const XMLCh * getValue() const = 0; |
122 | | |
123 | | // ----------------------------------------------------------------------- |
124 | | // Setter methods |
125 | | // ----------------------------------------------------------------------- |
126 | | /** |
127 | | * Sets the value of the attribute. A text node with the unparsed contents |
128 | | * of the string will be created. |
129 | | * |
130 | | * @param value The value of the DOM attribute to be set |
131 | | * @since DOM Level 1 |
132 | | */ |
133 | | virtual void setValue(const XMLCh *value) = 0; |
134 | | //@} |
135 | | |
136 | | /** @name Functions introduced in DOM Level 2. */ |
137 | | //@{ |
138 | | /** |
139 | | * The <code>DOMElement</code> node this attribute is attached to or |
140 | | * <code>null</code> if this attribute is not in use. |
141 | | * |
142 | | * @since DOM Level 2 |
143 | | */ |
144 | | virtual DOMElement *getOwnerElement() const = 0; |
145 | | //@} |
146 | | |
147 | | /** @name Functions introduced in DOM Level 3. */ |
148 | | //@{ |
149 | | /** |
150 | | * Returns whether this attribute is known to be of type ID or not. |
151 | | * When it is and its value is unique, the ownerElement of this attribute |
152 | | * can be retrieved using getElementById on DOMDocument. |
153 | | * |
154 | | * @return <code>bool</code> stating if this <code>DOMAttr</code> is an ID |
155 | | * @since DOM level 3 |
156 | | */ |
157 | | virtual bool isId() const = 0; |
158 | | |
159 | | |
160 | | /** |
161 | | * Returns the type information associated with this attribute. |
162 | | * |
163 | | * @return the <code>DOMTypeInfo</code> associated with this attribute |
164 | | * @since DOM level 3 |
165 | | */ |
166 | | virtual const DOMTypeInfo * getSchemaTypeInfo() const = 0; |
167 | | |
168 | | //@} |
169 | | |
170 | | }; |
171 | | |
172 | | XERCES_CPP_NAMESPACE_END |
173 | | |
174 | | #endif |
175 | | |
176 | | |