axis-c-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shan...@apache.org
Subject svn commit: r926489 - in /axis/axis2/c/core/trunk/axiom: include/axiom_document.h src/om/axiom_stax_builder_internal.h src/om/om_document.c src/om/om_stax_builder.c
Date Tue, 23 Mar 2010 07:56:16 GMT
Author: shankar
Date: Tue Mar 23 07:56:16 2010
New Revision: 926489

URL: http://svn.apache.org/viewvc?rev=926489&view=rev
Log:
refactor 

Modified:
    axis/axis2/c/core/trunk/axiom/include/axiom_document.h
    axis/axis2/c/core/trunk/axiom/src/om/axiom_stax_builder_internal.h
    axis/axis2/c/core/trunk/axiom/src/om/om_document.c
    axis/axis2/c/core/trunk/axiom/src/om/om_stax_builder.c

Modified: axis/axis2/c/core/trunk/axiom/include/axiom_document.h
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/axiom/include/axiom_document.h?rev=926489&r1=926488&r2=926489&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/axiom/include/axiom_document.h (original)
+++ axis/axis2/c/core/trunk/axiom/include/axiom_document.h Tue Mar 23 07:56:16 2010
@@ -56,7 +56,7 @@ extern "C"
       */
     AXIS2_EXTERN axiom_node_t *AXIS2_CALL
     axiom_document_get_root_element(
-        struct axiom_document *document,
+        axiom_document_t *document,
         const axutil_env_t * env);
 
     /**
@@ -67,7 +67,7 @@ extern "C"
      */
     AXIS2_EXTERN axiom_node_t *AXIS2_CALL
     axiom_document_build_all(
-        struct axiom_document *document,
+        axiom_document_t *document,
         const axutil_env_t * env);
 
     /** @} */

Modified: axis/axis2/c/core/trunk/axiom/src/om/axiom_stax_builder_internal.h
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/axiom/src/om/axiom_stax_builder_internal.h?rev=926489&r1=926488&r2=926489&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/axiom/src/om/axiom_stax_builder_internal.h (original)
+++ axis/axis2/c/core/trunk/axiom/src/om/axiom_stax_builder_internal.h Tue Mar 23 07:56:16
2010
@@ -66,18 +66,7 @@ extern "C"
         axiom_stax_builder_t * builder,
         const axutil_env_t * env);
 
-    /**
-      * Builds the next node from stream. Moves pull parser forward and reacts
-      * to events.
-      * @param builder pointer to stax builder struct to be used
-      * @param environment Environment. MUST NOT be NULL.
-      * @return a pointer to the next node, or NULL if there are no more nodes.
-      *     On erros sets the error and returns NULL.
-      */
-    axiom_node_t *AXIS2_CALL
-    axiom_stax_builder_next(
-        struct axiom_stax_builder *builder,
-        const axutil_env_t * env);
+
 
     /**
       * builder is finished building om structure
@@ -103,6 +92,19 @@ extern "C"
         struct axiom_stax_builder *builder,
         const axutil_env_t * env);
 
+    /**
+      * Builds the next node from stream. Moves pull parser forward and reacts
+      * to events.
+      * @param builder pointer to stax builder struct to be used
+      * @param environment Environment. MUST NOT be NULL.
+      * @return a pointer to the next node, or NULL if there are no more nodes.
+      *     On erros sets the error and returns NULL.
+      */
+    axiom_node_t *AXIS2_CALL
+    axiom_stax_builder_next(
+        struct axiom_stax_builder *builder,
+        const axutil_env_t * env);
+
 #if 0
     /**
       * Discards the element that is being built currently.
@@ -126,6 +128,7 @@ extern "C"
         const axutil_env_t * env,
         axis2_bool_t enable_cache);
 
+
 #endif
 
     /** @} */

Modified: axis/axis2/c/core/trunk/axiom/src/om/om_document.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/axiom/src/om/om_document.c?rev=926489&r1=926488&r2=926489&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/axiom/src/om/om_document.c (original)
+++ axis/axis2/c/core/trunk/axiom/src/om/om_document.c Tue Mar 23 07:56:16 2010
@@ -24,15 +24,11 @@ struct axiom_document
     /** root element */
     axiom_node_t *root_element;
 
-    /** last child */
-    axiom_node_t *last_child;
-
     /** builder of the document */
     struct axiom_stax_builder *builder;
 
 };
 
