예제 #1
0
        /**
         * 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);
        }
예제 #2
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());
        }