Exemple #1
0
 private int?attributeIndex(String namespace_, String name)
 {
     for (int i = 0; i < attributes.Count; i++)
     {
         AttributeInfo attrInfo = (AttributeInfo)attributes[i];
         if (name.Equals(attrInfo.getName()) && namespace_.Equals(attrInfo.getNamespace()))
         {
             return(i);
         }
     }
     return(null);
 }
Exemple #2
0
        /**
         * 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());
        }
        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());
                }
            }
        }