Exemple #1
0
 /// <summary>
 /// This <c>readText</c> method is used to read the text value
 /// from the XML element node specified. This will check the class
 /// schema to determine if a <c>Text</c> annotation was
 /// specified. If one was specified then the text within the XML
 /// element input node is used to populate the contact value.
 /// </summary>
 /// <param name="node">
 /// this is the XML element to acquire the text from
 /// </param>
 /// <param name="source">
 /// the type of the object that is being deserialized
 /// </param>
 /// <param name="schema">
 /// this is used to visit the element contacts
 /// </param>
 public void ReadText(InputNode node, Object source, Schema schema) {
    Label label = schema.getText();
    if(label != null) {
       Read(node, source, label);
    }
 }
Exemple #2
0
 /// <summary>
 /// This <c>validateText</c> method validates the text value
 /// from the XML element node specified. This will check the class
 /// schema to determine if a <c>Text</c> annotation was used.
 /// If one was specified then the text within the XML element input
 /// node is checked to determine if it is a valid entry.
 /// </summary>
 /// <param name="node">
 /// this is the XML element to acquire the text from
 /// </param>
 /// <param name="schema">
 /// this is used to visit the element contacts
 /// </param>
 public void ValidateText(InputNode node, Schema schema) {
    Label label = schema.getText();
    if(label != null) {
       Validate(node, label);
    }
 }
Exemple #3
0
 /// <summary>
 /// This write method is used to write the text contact from the
 /// provided source object to the XML element. This takes the text
 /// value from the source object and writes it to the single contact
 /// marked with the <c>Text</c> annotation. If the value is
 /// null and the contact value is required an exception is thrown.
 /// </summary>
 /// <param name="source">
 /// this is the source object to be serialized
 /// </param>
 /// <param name="node">
 /// this is the XML element to write text value to
 /// </param>
 /// <param name="schema">
 /// this is used to track the referenced elements
 /// </param>
 public void WriteText(OutputNode node, Object source, Schema schema) {
    Label label = schema.getText();
    if(label != null) {
       Contact contact = label.getContact();
       Object value = contact.Get(source);
       Class type = source.getClass();
       if(value == null) {
          value = label.getEmpty(context);
       }
       if(value == null && label.isRequired()) {
          throw new TextException("Value for %s is null for %s", label, type);
       }
       WriteText(node, value, label);
    }
 }