/// <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 the node is considered as null and is valid. /// </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 bool ValidateAttribute(InputNode node, String key) { String name = style.GetElement(key); InputNode child = node.GetAttribute(name); if (child == null) { return(true); } return(root.Validate(child)); }
/// <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)); }
/// <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 the node is considered as null and is valid. /// </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 bool ValidateAttribute(InputNode node, String key) { String name = style.GetElement(key); InputNode child = node.GetAttribute(name); if(child == null) { return true; } return root.Validate(child); }
/// <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); }
/// <summary> /// This <c>validateAttributes</c> method validates the attributes /// from the provided XML element. This will iterate over all attributes /// within the element and validate those attributes as primitives to /// contact values within the source object. /// <p> /// Once all attributes within the XML element have been evaluated the /// <c>Schema</c> is checked to ensure that there are no required /// contacts annotated with the <c>Attribute</c> that remain. If /// any required attribute remains an exception is thrown. /// </summary> /// <param name="node"> /// this is the XML element to be validated /// </param> /// <param name="schema"> /// this is used to visit the attribute contacts /// </param> public void ValidateAttributes(InputNode node, Schema schema) { NodeMap<InputNode> list = node.getAttributes(); LabelMap map = schema.getAttributes(); for(String name : list) { ValidateAttribute(node.GetAttribute(name), map); } Validate(node, map); }
/// <summary> /// This <c>readAttributes</c> method reads the attributes from /// the provided XML element. This will iterate over all attributes /// within the element and convert those attributes as primitives to /// contact values within the source object. /// <p> /// Once all attributes within the XML element have been evaluated /// the <c>Schema</c> is checked to ensure that there are no /// required contacts annotated with the <c>Attribute</c> that /// remain. If any required attribute remains an exception is thrown. /// </summary> /// <param name="node"> /// this is the XML element to be evaluated /// </param> /// <param name="source"> /// the type of the object that is being deserialized /// </param> /// <param name="schema"> /// this is used to visit the attribute contacts /// </param> public void ReadAttributes(InputNode node, Object source, Schema schema) { NodeMap<InputNode> list = node.getAttributes(); LabelMap map = schema.getAttributes(); for(String name : list) { ReadAttribute(node.GetAttribute(name), source, map); } Validate(node, map, source); }