Skip to content
yurkom edited this page Dec 22, 2012 · 8 revisions

Flat Format

The flat format (org.streum.configrity.io.FlatFormat) is composed of a list of entries taking the form:

key = value

Where key is a string which can contain any character except: #, = or any whitespace character (space, tab, newline, etc.) It cannot start or end with the dot: .. The value is either:

  1. a word composed of any character except: #, = any whitespace character;
  2. any string surrounded by double quotes " (which does not contain any other double quote character).

All whitespace around expressions are ignored. Everything starting with # is a comment and is then ignored.

For instance, the following text is valid:

site.url                  = http://www.example.com/3
site.credentials.username = bob
site.credentials.password = "b0b rul3z !!!"
upload.retrying           = on
upload.retrying.times     = 3

The Flat Format rules are defined in files src/io/StandardFormat.scala and src/io/StandardFormat.scala.

Block format (default format)

Block format (org.streum.configrity.io.BlockFormat) is an extension of Flat format (see above). All texts parsed by Flat format are also valid Block format texts. The only extension is the introduction of blocks:

blockKey {
  content
}

Where blockKey has the same restrictions as Flat format keys and content is a list of either key = value entries or other blocks. The order is not important. A block cannot be empty.

For instance, the following text is valid and the generated Configuration equals the one generated by the Flat format example:

site {
  url = http://www.example.com/3
  credentials {
    username = bob
    password = "b0b rul3z !!!"
  }    
}
upload {
  retrying = on
  retrying {
    times = 3
  }
}

Both style can be mixed, so last examples is identical to:

site {
  url = http://www.example.com/3
  credentials.username = bob
  credentials.password = "b0b rul3z !!!"
}
upload.retrying = on
upload.retrying {
  times = 3
}

JProperty Format

JProperty Format (org.streum.configrity.JProperties.format) is the standard text format of java.util.Properties, described in:

http://download.oracle.com/javase/6/docs/api/java/util/Properties.html

It allows interoperability for legacy java code and scripts.

Clone this wiki locally