Class PreparedXMLStatement

Object
com.tailf.navu.PreparedXMLStatement

public class PreparedXMLStatement extends Object
This class represents a parsed XML-string, optionally with parameterized values. The string "?" denotes a value that is unknown at the time when the XML-string is parsed. The "?"-strings can be replaced by actual values at a later time.

The put() method is used to replace a "?" parameter with its actual ConfValue. The parameter index is zero-based.

When all "?" parameters have been replaced, setValues() can be issued which will insert or replace (if values already exist) the configuration tree specified by the XML-string at the location where prepareXMLCall was called.

If a parameter is not replaced by a value before a setValues() occurs, the value is treated as a ConfDefault.

No validation of data types occurs when put() is called, but setValues() will fail if a parameter is set to a type other than the one mandated by the YANG-model.

 module mtest {
   namespace "http://tail-f.com/test/mtest/1.0";
   prefix mtest;

   import ietf-inet-types {
     prefix inet;
   }

   container mtest {
     container servers {
       list server {
         key name;
         max-elements 64;
         leaf name {
           type string;
         }
         leaf ip {
           type inet:host;
           mandatory true;
         }
         leaf port {
           type inet:port-number;
           default 80;
         }
         list interface {
           key name;
           max-elements 8;
           leaf name {
             type string;
           }
           leaf mtu {
             type int64;
             default 1500;
           }
         }
       }
     }
   }
 }
 
 
 PreparedXMLStatement xmlst =
     serversNavuNode.prepareXMLCall("<server>"
                                    + "<name>?</name>"
                                    + "<ip>?</ip>"
                                    + "<port>?</port>"
                                    + "</server>");

 xmlst.put(0, "www1");
 xmlst.put(1, new ConfIPv4("192.168.10.12"));
 xmlst.put(2, new ConfUInt16(80));
 xmlst.setValues();
  • Constructor Details

  • Method Details

    • put

      public void put(int index, ConfObject val)
      Populate the parameterized value at position index with the value val. The first parameter has index 0.
      Parameters:
      index - zero-based index of the parameter
      val - the value to give to the parameter
    • put

      public void put(int index, String strval)
      Populate the parameterized value at position index with the value strval. The first parameter has index 0. The input string is converted to the appropriate data type as specified by the current schema.
      Parameters:
      index - zero-based index of the parameter
      strval - string representation of the value to give to the parameter
    • reset

      public void reset()
    • setValues

      public void setValues() throws NavuException
      When all of the parameterized values have been filled in, this method is intended to be invoked for a final set operation with the given values.
      Throws:
      NavuException
    • setValues

      public void setValues(NavuContext context) throws NavuException
      When all of the parameterized values have been filled in, this method is intended to be invoked for a final set operation with the given values.
      Parameters:
      context - NavuContext object that the setValues() operation should use
      Throws:
      NavuException
    • setValues

      public void setValues(NavuNode node) throws NavuException
      Similar to setValues(NavuContext) but uses the context of the supplied node.
      Parameters:
      node - node containing the NavuContext to use
      Throws:
      NavuException
    • sharedSetValues

      public void sharedSetValues() throws NavuException
      Variant of setValues() with FastMap support.
      Throws:
      NavuException
    • sharedSetValues

      public void sharedSetValues(NavuContext context) throws NavuException
      Variant of setValues(NavuContext) with FastMap support.
      Parameters:
      context - NavuContext object that the sharedSetValues() operation should use
      Throws:
      NavuException
    • sharedSetValues

      public void sharedSetValues(NavuNode node) throws NavuException
      Variant of setValues(NavuNode) with FastMap support.
      Parameters:
      node - node containing the NavuContext to use
      Throws:
      NavuException