-
 axiom_document_t *AXIS2_CALL
 axiom_document_create(
     const axutil_env_t * env,
@@ -50,7 +46,6 @@ axiom_document_create(
 
     document->builder = builder;
     document->root_element = root;
-    document->last_child = root;
     return document;
 }
 
@@ -74,59 +69,18 @@ axiom_document_free_self(
     AXIS2_FREE(env->allocator, document);
 }
 
-axiom_node_t *AXIS2_CALL
-axiom_document_build_next(
-    axiom_document_t * document,
-    const axutil_env_t * env)
-{
-    axiom_node_t *last_child = NULL;
-
-
-    if(!document->builder)
-    {
-        return NULL;
-    }
-
-    if(!(document->root_element))
-    {
-        last_child = axiom_stax_builder_next(document->builder, env);
-        if(last_child)
-        {
-            document->last_child = last_child;
-            document->root_element = last_child;
-        }
-        return last_child;
-    }
-    else if((document->root_element) && (axiom_node_is_complete(document->root_element,
env)
-        == AXIS2_TRUE))
-        return NULL; /* Nothing wrong but done with pulling */
-
-    last_child = axiom_stax_builder_next(document->builder, env);
-    if(last_child)
-    {
-        document->last_child = last_child;
-    }
-    return last_child;
-}
-
 axis2_status_t AXIS2_CALL
 axiom_document_set_root_element(
     axiom_document_t * document,
     const axutil_env_t * env,
     axiom_node_t * node)
 {
-    AXIS2_PARAM_CHECK(env->error, node, AXIS2_FAILURE);
-
     if(document->root_element)
     {
         axiom_node_free_tree(document->root_element, env);
-        document->root_element = node;
-        return AXIS2_SUCCESS;
-    }
-    else
-    {
-        document->root_element = node;
     }
+
+    document->root_element = node;
     return AXIS2_SUCCESS;
 }
 
@@ -135,62 +89,42 @@ axiom_document_get_root_element(
     axiom_document_t * document,
     const axutil_env_t * env)
 {
-    axiom_node_t *node = NULL;
-
     if(document->root_element)
     {
         return document->root_element;
     }
-    node = axiom_document_build_next(document, env);
 
-    if(document->root_element)
+    /* force to build the root node */
+    if(!axiom_stax_builder_next(document->builder, env))
     {
-        return document->root_element;
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_DOCUMENT_STATE_ROOT_NULL, AXIS2_FAILURE);
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to get root node");
     }
-    AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_DOCUMENT_STATE_ROOT_NULL, AXIS2_FAILURE);
-    return NULL;
+
+    return document->root_element;
 }
 
 AXIS2_EXTERN axiom_node_t *AXIS2_CALL
 axiom_document_build_all(
-    struct axiom_document * document,
-    const axutil_env_t * env)
+    axiom_document_t *document,
+    const axutil_env_t *env)
 {
-    if(!document)
-    {
-        return NULL;
-    }
-    if(!document->root_element)
+    do
     {
-        axiom_document_get_root_element(document, env);
-    }
-    if(document->root_element)
-    {
-        do
+        axiom_node_t *ret_val = NULL;
+        ret_val = axiom_stax_builder_next(document->builder, env);
+        if(!ret_val && !axiom_node_is_complete(document->root_element, env))
         {
-            axiom_node_t *ret_val = NULL;
-            ret_val = axiom_document_build_next(document, env);
-            if(!ret_val)
-            {
-                if(axiom_node_is_complete(document->root_element, env) == AXIS2_TRUE)
-                {
-
-                    /** document is completly build */
-                    return document->root_element;
-                }
-                else
-                {
-
-                    /** error occurred */
-                    return NULL;
-                }
-            }
+            /* if return value is null and root node is not fully completed, this means there
is
+             * an error occurred */
+            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+                "Error occurred when building all nodes of document");
+            return NULL;
         }
-        while(!axiom_node_is_complete(document->root_element, env));
-        return document->root_element;
     }
-    else
-        return NULL;
+    while(document->root_element && !axiom_node_is_complete(document->root_element,
env));
+
+    return document->root_element;
 }
 
 #if 0
@@ -233,4 +167,17 @@ axiom_document_serialize(
         return AXIS2_FAILURE;
     }
 }
+
+axiom_node_t *AXIS2_CALL
+axiom_document_build_next(
+    axiom_document_t * document,
+    const axutil_env_t * env)
+{
+    if(document->root_element && axiom_node_is_complete(document->root_element,
env))
+    {
+        return NULL; /* Nothing wrong but done with pulling */
+    }
+
+    return axiom_stax_builder_next(document->builder, env);
+}
 #endif

Modified: axis/axis2/c/core/trunk/axiom/src/om/om_stax_builder.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/axiom/src/om/om_stax_builder.c?rev=926489&r1=926488&r2=926489&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/axiom/src/om/om_stax_builder.c (original)
+++ axis/axis2/c/core/trunk/axiom/src/om/om_stax_builder.c Tue Mar 23 07:56:16 2010
@@ -488,6 +488,11 @@ axiom_stax_builder_create_om_element(
     {
         /* since last node is null, this should be the root node */
         om_ele = axiom_element_create_str(env, NULL, temp_localname_str, NULL, &element_node);
+        if(!element_node)
+        {
+            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create element");
+            return NULL;
+        }
         om_builder->root_node = element_node;
         if(om_builder->document)
         {



Mime
View raw message