GME  13
XSIDCDefinition.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: XSIDCDefinition.cpp 471747 2006-11-06 14:31:56Z amassari $
00020  */
00021 
00022 #include <xercesc/framework/psvi/XSIDCDefinition.hpp>
00023 #include <xercesc/validators/schema/identity/IC_KeyRef.hpp>
00024 #include <xercesc/validators/schema/identity/IC_Selector.hpp>
00025 #include <xercesc/validators/schema/identity/XercesXPath.hpp>
00026 #include <xercesc/framework/psvi/XSModel.hpp>
00027 #include <xercesc/framework/psvi/XSAnnotation.hpp>
00028 #include <xercesc/util/StringPool.hpp>
00029 
00030 XERCES_CPP_NAMESPACE_BEGIN
00031 
00032 // ---------------------------------------------------------------------------
00033 //  XSIDCDefinition: Constructors and Destructor
00034 // ---------------------------------------------------------------------------
00035 XSIDCDefinition::XSIDCDefinition(IdentityConstraint* const identityConstraint,
00036                                  XSIDCDefinition*  const   keyIC,
00037                                  XSAnnotation* const       headAnnot,
00038                                  StringList* const         stringList,
00039                                  XSModel* const            xsModel,
00040                                  MemoryManager* const      manager)
00041     : XSObject(XSConstants::IDENTITY_CONSTRAINT, xsModel, manager)
00042     , fIdentityConstraint(identityConstraint)
00043     , fKey(keyIC)
00044     , fStringList(stringList)
00045     , fXSAnnotationList(0)
00046 {
00047     if (headAnnot)
00048     {        
00049         fXSAnnotationList = new (manager) RefVectorOf<XSAnnotation>(1, false, manager);
00050 
00051         XSAnnotation* annot = headAnnot;
00052         do
00053         {
00054             fXSAnnotationList->addElement(annot);
00055             annot = annot->getNext();        
00056         } while (annot);
00057     }
00058 
00059 }
00060 
00061 XSIDCDefinition::~XSIDCDefinition()
00062 {
00063     if (fStringList)
00064         delete fStringList;
00065 
00066     // don't delete fKey - deleted by XSModel
00067     if (fXSAnnotationList)
00068         delete fXSAnnotationList;
00069 }
00070 
00071 // ---------------------------------------------------------------------------
00072 //  XSIDCDefinition: XSObject virtual methods
00073 // ---------------------------------------------------------------------------
00074 const XMLCh *XSIDCDefinition::getName() const
00075 {
00076     return fIdentityConstraint->getIdentityConstraintName();
00077 }
00078 
00079 const XMLCh *XSIDCDefinition::getNamespace() 
00080 {
00081     return fXSModel->getURIStringPool()->getValueForId(fIdentityConstraint->getNamespaceURI());
00082 }
00083 
00084 XSNamespaceItem *XSIDCDefinition::getNamespaceItem() 
00085 {
00086     return fXSModel->getNamespaceItem(getNamespace());
00087 }
00088 
00089 // ---------------------------------------------------------------------------
00090 //  XSIDCDefinition: access methods
00091 // ---------------------------------------------------------------------------
00092 XSIDCDefinition::IC_CATEGORY XSIDCDefinition::getCategory() const
00093 {
00094     switch(fIdentityConstraint->getType()) {
00095         case IdentityConstraint::ICType_UNIQUE:
00096             return IC_UNIQUE;
00097         case IdentityConstraint::ICType_KEY:
00098             return IC_KEY;
00099         case IdentityConstraint::ICType_KEYREF:
00100             return IC_KEYREF;
00101         default:
00102             // REVISIT:
00103             // should never really get here... IdentityConstraint::Unknown is the other
00104             // choice so need a default case for completeness; should issues error?
00105             return IC_KEY;
00106     }
00107 }
00108 
00109 const XMLCh *XSIDCDefinition::getSelectorStr()
00110 {
00111     return fIdentityConstraint->getSelector()->getXPath()->getExpression();
00112 }
00113 
00114 
00115 XSAnnotationList *XSIDCDefinition::getAnnotations()
00116 {
00117     return fXSAnnotationList;
00118 }
00119 
00120 XERCES_CPP_NAMESPACE_END
00121 
00122