peersim.config
Class ParsedProperties

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<java.lang.Object,java.lang.Object>
          extended by java.util.Properties
              extended by peersim.config.ConfigProperties
                  extended by peersim.config.ParsedProperties
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Object,java.lang.Object>

public class ParsedProperties
extends ConfigProperties

Extends the class ConfigProperties with basic parsing capabilities.

See Also:
load(java.lang.String), Serialized Form

Field Summary
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
ParsedProperties(java.lang.String filename)
          Calls super constructor.
ParsedProperties(java.lang.String[] pars)
          Calls super constructor.
 
Method Summary
 void load(java.lang.String fileName)
          Loads given file.
 
Methods inherited from class peersim.config.ConfigProperties
loadPropertyString, loadSystemResource
 
Methods inherited from class java.util.Properties
getProperty, getProperty, list, list, load, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ParsedProperties

public ParsedProperties(java.lang.String[] pars)
Calls super constructor.

See Also:
ConfigProperties.ConfigProperties(String[])

ParsedProperties

public ParsedProperties(java.lang.String filename)
                 throws java.io.IOException
Calls super constructor.

Throws:
java.io.IOException
See Also:
ConfigProperties.ConfigProperties(String)
Method Detail

load

public void load(java.lang.String fileName)
          throws java.io.IOException
Loads given file. It works exactly as Properties.load with a file input stream to the given file, except that the file is parsed the following way allowing to compress some property names using { and }. When a bracket is present, it must be the only non-space element of a line. The last property defined before the opening bracket define the prefix that is added to all the properties defined included between brackets. In other words, a construct like this:
  control.degree GraphObserver 
  {
    protocol newscast
    undir
  }
  
is equivalent to the definition of these three properties:
  control.degree GraphObserver 
  control.degree.protocol newscast
  control.degree.undir
  
Nested brackets are possible. The rule of the last property before the opening bracket applies also to the inside brackets, with the prefix being the complete property definition (so, including the prefix observed before). Example:
        control.1 DynamicNetwork
        {
          add CRASH
          substitute
          init.0 WireKOut 
          {
            degree DEGREE
            protocol 0
          }
        }
  
defines the following properties:
        control.1 DynamicNetwork
        control.1.add CRASH
        control.1.substitute
        control.1.init.0 WireKOut 
        control.1.init.0.degree DEGREE
        control.1.init.0.protocol 0
  

Know limitations: The parsing mechanism is very simple; no complex error messages are provided. In case of missing closing brackets, the method will stop reporting the number of missing brackets. Additional closing brackets (i.e., missing opening brackets) produce an error messages reporting the line where the closing bracket is present. Misplaced brackets (included in lines that contains other characters) are ignored, thus may indirectly produce the previous error messages.

Overrides:
load in class ConfigProperties
Throws:
java.io.IOException