Read() public method

This read method will extract the text value from the node and replace any template variables before converting it to a primitive value. This uses the Context object used for this instance of serialization to replace all template variables with values from the context filter.
public Read ( InputNode node ) : Object
node InputNode /// this is the node to be converted to a primitive ///
return Object
Beispiel #1
0
        /// <summary>
        /// This method is used to read the key value from the node. The
        /// value read from the node is resolved using the template filter.
        /// If the key value can not be found according to the annotation
        /// attributes then an null is assumed and returned.
        /// </summary>
        /// <param name="node">
        /// this is the node to read the key value from
        /// </param>
        /// <param name="key">
        /// this is the name of the attribute used by the key
        /// </param>
        /// <returns>
        /// this returns the value deserialized from the node
        /// </returns>
        public Object ReadAttribute(InputNode node, String key)
        {
            String    name  = style.GetAttribute(key);
            InputNode child = node.GetAttribute(name);

            if (child == null)
            {
                return(null);
            }
            return(root.Read(child));
        }
Beispiel #2
0
        /// <summary>
        /// This method is used to read the value value from the node. The
        /// value read from the node is resolved using the template filter.
        /// If the value value can not be found according to the annotation
        /// attributes then an exception is thrown.
        /// </summary>
        /// <param name="node">
        /// this is the node to read the value object from
        /// </param>
        /// <returns>
        /// this returns the value deserialized from the node
        /// </returns>
        public Object Read(InputNode node)
        {
            Class  expect = type.Type;
            String name   = entry.GetValue();

            if (name == null)
            {
                name = context.GetName(expect);
            }
            if (entry.IsInline())
            {
                return(root.Read(node));
            }
            return(Read(node, name));
        }
Beispiel #3
0
        /// <summary>
        /// This <c>populate</c> method wll read the XML element list
        /// from the provided node and deserialize its children as entry types.
        /// This will deserialize each entry type as a primitive value. In
        /// order to do this the parent string provided forms the element.
        /// </summary>
        /// <param name="node">
        /// this is the XML element that is to be deserialized
        /// </param>
        /// <param name="result">
        /// this is the collection that is to be populated
        /// </param>
        /// <returns>
        /// this returns the item to attach to the object contact
        /// </returns>
        public Object Populate(InputNode node, Object result)
        {
            Collection list = (Collection)result;

            while (true)
            {
                InputNode next = node.getNext();
                if (next == null)
                {
                    return(list);
                }
                list.add(root.Read(next));
            }
        }
        /// <summary>
        /// This <c>read</c> method wll read the XML element list from
        /// the provided node and deserialize its children as entry types.
        /// This will deserialize each entry type as a primitive value. In
        /// order to do this the parent string provided forms the element.
        /// </summary>
        /// <param name="node">
        /// this is the XML element that is to be deserialized
        /// </param>
        /// <param name="list">
        /// this is the collection that is to be populated
        /// </param>
        /// <returns>
        /// this returns the item to attach to the object contact
        /// </returns>
        public Object Read(InputNode node, Collection list)
        {
            InputNode from = node.getParent();
            String    name = node.getName();

            while (node != null)
            {
                Object item = root.Read(node);
                if (item != null)
                {
                    list.add(item);
                }
                node = from.getNext(name);
            }
            return(list);
        }
Beispiel #5
0
        /// <summary>
        /// This <c>read</c> method will read the XML element list from
        /// the provided node and deserialize its children as entry types.
        /// This will deserialize each entry type as a primitive value. In
        /// order to do this the parent string provided forms the element.
        /// </summary>
        /// <param name="node">
        /// this is the XML element that is to be deserialized
        /// </param>
        /// <param name="list">
        /// this is the array to read the array values in to
        /// </param>
        /// <returns>
        /// this returns the item to attach to the object contact
        /// </returns>
        public Object Read(InputNode node, Object list)
        {
            int length = Array.getLength(list);

            for (int pos = 0; true; pos++)
            {
                Position  line = node.getPosition();
                InputNode next = node.getNext();
                if (next == null)
                {
                    return(list);
                }
                if (pos >= length)
                {
                    throw new ElementException("Array length missing or incorrect at %s", line);
                }
                Array.set(list, pos, root.Read(next));
            }
        }