Class ZConfig

java.lang.Object
org.zeromq.ZConfig

public class ZConfig extends Object

Lets applications load, work with, and save configuration files. This is a minimal implementation of the ZeroMQ Property Language, which is a simple structured text format for configuration files.

Here is an example ZPL stream and corresponding config structure:


       context
           iothreads = 1
           verbose = 1      #   Ask for a trace
       main
           type = zqueue    #  ZMQ_DEVICE type
           frontend
               option
                   hwm = 1000
                   swap = 25000000     #  25MB
               bind = 'inproc://addr1'
               bind = 'ipc://addr2'
           backend
               bind = inproc://addr3
  

  
   root                    Down = child
   |                     Across = next
   v
   context-->main
   |         |
   |         v
   |       type=queue-->frontend-->backend
   |                      |          |
   |                      |          v
   |                      |        bind=inproc://addr3
   |                      v
   |                    option-->bind=inproc://addr1-->bind=ipc://addr2
   |                      |
   |                      v
   |                    hwm=1000-->swap=25000000
   v
   iothreads=1-->verbose=false

It can put and get values and save and load them to disk:


ZConfig conf = new ZConfig("root", null);
conf.put("/curve/public-key","abcdef");
String val = conf.get("/curve/public-key","fallback-defaultkey");
conf.save("test.cert");
ZConfig loaded = ZConfig.load("test.cert");
  • Constructor Details

  • Method Details

    • getChild

      public ZConfig getChild(String name)
    • getValues

      public Map<String,String> getValues()
    • getName

      public String getName()
    • getValue

      public String getValue(String path)
    • getValue

      public String getValue(String path, String defaultValue)
    • pathExists

      public boolean pathExists(String path)
      check if a value-path exists
      Parameters:
      path -
      Returns:
      true if value-path exists
    • addComment

      public void addComment(String comment)
      add comment
      Parameters:
      comment -
    • putValue

      public ZConfig putValue(String path, String value)
      Parameters:
      path -
      value - set value of config item
    • putValues

      public void putValues(ZConfig src)
    • save

      public File save(String filename) throws IOException
      Saves the configuration to a file.

      This method will overwrite contents of existing file

      Parameters:
      filename - the path of the file to save the configuration into, or "-" to dump it to standard output
      Returns:
      the saved file or null if dumped to the standard output
      Throws:
      IOException - if unable to save the file.
    • save

      public void save(Writer writer) throws IOException
      Throws:
      IOException
    • load

      public static ZConfig load(String filename) throws IOException
      Throws:
      IOException