ws-axis-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ros...@apache.org
Subject cvs commit: ws-axis/c/include/axis IAttribute.h
Date Mon, 02 Aug 2004 14:15:28 GMT
roshan      2004/08/02 07:15:28

  Modified:    c/include/axis/server IHeaderBlock.h Attribute.h BasicNode.h
               c/src/soap Attribute.cpp HeaderBlock.h HeaderBlock.cpp
                        CharacterElement.h ComplexElement.h
                        ComplexElement.cpp
  Added:       c/include/axis IAttribute.h
  Log:
  added code to support adding of namespaces to HeaderBlocks and adding of attributes to Soap
Headers. This patch was submitted by Adrian Dick <adrian.dick@uk.ibm.com>
  
  Revision  Changes    Path
  1.17      +21 -0     ws-axis/c/include/axis/server/IHeaderBlock.h
  
  Index: IHeaderBlock.h
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/include/axis/server/IHeaderBlock.h,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- IHeaderBlock.h	26 Jul 2004 13:43:48 -0000	1.16
  +++ IHeaderBlock.h	2 Aug 2004 14:15:26 -0000	1.17
  @@ -19,6 +19,7 @@
   
   #include "BasicNode.h"
   #include "SoapEnvVersions.h"
  +#include <axis/IAttribute.h>
   
   #ifdef __cplusplus
   class Attribute;
  @@ -68,6 +69,26 @@
   class IHeaderBlock
   {
   public:
  +    /** 
  +      * Sets the namespace declaration of the Header Block. 
  +      * 
  +      * @param pAttribute The Attribute pointer which points to a valid 
  +      * namespace declartion Attribute. 
  +      * @return AXIS_SUCCESS to indicate successfull operation. 
  +      */ 
  +    virtual int addNamespaceDecl(IAttribute *pAttribute)=0;
  +
  +    /** 
  +      * Creates a Attribute and adds it to this Header Block as a namespace. 
  +      * 
  +      * @param prefix The prefix of the attribute. 
  +      * @param uri The namespace uri of the attribute. 
  +      * 
  +      * @return A pointer to the created Attribute will be returned. 
  +      */ 
  +    virtual IAttribute* createNamespaceDecl(const AxisChar *prefix, 
  +            const AxisChar *uri)=0; 
  +
       virtual const BasicNode* getFirstChild() =0;
       /**
        * Returns the number of child elements of this HeaderBlock.
  
  
  
  1.17      +3 -2      ws-axis/c/include/axis/server/Attribute.h
  
  Index: Attribute.h
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/include/axis/server/Attribute.h,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Attribute.h	26 Jul 2004 13:43:48 -0000	1.16
  +++ Attribute.h	2 Aug 2004 14:15:26 -0000	1.17
  @@ -32,6 +32,7 @@
   using namespace std;
   
   class SoapSerializer;
  +#include <axis/IAttribute.h>
   
   #endif
   
  @@ -39,7 +40,7 @@
    *   @class Attribute
    *   @brief interface for the Attribute class.
    *
  - *   @author Roshan Weerasuriya (roshan@opensource.lk, roshan@jkcs.slt.lk)
  + *   @author Roshan Weerasuriya (roshan@opensource.lk, roshanw@jkcsworld.com)
    *   @author Samisa Abeysinghe (sabeysinghe@virtusa.com)
    *   @author Susantha Kumara (susantha@opensource.lk, skumara@virtusa.com)
    *
  @@ -62,7 +63,7 @@
   
   #ifdef __cplusplus
   
  -class Attribute  
  +class Attribute : public IAttribute
   {
   public:        
   	static AttributeFunctions ms_VFtable;
  
  
  
  1.17      +30 -1     ws-axis/c/include/axis/server/BasicNode.h
  
  Index: BasicNode.h
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/include/axis/server/BasicNode.h,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- BasicNode.h	28 Jul 2004 08:41:46 -0000	1.16
  +++ BasicNode.h	2 Aug 2004 14:15:26 -0000	1.17
  @@ -18,7 +18,7 @@
   /**
    * @file BasicNode.h
    *
  - * @author Roshan Weerasuriya (roshan@opensource.lk, roshanw@jkcsworld.com) *
  + * @author Roshan Weerasuriya (roshan@opensource.lk, roshanw@jkcsworld.com)
    */
     
   #if !defined(_BASICNODE_H____OF_AXIS_INCLUDED_)
  @@ -36,6 +36,8 @@
   
   #endif
   
  +#include <axis/IAttribute.h>
  +
   enum NODE_TYPE { ELEMENT_NODE=1, CHARACTER_NODE};
   
   /*
  @@ -74,6 +76,32 @@
   {
   public:
   
  +    /** 
  +      * Creates an Attribute and adds it to this Basic Node. 
  +      * 
  +      * @param localname The local name of the attribute. 
  +      * @param prefix The prefix of the attribute. 
  +      * @param uri The namespace uri of the attribute. 
  +      * @param value The value of the attribute. 
  +      * 
  +      * @return A pointer to the created Attribute will be returned. 
  +      */
  +    virtual IAttribute* createAttribute(const AxisChar* localname, 
  +            const AxisChar* prefix, const AxisChar* uri, 
  +            const AxisChar* value) =0;
  +
  +    /** 
  +      * Creates an Attribute and adds it to this Basic Node. 
  +      * 
  +      * @param localname The local name of the attribute. 
  +      * @param prefix The prefix of the attribute. 
  +      * @param value The value of the attribute. 
  +      * 
  +      * @return A pointer to the created Attribute will be returned. 
  +      */
  +    virtual IAttribute* createAttribute(const AxisChar* localname,
  +        const AxisChar* prefix, const AxisChar* value)=0 ;
  +
       /**
         * Returns the local name of this node. The operation
         * behavior depends on the TYPE of the node.
  @@ -197,6 +225,7 @@
         * of the node.
         */
       AxisChar* m_pachValue;
  +
   };
   
   #endif
  
  
  
  1.22      +18 -1     ws-axis/c/src/soap/Attribute.cpp
  
  Index: Attribute.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/Attribute.cpp,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- Attribute.cpp	26 Jul 2004 13:43:48 -0000	1.21
  +++ Attribute.cpp	2 Aug 2004 14:15:26 -0000	1.22
  @@ -23,7 +23,7 @@
    *
    *
    *
  - * @author Roshan Weerasuriya (roshan@jkcs.slt.lk)
  + * @author Roshan Weerasuriya (roshan@opensource.lk, roshanw@jkcsworld.com)
    * @author Samisa Abeysinghe (sabeysinghe@virtusa.com)
    *
    */
  @@ -215,3 +215,20 @@
       m_prefix= prefix;
       m_value= value;
   }
  +
  +const AxisChar* Attribute::getValue() {
  +    return m_value.c_str();
  +}
  +
  +const AxisChar* Attribute::getLocalName() {
  +    return m_localname.c_str();
  +}
  +
  +const AxisChar* Attribute::getUri() {
  +    return m_uri.c_str();
  +}
  +
  +const AxisChar* Attribute::getPrefix() {
  +    return m_prefix.c_str();
  +}
  +
  
  
  
  1.13      +13 -1     ws-axis/c/src/soap/HeaderBlock.h
  
  Index: HeaderBlock.h
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/HeaderBlock.h,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- HeaderBlock.h	26 Jul 2004 13:43:48 -0000	1.12
  +++ HeaderBlock.h	2 Aug 2004 14:15:26 -0000	1.13
  @@ -102,6 +102,18 @@
       list<Attribute*> m_namespaceDecls;
   
   public:
  +
  +    /** 
  +      * Creates a Attribute and adds it to this Header Block as a namespace. 
  +      * 
  +      * @param prefix The prefix of the attribute. 
  +      * @param uri The namespace uri of the attribute. 
  +      * 
  +      * @return A pointer to the created Attribute will be returned. 
  +      */
  +    IAttribute* createNamespaceDecl(const AxisChar *prefix, 
  +            const AxisChar *uri); 
  +
       const BasicNode* getFirstChild();
   
       /**
  @@ -342,7 +354,7 @@
         * @return AXIS_SUCCESS to indicate successfull operation. AXIS_FAIL to
         *  to indicate unsuccessfull operation.
         */
  -    int addNamespaceDecl(Attribute *pAttribute);
  +    int addNamespaceDecl(IAttribute *pAttribute);
   
       /**
         * The Constructor.
  
  
  
  1.29      +11 -2     ws-axis/c/src/soap/HeaderBlock.cpp
  
  Index: HeaderBlock.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/HeaderBlock.cpp,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- HeaderBlock.cpp	26 Jul 2004 13:43:48 -0000	1.28
  +++ HeaderBlock.cpp	2 Aug 2004 14:15:26 -0000	1.29
  @@ -331,11 +331,20 @@
       return AXIS_SUCCESS;
   }
   
  -int HeaderBlock::addNamespaceDecl(Attribute *pAttribute)
  +IAttribute* HeaderBlock::createNamespaceDecl(const AxisChar *prefix,
  +        const AxisChar *uri) 
  +{
  +    Attribute* pAttribute = new Attribute(prefix, "xmlns", uri);
  +    m_namespaceDecls.push_back(pAttribute);
  +
  +    return (IAttribute*)pAttribute; 
  +}
  +
  +int HeaderBlock::addNamespaceDecl(IAttribute *pAttribute)
   {
       if (pAttribute)
       {
  -        m_namespaceDecls.push_back(pAttribute);
  +        m_namespaceDecls.push_back((Attribute*)pAttribute);
           return AXIS_SUCCESS;
       }
       else
  
  
  
  1.9       +29 -0     ws-axis/c/src/soap/CharacterElement.h
  
  Index: CharacterElement.h
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/CharacterElement.h,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- CharacterElement.h	28 Jul 2004 08:42:17 -0000	1.8
  +++ CharacterElement.h	2 Aug 2004 14:15:27 -0000	1.9
  @@ -49,6 +49,35 @@
   class CharacterElement : public BasicNode
   {
   public:
  +
  +    /** 
  +      * This method is overridden to always return NULL because this is a CharacterElement.

  +      * A user of a CharacterElement should not use this method 
  +      * 
  +      * @param localname The local name of the attribute. 
  +      * @param prefix The prefix of the attribute. 
  +      * @param uri The namespace uri of the attribute. 
  +      * @param value The value of the attribute. 
  +      * 
  +      * @return Will always return NULL 
  +      */
  +    IAttribute* createAttribute(const AxisChar* localname,
  +            const AxisChar* prefix, const AxisChar* uri, const AxisChar* value) 
  +            { return NULL; }
  +
  +    /** 
  +      * This method is overridden to always return NULL because this is a CharacterElement.

  +      * A user of a CharacterElement should not use this method 
  +      * 
  +      * @param localname The local name of the attribute. 
  +      * @param prefix The prefix of the attribute. 
  +      * @param value The value of the attribute. 
  +      * 
  +      * @return Will always return NULL 
  +      */ 
  +    IAttribute* createAttribute(const AxisChar* localname,
  +            const AxisChar* prefix, const AxisChar* value) { return NULL; }
  +
       bool operator ==( const CharacterElement &objChEle);
   
       /**
  
  
  
  1.14      +33 -0     ws-axis/c/src/soap/ComplexElement.h
  
  Index: ComplexElement.h
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/ComplexElement.h,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ComplexElement.h	28 Jul 2004 08:42:17 -0000	1.13
  +++ ComplexElement.h	2 Aug 2004 14:15:27 -0000	1.14
  @@ -50,6 +50,7 @@
   
   #include <list>
   #include <axis/server/BasicNode.h>
  +#include <axis/server/Attribute.h>
   
   using namespace std;
   
  @@ -66,6 +67,31 @@
   public:
       ComplexElement(AxisChar* pachLocalName, AxisChar* pachPrefix, AxisChar* pachUri);
   
  +    /** 
  +      * Creates an Attribute and adds it to this Complex Element. 
  +      * 
  +      * @param localname The local name of the attribute. 
  +      * @param prefix The prefix of the attribute. 
  +      * @param uri The namespace uri of the attribute. 
  +      * @param value The value of the attribute. 
  +      * 
  +      * @return A pointer to the created Attribute will be returned. 
  +      */ 
  +    IAttribute* createAttribute(const AxisChar* localname,
  +        const AxisChar* prefix, const AxisChar* uri, const AxisChar* value);
  +
  +    /** 
  +      * Creates an Attribute and adds it to this Complex Element. 
  +      * 
  +      * @param localname The local name of the attribute. 
  +      * @param prefix The prefix of the attribute. 
  +      * @param value The value of the attribute. 
  +      * 
  +      * @return A pointer to the created Attribute will be returned. 
  +      */ 
  +    IAttribute* createAttribute(const AxisChar* localname,
  +            const AxisChar* prefix, const AxisChar* value);
  +
       /**
         * Returns the number of child elements of this ComplexElement.
         *
  @@ -185,8 +211,15 @@
       int iNoOfChildren;
       int serializeChildren(SoapSerializer& pSZ);
       int serializeChildren(SoapSerializer& pSZ, list<AxisChar*>& lstTmpNameSpaceStack);
  +    int serializeNamespaceDecl(SoapSerializer &pSZ); 
  +    int attrSerialize(SoapSerializer& pSZ, list<AxisChar*>& lstTmpNameSpaceStack);
       bool isSerializable();
       list<BasicNode*> m_children;
  +    list<Attribute*> m_namespaceDecls;
  +     /**
  +      * Used to store the Attributes
  +      */
  +    list<Attribute*> m_attributes;
       AxisChar* m_pachPrefix;
       AxisChar* m_pachLocalName;
       AxisChar* m_pachURI;
  
  
  
  1.20      +79 -1     ws-axis/c/src/soap/ComplexElement.cpp
  
  Index: ComplexElement.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/ComplexElement.cpp,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- ComplexElement.cpp	28 Jul 2004 08:42:17 -0000	1.19
  +++ ComplexElement.cpp	2 Aug 2004 14:15:27 -0000	1.20
  @@ -45,6 +45,7 @@
   #include "ComplexElement.h"
   #include "SoapSerializer.h"
   #include <axis/server/GDefine.h>
  +#include <axis/server/Attribute.h>
   
   ComplexElement::ComplexElement()
   {
  @@ -102,6 +103,16 @@
       free(m_pachLocalName);
       free(m_pachURI);
   
  +    /* 
  +     *Clear the Attributes 
  +     */
  +    list<Attribute*>::iterator itCurrAttribute= m_attributes.begin();
  +    while(itCurrAttribute != m_attributes.end())
  +    {
  +        delete (*itCurrAttribute);
  +        itCurrAttribute++;
  +    }
  +    m_attributes.clear();
   
       /* Clear the children */
       list<BasicNode*>::iterator itCurrChild= m_children.begin();
  @@ -113,6 +124,27 @@
       m_children.clear();
   }
   
  +IAttribute* ComplexElement::createAttribute(const AxisChar *localname,
  +        const AxisChar *prefix,
  +        const AxisChar *value)
  +{
  +    Attribute* pAttribute = new Attribute(localname, prefix, value);
  +    m_attributes.push_back(pAttribute);
  +    
  +    return (IAttribute*)pAttribute;
  +}
  +
  +IAttribute* ComplexElement::createAttribute(const AxisChar *localname,
  +        const AxisChar *prefix,
  +        const AxisChar *uri,
  +        const AxisChar *value)
  +{
  +    Attribute* pAttribute = new Attribute(localname, prefix, uri, value);
  +    m_attributes.push_back(pAttribute);
  +   
  +    return (IAttribute*)pAttribute;
  +}
  +
   int ComplexElement::setPrefix(const AxisChar* pachPrefix)
   {
       m_pachPrefix = (AxisChar*) malloc(strlen(pachPrefix)+1);
  @@ -216,9 +248,22 @@
                       ( (m_pachURI != NULL) && (strlen(m_pachURI) != 0)) &&

                       (blnIsNewNamespace))
               {
  -                pSZ.serialize(" xmlns:", m_pachPrefix, "=\"", m_pachURI, "\"",
  +                pSZ.serialize(" xmlns:", m_pachPrefix, "=\"", m_pachURI, "\" ",
                       NULL);
               }
  +
  +	    iStatus= attrSerialize(pSZ, lstTmpNameSpaceStack);
  +   	    if(iStatus==AXIS_FAIL)
  +	    {
  +		break;
  +	    }
  +
  +       	    iStatus= serializeNamespaceDecl(pSZ);
  + 	    if(iStatus==AXIS_FAIL)
  +	    {
  +		break;
  +	    }
  +
               pSZ.serialize(">", NULL);
   
               iStatus= serializeChildren(pSZ, lstTmpNameSpaceStack);
  @@ -240,6 +285,39 @@
           }
       } while(0);    
       return iStatus;
  +}
  +
  +int ComplexElement::attrSerialize(SoapSerializer& pSZ,
  +        list<AxisChar*>& lstTmpNameSpaceStack)
  +{
  +    int iStatus= AXIS_SUCCESS;
  +    
  +    list<Attribute*>::iterator itCurrAttribute= m_attributes.begin();
  +
  +    while(itCurrAttribute != m_attributes.end())
  +    {
  +        iStatus= (*itCurrAttribute)->serialize(pSZ, lstTmpNameSpaceStack);
  +        if(iStatus==AXIS_FAIL)
  +        {
  +	    break;
  +	}
  +        itCurrAttribute++;
  +    }
  +
  +    return iStatus;
  +}
  +
  +int ComplexElement::serializeNamespaceDecl(SoapSerializer &pSZ)
  +{
  +    list<Attribute*>::iterator itCurrNamespaceDecl= m_namespaceDecls.begin();
  +
  +    while(itCurrNamespaceDecl != m_namespaceDecls.end())
  +    {
  +	(*itCurrNamespaceDecl)->serialize(pSZ);
  +    	itCurrNamespaceDecl++;
  +    }
  +
  +    return AXIS_SUCCESS;
   }
   
   bool ComplexElement::isSerializable()
  
  
  
  1.1                  ws-axis/c/include/axis/IAttribute.h
  
  Index: IAttribute.h
  ===================================================================
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   */
  
   /**
   * @file IAttribute.h
   *
   *
   */
   
  #if !defined(_IATTRIBUTE_H____OF_AXIS_INCLUDED_)
  #define _IATTRIBUTE_H____OF_AXIS_INCLUDED_
  
  #include <axis/server/GDefine.h>
  
  /**
   *   @class IAttribute
   *   @brief interface for the IAttribute class.
   *
   *   @author Roshan Weerasuriya (roshan@opensource.lk, roshanw@jkcsworld.com)
   *
   */
  
  #ifdef __cplusplus
  
  class IAttribute
  {
  public:        
  
      virtual ~IAttribute() {};
  
      virtual void setValue(const AxisChar* value) = 0;
      virtual void setUri(const AxisChar* uri) = 0;
      virtual void setPrefix(const AxisChar* prefix) = 0;
      virtual void setLocalName(const AxisChar* localname) = 0;    
      virtual const AxisChar* getValue() = 0;
      virtual const AxisChar* getUri() = 0;
      virtual const AxisChar* getPrefix() = 0;
      virtual const AxisChar* getLocalName() = 0;
  
  };
  
  #endif
  
  
  #endif
  
  
  

Mime
View raw message