Exemplo n.º 1
0
        public static List <ServiceTO> ReadSiblings(XmlReader reader)
        {
            List <ServiceTO> list = new List <ServiceTO>();

            /*
             * true if a matching descendant element is found; otherwise false.
             * If a matching child element is not found, the XmlReader is positioned
             * on the end tag (NodeType is XmlNodeType.EndElement) of the element.
             * If the XmlReader is not positioned on an element when ReadToDescendant
             * was called, this method returns false and the position of the XmlReader
             * is not changed.
             */
            bool found = reader.ReadToDescendant(ServiceTO.SERVICE);

            if (found)
            {
                do
                {
                    ServiceTO service = new ServiceTO(new List <PropTO>());
                    service.setProps(PropTO.ReadSiblings(reader));
                    list.Add(service);
                } while (reader.ReadToNextSibling(ServiceTO.SERVICE));
            }

            return(list);
        }
Exemplo n.º 2
0
 public bool addProp(PropTO propTO)
 {
     if (propTO == null)
     {
         return(false);
     }
     getProps().Add(propTO);
     return(true);
 }
Exemplo n.º 3
0
        public PropTO setData(byte[] data)
        {
            PropTO dat = new PropTO(PropTO.KEY_DATA, data);

            addProp(dat);
            if (dat.isBase64Encoding())
            {
                addProp(new PropTO(PropTO.KEY_DATAENCODING, PropTO.ENCODING_BASE64));
            }
            return(dat);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Access the raw property data
        /// </summary>
        /// <param name="key"></param>
        /// <returns>Never null</returns>
        public byte[] getPropValueBytes(String key)
        {
            PropTO propTO = getProp(key);

            if (propTO == null)
            {
                return(new byte[0]);
            }
            byte[] val = propTO.getValueBytes();
            return((val == null) ? new byte[0] : val);
        }
Exemplo n.º 5
0
        public String getPropValue(String key, String defaultValue)
        {
            PropTO propTO = getProp(key);

            if (propTO == null)
            {
                return(defaultValue);
            }
            String val = propTO.GetValue();

            return((val == null) ? defaultValue : val);
        }
Exemplo n.º 6
0
        /**
         * Access the property value.
         * @param key
         * @return never null
         */
        public String getPropValue(String key)
        {
            PropTO propTO = getProp(key);

            if (propTO == null)
            {
                return("");
            }
            String val = propTO.GetValue();

            return((val == null) ? "" : val);
        }
Exemplo n.º 7
0
        public void ReadXml(XmlReader reader)
        {
            bool found = true;

            if (!SERVICE.Equals(reader.LocalName))
            {
                found = reader.ReadToDescendant(SERVICE);
            }
            if (found)
            {
                this.propTOs = PropTO.ReadSiblings(reader);
            }
        }
Exemplo n.º 8
0
        public ServiceTO(ServiceTO service)
        {
            this.propTOs = new List <PropTO>();
            if (service == null)
            {
                return;
            }

            PropTO pp = service.getProp(PropTO.KEY_TASKTYPE);

            if (pp != null)
            {
                addProp(pp);
            }

            pp = service.getProp(PropTO.KEY_TASK);
            if (pp != null)
            {
                addProp(pp);
            }

            pp = service.getProp(PropTO.KEY_RESULTENCODING);
            if (pp != null)
            {
                addProp(pp);
            }

            pp = service.getProp(PropTO.KEY_RESULTMIME);
            if (pp != null)
            {
                addProp(pp);
            }

            List <PropTO> pc = service.getProps();

            foreach (PropTO p in pc)
            {
                if (p.GetKey().StartsWith(PropTO.KEY_BOUNCE))
                {
                    this.propTOs.Add(p);
                }
            }
        }
Exemplo n.º 9
0
        public static List <PropTO> ReadSiblings(XmlReader reader)
        {
            List <PropTO> list  = new List <PropTO>();
            bool          found = reader.ReadToDescendant(PROP);

            if (found)
            {
                string taskEncoding   = null;
                string resultEncoding = null;
                string dataEncoding   = null;
                do
                {
                    PropTO prop = new PropTO();
                    reader.MoveToAttribute(KEY);
                    prop.SetKey(reader.ReadContentAsString());
                    reader.MoveToContent();

                    /*This method reads the start tag, the contents of the element, and moves the reader past
                     * the end element tag. It expands entities and ignores processing instructions and comments.
                     * The element can only contain simple content. That is, it cannot have child elements.
                     */

                    if (resultEncoding != null && PropTO.KEY_RESULT.Equals(prop.GetKey()))
                    {
                        prop.SetEncoding(resultEncoding);
                    }
                    if (taskEncoding != null && PropTO.KEY_TASK.Equals(prop.GetKey()))
                    {
                        prop.SetEncoding(taskEncoding);
                    }
                    if (dataEncoding != null && PropTO.KEY_DATA.Equals(prop.GetKey()))
                    {
                        prop.SetEncoding(dataEncoding);
                    }

                    if (resultEncoding == null && PropTO.KEY_RESULT.Equals(prop.GetKey()) ||
                        taskEncoding == null && PropTO.KEY_TASK.Equals(prop.GetKey()) ||
                        dataEncoding == null && PropTO.KEY_DATA.Equals(prop.GetKey()))
                    {
                        // Expect subtags like "<A><B>Hello</B></A>"
                        string tmp = reader.ReadInnerXml();
                        tmp = tmp.Trim();
                        if (tmp.StartsWith("<![CDATA["))
                        { // strip CDATA token
                            tmp = tmp.Substring("<![CDATA[".Length);
                            if (tmp.EndsWith("]]>"))
                            {
                                tmp = tmp.Substring(0, tmp.Length - "]]>".Length);
                            }
                        }
                        else
                        {
                            tmp = org.xmlBlaster.util.XmlBuffer.UnEscape(tmp);
                        }
                        //XmlReader nestedReader = reader.ReadSubtree();
                        //tmp = reader.ReadString(); is empty if contains tags
                        //tmp = reader.Value; is empty if contains tags
                        prop.SetValue(tmp);
                    }
                    else
                    {
                        string val = reader.ReadElementContentAsString();
                        val = org.xmlBlaster.util.XmlBuffer.UnEscape(val);
                        prop.SetValue(val);
                    }

                    // Check if base64 encoded (this tag is a previous sibling before the content prop)
                    if (PropTO.KEY_ENCODING.Equals(prop.GetKey()))
                    {
                        taskEncoding = prop.GetValueRaw();
                    }
                    if (PropTO.KEY_RESULTENCODING.Equals(prop.GetKey()))
                    {
                        resultEncoding = prop.GetValueRaw();
                    }
                    if (PropTO.KEY_DATAENCODING.Equals(prop.GetKey()))
                    {
                        dataEncoding = prop.GetValueRaw();
                    }

                    list.Add(prop);
                } while (PROP.Equals(reader.LocalName));//reader.ReadToNextSibling(PROP));
            }
            return(list);
        }