コード例 #1
0
ファイル: Marshal.cs プロジェクト: Noisyfox/fSoap
        /**
         * Write the instance out. In case it is an AttributeContainer write those our first though.
         * If it HasAttributes then write the attributes and values.
         *
         * @param writer   the xml serializer.
         * @param instance
         * @throws IOException
         */

        public void writeInstance(XmlSerializer writer, Object instance)
        {
            if (instance is AttributeContainer)
            {
                AttributeContainer attributeContainer = (AttributeContainer)instance;
                int cnt = attributeContainer.getAttributeCount();
                for (int counter = 0; counter < cnt; counter++)
                {
                    AttributeInfo attributeInfo = new AttributeInfo();
                    attributeContainer.getAttributeInfo(counter, attributeInfo);
                    try
                    {
                        attributeContainer.getAttribute(counter, attributeInfo);
                    }
                    catch (Exception e)
                    {
                        //e.printStackTrace();
                    }
                    if (attributeInfo.getValue() != null)
                    {
                        writer.attribute(attributeInfo.getNamespace(), attributeInfo.getName(),
                                         (attributeInfo.getValue() != null) ? attributeInfo.getValue().ToString() : "");
                    }
                }
            }
            else if (instance is HasAttributes)
            {
                HasAttributes soapObject = (HasAttributes)instance;
                int           cnt        = soapObject.getAttributeCount();
                for (int counter = 0; counter < cnt; counter++)
                {
                    AttributeInfo attributeInfo = new AttributeInfo();
                    soapObject.getAttributeInfo(counter, attributeInfo);
                    try
                    {
                        soapObject.getAttribute(counter, attributeInfo);
                    }
                    catch (Exception e)
                    {
                        //e.printStackTrace();
                    }
                    if (attributeInfo.getValue() != null)
                    {
                        writer.attribute(attributeInfo.getNamespace(), attributeInfo.getName(),
                                         attributeInfo.getValue() != null ? attributeInfo.getValue().ToString() : "");
                    }
                }
            }
            writer.text(instance.ToString());
        }
コード例 #2
0
ファイル: AttributeContainer.cs プロジェクト: Noisyfox/fSoap
        /**
         * Checks that the two objects have identical sets of attributes.
         *
         * @param other
         * @return {@code true} of the attrubte sets are equal, {@code false} otherwise.
         */

        protected bool attributesAreEqual(AttributeContainer other)
        {
            int numAttributes = getAttributeCount();

            if (numAttributes != other.getAttributeCount())
            {
                return(false);
            }

            for (int attribIndex = 0; attribIndex < numAttributes; attribIndex++)
            {
                AttributeInfo thisAttrib      = (AttributeInfo)this.attributes[attribIndex];
                Object        thisAttribValue = thisAttrib.getValue();
                if (!other.hasAttribute(thisAttrib.getName()))
                {
                    return(false);
                }
                Object otherAttribValue = other.getAttributeSafely(thisAttrib.getName());
                if (!thisAttribValue.Equals(otherAttribValue))
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #3
0
        private void writeAttributes(XmlSerializer writer, HasAttributes obj)
        {
            HasAttributes soapObject = (HasAttributes)obj;
            int           cnt        = soapObject.getAttributeCount();

            for (int counter = 0; counter < cnt; counter++)
            {
                AttributeInfo attributeInfo = new AttributeInfo();
                soapObject.getAttributeInfo(counter, attributeInfo);
                soapObject.getAttribute(counter, attributeInfo);
                if (attributeInfo.getValue() != null)
                {
                    writer.attribute(attributeInfo.getNamespace(), attributeInfo.getName(),
                                     attributeInfo.getValue().ToString());
                }
            }
        }
コード例 #4
0
ファイル: AttributeContainer.cs プロジェクト: Noisyfox/fSoap
        public void getAttributeInfo(int index, AttributeInfo attributeInfo)
        {
            AttributeInfo p = (AttributeInfo)attributes[index];

            attributeInfo.name        = p.name;
            attributeInfo.namespace_  = p.namespace_;
            attributeInfo.flags       = p.flags;
            attributeInfo.type        = p.type;
            attributeInfo.elementType = p.elementType;
            attributeInfo.value       = p.getValue();
        }
コード例 #5
0
ファイル: AttributeContainer.cs プロジェクト: Noisyfox/fSoap
        /**
         * Get the attribute's toString value.
         */

        public String getAttributeAsString(int index)
        {
            AttributeInfo attributeInfo = (AttributeInfo)attributes[index];

            return(attributeInfo.getValue().ToString());
        }