source: icXML/icXML-devel/src/xercesc/framework/psvi/PSVIAttributeList.cpp @ 2722

Last change on this file since 2722 was 2722, checked in by cameron, 6 years ago

Original Xerces files with import mods for icxercesc

File size: 3.5 KB
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: PSVIAttributeList.cpp 674012 2008-07-04 11:18:21Z borisk $
20 */
21
22#include <xercesc/framework/psvi/PSVIAttributeList.hpp>
23#include <xercesc/framework/psvi/XSAttributeDeclaration.hpp>
24#include <icxercesc/util/XMLString.hpp>
25
26XERCES_CPP_NAMESPACE_BEGIN
27
28PSVIAttributeList::PSVIAttributeList( MemoryManager* const manager ):
29    fMemoryManager(manager)
30  , fAttrList(0)
31  , fAttrPos(0)
32{
33    fAttrList= new (fMemoryManager) RefVectorOf<PSVIAttributeStorage> (10, true, fMemoryManager);
34}
35
36/*
37 * Get the number of attributes whose PSVI contributions
38 * are contained in this list.
39 */
40XMLSize_t PSVIAttributeList::getLength() const
41{
42    return fAttrPos;
43}
44
45/*
46 * Get the PSVI contribution of attribute at position i
47 * in this list.  Indeces start from 0.
48 * @param index index from which the attribute PSVI contribution
49 * is to come.
50 * @return PSVIAttribute containing the attributes PSVI contributions;
51 * null is returned if the index is out of range.
52 */
53PSVIAttribute *PSVIAttributeList::getAttributePSVIAtIndex(const XMLSize_t index)
54{
55    if(index >= fAttrPos)
56        return 0;
57    return fAttrList->elementAt(index)->fPSVIAttribute;
58}
59
60/*
61 * Get local part of attribute name at position index in the list.
62 * Indeces start from 0.
63 * @param index index from which the attribute name
64 * is to come.
65 * @return local part of the attribute's name; null is returned if the index
66 * is out of range.
67 */
68const XMLCh *PSVIAttributeList::getAttributeNameAtIndex(const XMLSize_t index)
69{
70
71    if(index >= fAttrPos)
72        return 0;
73    return fAttrList->elementAt(index)->fAttributeName;
74}
75
76/*
77 * Get namespace of attribute at position index in the list.
78 * Indeces start from 0.
79 * @param index index from which the attribute namespace
80 * is to come.
81 * @return namespace of the attribute;
82 * null is returned if the index is out of range.
83 */
84const XMLCh *PSVIAttributeList::getAttributeNamespaceAtIndex(const XMLSize_t index)
85{
86    if(index >= fAttrPos)
87        return 0;
88    return fAttrList->elementAt(index)->fAttributeNamespace;
89}
90
91/*
92 * Get the PSVI contribution of attribute with given
93 * local name and namespace.
94 * @param attrName  local part of the attribute's name
95 * @param attrNamespace  namespace of the attribute
96 * @return null if the attribute PSVI does not exist
97 */
98PSVIAttribute *PSVIAttributeList::getAttributePSVIByName(const XMLCh *attrName
99                , const XMLCh * attrNamespace)
100{
101    for (XMLSize_t index=0; index < fAttrPos; index++) {
102        PSVIAttributeStorage* storage = fAttrList->elementAt(index);
103        if (XMLString::equals(attrName,storage->fAttributeName) &&
104            XMLString::equals(attrNamespace,storage->fAttributeNamespace))
105            return storage->fPSVIAttribute;
106    }
107    return 0;
108}
109
110XERCES_CPP_NAMESPACE_END
Note: See TracBrowser for help on using the repository browser.