GME  13
PSVIAttributeList.cpp
Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  *
00009  *      http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 /*
00019  * $Id: PSVIAttributeList.cpp 674012 2008-07-04 11:18:21Z borisk $
00020  */
00021 
00022 #include <xercesc/framework/psvi/PSVIAttributeList.hpp>
00023 #include <xercesc/framework/psvi/XSAttributeDeclaration.hpp>
00024 #include <xercesc/util/XMLString.hpp>
00025 
00026 XERCES_CPP_NAMESPACE_BEGIN
00027 
00028 PSVIAttributeList::PSVIAttributeList( MemoryManager* const manager ):
00029     fMemoryManager(manager)
00030   , fAttrList(0)
00031   , fAttrPos(0)
00032 {
00033     fAttrList= new (fMemoryManager) RefVectorOf<PSVIAttributeStorage> (10, true, fMemoryManager);
00034 }
00035 
00036 /*
00037  * Get the number of attributes whose PSVI contributions
00038  * are contained in this list.
00039  */
00040 XMLSize_t PSVIAttributeList::getLength() const
00041 {
00042     return fAttrPos;
00043 }
00044 
00045 /*
00046  * Get the PSVI contribution of attribute at position i
00047  * in this list.  Indeces start from 0.
00048  * @param index index from which the attribute PSVI contribution
00049  * is to come.
00050  * @return PSVIAttribute containing the attributes PSVI contributions;
00051  * null is returned if the index is out of range.
00052  */
00053 PSVIAttribute *PSVIAttributeList::getAttributePSVIAtIndex(const XMLSize_t index)
00054 {
00055     if(index >= fAttrPos)
00056         return 0;
00057     return fAttrList->elementAt(index)->fPSVIAttribute;
00058 }
00059 
00060 /*
00061  * Get local part of attribute name at position index in the list.
00062  * Indeces start from 0.
00063  * @param index index from which the attribute name
00064  * is to come.
00065  * @return local part of the attribute's name; null is returned if the index
00066  * is out of range.
00067  */
00068 const XMLCh *PSVIAttributeList::getAttributeNameAtIndex(const XMLSize_t index)
00069 {
00070 
00071     if(index >= fAttrPos)
00072         return 0;
00073     return fAttrList->elementAt(index)->fAttributeName;
00074 }
00075 
00076 /*
00077  * Get namespace of attribute at position index in the list.
00078  * Indeces start from 0.
00079  * @param index index from which the attribute namespace
00080  * is to come.
00081  * @return namespace of the attribute;
00082  * null is returned if the index is out of range.
00083  */
00084 const XMLCh *PSVIAttributeList::getAttributeNamespaceAtIndex(const XMLSize_t index)
00085 {
00086     if(index >= fAttrPos)
00087         return 0;
00088     return fAttrList->elementAt(index)->fAttributeNamespace;
00089 }
00090 
00091 /*
00092  * Get the PSVI contribution of attribute with given
00093  * local name and namespace.
00094  * @param attrName  local part of the attribute's name
00095  * @param attrNamespace  namespace of the attribute
00096  * @return null if the attribute PSVI does not exist
00097  */
00098 PSVIAttribute *PSVIAttributeList::getAttributePSVIByName(const XMLCh *attrName
00099                 , const XMLCh * attrNamespace)
00100 {
00101     for (XMLSize_t index=0; index < fAttrPos; index++) {
00102         PSVIAttributeStorage* storage = fAttrList->elementAt(index);
00103         if (XMLString::equals(attrName,storage->fAttributeName) &&
00104             XMLString::equals(attrNamespace,storage->fAttributeNamespace))
00105             return storage->fPSVIAttribute;
00106     }
00107     return 0;
00108 }
00109 
00110 XERCES_CPP_NAMESPACE_END