示例#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
        public bool matches(IDictionary <String, Object> document)
        {
            Object data = null;

            document.TryGetValue(info.getName(), out data);
            switch (match)
            {
            case MatchOp.EQUALS:
                return(matchesEQUALS(data));

            case MatchOp.ROUGHLY:
                return(matchesROUGHLY(data));

            case MatchOp.CONTAINS:
                return(matchesCONTAINS(data));

            case MatchOp.HAS:
                return(matchesHAS(data));

            case MatchOp.IN:
                return(matchesIN(data));

            case MatchOp.GREATER:
                return(matchesGREATER(data));

            case MatchOp.LESSER:
                return(matchesLESSER(data));

            default:
                return(false);
            }
        }
示例#3
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);
 }
示例#4
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());
        }
        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());
                }
            }
        }