[2674] | 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: XSAnnotation.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #if !defined(XSANNOTATION_HPP) |
---|
| 23 | #define XSANNOTATION_HPP |
---|
| 24 | |
---|
| 25 | #include <xercesc/framework/psvi/XSObject.hpp> |
---|
| 26 | #include <xercesc/internal/XSerializable.hpp> |
---|
| 27 | |
---|
| 28 | XERCES_CPP_NAMESPACE_BEGIN |
---|
| 29 | |
---|
| 30 | /** |
---|
| 31 | * This class describes all properties of a Schema Annotation |
---|
| 32 | * component. |
---|
| 33 | * This is *always* owned by the validator /parser object from which |
---|
| 34 | * it is obtained. |
---|
| 35 | */ |
---|
| 36 | |
---|
| 37 | // forward declarations |
---|
| 38 | class DOMNode; |
---|
| 39 | class ContentHandler; |
---|
| 40 | |
---|
| 41 | class XMLPARSER_EXPORT XSAnnotation : public XSerializable, public XSObject |
---|
| 42 | { |
---|
| 43 | public: |
---|
| 44 | |
---|
| 45 | // TargetType |
---|
| 46 | enum ANNOTATION_TARGET { |
---|
| 47 | /** |
---|
| 48 | * The object type is <code>org.w3c.dom.Element</code>. |
---|
| 49 | */ |
---|
| 50 | W3C_DOM_ELEMENT = 1, |
---|
| 51 | /** |
---|
| 52 | * The object type is <code>org.w3c.dom.Document</code>. |
---|
| 53 | */ |
---|
| 54 | W3C_DOM_DOCUMENT = 2 |
---|
| 55 | }; |
---|
| 56 | |
---|
| 57 | // Constructors and Destructor |
---|
| 58 | // ----------------------------------------------------------------------- |
---|
| 59 | /** @name Constructors */ |
---|
| 60 | //@{ |
---|
| 61 | |
---|
| 62 | /** |
---|
| 63 | * The default constructor |
---|
| 64 | * |
---|
| 65 | * @param contents The string that is to be the content of this XSAnnotation |
---|
| 66 | * @param manager The configurable memory manager |
---|
| 67 | */ |
---|
| 68 | XSAnnotation |
---|
| 69 | ( |
---|
| 70 | const XMLCh* const contents |
---|
| 71 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
---|
| 72 | ); |
---|
| 73 | |
---|
| 74 | //@}; |
---|
| 75 | |
---|
| 76 | /** @name Destructor */ |
---|
| 77 | //@{ |
---|
| 78 | ~XSAnnotation(); |
---|
| 79 | //@} |
---|
| 80 | |
---|
| 81 | //--------------------- |
---|
| 82 | /** @name XSAnnotation methods */ |
---|
| 83 | |
---|
| 84 | //@{ |
---|
| 85 | |
---|
| 86 | /** |
---|
| 87 | * Write contents of the annotation to the specified DOM object. In-scope |
---|
| 88 | * namespace declarations for <code>annotation</code> element are added as |
---|
| 89 | * attribute nodes of the serialized <code>annotation</code>. |
---|
| 90 | * @param node A target pointer to the annotation target object, i.e. |
---|
| 91 | * either <code>DOMDocument</code> or <code>DOMElement</code> cast as |
---|
| 92 | * <code>DOMNode</code>. |
---|
| 93 | * @param targetType A target type. |
---|
| 94 | */ |
---|
| 95 | |
---|
| 96 | void writeAnnotation(DOMNode* node, ANNOTATION_TARGET targetType); |
---|
| 97 | |
---|
| 98 | /** |
---|
| 99 | * Write contents of the annotation to the specified object. |
---|
| 100 | * The corresponding events for all in-scope namespace declarations are |
---|
| 101 | * sent via the specified document handler. |
---|
| 102 | * @param handler A target pointer to the annotation target object, i.e. |
---|
| 103 | * <code>ContentHandler</code>. |
---|
| 104 | */ |
---|
| 105 | void writeAnnotation(ContentHandler* handler); |
---|
| 106 | |
---|
| 107 | /** |
---|
| 108 | * A text representation of annotation. |
---|
| 109 | */ |
---|
| 110 | const XMLCh *getAnnotationString() const; |
---|
| 111 | XMLCh *getAnnotationString(); |
---|
| 112 | |
---|
| 113 | //@} |
---|
| 114 | |
---|
| 115 | //---------------------------------- |
---|
| 116 | /** methods needed by implementation */ |
---|
| 117 | //@{ |
---|
| 118 | void setNext(XSAnnotation* const nextAnnotation); |
---|
| 119 | XSAnnotation* getNext(); |
---|
| 120 | //@} |
---|
| 121 | |
---|
| 122 | //----------------------------- |
---|
| 123 | /** Getter */ |
---|
| 124 | //@{ |
---|
| 125 | inline void getLineCol(int& line, int& col) const; |
---|
| 126 | inline const XMLCh* getSystemId() const; |
---|
| 127 | //@} |
---|
| 128 | |
---|
| 129 | //----------------------------- |
---|
| 130 | /** Setter */ |
---|
| 131 | //@{ |
---|
| 132 | inline void setLineCol(int line, int col); |
---|
| 133 | void setSystemId(const XMLCh* const systemId); |
---|
| 134 | //@} |
---|
| 135 | |
---|
| 136 | /*** |
---|
| 137 | * Support for Serialization/De-serialization |
---|
| 138 | ***/ |
---|
| 139 | DECL_XSERIALIZABLE(XSAnnotation) |
---|
| 140 | XSAnnotation(MemoryManager* const manager); |
---|
| 141 | |
---|
| 142 | private: |
---|
| 143 | |
---|
| 144 | // ----------------------------------------------------------------------- |
---|
| 145 | // Unimplemented constructors and operators |
---|
| 146 | // ----------------------------------------------------------------------- |
---|
| 147 | XSAnnotation(const XSAnnotation&); |
---|
| 148 | XSAnnotation & operator=(const XSAnnotation &); |
---|
| 149 | |
---|
| 150 | protected: |
---|
| 151 | |
---|
| 152 | // ----------------------------------------------------------------------- |
---|
| 153 | // data members |
---|
| 154 | // ----------------------------------------------------------------------- |
---|
| 155 | XMLCh* fContents; |
---|
| 156 | XSAnnotation* fNext; |
---|
| 157 | |
---|
| 158 | private: |
---|
| 159 | |
---|
| 160 | XMLCh* fSystemId; |
---|
| 161 | int fLine; |
---|
| 162 | int fCol; |
---|
| 163 | |
---|
| 164 | }; |
---|
| 165 | |
---|
| 166 | inline const XMLCh *XSAnnotation::getAnnotationString() const |
---|
| 167 | { |
---|
| 168 | return fContents; |
---|
| 169 | } |
---|
| 170 | |
---|
| 171 | inline XMLCh *XSAnnotation::getAnnotationString() |
---|
| 172 | { |
---|
| 173 | return fContents; |
---|
| 174 | } |
---|
| 175 | |
---|
| 176 | inline void XSAnnotation::getLineCol(int& line, int& col) const |
---|
| 177 | { |
---|
| 178 | line = fLine; |
---|
| 179 | col = fCol; |
---|
| 180 | } |
---|
| 181 | |
---|
| 182 | inline const XMLCh* XSAnnotation::getSystemId() const |
---|
| 183 | { |
---|
| 184 | return fSystemId; |
---|
| 185 | } |
---|
| 186 | |
---|
| 187 | inline void XSAnnotation::setLineCol(int line, int col) |
---|
| 188 | { |
---|
| 189 | fLine = line; |
---|
| 190 | fCol = col; |
---|
| 191 | } |
---|
| 192 | |
---|
| 193 | XERCES_CPP_NAMESPACE_END |
---|
| 194 | |
---|
| 195 | #endif |
---|