Esempio n. 1
0
            /// <summary>
            /// This <c>read</c> method will perform a read using the
            /// provided object with the repeater. Reading with this method
            /// ensures that any additional XML elements within the source
            /// will be added to the value.
            /// </summary>
            /// <param name="node">
            /// this is the node that contains the extra data
            /// </param>
            /// <returns>
            /// this will return the original deserialized object
            /// </returns>
            public bool Validate(InputNode node)
            {
                Position line = node.getPosition();
                String   name = node.GetName();

                if (reader instanceof Repeater)
                {
                    Repeater repeat = (Repeater)reader;
                    return(repeat.Validate(node));
                }
                throw new PersistenceException("Element '%s' declared twice at %s", name, line);
            }
Esempio n. 2
0
        /// <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 each entry type is deserialized as a root type, that
        /// is, its <c>Root</c> annotation must be present and the
        /// name of the entry element must match that root element name.
        /// </summary>
        /// <param name="node">
        /// this is the XML element that is to be deserialized
        /// </param>
        /// <returns>
        /// this returns the item to attach to the object contact
        /// </returns>
        public bool Validate(InputNode node)
        {
            InputNode from = node.getParent();
            Class     type = entry.Type;
            String    name = node.GetName();

            while (node != null)
            {
                bool valid = root.Validate(node, type);
                if (valid == false)
                {
                    return(false);
                }
                node = from.getNext(name);
            }
            return(true);
        }
Esempio n. 3
0
        /// <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 each entry type is deserialized as a root type, that
        /// is, its <c>Root</c> annotation must be present and the
        /// name of the entry element must match that root element name.
        /// </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)
            {
                Class  type = entry.Type;
                Object item = Read(node, type);
                if (item != null)
                {
                    list.add(item);
                }
                node = from.getNext(name);
            }
            return(list);
        }
 /// <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 each entry type is deserialized as a root type, that
 /// is, its <c>Root</c> annotation must be present and the
 /// name of the entry element must match that root element name.
 /// </summary>
 /// <param name="node">
 /// this is the XML element that is to be deserialized
 /// </param>
 /// <returns>
 /// this returns the item to attach to the object contact
 /// </returns>
 public bool Validate(InputNode node) {
    InputNode from = node.getParent();
    Class type = entry.Type;
    String name = node.GetName();
    while(node != null) {
       bool valid = root.Validate(node, type);
       if(valid == false) {
          return false;
       }
       node = from.getNext(name);
    }
    return true;
 }
 /// <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 each entry type is deserialized as a root type, that
 /// is, its <c>Root</c> annotation must be present and the
 /// name of the entry element must match that root element name.
 /// </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) {
       Class type = entry.Type;
       Object item = Read(node, type);
       if(item != null) {
          list.add(item);
       }
       node = from.getNext(name);
    }
    return list;
 }
Esempio n. 6
0
 /// <summary>
 /// This <c>validateElement</c> method performs a validation
 /// of the provided node object using a delegate converter. This is
 /// typically another <c>Composite</c> converter, or if the
 /// node is an attribute a <c>Primitive</c> converter. If this
 /// fails validation then an exception is thrown to report the issue.
 /// </summary>
 /// <param name="node">
 /// this is the node that contains the contact value
 /// </param>
 /// <param name="map">
 /// this is the map that contains the label objects
 /// </param>
 public void ValidateElement(InputNode node, LabelMap map) {
    String name = node.GetName();
    Label label = map.take(name);
    if(label == null) {
       label = criteria.Get(name);
    }
    if(label == null) {
       Position line = node.getPosition();
       if(map.IsStrict(context) && revision.IsEqual()) {
          throw new ElementException("Element '%s' does not exist at %s", name, line);
       } else {
          node.skip();
       }
    } else {
       Validate(node, label);
    }
 }
Esempio n. 7
0
 /// <summary>
 /// This <c>validateAttribute</c> method performs a validation
 /// of the provided node object using a delegate converter. This is
 /// typically another <c>Composite</c> converter, or if the
 /// node is an attribute a <c>Primitive</c> converter. If this
 /// fails validation then an exception is thrown to report the issue.
 /// </summary>
 /// <param name="node">
 /// this is the node that contains the contact value
 /// </param>
 /// <param name="map">
 /// this is the map that contains the label objects
 /// </param>
 public void ValidateAttribute(InputNode node, LabelMap map) {
    Position line = node.getPosition();
    String name = node.GetName();
    Label label = map.take(name);
    if(label == null) {
       if(map.IsStrict(context) && revision.IsEqual()) {
          throw new AttributeException("Attribute '%s' does not exist at %s", name, line);
       }
    } else {
       Validate(node, label);
    }
 }
Esempio n. 8
0
 /// <summary>
 /// This <c>readElement</c> method is used for deserialization
 /// of the provided node object using a delegate converter. This is
 /// typically another <c>Composite</c> converter, or if the
 /// node is an attribute a <c>Primitive</c> converter. When
 /// the delegate converter has completed the deserialized value is
 /// assigned to the contact.
 /// </summary>
 /// <param name="node">
 /// this is the node that contains the contact value
 /// </param>
 /// <param name="source">
 /// the type of the object that is being deserialized
 /// </param>
 /// <param name="map">
 /// this is the map that contains the label objects
 /// </param>
 public void ReadElement(InputNode node, Object source, LabelMap map) {
    String name = node.GetName();
    Label label = map.take(name);
    if(label == null) {
       label = criteria.Get(name);
    }
    if(label == null) {
       Position line = node.getPosition();
       Class type = source.getClass();
       if(map.IsStrict(context) && revision.IsEqual()) {
          throw new ElementException("Element '%s' does not have a match in %s at %s", name, type, line);
       } else {
          node.skip();
       }
    } else {
       Read(node, source, label);
    }
 }
Esempio n. 9
0
 /// <summary>
 /// This <c>read</c> method will perform a read using the
 /// provided object with the repeater. Reading with this method
 /// ensures that any additional XML elements within the source
 /// will be added to the value.
 /// </summary>
 /// <param name="node">
 /// this is the node that contains the extra data
 /// </param>
 /// <returns>
 /// this will return the original deserialized object
 /// </returns>
 public bool Validate(InputNode node) {
    Position line = node.getPosition();
    String name = node.GetName();
    if(reader instanceof Repeater) {
       Repeater repeat = (Repeater) reader;
       return repeat.Validate(node);
    }
    throw new PersistenceException("Element '%s' declared twice at %s", name, line);
 }